Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions env/python/srwpy/examples/SRWLIB_Example02.py
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,13 @@ def AuxSaveMagFldData(dispFld3D, xc, yc, zc, filePath):
for ix in range(dispFld3D.nx):
if(arXdef == True):
x = dispFld3D.arX[ix] + xc
resStr = repr(x) + '\t' + repr(y) + '\t' + repr(z)
resStr = str(x) + '\t' + str(y) + '\t' + str(z)
if(arBxDef == True):
resStr += '\t' + repr(dispFld3D.arBx[i])
resStr += '\t' + str(dispFld3D.arBx[i])
if(arByDef == True):
resStr += '\t' + repr(dispFld3D.arBy[i])
resStr += '\t' + str(dispFld3D.arBy[i])
if(arBzDef == True):
resStr += '\t' + repr(dispFld3D.arBz[i])
resStr += '\t' + str(dispFld3D.arBz[i])
f.write(resStr + '\n')
i += 1
x += hx
Expand All @@ -172,13 +172,13 @@ def AuxSaveTrajData(traj, filePath):
ctStep = (traj.ctEnd - traj.ctStart)/(traj.np - 1)
ct = traj.ctStart
for i in range(traj.np):
resStr = str(ct) + '\t' + repr(traj.arX[i]) + '\t' + repr(traj.arXp[i]) + '\t' + repr(traj.arY[i]) + '\t' + repr(traj.arYp[i]) + '\t' + repr(traj.arZ[i]) + '\t' + repr(traj.arZp[i])
resStr = str(ct) + '\t' + str(traj.arX[i]) + '\t' + str(traj.arXp[i]) + '\t' + str(traj.arY[i]) + '\t' + str(traj.arYp[i]) + '\t' + str(traj.arZ[i]) + '\t' + str(traj.arZp[i])
if(hasattr(traj, 'arBx')):
resStr += '\t' + repr(traj.arBx[i])
resStr += '\t' + str(traj.arBx[i])
if(hasattr(traj, 'arBy')):
resStr += '\t' + repr(traj.arBy[i])
resStr += '\t' + str(traj.arBy[i])
if(hasattr(traj, 'arBz')):
resStr += '\t' + repr(traj.arBz[i])
resStr += '\t' + str(traj.arBz[i])
f.write(resStr + '\n')
ct += ctStep
f.close()
Expand Down
20 changes: 10 additions & 10 deletions env/python/srwpy/examples/SRWLIB_Example04.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,17 @@
#def AuxSaveIntData(arI, mesh, filePath):
# f = open(filePath, 'w')
# f.write('#C-aligned Intensity (inner loop is vs photon energy, outer loop vs vertical position)\n')
# f.write('#' + repr(mesh.eStart) + ' #Initial Photon Energy [eV]\n')
# f.write('#' + repr(mesh.eFin) + ' #Final Photon Energy [eV]\n')
# f.write('#' + repr(mesh.ne) + ' #Number of points vs Photon Energy\n')
# f.write('#' + repr(mesh.xStart) + ' #Initial Horizontal Position [m]\n')
# f.write('#' + repr(mesh.xFin) + ' #Final Horizontal Position [m]\n')
# f.write('#' + repr(mesh.nx) + ' #Number of points vs Horizontal Position\n')
# f.write('#' + repr(mesh.yStart) + ' #Initial Vertical Position [m]\n')
# f.write('#' + repr(mesh.yFin) + ' #Final Vertical Position [m]\n')
# f.write('#' + repr(mesh.ny) + ' #Number of points vs Vertical Position\n')
# f.write('#' + str(mesh.eStart) + ' #Initial Photon Energy [eV]\n')
# f.write('#' + str(mesh.eFin) + ' #Final Photon Energy [eV]\n')
# f.write('#' + str(mesh.ne) + ' #Number of points vs Photon Energy\n')
# f.write('#' + str(mesh.xStart) + ' #Initial Horizontal Position [m]\n')
# f.write('#' + str(mesh.xFin) + ' #Final Horizontal Position [m]\n')
# f.write('#' + str(mesh.nx) + ' #Number of points vs Horizontal Position\n')
# f.write('#' + str(mesh.yStart) + ' #Initial Vertical Position [m]\n')
# f.write('#' + str(mesh.yFin) + ' #Final Vertical Position [m]\n')
# f.write('#' + str(mesh.ny) + ' #Number of points vs Vertical Position\n')
# for i in range(mesh.ne*mesh.nx*mesh.ny): #write all data into one column using "C-alignment" as a "flat" 1D array
# f.write(' ' + repr(arI[i]) + '\n')
# f.write(' ' + str(arI[i]) + '\n')
# f.close()

