AMCLab / TemGymBasic

GNU General Public License v3.0
27 stars 7 forks source link

error after installation #3

Open azazellochg opened 1 year ago

azazellochg commented 1 year ago

After a fresh install and running python lens_example_pyqt.py I get:

Traceback (most recent call last):
File "/home/gsharov/soft/TemGymBasic/pyqtgraph_examples/lens_example_pyqt.py", line 20, in <module>
viewer = main()
File "/home/gsharov/soft/TemGymBasic/pyqtgraph_examples/lens_example_pyqt.py", line 12, in main
model_ = Model(components, beam_z = 1.0, beam_type = 'point', num_rays = 32, gun_beam_semi_angle = 0.15)
File "/home/gsharov/soft/TemGymBasic/src/temgymbasic/model.py", line 105, in __init__
self.generate_rays()
File "/home/gsharov/soft/TemGymBasic/src/temgymbasic/model.py", line 187, in generate_rays
self.r, self.spot_indices = point_beam(self.r, self.gun_beam_semi_angle)
File "/home/gsharov/soft/TemGymBasic/src/temgymbasic/functions.py", line 193, in point_beam
num_points_kth_ring[::-1][:index_to_stop_adding_rays+1] += num_rays_to_each_ring[
numpy.core._exceptions.UFuncTypeError: Cannot cast ufunc 'add' output from dtype('float64') to dtype('int64') with casting rule 'same_kind'

For other scripts, e.g. python beam_tilt_shift_advanced_example_pyqt.py, I get:

Traceback (most recent call last):
File "/home/gsharov/soft/TemGymBasic/pyqtgraph_examples/beam_tilt_shift_advanced_example_pyqt.py", line 26, in <module>
viewer = main()
File "/home/gsharov/soft/TemGymBasic/pyqtgraph_examples/beam_tilt_shift_advanced_example_pyqt.py", line 12, in main
comp.Sample(name = 'Sample', z = 0.5),
File "/home/gsharov/soft/TemGymBasic/src/temgymbasic/components.py", line 463, in __init__
self.sample_pixels = sample.shape[0]
AttributeError: 'NoneType' object has no attribute 'shape'
MarkVerbeek91 commented 12 months ago

The first issue can be solved by adding a .astype(int) to line 172.

so it becomes: num_rays_to_each_ring = np.ceil(proportion*remainder_rays).astype(int)[::-1]

there is another one at line 90: num_rays_to_each_ring = np.ceil(proportion*remainder_rays).astype(int)[::-1]

As the one with the examples. I think the examples are not fully up to date with the core implementation. So is beam_semi_angle renamed to gun_beam_semi_angle for the Model class constructor arguments.