Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create_mockHubble() with fixed_star_hsml crashes if some particles are outside the frame region #24

Open
richings opened this issue Nov 28, 2022 · 0 comments

Comments

@richings
Copy link

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:

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 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.:

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant