Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /branches/ein16/synth/d2/test_createField.py
ViewVC logotype

Diff of /branches/ein16/synth/d2/test_createField.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4235, Tue Jul 19 22:26:44 2016 UTC revision 4236, Wed Jul 20 03:02:00 2016 UTC
# Line 20  Line 20 
20  def progName(itype,outSize):  def progName(itype,outSize):
21      #call program due to field type      #call program due to field type
22      if (fty.isEq_id(itype,ty_scalarF_d1)):      if (fty.isEq_id(itype,ty_scalarF_d1)):
23          print "kitten-made a 1-d field"          #print "kitten-made a 1-d field"
24          return ("symb_fsd1"," -which 0 "," -s 1 "+str(outSize))          # 1-d scalar field          return ("symb_fsd1"," -which 0 "," -s 1 "+str(outSize))          # 1-d scalar field
25      elif (fty.isEq_id(itype,ty_scalarF_d2)):      elif (fty.isEq_id(itype,ty_scalarF_d2)):
26          return ("symb_fsd2"," -which 0 "," -s 1 "+str(outSize * outSize))          # 2-d scalar field          return ("symb_fsd2"," -which 0 "," -s 1 "+str(outSize * outSize))          # 2-d scalar field
# Line 34  Line 34 
34      elif(fty.isEq_id(itype,ty_vec3F_d3)):                      # 2-d length 2 vector field      elif(fty.isEq_id(itype,ty_vec3F_d3)):                      # 2-d length 2 vector field
35          size = 3* outSize *outSize*outSize          size = 3* outSize *outSize*outSize
36          return ("symb_fv3d3"," -which 0 "," -s 1 "+str(size))         # creates field with coefficients for each axis          return ("symb_fv3d3"," -which 0 "," -s 1 "+str(size))         # creates field with coefficients for each axis
37        elif(fty.isEq_id(itype, ty_mat2x2F_d3)):
38            # 3-d matrix field
39            size = 4* outSize *outSize*outSize
40            return ("symb_fm2x2d3"," -which 0 "," -s 1 "+str(size))
41      elif(fty.isEq_id(itype, ty_mat3x3F_d3)):      elif(fty.isEq_id(itype, ty_mat3x3F_d3)):
42          # 3-d matrix field          # 3-d matrix field
43          size = 9* outSize *outSize*outSize          size = 9* outSize *outSize*outSize
44          return ("symb_fm3x3d3"," -which 0 "," -s 1 "+str(size))          return ("symb_fm3x3d3"," -which 0 "," -s 1 "+str(size))
45      else:      else:
46          raise "type not supported in program name:"          raise Exception("type not supported in program name:"+itype.name)
47    
48    
49  # base,xsq,ysq,diag-coeffs  # base,xsq,ysq,diag-coeffs
# Line 133  Line 137 
137                  COEFF+=coeffToBase(cz0, "3_z0")+coeffToBase(cz1, "3_z1")+coeffToBase(cz2, "3_z2")                  COEFF+=coeffToBase(cz0, "3_z0")+coeffToBase(cz1, "3_z1")+coeffToBase(cz2, "3_z2")
138                  SIZE=" -sz0 "+ sout +" -sz1 "+ sout+" -sz2 "+ sout +" -width 1"    # giving sample size                  SIZE=" -sz0 "+ sout +" -sz1 "+ sout+" -sz2 "+ sout +" -width 1"    # giving sample size
139                  return COEFF + SIZE                  return COEFF + SIZE
140                elif(fty.isEq_id(itype, ty_mat2x2F_d3)):
141                    [m0, m1] = coeff
142                    [[az0, az1, az2], [cz0, cz1, cz2]] = m0
143                    [[bz0, bz1, bz2], [dz0, dz1, dz2]] = m1
144                    COEFF= coeffToBase(az0, "1_z0")+coeffToBase(az1, "1_z1")+coeffToBase(az2, "1_z2")
145                    COEFF+=coeffToBase(bz0, "2_z0")+coeffToBase(bz1, "2_z1")+coeffToBase(bz2, "2_z2")
146                    COEFF+=coeffToBase(cz0, "3_z0")+coeffToBase(cz1, "3_z1")+coeffToBase(cz2, "3_z2")
147                    COEFF+=coeffToBase(dz0, "4_z0")+coeffToBase(dz1, "4_z1")+coeffToBase(dz2, "4_z2")
148                    SIZE=" -sz0 "+ sout +" -sz1 "+ sout+" -sz2 "+ sout +" -width 1"    # giving sample size
149                    return COEFF + SIZE
150    
151              elif(fty.isEq_id(itype, ty_mat3x3F_d3)):              elif(fty.isEq_id(itype, ty_mat3x3F_d3)):
152                  [m0, _,_] = coeff                  [m0, _,_] = coeff
153                  # [[z0_1, z0_2, z0_3],[z1_1, z1_2, z1_3],[z2_1, z2_2, z2_3]]= m0                  # [[z0_1, z0_2, z0_3],[z1_1, z1_2, z1_3],[z2_1, z2_2, z2_3]]= m0
# Line 171  Line 186 
186                  # COEFF+=coeffToBase(z0_7, "7_z0")+coeffToBase(z1_7, "7_z1")+coeffToBase(z2_7, "7_z2")                  # COEFF+=coeffToBase(z0_7, "7_z0")+coeffToBase(z1_7, "7_z1")+coeffToBase(z2_7, "7_z2")
187                  # COEFF+=coeffToBase(z0_8, "8_z0")+coeffToBase(z1_8, "8_z1")+coeffToBase(z2_8, "8_z2")                  # COEFF+=coeffToBase(z0_8, "8_z0")+coeffToBase(z1_8, "8_z1")+coeffToBase(z2_8, "8_z2")
188                  # COEFF+=coeffToBase(z0_9, "9_z0")+coeffToBase(z1_9, "9_z1")+coeffToBase(z2_9, "9_z2")                  # COEFF+=coeffToBase(z0_9, "9_z0")+coeffToBase(z1_9, "9_z1")+coeffToBase(z2_9, "9_z2")
189                  print ("cmd",COEFF)                  #print ("cmd",COEFF)
190                  SIZE=" -sz0 "+ sout +" -sz1 "+ sout+" -sz2 "+ sout +" -width 1"    # giving sample size                  SIZE=" -sz0 "+ sout +" -sz1 "+ sout+" -sz2 "+ sout +" -width 1"    # giving sample size
191                  return COEFF + SIZE                  return COEFF + SIZE
192              else:              else:
# Line 180  Line 195 
195              raise "dim not supported:"              raise "dim not supported:"
196      PARAMS = get_Params()      PARAMS = get_Params()
197      # get program name and which command      # get program name and which command
198      print "create field A"      #print "create field A"
199      (e_Orig,w_coeff,w_shape) = progName(itype, outSize)      (e_Orig,w_coeff,w_shape) = progName(itype, outSize)
200      print "create field B"      #print "create field B"
201      p_Orig=  e_Orig+".diderot"      p_Orig=  e_Orig+".diderot"
202      #compile program      #compile program
203      print "create field C",(branch+p_Orig)      os.system("cp symb/"+ p_Orig +" "+ p_Orig)
204        #print "create field C",(branch+p_Orig)
205      os.system(branch+p_Orig)      os.system(branch+p_Orig)
206      #execute program      #execute program
207      print "create field D"      #print "create field D"
208      print "+e_Orig+w_coeff+PARAMS-0./",e_Orig+w_coeff+PARAMS      #print "+e_Orig+w_coeff+PARAMS-0./",e_Orig+w_coeff+PARAMS
209      os.system("./"+e_Orig+w_coeff+PARAMS)      os.system("./"+e_Orig+w_coeff+PARAMS)
210      print "+e_Orig+w_coeff+PARAMS-1"      #print "+e_Orig+w_coeff+PARAMS-1"
211      print "create field E"      #print "create field E"
212      print ("./"+e_Orig+w_coeff+PARAMS+"| unu save -f nrrd -o "+outputnrrd)      #print ("./"+e_Orig+w_coeff+PARAMS+"| unu save -f nrrd -o "+outputnrrd)
213      os.system("./"+e_Orig+w_coeff+PARAMS+"| unu save -f nrrd -o "+outputnrrd)      os.system("./"+e_Orig+w_coeff+PARAMS+"| unu save -f nrrd -o "+outputnrrd)
214      print "create field F"      #print "create field F"
215      print ("unu reshape -i "+outputnrrd+w_shape+" | unu save -f text -o "+orig+".txt")      #print ("unu reshape -i "+outputnrrd+w_shape+" | unu save -f text -o "+orig+".txt")
216      os.system("unu reshape -i "+outputnrrd+w_shape+" | unu save -f text -o "+orig+".txt")      os.system("unu reshape -i "+outputnrrd+w_shape+" | unu save -f text -o "+orig+".txt")
217      #save nrrd file      #save nrrd file
218      os.system("rm *.o")      os.system("rm *.o")

Legend:
Removed from v.4235  
changed lines
  Added in v.4236

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0