Repository navigation
Add PointLikeSource.from_degrees and from_skycoord constructors - #334
Conversation
233e7e7 to
d2d2047
Compare
d2d2047 to
c7a9e06
Compare
c7a9e06 to
d8ad178
Compare
chiarabellenghi
left a comment
There was a problem hiding this comment.
Hm... the main PointLikeSource constructor still assumes radians and runs no checks, right? Maybe we could add minimal checks that the input values are within the expected ranges? It should catch most (though not all) mistakes if the user passes degree coordinates to it...
I don't know how to make the check more robust otherwise.
| if not -90 <= dec <= 90: | ||
| raise ValueError(f'The declination must be within [-90, 90] degrees! Got {dec} degrees.') |
There was a problem hiding this comment.
And a check on the input R.A. value? Should be between 0 and 360
There was a problem hiding this comment.
Fixed in 3594178 , also adding an additional check for ra/dec range in radians
| self.dec = dec | ||
|
|
||
| @classmethod | ||
| def from_degrees( |
There was a problem hiding this comment.
source = PointLikeSource.from_degrees(10*u.deg, 5*u.deg) fails with:
UnitConversionError: Can only apply 'greater_equal' function to dimensionless quantities when other argument is not a quantity (unless the latter is all zero/infinity/nan).
Maybe we could catch this and suggest that they use the from_skycoord method, or we could convert with .to_value(u.deg) inside this method.
|
I guess we wanna add examples of this in the notebooks... |
Add two alternative constructors to PointLikeSource so users no longer have to convert coordinates to radians by hand: - from_degrees(ra, dec, ...) takes R.A. and Dec. in degrees and validates that the declination lies within [-90, 90] degrees. - from_skycoord(coord, ...) takes a scalar astropy SkyCoord in any celestial frame and transforms it into ICRS. Combined with SkyCoord.from_name this allows defining sources by name.
d8ad178 to
107cc28
Compare
Add two alternative constructors to PointLikeSource so users no longer have to convert coordinates to radians by hand: