Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:49:05

0001 #!/usr/bin/env python
0002 """
0003 hemisphere_polarized.py
0004 =================================
0005 
0006 As everything is happening at the origin it would be 
0007 impossible to visualize everything on top of each other. 
0008 So represent the incoming hemisphere of photons with 
0009 points and vectors on the unit hemi-sphere with mom
0010 directions all pointing at the origin and polarization 
0011 vector either within the plane of incidence (P-polarized)
0012 or perpendicular to the plane of incidence (S-polarized). 
0013 
0014 
0015 
0016                    .
0017             .              .            
0018         .                     .
0019   
0020      .                          .
0021 
0022     -------------0---------------
0023 
0024 
0025 
0026 Notice with S-polarized that the polarization vectors Z-component is zero 
0027 
0028 ::
0029 
0030    EYE=-1,-1,1 LOOK=0,0,0.5 PARA=1 ./QSimTest.sh ana
0031 
0032 
0033 """
0034 import os, numpy as np
0035 from opticks.ana.fold import Fold
0036 MODE = int(os.environ.get("MODE","0"))
0037 
0038 
0039 if MODE in [2,3]:
0040     from opticks.ana.pvplt import *
0041     import pyvista as pv
0042 pass
0043 
0044 TEST = os.environ["TEST"]
0045 GUI = not "NOGUI" in os.environ
0046 
0047 
0048 if __name__ == '__main__':
0049     t = Fold.Load(symbol="t")
0050     print(repr(t))
0051 
0052 
0053     p = t.p
0054     prd = t.prd
0055     lim = slice(0,1000)
0056 
0057     print( " TEST : %s " % TEST)
0058     print( "p.shape %s " % str(p.shape) )
0059     print( "prd.shape %s " % str(prd.shape) )
0060     print(" using lim for plotting %s " % lim )
0061 
0062     mom = p[:,1,:3]   # hemisphere of photons all directed at origin 
0063     pol = p[:,2,:3]   # S or P polarized 
0064     pos = -mom          # illustrative choice of position on unit hemisphere 
0065 
0066     normal = prd[:,0,:3]  # saved from qprd 
0067     point = np.array( [0,0,0], dtype=np.float32 )
0068 
0069     print("mom\n", mom) 
0070     print("pol\n", pol) 
0071     print("pos\n", pos) 
0072 
0073     if MODE == 3:
0074         label = "pvplt_polarized"
0075         pl = pvplt_plotter(label=label)   
0076 
0077         pvplt_viewpoint( pl ) 
0078         pvplt_polarized( pl, pos[lim], mom[lim], pol[lim] )
0079         pvplt_lines(     pl, pos[lim], mom[lim] )
0080 
0081         pvplt_arrows( pl, point, normal )
0082 
0083         outpath = os.path.join(FOLD, "figs/%s.png" % label )
0084         outdir = os.path.dirname(outpath)
0085         if not os.path.isdir(outdir):
0086             os.makedirs(outdir)
0087         pass
0088 
0089         print(" outpath: %s " % outpath ) 
0090         cp = pl.show(screenshot=outpath) if GUI else None
0091     pass
0092 pass
0093