Skip to content

Add PointLikeSource.from_degrees and from_skycoord constructors - #334

Merged
tomaskontrimas merged 2 commits into
masterfrom
claude/pointlikesource-degrees-skycoord
Nov 17, 2026
Merged

tomaskontrimas merged 2 commits into
masterfrom
claude/pointlikesource-degrees-skycoord

Conversation

@tomaskontrimas

Copy link
Copy Markdown
Collaborator

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.

@tomaskontrimas tomaskontrimas self-assigned this Sep 30, 2026
Copilot AI balanced review requested due to automatic review settings September 30, 2026 18:46
@tomaskontrimas tomaskontrimas added the enhancement New feature or request label Sep 30, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@tomaskontrimas
tomaskontrimas force-pushed the claude/pointlikesource-degrees-skycoord branch from 233e7e7 to d2d2047 Compare October 9, 2026 19:50
@tomaskontrimas
tomaskontrimas force-pushed the claude/pointlikesource-degrees-skycoord branch from d2d2047 to c7a9e06 Compare November 2, 2026 17:58
@tomaskontrimas
tomaskontrimas force-pushed the claude/pointlikesource-degrees-skycoord branch from c7a9e06 to d8ad178 Compare November 10, 2026 16:19

@chiarabellenghi chiarabellenghi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread skyllh/core/source_model.py Outdated
Comment on lines +302 to +303
if not -90 <= dec <= 90:
raise ValueError(f'The declination must be within [-90, 90] degrees! Got {dec} degrees.')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And a check on the input R.A. value? Should be between 0 and 360

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 3594178 , also adding an additional check for ra/dec range in radians

self.dec = dec

@classmethod
def from_degrees(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 3594178

@chiarabellenghi

Copy link
Copy Markdown
Member

I guess we wanna add examples of this in the notebooks...
Maybe in a subsequent PR, though.

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.
@tomaskontrimas
tomaskontrimas force-pushed the claude/pointlikesource-degrees-skycoord branch from d8ad178 to 107cc28 Compare November 16, 2026 16:25
@tomaskontrimas
tomaskontrimas merged commit 52efcf4 into master Nov 17, 2026
6 checks passed
@tomaskontrimas
tomaskontrimas deleted the claude/pointlikesource-degrees-skycoord branch November 17, 2026 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants