def getshonecol(beam,col): ''' Extract a column from a shadow file (eg. begin.dat) or a Shadow.Beam instance. The column are numbered in the fortran convention, i.e. starting from 1. It returns a numpy.array filled with the values of the chosen column. Inumpy.ts: beam : str instance with the name of the shadow file to be loaded. OR Shadow.Beam initialized instance. col : int for the chosen columns. Outputs: numpy.array 1-D with length numpy.INT. Error: if an error occurs an ArgsError is raised. Possible choice for col are: 1 X spatial coordinate [user's unit] 2 Y spatial coordinate [user's unit] 3 Z spatial coordinate [user's unit] 4 Xp direction or divergence [rads] 5 Yp direction or divergence [rads] 6 Zp direction or divergence [rads] 7 X component of the electromagnetic vector (s-polariz) 8 Y component of the electromagnetic vector (s-polariz) 9 Z component of the electromagnetic vector (s-polariz) 10 Lost ray flag 11 Energy [eV] 12 Ray index 13 Optical path length 14 Phase (s-polarization) 15 Phase (p-polarization) 16 X component of the electromagnetic vector (p-polariz) 17 Y component of the electromagnetic vector (p-polariz) 18 Z component of the electromagnetic vector (p-polariz) 19 Wavelength [A] 20 R= SQRT(X^2+Y^2+Z^2) 21 angle from Y axis 22 the magnituse of the Electromagnetic vector 23 |E|^2 (total intensity) 24 total intensity for s-polarization 25 total intensity for p-polarization 26 K = 2 pi / lambda [A^-1] 27 K = 2 pi / lambda * col4 [A^-1] 28 K = 2 pi / lambda * col5 [A^-1] 29 K = 2 pi / lambda * col6 [A^-1] 30 S0-stokes = |Es|^2 + |Ep|^2 31 S1-stokes = |Es|^2 - |Ep|^2 32 S2-stokes = 2 |Es| |Ep| cos(phase_s-phase_p) 33 S3-stokes = 2 |Es| |Ep| sin(phase_s-phase_p) ''' try: stp.getshonecol_CheckArg(beam,col) except stp.ArgsError as e: raise e col=col-1 if isinstance(beam,sd.Beam): ray = beam.rays else: bm = sd.Beam() bm.load(beam) ray = bm.rays if col>=0 and col<18 and col!=10: column = ray[:,col] if col==10: column = ray[:,col]/A2EV if col==18: column = 2*numpy.pi*1.0e8/ray[:,10] if col==19: column = numpy.sqrt(ray[:,0]*ray[:,0]+ray[:,1]*ray[:,1]+ray[:,2]*ray[:,2]) if col==20: column = numpy.arccos(ray[:,4]) if col==21: column = numpy.sqrt(numpy.sum(numpy.array([ ray[:,i]*ray[:,i] for i in [6,7,8,15,16,17] ]),axis=0)) if col==22: column = numpy.sum(numpy.array([ ray[:,i]*ray[:,i] for i in [6,7,8,15,16,17] ]),axis=0) if col==23: column = numpy.sum(numpy.array([ ray[:,i]*ray[:,i] for i in [6,7,8] ]),axis=0) if col==24: column = numpy.sum(numpy.array([ ray[:,i]*ray[:,i] for i in [15,16,17] ]),axis=0) if col==25: column = ray[:,10]*1.0e8 if col==26: column = ray[:,3]*ray[:,10]*1.0e8 if col==27: column = ray[:,4]*ray[:,10]*1.0e8 if col==28: column = ray[:,5]*ray[:,10]*1.0e8 if col==29: E2s = numpy.sum(numpy.array([ ray[:,i]*ray[:,i] for i in [6,7,8] ]),axis=0) E2p = numpy.sum(numpy.array([ ray[:,i]*ray[:,i] for i in [15,16,17] ]),axis=0) column = E2p+E2s if col==30: E2s = numpy.sum(numpy.array([ ray[:,i]*ray[:,i] for i in [6,7,8] ]),axis=0) E2p = numpy.sum(numpy.array([ ray[:,i]*ray[:,i] for i in [15,16,17] ]),axis=0) column = E2p-E2s if col==31: E2s = numpy.sum(numpy.array([ ray[:,i]*ray[:,i] for i in [6,7,8] ]),axis=0) E2p = numpy.sum(numpy.array([ ray[:,i]*ray[:,i] for i in [15,16,17] ]),axis=0) Cos = numpy.cos(ray[:,13]-ray[:,14]) column = 2*E2s*E2p*Cos if col==32: E2s = numpy.sum(numpy.array([ ray[:,i]*ray[:,i] for i in [6,7,8] ]),axis=0) E2p = numpy.sum(numpy.array([ ray[:,i]*ray[:,i] for i in [15,16,17] ]),axis=0) Sin = numpy.sin(ray[:,13]-ray[:,14]) column = 2*E2s*E2p*Sin return column