#**********************Calculation (SRWLIB function calls) and post-processing
Expand Down
28 changes: 14 additions & 14 deletions env/python/srwpy/examples/SRWLIB_Example05.py
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ def AuxSaveTrajData(traj, filePath):
ctStep = (traj.ctEnd - traj.ctStart)/(traj.np - 1)
ct = traj.ctStart
for i in range(traj.np):
resStr = str(ct) + '\t' + repr(traj.arX[i]) + '\t' + repr(traj.arXp[i]) + '\t' + repr(traj.arY[i]) + '\t' + repr(traj.arYp[i]) + '\t' + repr(traj.arZ[i]) + '\t' + repr(traj.arZp[i])
resStr = str(ct) + '\t' + str(traj.arX[i]) + '\t' + str(traj.arXp[i]) + '\t' + str(traj.arY[i]) + '\t' + str(traj.arYp[i]) + '\t' + str(traj.arZ[i]) + '\t' + str(traj.arZp[i])
if(hasattr(traj, 'arBx')):
resStr += '\t' + repr(traj.arBx[i])
resStr += '\t' + str(traj.arBx[i])
if(hasattr(traj, 'arBy')):
resStr += '\t' + repr(traj.arBy[i])
resStr += '\t' + str(traj.arBy[i])
if(hasattr(traj, 'arBz')):
resStr += '\t' + repr(traj.arBz[i])
resStr += '\t' + str(traj.arBz[i])
f.write(resStr + '\n')
ct += ctStep
f.close()
Expand All @@ -91,17 +91,17 @@ def AuxSaveTrajData(traj, filePath):
#def AuxSaveIntData(arI, mesh, filePath):
# f = open(filePath, 'w')
# f.write('#C-aligned Intensity (inner loop is vs photon energy, outer loop vs vertical position)\n')
# f.write('#' + repr(mesh.eStart) + ' #Initial Photon Energy [eV]\n')
# f.write('#' + repr(mesh.eFin) + ' #Final Photon Energy [eV]\n')
# f.write('#' + repr(mesh.ne) + ' #Number of points vs Photon Energy\n')
# f.write('#' + repr(mesh.xStart) + ' #Initial Horizontal Position [m]\n')
# f.write('#' + repr(mesh.xFin) + ' #Final Horizontal Position [m]\n')
# f.write('#' + repr(mesh.nx) + ' #Number of points vs Horizontal Position\n')
# f.write('#' + repr(mesh.yStart) + ' #Initial Vertical Position [m]\n')
# f.write('#' + repr(mesh.yFin) + ' #Final Vertical Position [m]\n')
# f.write('#' + repr(mesh.ny) + ' #Number of points vs Vertical Position\n')
# f.write('#' + str(mesh.eStart) + ' #Initial Photon Energy [eV]\n')
# f.write('#' + str(mesh.eFin) + ' #Final Photon Energy [eV]\n')
# f.write('#' + str(mesh.ne) + ' #Number of points vs Photon Energy\n')
# f.write('#' + str(mesh.xStart) + ' #Initial Horizontal Position [m]\n')
# f.write('#' + str(mesh.xFin) + ' #Final Horizontal Position [m]\n')
# f.write('#' + str(mesh.nx) + ' #Number of points vs Horizontal Position\n')
# f.write('#' + str(mesh.yStart) + ' #Initial Vertical Position [m]\n')
# f.write('#' + str(mesh.yFin) + ' #Final Vertical Position [m]\n')
# f.write('#' + str(mesh.ny) + ' #Number of points vs Vertical Position\n')
# for i in range(mesh.ne*mesh.nx*mesh.ny): #write all data into one column using "C-alignment" as a "flat" 1D array
# f.write(' ' + repr(arI[i]) + '\n')
# f.write(' ' + str(arI[i]) + '\n')
# f.close()

