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

updates for upcoming ASDF standard 1.6.0 #324

Merged
merged 10 commits into from
Apr 15, 2024
1 change: 1 addition & 0 deletions changelog/324.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update ASDF schemas for upcoming ASDF standard 1.6.0.
19 changes: 10 additions & 9 deletions dkist/io/asdf/converters/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@

class VaryingCelestialConverter(TransformConverterBase):
tags = [
"asdf://dkist.nso.edu/tags/varying_celestial_transform-1.1.0",
"asdf://dkist.nso.edu/tags/varying_celestial_transform-1.0.0",
"asdf://dkist.nso.edu/tags/inverse_varying_celestial_transform-1.1.0",
"asdf://dkist.nso.edu/tags/inverse_varying_celestial_transform-1.0.0",
"asdf://dkist.nso.edu/tags/varying_celestial_transform-*",
"asdf://dkist.nso.edu/tags/inverse_varying_celestial_transform-*",
# Old slit tags must be kept so we can read old files, but not types as
# we will not save slit classes any more
"asdf://dkist.nso.edu/tags/varying_celestial_transform_slit-1.0.0",
Expand All @@ -23,10 +21,13 @@
]

def select_tag(self, obj, tags, ctx):
tag_pattern = "asdf://dkist.nso.edu/tags/varying_celestial_transform"

Check warning on line 24 in dkist/io/asdf/converters/models.py

View check run for this annotation

Codecov / codecov/patch

dkist/io/asdf/converters/models.py#L24

Added line #L24 was not covered by tests
if obj._is_inverse:
return "asdf://dkist.nso.edu/tags/inverse_varying_celestial_transform-1.1.0"
tag_pattern = "asdf://dkist.nso.edu/tags/inverse_varying_celestial_transform"

Check warning on line 26 in dkist/io/asdf/converters/models.py

View check run for this annotation

Codecov / codecov/patch

dkist/io/asdf/converters/models.py#L26

Added line #L26 was not covered by tests

return "asdf://dkist.nso.edu/tags/varying_celestial_transform-1.1.0"
for tag in tags:
if tag.startswith(tag_pattern):
return tag

Check warning on line 30 in dkist/io/asdf/converters/models.py

View check run for this annotation

Codecov / codecov/patch

dkist/io/asdf/converters/models.py#L28-L30

Added lines #L28 - L30 were not covered by tests

def from_yaml_tree_transform(self, node, tag, ctx):
from dkist.wcs.models import varying_celestial_transform_from_tables
Expand Down Expand Up @@ -74,7 +75,7 @@
ASDF serialization support for CompoundModel.
"""
tags = [
"asdf://dkist.nso.edu/tags/coupled_compound_model-1.0.0",
"asdf://dkist.nso.edu/tags/coupled_compound_model-*",
]

types = ["dkist.wcs.models.CoupledCompoundModel"]
Expand Down Expand Up @@ -122,7 +123,7 @@
"""

tags = [
"asdf://dkist.nso.edu/tags/ravel_model-1.0.0"
"asdf://dkist.nso.edu/tags/ravel_model-*"
]

