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

Add Geodetic Representations #40

Closed

Conversation

WilliamJamieson
Copy link
Contributor

fixes #39

@WilliamJamieson WilliamJamieson requested a review from braingram May 23, 2023 17:53
Copy link
Contributor

@braingram braingram left a comment

Choose a reason for hiding this comment

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

resources/schemas/representation-1.1.0 .yaml has a space in the file name.

@WilliamJamieson
Copy link
Contributor Author

resources/schemas/representation-1.1.0 .yaml has a space in the file name.

FYI it is more than just that. We need asdf-astropy support to complete the transition to the 1.1.0

Comment on lines +14 to +35
- A SphericalRepresentation
- |
!<tag:astropy.org:astropy/coordinates/representation-1.1.0>
components:
distance: !unit/quantity-1.1.0 {unit: !unit/unit-1.0.0 AU, value: 1.0}
lat: !<tag:astropy.org:astropy/coordinates/latitude-1.0.0> {unit: !unit/unit-1.0.0 deg,
value: 10.0}
lon: !<tag:astropy.org:astropy/coordinates/longitude-1.0.0>
unit: !unit/unit-1.0.0 deg
value: 10.0
wrap_angle: !<tag:astropy.org:astropy/coordinates/angle-1.0.0> {unit: !unit/unit-1.0.0 deg,
value: 360.0}
type: SphericalRepresentation
-
- A CartesianDifferential
- |
!<tag:astropy.org:astropy/coordinates/representation-1.1.0>
components:
d_x: !unit/quantity-1.1.0 {unit: !unit/unit-1.0.0 km s-1, value: 100.0}
d_y: !unit/quantity-1.1.0 {unit: !unit/unit-1.0.0 km s-1, value: 200.0}
d_z: !unit/quantity-1.1.0 {unit: !unit/unit-1.0.0 km s-1, value: 3141.0}
type: CartesianDifferential
Copy link
Contributor Author

Choose a reason for hiding this comment

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

asdf-astropy does not currently support the 1.1.0 tag meaning this will fall back on astropy which fails due to warnings.

Copy link
Contributor

@braingram braingram left a comment

Choose a reason for hiding this comment

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

Looking into these geodetic classes it appears that the changes and API for this are not yet finalized (based off this open issue: astropy/astropy#11170).

The original PR adding these representations involved a discussion about deprecating EarthLocation.to_geodetic and making a new method that returns these new types:
astropy/astropy#11086
However it was decided to leave these types as internal and keep the currently used astropy.coordinates.earth.GeodeticLocation that is produced when calling astropy.coordinates.earth.EarthLocation.to_geodetic.

It appears that the return type for this is unsupported in asdf-astropy on main and with this PR.

import asdf
import astropy.coordinates.earth

c = astropy.coordinates.earth.EarthLocation.of_site('Keck Observatory')
g = c.to_geodetic()
asdf.AsdfFile({'g': g})

fails with

Warning: Failed to serialize instance of <class 'astropy.coordinates.earth.GeodeticLocation'>, converting to list instead
  warnings.warn(f"Failed to serialize instance of {type(node)}, converting to list instead", AsdfWarning)

I'm inclined to wait until the new geodetic api is finished before adding support for it in the asdf schema.

@WilliamJamieson
Copy link
Contributor Author

Looking into these geodetic classes it appears that the changes and API for this are not yet finalized (based off this open issue: astropy/astropy#11170).

The original PR adding these representations involved a discussion about deprecating EarthLocation.to_geodetic and making a new method that returns these new types: astropy/astropy#11086 However it was decided to leave these types as internal and keep the currently used astropy.coordinates.earth.GeodeticLocation that is produced when calling astropy.coordinates.earth.EarthLocation.to_geodetic.

It appears that the return type for this is unsupported in asdf-astropy on main and with this PR.

import asdf
import astropy.coordinates.earth

c = astropy.coordinates.earth.EarthLocation.of_site('Keck Observatory')
g = c.to_geodetic()
asdf.AsdfFile({'g': g})

fails with

Warning: Failed to serialize instance of <class 'astropy.coordinates.earth.GeodeticLocation'>, converting to list instead
  warnings.warn(f"Failed to serialize instance of {type(node)}, converting to list instead", AsdfWarning)

I'm inclined to wait until the new geodetic api is finished before adding support for it in the asdf schema.

I will close this PR since you feel this way.

I want to point out that these representations have been added to the public API for astropy: https://github.com/astropy/astropy/blob/08dba88089f124064492d3fde40919561640ea51/astropy/coordinates/representation/__init__.py#L9-L14 and that your API comments are irrelevant since we only care about the data contained within the object not its general API with astropy. Our support for astropy representations is based on the baseline object and the common way they store their information: https://github.com/astropy/asdf-astropy/blob/6c0e91a1db88d1c7253ac476dcc5eebc2a1a33fd/asdf_astropy/converters/coordinates/representation.py#L24-L39 not some other astropy API.

@WilliamJamieson WilliamJamieson deleted the add_geodetic branch May 23, 2023 20:32
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

Successfully merging this pull request may close these issues.

Update representation with new astropy types.
2 participants