#**********************Defining Magnetic Field:
Expand Down
8 changes: 4 additions & 4 deletions env/python/srwpy/examples/SRWLIB_Example06_PETRA.py
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,13 @@ def AuxSaveTrajData(traj, filePath):
ctStep = (traj.ctEnd - traj.ctStart)/(traj.np - 1)
ct = traj.ctStart
for i in range(traj.np):
resStr = str(ct) + '\t' + repr(traj.arX[i]) + '\t' + repr(traj.arXp[i]) + '\t' + repr(traj.arY[i]) + '\t' + repr(traj.arYp[i]) + '\t' + repr(traj.arZ[i]) + '\t' + repr(traj.arZp[i])
resStr = str(ct) + '\t' + str(traj.arX[i]) + '\t' + str(traj.arXp[i]) + '\t' + str(traj.arY[i]) + '\t' + str(traj.arYp[i]) + '\t' + str(traj.arZ[i]) + '\t' + str(traj.arZp[i])
if(hasattr(traj, 'arBx')):
resStr += '\t' + repr(traj.arBx[i])
resStr += '\t' + str(traj.arBx[i])
if(hasattr(traj, 'arBy')):
resStr += '\t' + repr(traj.arBy[i])
resStr += '\t' + str(traj.arBy[i])
if(hasattr(traj, 'arBz')):
resStr += '\t' + repr(traj.arBz[i])
resStr += '\t' + str(traj.arBz[i])
f.write(resStr + '\n')
ct += ctStep
f.close()
Expand Down
4 changes: 2 additions & 2 deletions env/python/srwpy/examples/SRWLIB_Example12.py
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def calcSE(_e_beam, _mag, _mesh, _bl, _sr_meth=1, _sr_prec=0.01, _sr_samp_fact=1
sys.stdout.write(' Simulating Electric Field Wavefront Propagation ... '); sys.stdout.flush()
t0 = time.time()
srwl.PropagElecField(wfr, _bl)
sys.stdout.write('done\n lasted '+repr(round(time.time() - t0))+' s\n')
sys.stdout.write('done\n lasted '+str(round(time.time() - t0))+' s\n')
mesh1 = deepcopy(wfr.mesh)
sys.stdout.write(' Extracting Intensity from the Propagated Electric Field ... '); sys.stdout.flush()
arI1 = array('f', [0]*mesh1.nx*mesh1.ny) #"flat" 2D array to take intensity data
Expand Down Expand Up @@ -382,7 +382,7 @@ def calcME(_e_beam, _mag, _mesh, _bl, _bw=0, _sr_meth=1, _sr_prec=0.01, _sr_samp
e_beam = setElecBeam(-1.9)
beamline = setBeamline(opt.en, opt.noptel)

fileNameSuf = opt.fnsuf+'_'+repr(enPhExact)+"eV.dat"
fileNameSuf = opt.fnsuf+'_'+str(enPhExact)+"eV.dat"

if(opt.melec <= 1):
calcSE(e_beam, mag, mesh, beamline, _sr_samp_fact=opt.isamp, _fnsuf=fileNameSuf)
Expand Down
8 changes: 4 additions & 4 deletions env/python/srwpy/examples/SRWLIB_Example14.py
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ def ExtractAndSavePulseData(_wfr, _fn_prefix, _ec=0, _xc=0, _yc=0):
if(meshP0vsXY != None):
plotMeshP0vsX = [meshP0vsXY.xStart, meshP0vsXY.xFin, meshP0vsXY.nx]
plotMeshP0vsY = [meshP0vsXY.yStart, meshP0vsXY.yFin, meshP0vsXY.ny]
uti_plot2d1d(arP0vsXY, plotMeshP0vsX, plotMeshP0vsY, x=0, y=0, labels=['Horizontal Position', 'Vertical Position', 'Power Density Before Propagation at t=' + repr(round(tc0*1.e+15)) + ' fs'], units=['m', 'm', 'W/mm^2'])
uti_plot2d1d(arP0vsXY, plotMeshP0vsX, plotMeshP0vsY, x=0, y=0, labels=['Horizontal Position', 'Vertical Position', 'Power Density Before Propagation at t=' + str(round(tc0*1.e+15)) + ' fs'], units=['m', 'm', 'W/mm^2'])

if(meshI0vsE != None):
plotMeshI0vsE = [meshI0vsE.eStart, meshI0vsE.eFin, meshI0vsE.ne]
Expand All @@ -387,7 +387,7 @@ def ExtractAndSavePulseData(_wfr, _fn_prefix, _ec=0, _xc=0, _yc=0):

plotMeshI0vsX = [meshI0vsXY.xStart, meshI0vsXY.xFin, meshI0vsXY.nx]
plotMeshI0vsY = [meshI0vsXY.yStart, meshI0vsXY.yFin, meshI0vsXY.ny]
uti_plot2d1d(arI0vsXY, plotMeshI0vsX, plotMeshI0vsY, labels=['Horizontal Position', 'Vertical Position', 'Spectral Fluence Before Propagation at E=' + repr(round(ec0)) + ' eV'], units=['m', 'm', 'J/eV/mm^2'])
uti_plot2d1d(arI0vsXY, plotMeshI0vsX, plotMeshI0vsY, labels=['Horizontal Position', 'Vertical Position', 'Spectral Fluence Before Propagation at E=' + str(round(ec0)) + ' eV'], units=['m', 'm', 'J/eV/mm^2'])

if(arF0vsXY != None):
uti_plot2d1d(arF0vsXY, plotMeshI0vsX, plotMeshI0vsY, x=0, y=0, labels=['Horizontal Position', 'Vertical Position', 'Fluence Before Propagation'], units=['m', 'm', 'J/mm^2'])
Expand All @@ -400,7 +400,7 @@ def ExtractAndSavePulseData(_wfr, _fn_prefix, _ec=0, _xc=0, _yc=0):

plotMeshI1vsX = [meshI1vsXY.xStart, meshI1vsXY.xFin, meshI1vsXY.nx]
plotMeshI1vsY = [meshI1vsXY.yStart, meshI1vsXY.yFin, meshI1vsXY.ny]
uti_plot2d1d(arI1vsXY, plotMeshI1vsX, plotMeshI1vsY, labels=['Horizontal Position', 'Vertical Position', 'Spectral Fluence After Propagation at E=' + repr(round(ec1)) + ' eV'], units=['m', 'm', 'J/eV/mm^2'])
uti_plot2d1d(arI1vsXY, plotMeshI1vsX, plotMeshI1vsY, labels=['Horizontal Position', 'Vertical Position', 'Spectral Fluence After Propagation at E=' + str(round(ec1)) + ' eV'], units=['m', 'm', 'J/eV/mm^2'])

if(arF1vsXY != None):
uti_plot2d1d(arF1vsXY, plotMeshI1vsX, plotMeshI1vsY, x=0, y=0, labels=['Horizontal Position', 'Vertical Position', 'Fluence After Propagation'], units=['m', 'm', 'J/mm^2'])
Expand All @@ -413,7 +413,7 @@ def ExtractAndSavePulseData(_wfr, _fn_prefix, _ec=0, _xc=0, _yc=0):
if(meshP1vsXY != None):
plotMeshP1vsX = [meshP1vsXY.xStart, meshP1vsXY.xFin, meshP1vsXY.nx]
plotMeshP1vsY = [meshP1vsXY.yStart, meshP1vsXY.yFin, meshP1vsXY.ny]
uti_plot2d1d(arP1vsXY, plotMeshP1vsX, plotMeshP1vsY, x=0, y=0, labels=['Horizontal Position', 'Vertical Position', 'Power Density After Propagation at t= ' + repr(round(tc1*1.e+15)) + ' fs'], units=['m', 'm', 'W/mm^2'])
uti_plot2d1d(arP1vsXY, plotMeshP1vsX, plotMeshP1vsY, x=0, y=0, labels=['Horizontal Position', 'Vertical Position', 'Power Density After Propagation at t= ' + str(round(tc1*1.e+15)) + ' fs'], units=['m', 'm', 'W/mm^2'])

#TEST
#plotMeshI2vsE = [meshI2vsE.eStart, meshI2vsE.eFin, meshI2vsE.ne]
Expand Down
6 changes: 3 additions & 3 deletions env/python/srwpy/srwl_bl.py
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Original file line number Diff line number Diff line change
Expand Up @@ -1463,7 +1463,7 @@ def prep_stokes_fname(self, _type, _pol=6, _fname=None): #OC10102023
# nameCore = _fname[:indLastDot]
# sExt = _fname[indLastDot:len_fname] #extension with '.'
# for i in range(6):
# fnPol = nameCore + '_' + repr(i) + sExt
# fnPol = nameCore + '_' + str(i) + sExt
# srwl_uti_save_intens_ascii(arI[i], stk.mesh, fnPol, 0, ['Photon Energy', 'Horizontal Position', 'Vertical Position', sValName], _arUnits=['eV', 'm', 'm', sValUnitName])
# return arI

Expand Down Expand Up @@ -2026,7 +2026,7 @@ def calc_wfr_prop(self, _wfr, _pres_ang=0, _pol=6, _int_type=0, _dep_type=3, _fn
for i in range(nInd):
curRadData = radView[i]
if((len(curRadData) > 6) and (curRadData[6] is not None)):
curIntFileName = intNameCore + '_intermed_' + repr(curRadData[0]) + '.' + sExt
curIntFileName = intNameCore + '_intermed_' + str(curRadData[0]) + '.' + sExt
#DEBUG
#print(curIntFileName)
#END DEBUG
Expand Down Expand Up @@ -3922,7 +3922,7 @@ def calc_all(self, _v, _op=None): #16122018
[curMesh.yStart, curMesh.yFin, curMesh.ny],
0, #0.5*(curMesh.xStart + curMesh.xFin),
0, #0.5*(curMesh.yStart + curMesh.yFin),
['Horizontal Position', 'Vertical Position', sValLabel + ' After Elem. #' + repr(curIntData[0])],
['Horizontal Position', 'Vertical Position', sValLabel + ' After Elem. #' + str(curIntData[0])],
['m', 'm', sValUnit],
True)

Expand Down
Loading