types = ["dkist.wcs.models.Ravel"]
Expand All @@ -142,7 +143,7 @@
"""

tags = [
"asdf://dkist.nso.edu/tags/asymmetric_mapping_model-1.0.0"
"asdf://dkist.nso.edu/tags/asymmetric_mapping_model-*"
]

types = ["dkist.wcs.models.AsymmetricMapping"]
Expand Down
2 changes: 2 additions & 0 deletions dkist/io/asdf/entry_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ def get_extensions():
converters=dkist_converters),
ManifestExtension.from_uri("asdf://dkist.nso.edu/manifests/dkist-1.0.0",
converters=dkist_converters),
ManifestExtension.from_uri("asdf://dkist.nso.edu/manifests/dkist-wcs-1.3.0",
converters=wcs_converters),
ManifestExtension.from_uri("asdf://dkist.nso.edu/manifests/dkist-wcs-1.2.0",
converters=wcs_converters),
ManifestExtension.from_uri("asdf://dkist.nso.edu/manifests/dkist-wcs-1.1.0",
Expand Down
2 changes: 1 addition & 1 deletion dkist/io/asdf/resources/manifests/dkist-0.9.0.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
%YAML 1.1
---
id: asdf://dkist.nso.edu/dkist/manifests/dkist-0.9.0
id: asdf://dkist.nso.edu/manifests/dkist-0.9.0
extension_uri: asdf://dkist.nso.edu/dkist/extensions/dkist-0.9.0
title: DKIST extension
description: ASDF schemas and tags for pre-1.0 DKIST tags.
Expand Down
2 changes: 1 addition & 1 deletion dkist/io/asdf/resources/manifests/dkist-1.0.0.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
%YAML 1.1
---
id: asdf://dkist.nso.edu/dkist/manifests/dkist-1.0.0
id: asdf://dkist.nso.edu/manifests/dkist-1.0.0
extension_uri: asdf://dkist.nso.edu/dkist/extensions/dkist-1.0.0
title: DKIST extension
description: ASDF schemas and tags for DKIST classes.
Expand Down
4 changes: 2 additions & 2 deletions dkist/io/asdf/resources/manifests/dkist-1.1.0.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%YAML 1.1
---
id: asdf://dkist.nso.edu/dkist/manifests/dkist-1.1.0
extension_uri: asdf://dkist.nso.edu/dkist/extensions/dkist-1.0.0
id: asdf://dkist.nso.edu/manifests/dkist-1.1.0
extension_uri: asdf://dkist.nso.edu/dkist/extensions/dkist-1.1.0
title: DKIST extension
description: ASDF schemas and tags for DKIST classes.

Expand Down
4 changes: 2 additions & 2 deletions dkist/io/asdf/resources/manifests/dkist-1.2.0.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%YAML 1.1
---
id: asdf://dkist.nso.edu/dkist/manifests/dkist-1.2.0
extension_uri: asdf://dkist.nso.edu/dkist/extensions/dkist-1.0.0
id: asdf://dkist.nso.edu/manifests/dkist-1.2.0
extension_uri: asdf://dkist.nso.edu/dkist/extensions/dkist-1.2.0
title: DKIST extension
description: ASDF schemas and tags for DKIST classes.

Expand Down
2 changes: 1 addition & 1 deletion dkist/io/asdf/resources/manifests/dkist-wcs-1.0.0.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
%YAML 1.1
---
id: asdf://dkist.nso.edu/dkist/manifests/dkist-wcs-1.0.0
id: asdf://dkist.nso.edu/manifests/dkist-wcs-1.0.0
extension_uri: asdf://dkist.nso.edu/dkist/extensions/dkist-wcs-1.0.0
title: DKIST WCS extension
description: ASDF schemas and tags for models and WCS related classes.
Expand Down
2 changes: 1 addition & 1 deletion dkist/io/asdf/resources/manifests/dkist-wcs-1.1.0.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
%YAML 1.1
---
id: asdf://dkist.nso.edu/dkist/manifests/dkist-wcs-1.1.0
id: asdf://dkist.nso.edu/manifests/dkist-wcs-1.1.0
extension_uri: asdf://dkist.nso.edu/dkist/extensions/dkist-wcs-1.1.0
title: DKIST WCS extension
description: ASDF schemas and tags for models and WCS related classes.
Expand Down
2 changes: 1 addition & 1 deletion dkist/io/asdf/resources/manifests/dkist-wcs-1.2.0.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
%YAML 1.1
---
id: asdf://dkist.nso.edu/dkist/manifests/dkist-wcs-1.2.0
id: asdf://dkist.nso.edu/manifests/dkist-wcs-1.2.0
extension_uri: asdf://dkist.nso.edu/dkist/extensions/dkist-wcs-1.2.0
title: DKIST WCS extension
description: ASDF schemas and tags for models and WCS related classes.
Expand Down
27 changes: 27 additions & 0 deletions dkist/io/asdf/resources/manifests/dkist-wcs-1.3.0.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
%YAML 1.1
---
id: asdf://dkist.nso.edu/manifests/dkist-wcs-1.3.0
extension_uri: asdf://dkist.nso.edu/dkist/extensions/dkist-wcs-1.3.0
asdf_standard_requirement:
gte: 1.6.0

title: DKIST WCS extension
description: ASDF schemas and tags for models and WCS related classes.

tags:
# the tag version does not match the schema version
- schema_uri: "asdf://dkist.nso.edu/schemas/varying_celestial_transform-1.1.0"
tag_uri: "asdf://dkist.nso.edu/tags/varying_celestial_transform-1.2.0"

# the varying_celestial_transform schema is reused here
- schema_uri: "asdf://dkist.nso.edu/schemas/varying_celestial_transform-1.1.0"
tag_uri: "asdf://dkist.nso.edu/tags/inverse_varying_celestial_transform-1.2.0"

- schema_uri: "asdf://dkist.nso.edu/schemas/coupled_compound_model-1.1.0"
tag_uri: "asdf://dkist.nso.edu/tags/coupled_compound_model-1.1.0"

- schema_uri: "asdf://dkist.nso.edu/schemas/ravel_model-1.1.0"
tag_uri: "asdf://dkist.nso.edu/tags/ravel_model-1.1.0"

- schema_uri: "asdf://dkist.nso.edu/schemas/asymmetric_mapping_model-1.1.0"
tag_uri: "asdf://dkist.nso.edu/tags/asymmetric_mapping_model-1.1.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
%YAML 1.1
---
$schema: "http://stsci.edu/schemas/yaml-schema/draft-01"
id: "asdf://dkist.nso.edu/schemas/asymmetric_mapping_model-1.1.0"
title: >
Reorder, add and drop axes with different mappings in forward and reverse transforms.

definitions:
mapping:
type: array
items:
type: integer

allOf:
- $ref: "http://stsci.edu/schemas/asdf/transform/transform-1.3.0"
- properties:
forward_n_inputs:
description: |
Explicitly set the number of input axes in the forward direction.
type: integer
backward_n_inputs:
description: |
Explicitly set the number of input axes in the backward direction.
type: integer
forward_mapping:
$ref: "#/definitions/mapping"
backward_mapping:
$ref: "#/definitions/mapping"
required: [forward_mapping, backward_mapping]
...
85 changes: 85 additions & 0 deletions dkist/io/asdf/resources/schemas/coupled_compound_model-1.1.0.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
%YAML 1.1
---
$schema: "http://stsci.edu/schemas/yaml-schema/draft-01"
id: "asdf://dkist.nso.edu/schemas/coupled_compound_model-1.1.0"
title: >
Send axes to different subtransforms.
description: |
This transform takes two models which share one or more inputs on the forward
transform, and where the left hand model's inverse is dependent on the
output of the right hand model's inverse output.

Take the following example with a time dependent celestial transform
(modelled as dependent upon the pixel coordinate for time rather than the
world coordinate).

The forward transform uses the "z" pixel dimension as input to both the
Celestial and Temporal models, this leads to the following transform in the
forward direction:

```
: x y z
: │ │ │
: │ │ ┌────────┤
: │ │ │ │
: ▼ ▼ ▼ ▼
: ┌─────────┐ ┌────────┐
: │Celestial│ │Temporal│
: └─┬───┬───┘ └───┬────┘
: │ │ │
: │ │ │
: │ │ │
: ▼ ▼ ▼
: lon lat time
```

The complexity is in the reverse transform, where the inverse Celestial
transform is also dependent upon the pixel coordinate z.
This means that the output of the inverse Temporal transform has to be
duplicated as an input to the Celestial transform's inverse.
This is achieved by the use of the ``Mapping`` models in
``CoupledCompoundModel.inverse`` to create a multi-stage compound model
which duplicates the output of the right hand side model::

```
: lon lat time
: │ │ │
: │ │ ▼
: │ │ ┌─────────┐
: │ │ │Temporal'│
: │ │ └──┬──┬───┘
: │ │ z │ │
: │ │ ┌─────┘ │
: │ │ │ │
: ▼ ▼ ▼ │
: ┌──────────┐ │
: │Celestial'│ │
: └─┬───┬────┘ │
: │ │ │
: ▼ ▼ ▼
: x y z
```

examples:
-
- A set of transforms
- asdf-standard-1.6.0
- |
!<asdf://dkist.nso.edu/tags/coupled_compound_model-1.1.0>
shared_inputs: 1
forward:
- !transform/shift-1.3.0
offset: 2.0
- !transform/shift-1.3.0
offset: 3.0
allOf:
- $ref: "http://stsci.edu/schemas/asdf/transform/transform-1.3.0"
- properties:
forward:
type: array
items:
$ref: "http://stsci.edu/schemas/asdf/transform/transform-1.3.0"
shared_inputs:
type: number
required: [forward, shared_inputs]
...
17 changes: 17 additions & 0 deletions dkist/io/asdf/resources/schemas/ravel_model-1.1.0.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
%YAML 1.1
---
$schema: "http://stsci.edu/schemas/yaml-schema/draft-01"
id: "asdf://dkist.nso.edu/schemas/ravel_model-1.1.0"

title: A model to flatten 2D indices into 1D
description:
A model which takes a pair of indices and flattens them into the corresponding index for a 1D array. This can be used as a compound with Tabular1D to enable it to be indexed as if it were Tabular2D.

allOf:
- $ref: "http://stsci.edu/schemas/asdf/transform/transform-1.3.0"
- properties:
array_shape:
type: array
order:
type: string
required: [array_shape, order]
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@ allOf:
- properties:
crpix:
anyOf:
- tag: "core/ndarray-1.*"
- tag: "tag:stsci.edu:asdf/core/ndarray-1.*"
- tag: "tag:stsci.edu:asdf/unit/quantity-1.*"
cdelt:
anyOf:
- tag: "core/ndarray-1.*"
- tag: "tag:stsci.edu:asdf/core/ndarray-1.*"
- tag: "tag:stsci.edu:asdf/unit/quantity-1.*"
lon_pole:
anyOf:
- type: number
- tag: "tag:stsci.edu:asdf/unit/quantity-1.*"
crval_table:
anyOf:
- tag: "core/ndarray-1.*"
- tag: "tag:stsci.edu:asdf/core/ndarray-1.*"
- tag: "tag:stsci.edu:asdf/unit/quantity-1.*"
pc_table:
anyOf:
- tag: "core/ndarray-1.*"
- tag: "tag:stsci.edu:asdf/core/ndarray-1.*"
- tag: "tag:stsci.edu:asdf/unit/quantity-1.*"
projection:
$ref: "http://stsci.edu/schemas/asdf/transform/transform-1.2.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
%YAML 1.1
---
$schema: "http://stsci.edu/schemas/yaml-schema/draft-01"
id: "asdf://dkist.nso.edu/schemas/varying_celestial_transform-1.1.0"

title: A varying FITS-like celestial transform.
description:
A model which represents a FITS-like celestial WCS transform which varies over a third pixel input.

allOf:
- $ref: "http://stsci.edu/schemas/asdf/transform/transform-1.3.0"
- properties:
crpix:
anyOf:
- tag: "tag:stsci.edu:asdf/core/ndarray-1.*"
- tag: "tag:stsci.edu:asdf/unit/quantity-1.*"
cdelt:
anyOf:
- tag: "tag:stsci.edu:asdf/core/ndarray-1.*"
- tag: "tag:stsci.edu:asdf/unit/quantity-1.*"
lon_pole:
anyOf:
- type: number
- tag: "tag:stsci.edu:asdf/unit/quantity-1.*"
crval_table:
anyOf:
- tag: "tag:stsci.edu:asdf/core/ndarray-1.*"
- tag: "tag:stsci.edu:asdf/unit/quantity-1.*"
pc_table:
anyOf:
- tag: "tag:stsci.edu:asdf/core/ndarray-1.*"
- tag: "tag:stsci.edu:asdf/unit/quantity-1.*"
projection:
$ref: "http://stsci.edu/schemas/asdf/transform/transform-1.3.0"

required: [crpix, cdelt, lon_pole, crval_table, pc_table, projection]
additionalProperties: true
...
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ dependencies = [
# Some of these schema dependencies are minimums because we generated asdf
# files with them unpinned so they are now required to read generated asdf
# files.
"asdf>=2.11.2", # Pick up jsonschema bug fix
"asdf>=2.11.2",
"asdf-astropy>=0.2.0",
"asdf-coordinates-schemas>=0.1.0",
"asdf-standard>=1.0.3",
"asdf-transform-schemas>=0.3.0",
"asdf-unit-schemas>=0.1.0",
"asdf-wcs-schemas>=0.3.0",
"astropy>=5.3",
"dask[array]>=2021.8.0",
Expand Down
8 changes: 6 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,12 @@ commands =
# !online: {env:PYTEST_COMMAND} {posargs}
# Then specify a specific one like this
# online: {env:PYTEST_COMMAND} --remote-data=any {posargs}
!online: {env:PYTEST_COMMAND} {posargs}
online: {env:PYTEST_COMMAND} --remote-data=any {posargs}
{env:PYTEST_COMMAND} \
online: --remote-data=any \
# It's not possible to test the new schemas with the oldest dependencies
# as the new schemas require new dependent schemas
oldestdeps: -o asdf_schema_tests_enabled=false
{posargs}
Comment on lines +63 to +68
Copy link
Member

Choose a reason for hiding this comment

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

oh hey, I didn't know you could do that 🤔


[testenv:codestyle]
pypi_filter =
Expand Down
Loading