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

handle nans from bad arguments to np.arccos #109

Merged
merged 1 commit into from
Jun 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion skycatalogs/objects/sso_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,17 @@ def get_gsobject_components(self, gsparams=None, rng=None,

init_v = UnitVector3d(LonLat.fromDegrees(ra, dec))
final_v = UnitVector3d(LonLat.fromDegrees(ra_final, dec_final))
length = np.degrees(np.arccos(init_v.dot(final_v))) * 3600.0
cos_sep = init_v.dot(final_v)
if cos_sep > 1.0:
# Handle values like cos_sep = 1.0000000000000002
length = 0.0
else:
length = np.degrees(np.arccos(cos_sep)) * 3600.0
if np.isnan(length):
# This will raise if cos_sep < -1.0. A value of cos_sep = -1.0
# is almost certainly unphysical, so we want to catch these cases.
raise ValueError("SSO streak length is nan")

if length * trail_width == 0:
# Treat as a point source.
return {'this_object': galsim.DeltaFunction(gsparams=gsparams)}
Expand Down