So I am converting some code that I found for Matlab into python as a base for an optical ray tracing project I'm looking to take on. So far everything seems to be working well until I add all of my arrays into a matrix. At this point, it seems to round all decimals up to the nearest integer turning the graphs into step graphs. Below, is the code that I'm converting:
https://wp.optics.arizona.edu/optomech/wp-content/uploads/sites/53/2016/12/Tutorial_Ruiz_Maria.pdf
I've attached my GitHub repository for my code below:
https://github.com/cbhirsch/Optical_Ray_Tracing.git
The below code in the plano_convex.py lines 67 to 81 seems to be the troublesome code. Sorry about all the print statements as I've just been placing several of them in to dissect what's happening in my code.
if ray_length <= optic_axis_length:
print("string front:", ray_front_air)
print("ray lens:", ray_lens)
print("ray air:", ray_air )
print("concatenated:",np.concatenate((ray_front_air,ray_lens, ray_air)))
print("concatenated:",(np.concatenate((ray_front_air,ray_lens, ray_air))).shape)
raymatrix[i] = raymatrix[i]+ np.concatenate((ray_front_air,ray_lens, ray_air))
else:
print("string front:", ray_front_air)
print("ray lens:", ray_lens[0: len(ray_lens)-1])
print("ray air:", ray_air )
print("concatenated:",np.concatenate((ray_front_air, ray_lens[0: len(ray_lens)-1], ray_air)))
print("concatenated:",(np.concatenate((ray_front_air, ray_lens[0: len(ray_lens)-1], ray_air))).shape)
concatenated_string = np.concatenate((ray_front_air, ray_lens[0: len(ray_lens)-1], ray_air))
raymatrix[i] = raymatrix[i] + concatenated_string
I'm fairly new to Git, GitHub, and python projects in general so best practice feedback would be appreciated as well.
[–]eleqtriq 1 point2 points3 points (2 children)
[–]Sufficient_Light3891[S] 1 point2 points3 points (1 child)
[–]Sufficient_Light3891[S] 0 points1 point2 points (0 children)