Skip to content

Commit

Permalink
Merge pull request #109 from LSSTDESC/u/jchiang/sso_nan_streak_length…
Browse files Browse the repository at this point in the history
…_fix

handle nans from bad arguments to np.arccos
  • Loading branch information
jchiang87 authored Jun 14, 2024
2 parents 4e1d1f0 + 80351bf commit 125e081
Showing 1 changed file with 11 additions and 1 deletion.
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

0 comments on commit 125e081

Please sign in to comment.