diff --git a/sirepo/template/srw_importer.py b/sirepo/template/srw_importer.py index 6022f3e30d..4a67543aed 100644 --- a/sirepo/template/srw_importer.py +++ b/sirepo/template/srw_importer.py @@ -789,7 +789,7 @@ def _patch_mirror_profile(code, mirror_file='mirror_1d.dat'): final_mirror_file = None var_name = 'ifn' + var_name for i in range(len(code_list)): - if re.search('^(\s*)' + var_name + '(\d*)(\s*)=(\s*)(.*\.dat\w*)(\s*)', code_list[i]): + if re.search(r'^(\s*)' + var_name + r'(\d*)(\s*)=(\s*)(.*\.dat\w*)(\s*)', code_list[i]): full_var_name = code_list[i].strip().split('=')[0].strip() code_list[i] = code_list[i].replace( full_var_name, diff --git a/tests/template/srw_import_data/amx.json b/tests/template/srw_import_data/amx.json index 7222d28047..a3a86fb61d 100644 --- a/tests/template/srw_import_data/amx.json +++ b/tests/template/srw_import_data/amx.json @@ -295,7 +295,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "3": [ @@ -322,7 +330,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "4": [ @@ -409,7 +425,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "7": [ @@ -466,7 +490,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ] }, diff --git a/tests/template/srw_import_data/amx.py b/tests/template/srw_import_data/amx.py index 9a10f3e675..14a00fa5c5 100644 --- a/tests/template/srw_import_data/amx.py +++ b/tests/template/srw_import_data/amx.py @@ -145,7 +145,7 @@ def set_optics(_v): #print('DCM Fourier Components:', psi) #---------------------- DCM Crystal #1 - opCr1 = SRWLOptCryst(_d_sp=dc, _psi0r=psi[0], _psi0i=psi[1], _psi_hr=psi[2], _psi_hi=psi[3], _psi_hbr=psi[2], _psi_hbi=psi[3], _tc=tc, _ang_as=angAs) + opCr1 = SRWLOptCryst(_d_sp=dc, _psi0r=psi[0], _psi0i=psi[1], _psi_hr=psi[2], _psi_hi=psi[3], _psi_hbr=psi[2], _psi_hbi=psi[3], _tc=tc, _ang_as=angAs, _ang_roll=1.5707963) #Find appropriate orientation of the Crystal #1 and the Output Beam Frame (using a member-function in SRWLOptCryst): orientDataCr1 = opCr1.find_orient(_en=_v.op_DCM_e, _ang_dif_pl=1.5707963) # Horizontally-deflecting @@ -184,7 +184,7 @@ def set_optics(_v): el.append(opCr1); pp.append(_v.op_DCMC1_pp) #---------------------- DCM Crystal #2 - opCr2 = SRWLOptCryst(_d_sp=dc, _psi0r=psi[0], _psi0i=psi[1], _psi_hr=psi[2], _psi_hi=psi[3], _psi_hbr=psi[2], _psi_hbi=psi[3], _tc=tc, _ang_as=angAs) + opCr2 = SRWLOptCryst(_d_sp=dc, _psi0r=psi[0], _psi0i=psi[1], _psi_hr=psi[2], _psi_hi=psi[3], _psi_hbr=psi[2], _psi_hbi=psi[3], _tc=tc, _ang_as=angAs, _ang_roll=-1.5707963) #Find appropriate orientation of the Crystal #2 and the Output Beam Frame orientDataCr2 = opCr2.find_orient(_en=_v.op_DCM_e, _ang_dif_pl=-1.5707963) diff --git a/tests/template/srw_import_data/amx_bl2.json b/tests/template/srw_import_data/amx_bl2.json index 7222d28047..a3a86fb61d 100644 --- a/tests/template/srw_import_data/amx_bl2.json +++ b/tests/template/srw_import_data/amx_bl2.json @@ -295,7 +295,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "3": [ @@ -322,7 +330,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "4": [ @@ -409,7 +425,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "7": [ @@ -466,7 +490,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ] }, diff --git a/tests/template/srw_import_data/amx_bl3.json b/tests/template/srw_import_data/amx_bl3.json index c40aebf4ce..4f8024f796 100644 --- a/tests/template/srw_import_data/amx_bl3.json +++ b/tests/template/srw_import_data/amx_bl3.json @@ -301,7 +301,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "3": [ @@ -328,7 +336,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "4": [ @@ -415,7 +431,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "7": [ @@ -502,7 +526,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ] }, diff --git a/tests/template/srw_import_data/amx_bl4.json b/tests/template/srw_import_data/amx_bl4.json index e11e49c5f4..bb7948ef7c 100644 --- a/tests/template/srw_import_data/amx_bl4.json +++ b/tests/template/srw_import_data/amx_bl4.json @@ -241,7 +241,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "3": [ @@ -268,7 +276,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "4": [ @@ -385,7 +401,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ] }, diff --git a/tests/template/srw_import_data/chx.json b/tests/template/srw_import_data/chx.json index 66b77e20e9..0f72349b68 100644 --- a/tests/template/srw_import_data/chx.json +++ b/tests/template/srw_import_data/chx.json @@ -318,7 +318,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "2": [ @@ -345,7 +353,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "3": [ @@ -462,7 +478,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "7": [ @@ -519,7 +543,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "9": [ diff --git a/tests/template/srw_import_data/chx.py b/tests/template/srw_import_data/chx.py index 85ef6402ea..33efc226dd 100644 --- a/tests/template/srw_import_data/chx.py +++ b/tests/template/srw_import_data/chx.py @@ -38,7 +38,7 @@ def set_optics(_v): Such function has to be written for every beamline to be simulated; it is specific to a particular beamline. :param _v: structure containing all parameters allowed to be varied for that particular beamline """ - + #---Nominal Positions of Optical Elements [m] (with respect to straight section center) zS0 = 20.5 #S0 (primary slit) zHDM = 27.4 #Horizontally-Deflecting Mirror (HDM) @@ -66,7 +66,7 @@ def set_optics(_v): if(_v.op_fin not in arElNamesAll): raise Exception('Optical element with the name specified in the "op_fin" option is not present in this beamline') #Could be made more general - arElNames = []; + arElNames = []; for i in range(len(arElNamesAll)): arElNames.append(arElNamesAll[i]) if(len(_v.op_fin) > 0): @@ -75,19 +75,19 @@ def set_optics(_v): el = []; pp = [] #lists of SRW optical element objects and their corresponding propagation parameters #S0 (primary slit) - if('S0' in arElNames): + if('S0' in arElNames): el.append(SRWLOptA('r', 'a', _v.op_S0_dx, _v.op_S0_dy, _v.op_S0_x, _v.op_S0_y)); pp.append(_v.op_S0_pp) #Drift S0 -> HDM - if('S0_HDM' in arElNames): + if('S0_HDM' in arElNames): el.append(SRWLOptD(zHDM - zS0)); pp.append(_v.op_S0_HDM_pp) #Drift S0 -> S1 - if('S0_S1' in arElNames): + if('S0_S1' in arElNames): el.append(SRWLOptD(zS1 - zS0)); pp.append(_v.op_S0_S1_pp) - + #HDM (Height Profile Error) - if('HDM' in arElNames): + if('HDM' in arElNames): horApHDM = 0.94e-03 #Projected dimensions verApHDM = 1.e-03 angHDM = 3.1415926e-03 #? grazing angle @@ -100,17 +100,17 @@ def set_optics(_v): pathDifHDM = opHDM.get_data(3, 3) srwl_uti_save_intens_ascii(pathDifHDM, opHDM.mesh, ofnHDM, 0, ['', 'Horizontal Position', 'Vertical Position', 'Opt. Path Dif.'], _arUnits=['', 'm', 'm', 'm']) el.append(opHDM); pp.append(_v.op_HDM_pp) - + #Drift HDM -> S1 - if('HDM_S1' in arElNames): + if('HDM_S1' in arElNames): el.append(SRWLOptD(zS1 - zHDM + _v.op_S1_dz)); pp.append(_v.op_HDM_S1_pp) #S1 slit - if('S1' in arElNames): + if('S1' in arElNames): el.append(SRWLOptA('r', 'a', _v.op_S1_dx, _v.op_S1_dy, _v.op_S1_x, _v.op_S1_y)); pp.append(_v.op_S1_pp) #Drift S1 -> DCM - if('S1_DCM' in arElNames): + if('S1_DCM' in arElNames): el.append(SRWLOptD(zDCM - zS1)); pp.append(_v.op_S1_DCM_pp) #Double-Crystal Monochromator @@ -125,12 +125,12 @@ def set_optics(_v): #print('DCM Fourier Components:', psi) #---------------------- DCM Crystal #1 - opCr1 = SRWLOptCryst(_d_sp=dc, _psi0r=psi[0], _psi0i=psi[1], _psi_hr=psi[2], _psi_hi=psi[3], _psi_hbr=psi[2], _psi_hbi=psi[3], _tc=tc, _ang_as=angAs) + opCr1 = SRWLOptCryst(_d_sp=dc, _psi0r=psi[0], _psi0i=psi[1], _psi_hr=psi[2], _psi_hi=psi[3], _psi_hbr=psi[2], _psi_hbi=psi[3], _tc=tc, _ang_as=angAs, _e_avg=_v.op_DCM_e) #Find appropriate orientation of the Crystal #1 and the Output Beam Frame (using a member-function in SRWLOptCryst): #orientDataCr1 = opCr1.find_orient(_en=_v.op_DCM_e, _ang_dif_pl=1.5707963) # Horizontally-deflecting (from HXN) orientDataCr1 = opCr1.find_orient(_en=_v.op_DCM_e) # Vertically-deflecting - + #Crystal #1 Orientation found: orientCr1 = orientDataCr1[0] tCr1 = orientCr1[0] #Tangential Vector to Crystal surface @@ -138,13 +138,13 @@ def set_optics(_v): nCr1 = orientCr1[2] #Normal Vector to Crystal surface print('DCM Crystal #1 Orientation (original):') print(' t =', tCr1, 's =', orientCr1[1], 'n =', nCr1) - + if(_v.op_DCM_ac1 != 0): #Small rotation of DCM Crystal #1: rot = uti_math.trf_rotation([0,1,0], _v.op_DCM_ac1, [0,0,0]) tCr1 = uti_math.matr_prod(rot[0], tCr1) sCr1 = uti_math.matr_prod(rot[0], sCr1) nCr1 = uti_math.matr_prod(rot[0], nCr1) - + #Set the Crystal #1 orientation: opCr1.set_orient(nCr1[0], nCr1[1], nCr1[2], tCr1[0], tCr1[1]) @@ -219,7 +219,7 @@ def set_optics(_v): el.append(opDCME); pp.append(_v.op_DCME_pp) #Drift DCM -> S2 - if('DCM_S2' in arElNames): + if('DCM_S2' in arElNames): el.append(SRWLOptD(zS2 - zDCM + _v.op_S2_dz)); pp.append(_v.op_DCM_S2_pp) #Boron Fiber (with Tungsten core) @@ -232,23 +232,23 @@ def set_optics(_v): pp.append(_v.op_FIB_pp) #Drift S1 -> S2 - if('S1_S2' in arElNames): + if('S1_S2' in arElNames): el.append(SRWLOptD(zS2 - zS1 + _v.op_S2_dz)); pp.append(_v.op_S1_S2_pp) #S2 slit - if('S2' in arElNames): + if('S2' in arElNames): el.append(SRWLOptA('r', 'a', _v.op_S2_dx, _v.op_S2_dy, _v.op_S2_x, _v.op_S2_y)); pp.append(_v.op_S2_pp) #Drift S2 -> BPM - if('S2_BPM' in arElNames): + if('S2_BPM' in arElNames): el.append(SRWLOptD(zBPM - zS2 + _v.op_BPM_dz)); pp.append(_v.op_S2_BPM_pp) #Drift BPM -> CRL - if('BPM_CRL' in arElNames): + if('BPM_CRL' in arElNames): el.append(SRWLOptD(zCRL - zBPM + _v.op_CRL_dz)); pp.append(_v.op_BPM_CRL_pp) #Drift S2 -> CRL - if('S2_CRL' in arElNames): + if('S2_CRL' in arElNames): el.append(SRWLOptD(zCRL - zS2 - _v.op_S2_dz + _v.op_CRL_dz)); pp.append(_v.op_S2_CRL_pp) #CRL1 (1D, vertically-focusing) @@ -280,7 +280,7 @@ def set_optics(_v): el.append(SRWLOptD(zSample - zCRL - _v.op_CRL_dz + _v.op_SMP_dz)); pp.append(_v.op_CRL_SMP_pp) #KL Aperture - if('KLA' in arElNames): + if('KLA' in arElNames): el.append(SRWLOptA('r', 'a', _v.op_KLA_dx, _v.op_KLA_dy, _v.op_KL_x, _v.op_KL_y)); pp.append(_v.op_KLA_pp) #KL (1D, horizontally-focusing) @@ -306,7 +306,7 @@ def set_optics(_v): if(len(ifnSMP) > 0): ifSMP = open(ifnSMP, 'rb') opSMP = pickle.load(ifSMP) - + #Implementing transverse shift of sample ?? xSt = opSMP.mesh.xStart xFi = opSMP.mesh.xFin @@ -318,14 +318,14 @@ def set_optics(_v): halfRangeY = 0.5*(yFi - ySt) opSMP.mesh.yStart = -halfRangeY + _v.op_SMP_y opSMP.mesh.yFin = halfRangeY + _v.op_SMP_y - + ofnSMP = os.path.join(_v.fdir, _v.op_SMP_ofn) if len(_v.op_SMP_ofn) > 0 else '' if(len(ofnSMP) > 0): pathDifSMP = opSMP.get_data(3, 3) srwl_uti_save_intens_ascii(pathDifSMP, opSMP.mesh, ofnSMP, 0, ['', 'Horizontal Position', 'Vertical Position', 'Opt. Path Dif.'], _arUnits=['', 'm', 'm', 'm']) el.append(opSMP); pp.append(_v.op_SMP_pp) ifSMP.close() - + #Drift Sample -> Detector if('SMP_D' in arElNames): el.append(SRWLOptD(zD - zSample + _v.op_D_dz)); pp.append(_v.op_SMP_D_pp) @@ -335,7 +335,7 @@ def set_optics(_v): return SRWLOptC(el, pp) #*********************************List of Parameters allowed to be varied -#---List of supported options / commands / parameters allowed to be varied for this Beamline (comment-out unnecessary): +#---List of supported options / commands / parameters allowed to be varied for this Beamline (comment-out unnecessary): varParam = [ #---Data Folder ['fdir', 's', os.path.join(os.getcwd(), 'data_CHX'), 'folder (directory) name for reading-in input and saving output data files'], @@ -354,7 +354,7 @@ def set_optics(_v): ['ebm_ens', 'f', -1, 'electron beam relative energy spread'], ['ebm_emx', 'f', -1, 'electron beam horizontal emittance [m]'], ['ebm_emy', 'f', -1, 'electron beam vertical emittance [m]'], - + #---Undulator ['und_per', 'f', 0.02, 'undulator period [m]'], ['und_len', 'f', 3., 'undulator length [m]'], @@ -374,14 +374,14 @@ def set_optics(_v): #NOTE: the above option/variable names (fdir, ebm*, und*, ss*, sm*, pw*, is*, ws*, wm*) should be the same in all beamline scripts #on the other hand, the beamline optics related options below (op*) are specific to a particular beamline (and can be differ from beamline to beamline). #However, the default values of all the options/variables (above and below) can differ from beamline to beamline. - + #---Beamline Optics - + ['op_r', 'f', 20.5, 'longitudinal position of the first optical element [m]'], ['op_fin', 's', 'S3_SMP', 'name of the final optical element wavefront has to be propagated through'], ['op_BL', 'f', 1, 'beamline version/option number'], - + ['op_S0_dx', 'f', 0.2e-03, 'slit S0: horizontal size [m]'], ['op_S0_dy', 'f', 1.0e-03, 'slit S0: vertical size [m]'], ['op_S0_x', 'f', 0., 'slit S0: horizontal center position [m]'], @@ -424,9 +424,9 @@ def set_optics(_v): ['op_S2_dy', 'f', 0.2e-03, 'slit S2: vertical size [m]'], #1.0e-03, 'slit S2: vertical size [m]'], ['op_S2_x', 'f', 0., 'slit S2: horizontal center position [m]'], ['op_S2_y', 'f', 0., 'slit S2: vertical center position [m]'], - + ['op_BPM_dz', 'f', 0., 'BPM: offset of longitudinal position [m]'], - + ['op_CRL_dz', 'f', 0., 'CRL: offset of longitudinal position [m]'], ['op_CRL1_fpl', 's', 'v', 'CRL1: focusing plane ("h" or "v" or "hv" or "")'], ['op_CRL1_delta', 'f', 4.20756805e-06, 'CRL1: refractive index decrements of material'], @@ -438,7 +438,7 @@ def set_optics(_v): ['op_CRL1_thck', 'f', 80.e-06, 'CRL1: wall thickness (at the tip of parabola) [m]'], ['op_CRL1_x', 'f', 0., 'CRL1: horizontal center position [m]'], ['op_CRL1_y', 'f', 0., 'CRL1: vertical center position [m]'], - + ['op_CRL2_fpl', 's', 'v', 'CRL2: focusing plane ("h" or "v" or "hv" or "")'], ['op_CRL2_delta', 'f', 4.20756805e-06, 'CRL2: refractive index decrements of material'], ['op_CRL2_atnl', 'f', 7312.94e-06, 'CRL2: attenuation length of material [m]'], @@ -449,7 +449,7 @@ def set_optics(_v): ['op_CRL2_thck', 'f', 80.e-06, 'CRL2: wall thickness (at the tip of parabola) [m]'], ['op_CRL2_x', 'f', 0., 'CRL2: horizontal center position [m]'], ['op_CRL2_y', 'f', 0., 'CRL2: vertical center position [m]'], - + ['op_KLA_dx', 'f', 1.0e-03, 'KL aperture: horizontal size [m]'], #1.4e-03, 'KL Aperture: horizontal size [m]'], ['op_KLA_dy', 'f', 0.1e-03, 'KL aperture: vertical size [m]'], #0.2e-03, 'KL Aperture: vertical size [m]'], ['op_KL_dz', 'f', 0., 'KL: offset of longitudinal position [m]'], @@ -457,19 +457,19 @@ def set_optics(_v): ['op_KL_fy', 'f', 1.e+23, 'KL: vertical focal length [m]'], ['op_KL_x', 'f', 0., 'KL: horizontal center position [m]'], ['op_KL_y', 'f', 0., 'KL: vertical center position [m]'], - + ['op_S3_dz', 'f', 0., 'S3: offset of longitudinal position [m]'], ['op_S3_dx', 'f', 10.e-06, 'slit S3: horizontal size [m]'], ['op_S3_dy', 'f', 10.e-06, 'slit S3: vertical size [m]'], ['op_S3_x', 'f', 0., 'slit S3: horizontal center position [m]'], ['op_S3_y', 'f', 0., 'slit S3: vertical center position [m]'], - + ['op_SMP_dz', 'f', 0., 'sample: offset of longitudinal position [m]'], ['op_SMP_ifn', 's', 'CHX_SMP_CDI_001.pickle', 'sample: model file name (binary "dumped" SRW transmission object)'], ['op_SMP_ofn', 's', 'res_CHX_SMP_opt_path_dif.dat', 'sample: output file name of optical path difference data'], ['op_SMP_x', 'f', 0., 'sample: horizontal center position [m]'], ['op_SMP_y', 'f', 0., 'sample: vertical center position [m]'], - + ['op_D_dz', 'f', 0., 'detector: offset of longitudinal position [m]'], #to add options for different beamline cases, etc. @@ -530,13 +530,13 @@ def set_optics(_v): ] varParam = srwl_uti_ext_options(varParam) - + #*********************************Entry if __name__ == "__main__": #---Parse options, defining Beamline elements and running calculations v = srwl_uti_parse_options(varParam) - + #---Add some constant "parameters" (not allowed to be varied) for the beamline #v.und_per = 0.02 #['und_per', 'f', 0.02, 'undulator period [m]'], #v.und_len = 3. #['und_len', 'f', 3., 'undulator length [m]'], diff --git a/tests/template/srw_import_data/chx_fiber.json b/tests/template/srw_import_data/chx_fiber.json index 62e59762a7..82d529b6f3 100644 --- a/tests/template/srw_import_data/chx_fiber.json +++ b/tests/template/srw_import_data/chx_fiber.json @@ -370,7 +370,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "5": [ @@ -397,7 +405,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "6": [ @@ -454,7 +470,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "8": [ @@ -511,7 +535,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ] }, diff --git a/tests/template/srw_import_data/chx_fiber.py b/tests/template/srw_import_data/chx_fiber.py index aad386471b..8b83079667 100644 --- a/tests/template/srw_import_data/chx_fiber.py +++ b/tests/template/srw_import_data/chx_fiber.py @@ -38,7 +38,7 @@ def set_optics(_v): Such function has to be written for every beamline to be simulated; it is specific to a particular beamline. :param _v: structure containing all parameters allowed to be varied for that particular beamline """ - + #---Nominal Positions of Optical Elements [m] (with respect to straight section center) zS0 = 20.5 #S0 (primary slit) zHDM = 27.4 #Horizontally-Deflecting Mirror (HDM) @@ -66,7 +66,7 @@ def set_optics(_v): if(_v.op_fin not in arElNamesAll): raise Exception('Optical element with the name specified in the "op_fin" option is not present in this beamline') #Could be made more general - arElNames = []; + arElNames = []; for i in range(len(arElNamesAll)): arElNames.append(arElNamesAll[i]) if(len(_v.op_fin) > 0): @@ -75,19 +75,19 @@ def set_optics(_v): el = []; pp = [] #lists of SRW optical element objects and their corresponding propagation parameters #S0 (primary slit) - if('S0' in arElNames): + if('S0' in arElNames): el.append(SRWLOptA('r', 'a', _v.op_S0_dx, _v.op_S0_dy, _v.op_S0_x, _v.op_S0_y)); pp.append(_v.op_S0_pp) #Drift S0 -> HDM - if('S0_HDM' in arElNames): + if('S0_HDM' in arElNames): el.append(SRWLOptD(zHDM - zS0)); pp.append(_v.op_S0_HDM_pp) #Drift S0 -> S1 - if('S0_S1' in arElNames): + if('S0_S1' in arElNames): el.append(SRWLOptD(zS1 - zS0)); pp.append(_v.op_S0_S1_pp) - + #HDM (Height Profile Error) - if('HDM' in arElNames): + if('HDM' in arElNames): horApHDM = 0.94e-03 #Projected dimensions verApHDM = 1.e-03 angHDM = 3.1415926e-03 #? grazing angle @@ -100,17 +100,17 @@ def set_optics(_v): pathDifHDM = opHDM.get_data(3, 3) srwl_uti_save_intens_ascii(pathDifHDM, opHDM.mesh, ofnHDM, 0, ['', 'Horizontal Position', 'Vertical Position', 'Opt. Path Dif.'], _arUnits=['', 'm', 'm', 'm']) el.append(opHDM); pp.append(_v.op_HDM_pp) - + #Drift HDM -> S1 - if('HDM_S1' in arElNames): + if('HDM_S1' in arElNames): el.append(SRWLOptD(zS1 - zHDM + _v.op_S1_dz)); pp.append(_v.op_HDM_S1_pp) #S1 slit - if('S1' in arElNames): + if('S1' in arElNames): el.append(SRWLOptA('r', 'a', _v.op_S1_dx, _v.op_S1_dy, _v.op_S1_x, _v.op_S1_y)); pp.append(_v.op_S1_pp) #Drift S1 -> DCM - if('S1_DCM' in arElNames): + if('S1_DCM' in arElNames): el.append(SRWLOptD(zDCM - zS1)); pp.append(_v.op_S1_DCM_pp) #Double-Crystal Monochromator @@ -130,7 +130,7 @@ def set_optics(_v): #Find appropriate orientation of the Crystal #1 and the Output Beam Frame (using a member-function in SRWLOptCryst): #orientDataCr1 = opCr1.find_orient(_en=_v.op_DCM_e, _ang_dif_pl=1.5707963) # Horizontally-deflecting (from HXN) orientDataCr1 = opCr1.find_orient(_en=_v.op_DCM_e) # Vertically-deflecting - + #Crystal #1 Orientation found: orientCr1 = orientDataCr1[0] tCr1 = orientCr1[0] #Tangential Vector to Crystal surface @@ -138,13 +138,13 @@ def set_optics(_v): nCr1 = orientCr1[2] #Normal Vector to Crystal surface print('DCM Crystal #1 Orientation (original):') print(' t =', tCr1, 's =', orientCr1[1], 'n =', nCr1) - + if(_v.op_DCM_ac1 != 0): #Small rotation of DCM Crystal #1: rot = uti_math.trf_rotation([0,1,0], _v.op_DCM_ac1, [0,0,0]) tCr1 = uti_math.matr_prod(rot[0], tCr1) sCr1 = uti_math.matr_prod(rot[0], sCr1) nCr1 = uti_math.matr_prod(rot[0], nCr1) - + #Set the Crystal #1 orientation: opCr1.set_orient(nCr1[0], nCr1[1], nCr1[2], tCr1[0], tCr1[1]) @@ -165,12 +165,12 @@ def set_optics(_v): el.append(opCr1); pp.append(_v.op_DCMC1_pp) #---------------------- DCM Crystal #2 - opCr2 = SRWLOptCryst(_d_sp=dc, _psi0r=psi[0], _psi0i=psi[1], _psi_hr=psi[2], _psi_hi=psi[3], _psi_hbr=psi[2], _psi_hbi=psi[3], _tc=tc, _ang_as=angAs) + opCr2 = SRWLOptCryst(_d_sp=dc, _psi0r=psi[0], _psi0i=psi[1], _psi_hr=psi[2], _psi_hi=psi[3], _psi_hbr=psi[2], _psi_hbi=psi[3], _tc=tc, _ang_as=angAs, _ang_roll=3.1415926) #Find appropriate orientation of the Crystal #2 and the Output Beam Frame #orientDataCr2 = opCr2.find_orient(_en=_v.op_DCM_e, _ang_dif_pl=-1.5707963) #from HXN orientDataCr2 = opCr2.find_orient(_en=_v.op_DCM_e, _ang_dif_pl=3.1415926) #Vertically-deflecting - + #Crystal #2 Orientation found: orientCr2 = orientDataCr2[0] tCr2 = orientCr2[0] #Tangential Vector to Crystal surface @@ -220,7 +220,7 @@ def set_optics(_v): el.append(opDCME); pp.append(_v.op_DCME_pp) #Drift DCM -> S2 - if('DCM_S2' in arElNames): + if('DCM_S2' in arElNames): el.append(SRWLOptD(zS2 - zDCM + _v.op_S2_dz)); pp.append(_v.op_DCM_S2_pp) #Boron Fiber (with Tungsten core) @@ -233,23 +233,23 @@ def set_optics(_v): pp.append(_v.op_FIB_pp) #Drift S1 -> S2 - if('S1_S2' in arElNames): + if('S1_S2' in arElNames): el.append(SRWLOptD(zS2 - zS1 + _v.op_S2_dz)); pp.append(_v.op_S1_S2_pp) #S2 slit - if('S2' in arElNames): + if('S2' in arElNames): el.append(SRWLOptA('r', 'a', _v.op_S2_dx, _v.op_S2_dy, _v.op_S2_x, _v.op_S2_y)); pp.append(_v.op_S2_pp) #Drift S2 -> BPM - if('S2_BPM' in arElNames): + if('S2_BPM' in arElNames): el.append(SRWLOptD(zBPM - zS2 + _v.op_BPM_dz)); pp.append(_v.op_S2_BPM_pp) #Drift BPM -> CRL - if('BPM_CRL' in arElNames): + if('BPM_CRL' in arElNames): el.append(SRWLOptD(zCRL - zBPM + _v.op_CRL_dz)); pp.append(_v.op_BPM_CRL_pp) #Drift S2 -> CRL - if('S2_CRL' in arElNames): + if('S2_CRL' in arElNames): el.append(SRWLOptD(zCRL - zS2 - _v.op_S2_dz + _v.op_CRL_dz)); pp.append(_v.op_S2_CRL_pp) #CRL1 (1D, vertically-focusing) @@ -281,7 +281,7 @@ def set_optics(_v): el.append(SRWLOptD(zSample - zCRL - _v.op_CRL_dz + _v.op_SMP_dz)); pp.append(_v.op_CRL_SMP_pp) #KL Aperture - if('KLA' in arElNames): + if('KLA' in arElNames): el.append(SRWLOptA('r', 'a', _v.op_KLA_dx, _v.op_KLA_dy, _v.op_KL_x, _v.op_KL_y)); pp.append(_v.op_KLA_pp) #KL (1D, horizontally-focusing) @@ -307,7 +307,7 @@ def set_optics(_v): if(len(ifnSMP) > 0): ifSMP = open(ifnSMP, 'rb') opSMP = pickle.load(ifSMP) - + #Implementing transverse shift of sample ?? xSt = opSMP.mesh.xStart xFi = opSMP.mesh.xFin @@ -319,14 +319,14 @@ def set_optics(_v): halfRangeY = 0.5*(yFi - ySt) opSMP.mesh.yStart = -halfRangeY + _v.op_SMP_y opSMP.mesh.yFin = halfRangeY + _v.op_SMP_y - + ofnSMP = os.path.join(_v.fdir, _v.op_SMP_ofn) if len(_v.op_SMP_ofn) > 0 else '' if(len(ofnSMP) > 0): pathDifSMP = opSMP.get_data(3, 3) srwl_uti_save_intens_ascii(pathDifSMP, opSMP.mesh, ofnSMP, 0, ['', 'Horizontal Position', 'Vertical Position', 'Opt. Path Dif.'], _arUnits=['', 'm', 'm', 'm']) el.append(opSMP); pp.append(_v.op_SMP_pp) ifSMP.close() - + #Drift Sample -> Detector if('SMP_D' in arElNames): el.append(SRWLOptD(zD - zSample + _v.op_D_dz)); pp.append(_v.op_SMP_D_pp) @@ -336,7 +336,7 @@ def set_optics(_v): return SRWLOptC(el, pp) #*********************************List of Parameters allowed to be varied -#---List of supported options / commands / parameters allowed to be varied for this Beamline (comment-out unnecessary): +#---List of supported options / commands / parameters allowed to be varied for this Beamline (comment-out unnecessary): varParam = [ #---Data Folder ['fdir', 's', os.path.join(os.getcwd(), 'data_CHX'), 'folder (directory) name for reading-in input and saving output data files'], @@ -375,14 +375,14 @@ def set_optics(_v): #NOTE: the above option/variable names (fdir, ebm*, und*, ss*, sm*, pw*, is*, ws*, wm*) should be the same in all beamline scripts #on the other hand, the beamline optics related options below (op*) are specific to a particular beamline (and can be differ from beamline to beamline). #However, the default values of all the options/variables (above and below) can differ from beamline to beamline. - + #---Beamline Optics - + ['op_r', 'f', 20.5, 'longitudinal position of the first optical element [m]'], ['op_fin', 's', 'FIB', 'name of the final optical element wavefront has to be propagated through'], ['op_BL', 'f', 5, 'beamline version/option number'], - + ['op_S0_dx', 'f', 0.2e-03, 'slit S0: horizontal size [m]'], ['op_S0_dy', 'f', 1.0e-03, 'slit S0: vertical size [m]'], ['op_S0_x', 'f', 0., 'slit S0: horizontal center position [m]'], @@ -425,9 +425,9 @@ def set_optics(_v): ['op_S2_dy', 'f', 0.2e-03, 'slit S2: vertical size [m]'], #1.0e-03, 'slit S2: vertical size [m]'], ['op_S2_x', 'f', 0., 'slit S2: horizontal center position [m]'], ['op_S2_y', 'f', 0., 'slit S2: vertical center position [m]'], - + ['op_BPM_dz', 'f', 0., 'BPM: offset of longitudinal position [m]'], - + ['op_CRL_dz', 'f', 0., 'CRL: offset of longitudinal position [m]'], ['op_CRL1_fpl', 's', 'v', 'CRL1: focusing plane ("h" or "v" or "hv" or "")'], ['op_CRL1_delta', 'f', 4.20756805e-06, 'CRL1: refractive index decrements of material'], @@ -439,7 +439,7 @@ def set_optics(_v): ['op_CRL1_thck', 'f', 80.e-06, 'CRL1: wall thickness (at the tip of parabola) [m]'], ['op_CRL1_x', 'f', 0., 'CRL1: horizontal center position [m]'], ['op_CRL1_y', 'f', 0., 'CRL1: vertical center position [m]'], - + ['op_CRL2_fpl', 's', 'v', 'CRL2: focusing plane ("h" or "v" or "hv" or "")'], ['op_CRL2_delta', 'f', 4.20756805e-06, 'CRL2: refractive index decrements of material'], ['op_CRL2_atnl', 'f', 7312.94e-06, 'CRL2: attenuation length of material [m]'], @@ -450,7 +450,7 @@ def set_optics(_v): ['op_CRL2_thck', 'f', 80.e-06, 'CRL2: wall thickness (at the tip of parabola) [m]'], ['op_CRL2_x', 'f', 0., 'CRL2: horizontal center position [m]'], ['op_CRL2_y', 'f', 0., 'CRL2: vertical center position [m]'], - + ['op_KLA_dx', 'f', 1.0e-03, 'KL aperture: horizontal size [m]'], #1.4e-03, 'KL Aperture: horizontal size [m]'], ['op_KLA_dy', 'f', 0.1e-03, 'KL aperture: vertical size [m]'], #0.2e-03, 'KL Aperture: vertical size [m]'], ['op_KL_dz', 'f', 0., 'KL: offset of longitudinal position [m]'], @@ -458,19 +458,19 @@ def set_optics(_v): ['op_KL_fy', 'f', 1.e+23, 'KL: vertical focal length [m]'], ['op_KL_x', 'f', 0., 'KL: horizontal center position [m]'], ['op_KL_y', 'f', 0., 'KL: vertical center position [m]'], - + ['op_S3_dz', 'f', 0., 'S3: offset of longitudinal position [m]'], ['op_S3_dx', 'f', 10.e-06, 'slit S3: horizontal size [m]'], ['op_S3_dy', 'f', 10.e-06, 'slit S3: vertical size [m]'], ['op_S3_x', 'f', 0., 'slit S3: horizontal center position [m]'], ['op_S3_y', 'f', 0., 'slit S3: vertical center position [m]'], - + ['op_SMP_dz', 'f', 0., 'sample: offset of longitudinal position [m]'], ['op_SMP_ifn', 's', 'CHX_SMP_CDI_001.pickle', 'sample: model file name (binary "dumped" SRW transmission object)'], ['op_SMP_ofn', 's', 'res_CHX_SMP_opt_path_dif.dat', 'sample: output file name of optical path difference data'], ['op_SMP_x', 'f', 0., 'sample: horizontal center position [m]'], ['op_SMP_y', 'f', 0., 'sample: vertical center position [m]'], - + ['op_D_dz', 'f', 0., 'detector: offset of longitudinal position [m]'], #to add options for different beamline cases, etc. @@ -531,13 +531,13 @@ def set_optics(_v): ] varParam = srwl_uti_ext_options(varParam) - + #*********************************Entry if __name__ == "__main__": #---Parse options, defining Beamline elements and running calculations v = srwl_uti_parse_options(varParam) - + #---Add some constant "parameters" (not allowed to be varied) for the beamline #v.und_per = 0.02 #['und_per', 'f', 0.02, 'undulator period [m]'], #v.und_len = 3. #['und_len', 'f', 3., 'undulator length [m]'], diff --git a/tests/template/srw_import_data/exported_chx.json b/tests/template/srw_import_data/exported_chx.json index c8b777af36..79ecf87563 100644 --- a/tests/template/srw_import_data/exported_chx.json +++ b/tests/template/srw_import_data/exported_chx.json @@ -270,7 +270,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "2": [ @@ -366,7 +374,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "6": [ @@ -414,7 +430,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "8": [ diff --git a/tests/template/srw_import_data/exported_gaussian_beam.json b/tests/template/srw_import_data/exported_gaussian_beam.json index 7f23cd3708..e777ea1ca4 100644 --- a/tests/template/srw_import_data/exported_gaussian_beam.json +++ b/tests/template/srw_import_data/exported_gaussian_beam.json @@ -204,7 +204,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ] }, diff --git a/tests/template/srw_import_data/lcls_simplified.json b/tests/template/srw_import_data/lcls_simplified.json index 8e413af97e..4453318954 100644 --- a/tests/template/srw_import_data/lcls_simplified.json +++ b/tests/template/srw_import_data/lcls_simplified.json @@ -243,7 +243,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ] }, diff --git a/tests/template/srw_import_data/lcls_sxr.json b/tests/template/srw_import_data/lcls_sxr.json index 40fb92208e..ea0ffca574 100644 --- a/tests/template/srw_import_data/lcls_sxr.json +++ b/tests/template/srw_import_data/lcls_sxr.json @@ -418,7 +418,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ] }, diff --git a/tests/template/srw_import_data/nsls-ii-esm-beamline.json b/tests/template/srw_import_data/nsls-ii-esm-beamline.json index de1e3c8f72..515c722eb7 100644 --- a/tests/template/srw_import_data/nsls-ii-esm-beamline.json +++ b/tests/template/srw_import_data/nsls-ii-esm-beamline.json @@ -328,7 +328,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "2": [ @@ -360,7 +368,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "3": [ @@ -432,7 +448,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "5": [ @@ -544,7 +568,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "8": [ diff --git a/tests/template/srw_import_data/sample_from_image.json b/tests/template/srw_import_data/sample_from_image.json index a04cab9db7..9a1ead780a 100644 --- a/tests/template/srw_import_data/sample_from_image.json +++ b/tests/template/srw_import_data/sample_from_image.json @@ -146,7 +146,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ] }, diff --git a/tests/template/srw_import_data/smi_es1_bump_norm.json b/tests/template/srw_import_data/smi_es1_bump_norm.json index f3b6fe2bdf..68f2dc89c9 100644 --- a/tests/template/srw_import_data/smi_es1_bump_norm.json +++ b/tests/template/srw_import_data/smi_es1_bump_norm.json @@ -45,7 +45,7 @@ "horizontalFocalLength": 1e+23, "horizontalOffset": 0, "id": 5, - "position": 38.30244, + "position": 38.302440000000004, "title": "KL2", "type": "lens", "verticalFocalLength": 9.611423401717389, @@ -58,7 +58,7 @@ "horizontalTransverseSize": 6.0, "id": 6, "orientation": "y", - "position": 38.30244, + "position": 38.302440000000004, "title": "HDM3", "type": "mirror", "verticalTransverseSize": 1.2566350129158168 @@ -70,7 +70,7 @@ "horizontalTransverseSize": 6.0, "id": 7, "orientation": "y", - "position": 39.00244, + "position": 39.00244000000001, "title": "HDM4", "type": "mirror", "verticalTransverseSize": 1.5707937661447706 @@ -79,7 +79,7 @@ "horizontalOffset": 0, "horizontalSize": 0.4, "id": 8, - "position": 47.00244, + "position": 47.00244000000001, "shape": "r", "title": "S1", "type": "aperture", @@ -88,7 +88,7 @@ }, { "id": 9, - "position": 50.90244, + "position": 50.902440000000006, "title": "Watch", "type": "watch" } @@ -260,7 +260,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "3": [ @@ -317,7 +325,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "5": [ @@ -434,7 +450,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ] }, diff --git a/tests/template/srw_import_data/smi_es1_nobump.json b/tests/template/srw_import_data/smi_es1_nobump.json index 1e69f73069..7520e9f53b 100644 --- a/tests/template/srw_import_data/smi_es1_nobump.json +++ b/tests/template/srw_import_data/smi_es1_nobump.json @@ -21,7 +21,7 @@ "horizontalFocalLength": 1e+23, "horizontalOffset": 0, "id": 3, - "position": 38.30244, + "position": 38.302440000000004, "title": "KL2", "type": "lens", "verticalFocalLength": 9.611423401717389, @@ -31,7 +31,7 @@ "horizontalOffset": 0, "horizontalSize": 0.4, "id": 4, - "position": 47.00244, + "position": 47.00244000000001, "shape": "r", "title": "S1", "type": "aperture", @@ -40,7 +40,7 @@ }, { "id": 5, - "position": 50.90244, + "position": 50.902440000000006, "title": "Watch", "type": "watch" } @@ -272,7 +272,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ] }, diff --git a/tests/template/srw_import_data/smi_es2_bump_lowdiv.json b/tests/template/srw_import_data/smi_es2_bump_lowdiv.json index c191b4f99c..0b8a56910d 100644 --- a/tests/template/srw_import_data/smi_es2_bump_lowdiv.json +++ b/tests/template/srw_import_data/smi_es2_bump_lowdiv.json @@ -45,7 +45,7 @@ "horizontalFocalLength": 1e+23, "horizontalOffset": 0, "id": 5, - "position": 38.30244, + "position": 38.302440000000004, "title": "KL2", "type": "lens", "verticalFocalLength": 10.730747950189782, @@ -58,7 +58,7 @@ "horizontalTransverseSize": 6.0, "id": 6, "orientation": "y", - "position": 38.30244, + "position": 38.302440000000004, "title": "HDM3", "type": "mirror", "verticalTransverseSize": 1.2566350129158168 @@ -70,7 +70,7 @@ "horizontalTransverseSize": 6.0, "id": 7, "orientation": "y", - "position": 39.00244, + "position": 39.00244000000001, "title": "HDM4", "type": "mirror", "verticalTransverseSize": 1.5707937661447706 @@ -79,7 +79,7 @@ "horizontalOffset": 0, "horizontalSize": 0.9, "id": 8, - "position": 47.00244, + "position": 47.00244000000001, "shape": "r", "title": "S1", "type": "aperture", @@ -90,7 +90,7 @@ "horizontalOffset": 0, "horizontalSize": 1.0, "id": 9, - "position": 57.33736, + "position": 57.337360000000004, "shape": "c", "title": "S2", "type": "aperture", @@ -103,7 +103,7 @@ "horizontalApertureSize": 1.0, "id": 10, "numberOfLenses": 23, - "position": 57.33736, + "position": 57.337360000000004, "radius": 5e-05, "refractiveIndex": 8.21692879e-07, "shape": 1, @@ -114,7 +114,7 @@ }, { "id": 11, - "position": 59.00244, + "position": 59.00244000000001, "title": "Watch", "type": "watch" } @@ -286,7 +286,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "2": [ @@ -313,7 +321,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "3": [ @@ -370,7 +386,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "5": [ @@ -487,7 +511,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "9": [ diff --git a/tests/template/srw_import_data/smi_es2_bump_norm.json b/tests/template/srw_import_data/smi_es2_bump_norm.json index 36ce0b1c59..67aa58b50b 100644 --- a/tests/template/srw_import_data/smi_es2_bump_norm.json +++ b/tests/template/srw_import_data/smi_es2_bump_norm.json @@ -45,7 +45,7 @@ "horizontalFocalLength": 1e+23, "horizontalOffset": 0, "id": 5, - "position": 38.30244, + "position": 38.302440000000004, "title": "KL2", "type": "lens", "verticalFocalLength": 9.611423401717389, @@ -58,7 +58,7 @@ "horizontalTransverseSize": 6.0, "id": 6, "orientation": "y", - "position": 38.30244, + "position": 38.302440000000004, "title": "HDM3", "type": "mirror", "verticalTransverseSize": 1.2566350129158168 @@ -70,7 +70,7 @@ "horizontalTransverseSize": 6.0, "id": 7, "orientation": "y", - "position": 39.00244, + "position": 39.00244000000001, "title": "HDM4", "type": "mirror", "verticalTransverseSize": 1.5707937661447706 @@ -79,7 +79,7 @@ "horizontalOffset": 0, "horizontalSize": 0.9, "id": 8, - "position": 47.00244, + "position": 47.00244000000001, "shape": "r", "title": "S1", "type": "aperture", @@ -90,7 +90,7 @@ "horizontalOffset": 0, "horizontalSize": 1.0, "id": 9, - "position": 57.33736, + "position": 57.337360000000004, "shape": "c", "title": "S2", "type": "aperture", @@ -103,7 +103,7 @@ "horizontalApertureSize": 1.0, "id": 10, "numberOfLenses": 23, - "position": 57.33736, + "position": 57.337360000000004, "radius": 5e-05, "refractiveIndex": 8.21692879e-07, "shape": 1, @@ -114,7 +114,7 @@ }, { "id": 11, - "position": 59.00244, + "position": 59.00244000000001, "title": "Watch", "type": "watch" } @@ -286,7 +286,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "2": [ @@ -313,7 +321,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "3": [ @@ -370,7 +386,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "5": [ @@ -487,7 +511,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "9": [ diff --git a/tests/template/srw_import_data/srx.json b/tests/template/srw_import_data/srx.json index 67f88195da..0a727e4219 100644 --- a/tests/template/srw_import_data/srx.json +++ b/tests/template/srw_import_data/srx.json @@ -87,7 +87,7 @@ "horizontalOffset": 0, "horizontalSize": 3.0, "id": 5, - "position": 48.1692, + "position": 48.169200000000004, "shape": "r", "title": "S3", "type": "aperture", @@ -232,7 +232,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "2": [ @@ -289,7 +297,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "4": [ @@ -346,7 +362,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ] }, diff --git a/tests/template/srw_import_data/srx.py b/tests/template/srw_import_data/srx.py index b294a76d63..e9f4dd96b4 100644 --- a/tests/template/srw_import_data/srx.py +++ b/tests/template/srw_import_data/srx.py @@ -76,7 +76,7 @@ def set_optics(_v): #Could be made more general ''' - arElNames = []; + arElNames = []; for i in range(len(arElNamesAll)): arElNames.append(arElNamesAll[i]) if(len(_v.op_fin) > 0): @@ -85,13 +85,13 @@ def set_optics(_v): el = []; pp = [] #lists of SRW optical element objects and their corresponding propagation parameters #S0 (primary slit) - if('S0' in arElNames): + if('S0' in arElNames): el.append(SRWLOptA('r', 'a', _v.op_S0_dx, _v.op_S0_dy)); pp.append(_v.op_S0_pp) #Drift S0 -> HFM - if('S0_HFM' in arElNames): + if('S0_HFM' in arElNames): el.append(SRWLOptD(zHFM - zS0)); pp.append(_v.op_S0_HFM_pp) - + #HDM (Height Profile Error) if('HFM' in arElNames): lenHFM = 0.95 #Length [m] @@ -119,19 +119,19 @@ def set_optics(_v): el.append(opHFM); pp.append(_v.op_HFMT_pp) #Drift HFM -> S1 - if('HFM_S1' in arElNames): + if('HFM_S1' in arElNames): el.append(SRWLOptD(zS1 - zHFM + _v.op_S1_dz)); pp.append(_v.op_HFM_S1_pp) #S1 slit - if('S1' in arElNames): + if('S1' in arElNames): el.append(SRWLOptA('r', 'a', _v.op_S1_dx, _v.op_S1_dy)); pp.append(_v.op_S1_pp) #Drift S1 -> DCM - if('S1_DCM' in arElNames): + if('S1_DCM' in arElNames): el.append(SRWLOptD(zDCM - zS1 - _v.op_S1_dz)); pp.append(_v.op_S1_DCM_pp) #Drift S1 -> SSA - if('S1_SSA' in arElNames): + if('S1_SSA' in arElNames): el.append(SRWLOptD(zSSA - zS1 - _v.op_S1_dz + _v.op_SSA_dz)); pp.append(_v.op_S1_SSA_pp) #Double-Crystal Monochromator @@ -140,32 +140,32 @@ def set_optics(_v): angAs = 0.*pi/180. # [rad] asymmetry angle hc = [1,1,1] if(_v.op_DCM_r == '311'): hc = [3,1,1] - + dc = srwl_uti_cryst_pl_sp(hc, 'Si') #print('DCM Interplannar dist.:', dc) psi = srwl_uti_cryst_pol_f(_v.op_DCM_e0, hc, 'Si') #MR15032016: replaced "op_DCM_e" by "op_DCM_e0" to test the import in Sirepo #print('DCM Fourier Components:', psi) #---------------------- DCM Crystal #1 - opCr1 = SRWLOptCryst(_d_sp=dc, _psi0r=psi[0], _psi0i=psi[1], _psi_hr=psi[2], _psi_hi=psi[3], _psi_hbr=psi[2], _psi_hbi=psi[3], _tc=tc, _ang_as=angAs) + opCr1 = SRWLOptCryst(_d_sp=dc, _psi0r=psi[0], _psi0i=psi[1], _psi_hr=psi[2], _psi_hi=psi[3], _psi_hbr=psi[2], _psi_hbi=psi[3], _tc=tc, _ang_as=angAs, _ang_roll=1.5707963, _e_avg=_v.op_DCM_e0) #Find appropriate orientation of the Crystal #1 and the Output Beam Frame (using a member-function in SRWLOptCryst): orientDataCr1 = opCr1.find_orient(_en=_v.op_DCM_e0, _ang_dif_pl=1.5707963) # Horizontally-deflecting #MR15032016: replaced "op_DCM_e" by "op_DCM_e0" to test the import in Sirepo #Crystal #1 Orientation found: orientCr1 = orientDataCr1[0] tCr1 = orientCr1[0] #Tangential Vector to Crystal surface - sCr1 = orientCr1[1] + sCr1 = orientCr1[1] nCr1 = orientCr1[2] #Normal Vector to Crystal surface # print('DCM Crystal #1 Orientation (original):') # print(' t =', tCr1, 's =', orientCr1[1], 'n =', nCr1) - + import uti_math if(_v.op_DCM_ac1 != 0): #Small rotation of DCM Crystal #1: rot = uti_math.trf_rotation([0,1,0], _v.op_DCM_ac1, [0,0,0]) tCr1 = uti_math.matr_prod(rot[0], tCr1) sCr1 = uti_math.matr_prod(rot[0], sCr1) nCr1 = uti_math.matr_prod(rot[0], nCr1) - + #Set the Crystal #1 orientation: opCr1.set_orient(nCr1[0], nCr1[1], nCr1[2], tCr1[0], tCr1[1]) @@ -186,7 +186,7 @@ def set_optics(_v): el.append(opCr1); pp.append(_v.op_DCMC1_pp) #---------------------- DCM Crystal #2 - opCr2 = SRWLOptCryst(_d_sp=dc, _psi0r=psi[0], _psi0i=psi[1], _psi_hr=psi[2], _psi_hi=psi[3], _psi_hbr=psi[2], _psi_hbi=psi[3], _tc=tc, _ang_as=angAs) + opCr2 = SRWLOptCryst(_d_sp=dc, _psi0r=psi[0], _psi0i=psi[1], _psi_hr=psi[2], _psi_hi=psi[3], _psi_hbr=psi[2], _psi_hbi=psi[3], _tc=tc, _ang_as=angAs, _ang_roll=-1.5707963, _e_avg=_v.op_DCM_e0) #Find appropriate orientation of the Crystal #2 and the Output Beam Frame orientDataCr2 = opCr2.find_orient(_en=_v.op_DCM_e0, _ang_dif_pl=-1.5707963) #MR15032016: replaced "op_DCM_e" by "op_DCM_e0" to test the import in Sirepo @@ -225,15 +225,15 @@ def set_optics(_v): el.append(opCr2); pp.append(_v.op_DCMC2_pp) #Drift DCM -> SSA - if('DCM_SSA' in arElNames): + if('DCM_SSA' in arElNames): el.append(SRWLOptD(zSSA - zDCM + _v.op_SSA_dz)); pp.append(_v.op_DCM_SSA_pp) #SSA slit - if('SSA' in arElNames): + if('SSA' in arElNames): el.append(SRWLOptA('r', 'a', _v.op_SSA_dx, _v.op_SSA_dy)); pp.append(_v.op_SSA_pp) #Drift SSA -> DBPM2 - if('SSA_DBPM2' in arElNames): + if('SSA_DBPM2' in arElNames): el.append(SRWLOptD(zDBPM2 - zSSA - _v.op_SSA_dz + _v.op_DBPM2_dz)); pp.append(_v.op_SSA_DBPM2_pp) ###############To continue @@ -250,7 +250,7 @@ def set_optics(_v): ## srwl_uti_save_intens_ascii(pathDifSMP, opSMP.mesh, ofnSMP, 0, ['', 'Horizontal Position', 'Vertical Position', 'Opt. Path Dif.'], _arUnits=['', 'm', 'm', 'm']) ## el.append(opSMP); pp.append(v.op_SMP_pp) ## ifSMP.close() - + ## #Drift Sample -> Detector ## if('SMP_D' in arElNames): ## el.append(SRWLOptD(zD - zSample + v.op_D_dz)); pp.append(v.op_SMP_D_pp) @@ -260,7 +260,7 @@ def set_optics(_v): return SRWLOptC(el, pp) #*********************************List of Parameters allowed to be varied -#---List of supported options / commands / parameters allowed to be varied for this Beamline (comment-out unnecessary): +#---List of supported options / commands / parameters allowed to be varied for this Beamline (comment-out unnecessary): varParam = [ #---Data Folder ['fdir', 's', os.path.join(os.getcwd(), 'data_SRX'), 'folder (directory) name for reading-in input and saving output data files'], @@ -280,7 +280,7 @@ def set_optics(_v): ['ebm_ens', 'f', -1, 'electron beam relative energy spread'], ['ebm_emx', 'f', -1, 'electron beam horizontal emittance [m]'], ['ebm_emy', 'f', -1, 'electron beam vertical emittance [m]'], - + #---Undulator ['und_per', 'f', 0.021, 'undulator period [m]'], ['und_len', 'f', 1.5, 'undulator length [m]'], @@ -365,7 +365,7 @@ def set_optics(_v): ['ws', '', '', 'calculate single-electron (/ fully coherent) wavefront propagation', 'store_true'], #Multi-Electron (partially-coherent) Wavefront Propagation ['wm', '', '', 'calculate multi-electron (/ partially coherent) wavefront propagation', 'store_true'], - + ['w_e', 'f', 9000., 'photon energy [eV] for calculation of intensity distribution vs horizontal and vertical position'], ['w_ef', 'f', -1., 'final photon energy [eV] for calculation of intensity distribution vs horizontal and vertical position'], ['w_ne', 'i', 1, 'number of points vs photon energy for calculation of intensity distribution'], @@ -402,17 +402,17 @@ def set_optics(_v): #['ws_fn', 's', '', 'file name for saving single-e (/ fully coherent) wavefront data'], #['wm_fn', 's', '', 'file name for saving multi-e (/ partially coherent) wavefront data'], #to add options - + ['op_r', 'f', 33.1798, 'longitudinal position of the first optical element [m]'], ['op_fin', 's', 'S3_SMP', 'name of the final optical element wavefront has to be propagated through'], - + #NOTE: the above option/variable names (fdir, ebm*, und*, ss*, sm*, pw*, is*, ws*, wm*) should be the same in all beamline scripts #on the other hand, the beamline optics related options below (op*) are specific to a particular beamline (and can be differ from beamline to beamline). #However, the default values of all the options/variables (above and below) can differ from beamline to beamline. - + #---Beamline Optics ['op_BL', 'f', 1, 'beamline version/option number'], - + ['op_S0_dx', 'f', 2.375e-03, 'slit S0: horizontal size [m]'], ['op_S0_dy', 'f', 2.0e-03, 'slit S0: vertical size [m]'], @@ -469,12 +469,12 @@ def set_optics(_v): ['op_SSA_DBPM2_pp', 'f',[0, 0, 1, 1, 0, 1.0, 1.0, 1.0, 1.0, 0, 0, 0], 'drift SSA -> DBPM2: propagation parameters'], ###############To continue - + ## ['op_S3_SMP_pp', 'f', [0, 0, 1, 0, 0, 1.0, 1.0, 1.0, 1.0, 0, 0, 0], 'drift S3 -> sample: propagation parameters'], ## ['op_SMP_pp', 'f', [0, 0, 1, 0, 0, 1.0, 1.0, 1.0, 1.0, 0, 0, 0], 'sample: propagation parameters'], ## ['op_SMP_D_pp', 'f', [0, 0, 1, 3, 0, 1.0, 1.0, 1.0, 1.0, 0, 0, 0], 'sample -> detector: propagation parameters'], - #['op_fin_pp', 'f', [0, 0, 1, 0, 1, 0.1, 5.0, 1.0, 1.5, 0, 0, 0], 'final post-propagation (resize) parameters'], + #['op_fin_pp', 'f', [0, 0, 1, 0, 1, 0.1, 5.0, 1.0, 1.5, 0, 0, 0], 'final post-propagation (resize) parameters'], ['op_fin_pp', 'f', [0, 0, 1, 0, 0, 1.0, 1.0, 1.0, 1.0, 0, 0, 0], 'final post-propagation (resize) parameters'], #[ 0]: Auto-Resize (1) or not (0) Before propagation @@ -503,7 +503,7 @@ def set_optics(_v): #---Parse options, defining Beamline elements and running calculations v = srwl_uti_parse_options(varParam) - + #---Add some constant "parameters" (not allowed to be varied) for the beamline v.und_per = 0.021 #['und_per', 'f', 0.021, 'undulator period [m]'], v.und_len = 1.5 #['und_len', 'f', 1.5, 'undulator length [m]'], diff --git a/tests/template/srw_import_data/srx_bl2.json b/tests/template/srw_import_data/srx_bl2.json index 009a8ebc89..ed048539ff 100644 --- a/tests/template/srw_import_data/srx_bl2.json +++ b/tests/template/srw_import_data/srx_bl2.json @@ -295,7 +295,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "3": [ @@ -322,7 +330,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "4": [ @@ -409,7 +425,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "7": [ @@ -466,7 +490,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ] }, diff --git a/tests/template/srw_import_data/srx_bl3.json b/tests/template/srw_import_data/srx_bl3.json index 9907716b61..86a8b31a66 100644 --- a/tests/template/srw_import_data/srx_bl3.json +++ b/tests/template/srw_import_data/srx_bl3.json @@ -301,7 +301,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "3": [ @@ -328,7 +336,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "4": [ @@ -415,7 +431,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "7": [ @@ -502,7 +526,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ] }, diff --git a/tests/template/srw_import_data/srx_bl4.json b/tests/template/srw_import_data/srx_bl4.json index 845324ca02..1501a49d64 100644 --- a/tests/template/srw_import_data/srx_bl4.json +++ b/tests/template/srw_import_data/srx_bl4.json @@ -241,7 +241,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "3": [ @@ -268,7 +276,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ], "4": [ @@ -385,7 +401,15 @@ 1.0, 1.0, 1.0, - 1.0 + 1.0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 ] ] }, diff --git a/tests/template/srw_import_test.py b/tests/template/srw_import_test.py index 92860bea38..697a2edca2 100644 --- a/tests/template/srw_import_test.py +++ b/tests/template/srw_import_test.py @@ -29,6 +29,7 @@ def test_srw_1(): @srunit.wrap_in_request(want_cookie=True, want_user=True) def test_srw_2(): _t({ + 'nsls-ii-esm-beamline': ('nsls-ii-esm-beamline', None), 'sample_from_image': ('sample_from_image', None), 'smi_es1_bump_norm': ('smi', '--beamline ES1 --bump --BMmode Norm'), 'smi_es1_nobump': ('smi', '--beamline ES1'), @@ -38,7 +39,6 @@ def test_srw_2(): 'srx_bl2': ('srx', '--op_BL=2'), 'srx_bl3': ('srx', '--op_BL=3'), 'srx_bl4': ('srx', '--op_BL=4'), - 'nsls-ii-esm-beamline': ('nsls-ii-esm-beamline', None), })