Closed ShTwc closed 2 years ago
Use the Shadow File Reader widget that will transform it into python object.
The entity in the output wire is a ShadowBeam object (from module rangecontrib.shadow.util.shadow_objects). The native shadow3 object (please refer to its author and documentation about it) is accessible in this way, by wiring a Python Script widget:
import numpy
shadow3_beam = in_object_1._beam
rays_matrix = shadow3_beam.rays # this is the matrix of the rays, each row containing the properties of a single ray
'''
Here are the columns:
1 - position x in user units
2 - position y in user units
3 - position z in user units
4 - director cosine x (approx angle x' in rad)
5 - director cosine y
6 - director cosine z (approx angle z' in rad)
7 - electric field s-polarized Es_x
8 - electric field s-polarized Es_y
9 - electric field s-polarized Es_z
10 - flag: 1.0 the ray is good, <1 the ray is lost
11 - wavevector modulus: 2 pi / lambda
12 - ray index (starting from 1.0)
13 - optical path, in user units
14 - s-polarized phase Es_phi
15 - p-polarized phase Ep_phi
16 - electric field p-polarized Ep_x
17 - electric field p-polarized Ep_y
18 - electric field p-polarized Ep_z
'''
# ex: read the z coordinate of all the rays:
z_coord = rays_matrix[:, 2]
# select good only rays
go = numpy.where(rays_matrix[:, 9] == 1)
z_coord_go = rays_matrix[go, 2]
hello,
I want to do some calculation using beam data from Shadow and try to output those data by tool 'Shadow File Writer'. I got a file successfully but don't know what its format is. Could you tell me how to read it? Thanks.
Chen
Shanghai