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

Make asdf schemas and tags support more coordinates and representations #7079

Merged
merged 5 commits into from Mar 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.rst
Expand Up @@ -35,6 +35,8 @@ astropy.io.ascii
astropy.io.misc
^^^^^^^^^^^^^^^

Added support for saving all representation classes and many coordinate frames to the asdf format. [#7079]

astropy.io.fits
^^^^^^^^^^^^^^^

Expand Down
4 changes: 4 additions & 0 deletions astropy/coordinates/attributes.py
Expand Up @@ -318,6 +318,7 @@ def convert_input(self, value):
converted = oldvalue is not value
return value, converted


class EarthLocationAttribute(Attribute):
"""
A frame attribute that can act as a `~astropy.coordinates.EarthLocation`.
Expand Down Expand Up @@ -498,20 +499,23 @@ def __init__(self, *args, **kwargs):
AstropyDeprecationWarning)
super().__init__(*args, **kwargs)


class TimeFrameAttribute(TimeAttribute):

def __init__(self, *args, **kwargs):
warnings.warn("TimeFrameAttribute has been renamed to TimeAttribute.",
AstropyDeprecationWarning)
super().__init__(*args, **kwargs)


class QuantityFrameAttribute(QuantityAttribute):

def __init__(self, *args, **kwargs):
warnings.warn("QuantityFrameAttribute has been renamed to "
"QuantityAttribute.", AstropyDeprecationWarning)
super().__init__(*args, **kwargs)


class CartesianRepresentationFrameAttribute(CartesianRepresentationAttribute):

def __init__(self, *args, **kwargs):
Expand Down
2 changes: 2 additions & 0 deletions astropy/io/misc/asdf/extension.py
Expand Up @@ -11,6 +11,8 @@
# the extension class so that _astropy_asdf_types is populated correctly. We
# could do this using __init__ files, except it causes pytest import errors in
# the case that asdf is not installed.
from .tags.coordinates.angle import *
from .tags.coordinates.representation import *
from .tags.coordinates.frames import *
from .tags.fits.fits import *
from .tags.table.table import *
Expand Down
@@ -0,0 +1,35 @@
%YAML 1.1
---
$schema: "http://stsci.edu/schemas/yaml-schema/draft-01"
id: "http://astropy.org/schemas/astropy/coordinates/angle-1.0.0"
tag: "tag:astropy.org:astropy/coordinates/angle-1.0.0"

title: |
Represents an Angle.

description:
This object represents a subtype of Quantity which has units equivalent to
radians or degrees.

examples:
-
- An Angle object in Degrees
- |
!<tag:astropy.org:astropy/coordinates/angle-1.0.0>
unit: !unit/unit-1.0.0 deg
value: 10.0

type: object
properties:
value:
description: |
A vector of one or more values
anyOf:
- type: number
- $ref: "tag:stsci.edu:asdf/core/ndarray-1.0.0"
unit:
description: |
The unit corresponding to the values
$ref: "tag:stsci.edu:asdf/unit/unit-1.0.0"
required: [value, unit]
...
@@ -0,0 +1,27 @@
%YAML 1.1
---
$schema: "http://stsci.edu/schemas/yaml-schema/draft-01"
id: "http://astropy.org/schemas/astropy/coordinates/baseframe-1.0.0"

title: |
Represents a coordinate frame object from astropy

description:
This schema is designed to be extended by other schemas to restrict the
allowable frame_attributes.

type: object
properties:
data:
description: |
The representation object holding any data associated with the frame.
$ref: "./representation-1.0.0"
frame_attributes:
description: |
Attributes on the coordinate frame.
type: object


additionalProperties: false
required: [frame_attributes]
...
@@ -0,0 +1,43 @@
%YAML 1.1
---
$schema: "http://stsci.edu/schemas/yaml-schema/draft-01"
id: "http://astropy.org/schemas/astropy/coordinates/frames/cirs-1.0.0"
tag: "tag:astropy.org:astropy/coordinates/frames/cirs-1.0.0"

title: |
Represents a CIRS coordinate object from astropy

examples:
-
- A CIRS frame without data
- |
!<tag:astropy.org:astropy/coordinates/frames/cirs-1.0.0>
frame_attributes:
obstime: !time/time-1.1.0 {scale: tai, value: B1950.000}
-
- A CIRS frame with data
- |
!<tag:astropy.org:astropy/coordinates/frames/cirs-1.0.0>
data: !<tag:astropy.org:astropy/coordinates/representation-1.0.0>
components:
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: 120.0
wrap_angle: !<tag:astropy.org:astropy/coordinates/angle-1.0.0> {unit: !unit/unit-1.0.0 deg,
value: 360.0}
type: UnitSphericalRepresentation
frame_attributes:
obstime: !time/time-1.1.0 {scale: tai, value: B1950.000}

allOf:
- $ref: baseframe-1.0.0
- properties:
frame_attributes:
type: object
properties:
obstime:
$ref: "tag:stsci.edu:asdf/time/time-1.1.0"
required: [obstime]
...
@@ -0,0 +1,47 @@
%YAML 1.1
---
$schema: "http://stsci.edu/schemas/yaml-schema/draft-01"
id: "http://astropy.org/schemas/astropy/coordinates/frames/fk4-1.0.0"
tag: "tag:astropy.org:astropy/coordinates/frames/fk4-1.0.0"

title: |
Represents a FK4 coordinate object from astropy

examples:
-
- A FK4 frame without data
- |
!<tag:astropy.org:astropy/coordinates/frames/fk4-1.0.0>
frame_attributes:
equinox: !time/time-1.1.0 {scale: tai, value: B1950.000}
obstime: !time/time-1.1.0 {scale: tai, value: B1950.000}
-
- A FK4 frame with data
- |
!<tag:astropy.org:astropy/coordinates/frames/fk4-1.0.0>
data: !<tag:astropy.org:astropy/coordinates/representation-1.0.0>
components:
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: 120.0
wrap_angle: !<tag:astropy.org:astropy/coordinates/angle-1.0.0> {unit: !unit/unit-1.0.0 deg,
value: 360.0}
type: UnitSphericalRepresentation
frame_attributes:
equinox: !time/time-1.1.0 {scale: tai, value: B1950.000}
obstime: !time/time-1.1.0 {scale: tai, value: B1950.000}

allOf:
- $ref: baseframe-1.0.0
- properties:
frame_attributes:
type: object
properties:
equinox:
$ref: "tag:stsci.edu:asdf/time/time-1.1.0"
obstime:
$ref: "tag:stsci.edu:asdf/time/time-1.1.0"
required: [equinox]
...
@@ -0,0 +1,47 @@
%YAML 1.1
---
$schema: "http://stsci.edu/schemas/yaml-schema/draft-01"
id: "http://astropy.org/schemas/astropy/coordinates/frames/fk4noeterms-1.0.0"
tag: "tag:astropy.org:astropy/coordinates/frames/fk4noeterms-1.0.0"

title: |
Represents a FK4NoETerms coordinate object from astropy

examples:
-
- A FK4NoETerms frame without data
- |
!<tag:astropy.org:astropy/coordinates/frames/fk4noeterms-1.0.0>
frame_attributes:
equinox: !time/time-1.1.0 {scale: tai, value: B1950.000}
obstime: !time/time-1.1.0 {scale: tai, value: B1950.000}
-
- A FK4NoETerms frame with data
- |
!<tag:astropy.org:astropy/coordinates/frames/fk4noeterms-1.0.0>
data: !<tag:astropy.org:astropy/coordinates/representation-1.0.0>
components:
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: 120.0
wrap_angle: !<tag:astropy.org:astropy/coordinates/angle-1.0.0> {unit: !unit/unit-1.0.0 deg,
value: 360.0}
type: UnitSphericalRepresentation
frame_attributes:
equinox: !time/time-1.1.0 {scale: tai, value: B1950.000}
obstime: !time/time-1.1.0 {scale: tai, value: B1950.000}

allOf:
- $ref: baseframe-1.0.0
- properties:
frame_attributes:
type: object
properties:
equinox:
$ref: "tag:stsci.edu:asdf/time/time-1.1.0"
obstime:
$ref: "tag:stsci.edu:asdf/time/time-1.1.0"
required: [equinox]
...
@@ -0,0 +1,41 @@
%YAML 1.1
---
$schema: "http://stsci.edu/schemas/yaml-schema/draft-01"
id: "http://astropy.org/schemas/astropy/coordinates/frames/fk5-1.0.0"
tag: "tag:astropy.org:astropy/coordinates/frames/fk5-1.0.0"

title: |
Represents a FK5 coordinate object from astropy

examples:
-
- A FK5 frame without data with a custom equinox
- |
!<tag:astropy.org:astropy/coordinates/frames/fk5-1.0.0>
frame_attributes: {equinox: !time/time-1.1.0 '2011-01-02 00:00:00.000'}
-
- A FK5 frame with data
- |
!<tag:astropy.org:astropy/coordinates/frames/fk5-1.0.0>
data: !<tag:astropy.org:astropy/coordinates/representation-1.0.0>
components:
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: 120.0
wrap_angle: !<tag:astropy.org:astropy/coordinates/angle-1.0.0> {unit: !unit/unit-1.0.0 deg,
value: 360.0}
type: UnitSphericalRepresentation
frame_attributes: {equinox: !time/time-1.1.0 J2000.000}

allOf:
- $ref: baseframe-1.0.0
- properties:
frame_attributes:
type: object
properties:
equinox:
$ref: "tag:stsci.edu:asdf/time/time-1.1.0"
required: [equinox]
...
@@ -0,0 +1,37 @@
%YAML 1.1
---
$schema: "http://stsci.edu/schemas/yaml-schema/draft-01"
id: "http://astropy.org/schemas/astropy/coordinates/frames/galactic-1.0.0"
tag: "tag:astropy.org:astropy/coordinates/frames/galactic-1.0.0"

title: |
Represents an Galactic coordinate object from astropy.

examples:
-
- An Galactic frame without data
- |
!<tag:astropy.org:astropy/coordinates/frames/galactic-1.0.0>
frame_attributes: {}
-
- An Galactic frame with data
- |
!<tag:astropy.org:astropy/coordinates/frames/galactic-1.0.0>
data: !<tag:astropy.org:astropy/coordinates/representation-1.0.0>
components:
lat: !<tag:astropy.org:astropy/coordinates/latitude-1.0.0> {unit: !unit/unit-1.0.0 deg,
value: 2.0}
lon: !<tag:astropy.org:astropy/coordinates/longitude-1.0.0>
unit: !unit/unit-1.0.0 deg
value: 1.0
wrap_angle: !<tag:astropy.org:astropy/coordinates/angle-1.0.0> {unit: !unit/unit-1.0.0 deg,
value: 360.0}
type: UnitSphericalRepresentation
frame_attributes: {}




allOf:
- $ref: baseframe-1.0.0
...
@@ -0,0 +1,56 @@
%YAML 1.1
---
$schema: "http://stsci.edu/schemas/yaml-schema/draft-01"
id: "http://astropy.org/schemas/astropy/coordinates/frames/galactocentric-1.0.0"
tag: "tag:astropy.org:astropy/coordinates/frames/galactocentric-1.0.0"

title: |
Represents an galactocentric coordinate object from astropy

examples:
-
- A Galactocentric frame without data
- |
!<tag:astropy.org:astropy/coordinates/frames/galactocentric-1.0.0>
frame_attributes:
galcen_coord: !<tag:astropy.org:astropy/coordinates/frames/icrs-1.1.0>
data: !<tag:astropy.org:astropy/coordinates/representation-1.0.0>
components:
lat: !<tag:astropy.org:astropy/coordinates/latitude-1.0.0> {unit: !unit/unit-1.0.0 deg,
value: -28.936175}
lon: !<tag:astropy.org:astropy/coordinates/longitude-1.0.0>
unit: !unit/unit-1.0.0 deg
value: 266.4051
wrap_angle: !<tag:astropy.org:astropy/coordinates/angle-1.0.0> {unit: !unit/unit-1.0.0 deg,
value: 360.0}
type: UnitSphericalRepresentation
frame_attributes: {}
galcen_distance: !unit/quantity-1.1.0 {unit: !unit/unit-1.0.0 kpc, value: 8.3}
galcen_v_sun: !<tag:astropy.org:astropy/coordinates/representation-1.0.0>
components:
d_x: !unit/quantity-1.1.0 {unit: !unit/unit-1.0.0 km s-1, value: 11.1}
d_y: !unit/quantity-1.1.0 {unit: !unit/unit-1.0.0 km s-1, value: 232.24}
d_z: !unit/quantity-1.1.0 {unit: !unit/unit-1.0.0 km s-1, value: 7.25}
type: CartesianDifferential
roll: !unit/quantity-1.1.0 {unit: !unit/unit-1.0.0 deg, value: 0.0}
z_sun: !unit/quantity-1.1.0 {unit: !unit/unit-1.0.0 pc, value: 27.0}

allOf:
- $ref: baseframe-1.0.0
- properties:
frame_attributes:
type: object
properties:
galacen_coord:
$ref: "icrs-1.1.0"
galcen_distance:
$ref: "tag:stsci.edu:asdf/unit/quantity-1.1.0"
galcen_v_sun:
$ref: "../representation-1.0.0"
z_sun:
$ref: "tag:stsci.edu:asdf/unit/quantity-1.1.0"
roll:
$ref: "tag:stsci.edu:asdf/unit/quantity-1.1.0"

required: [galcen_coord, galcen_distance, galcen_v_sun, z_sun, roll]
...