You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running StarStudio to create a mock Hubble image, if the smoothing lengths of the star particles are not present in the snapshot then by default it sets them to a fixed value (this defaults to fixed_star_hsml=0.028 in the compute_mockHubbleImage() function). However, if there are star particles outside the region of the frame (i.e. that get culled by the camera.project_and_clip() function) then it crashes on line 399 of star_studio.py:
h_star = Hsml[star_mask].astype(np.float32)
It crashes because the length of the star_mask array is equal to the total number of star particles that were originally passed in to StarStudio(), i.e. before the particles outside the frame region were culled. However, when using a fixed star smoothing length, the Hsml array is set on line 392 of star_studio.py as follows:
At this point in the code the star_pos array has already had the particles outside the frame region culled. So the arrays Hsml and star_mask have different lengths, which causes it to crash.
This only happens when we use a fixed star smoothing length. If we pass in an array of smoothing lengths in the star_dict dictionary, or if we make it calculate the smoothing lengths with get_HSML(), then it runs fine.
To fix this bug, I think we would need to record the original length of the star_pos array, before it is culled, i.e.:
When running StarStudio to create a mock Hubble image, if the smoothing lengths of the star particles are not present in the snapshot then by default it sets them to a fixed value (this defaults to
fixed_star_hsml=0.028
in thecompute_mockHubbleImage()
function). However, if there are star particles outside the region of the frame (i.e. that get culled by thecamera.project_and_clip()
function) then it crashes on line 399 ofstar_studio.py
:h_star = Hsml[star_mask].astype(np.float32)
It crashes because the length of the
star_mask
array is equal to the total number of star particles that were originally passed in toStarStudio()
, i.e. before the particles outside the frame region were culled. However, when using a fixed star smoothing length, theHsml
array is set on line 392 ofstar_studio.py
as follows:Hsml = np.repeat(fixed_star_hsml,star_pos.shape[0])
At this point in the code the
star_pos
array has already had the particles outside the frame region culled. So the arraysHsml
andstar_mask
have different lengths, which causes it to crash.This only happens when we use a fixed star smoothing length. If we pass in an array of smoothing lengths in the
star_dict
dictionary, or if we make it calculate the smoothing lengths withget_HSML()
, then it runs fine.To fix this bug, I think we would need to record the original length of the
star_pos
array, before it is culled, i.e.:star_pos = self.star_snapdict['Coordinates']
N_star_original = star_pos.shape[0]`Then the fixed star smoothing lengths can be set as follows:
Hsml = np.repeat(fixed_star_hsml, N_star_original)
The text was updated successfully, but these errors were encountered: