Пример #1
0
def get_extensions():
    """
    Get the list of extensions.
    """
    dkist_converters = [
        FileManagerConverter(),
        DatasetConverter(),
        TiledDatasetConverter()
    ]
    wcs_converters = [VaryingCelestialConverter(), CoupledCompoundConverter()]
    return [
        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.0.0",
            converters=wcs_converters),
        # This manifest handles all pre-refactor tags
        ManifestExtension.from_uri(
            "asdf://dkist.nso.edu/manifests/dkist-0.9.0",
            converters=dkist_converters,
            # Register that this is a replacement for the old extension
            legacy_class_names=["dkist.io.asdf.extension.DKISTExtension"])
    ]
Пример #2
0
def get_extensions():
    """
    Get the list of extensions.
    """
    from sunpy.io.special.asdf.converters.frames import SUNPY_FRAME_CONVERTERS
    from sunpy.io.special.asdf.converters.generic_map import GenericMapConverter

    sunpy_converters = [GenericMapConverter()] + SUNPY_FRAME_CONVERTERS

    return [
        ManifestExtension.from_uri(
            "asdf://sunpy.org/sunpy/manifests/sunpy-1.0.0",
            converters=sunpy_converters,
            # Register that this is a replacement for
            # the old extension so old files still work.
            # without throwing a warning.
            legacy_class_names=[
                "sunpy.io.special.asdf.extension.SunpyExtension"
            ])
    ]
Пример #3
0
# that occur earlier in the list.
TRANSFORM_MANIFEST_URIS = [
    "http://stsci.edu/asdf/extensions/transform/manifests/transform-1.5.0",
    "http://stsci.edu/asdf/extensions/transform/manifests/transform-1.4.0",
    "http://stsci.edu/asdf/extensions/transform/manifests/transform-1.3.0",
    "http://stsci.edu/asdf/extensions/transform/manifests/transform-1.2.0",
    "http://stsci.edu/asdf/extensions/transform/manifests/transform-1.1.0",
    "http://stsci.edu/asdf/extensions/transform/manifests/transform-1.0.0",
]

TRANSFORM_EXTENSIONS = [
    ManifestExtension.from_uri(
        uri,
        # This prevents a warning about a missing extension when opening
        # files written by older versions of the asdf library:
        legacy_class_names=[
            "astropy.io.misc.asdf.extension.AstropyAsdfExtension"
        ],
        converters=TRANSFORM_CONVERTERS,
    ) for uri in TRANSFORM_MANIFEST_URIS
]

ASTROPY_CONVERTERS = [
    UnitsMappingConverter(),
]

ASTROPY_EXTENSION = ManifestExtension.from_uri(
    # This prevents a warning about a missing extension when opening
    # files written by older versions of astropy:
    "http://astropy.org/asdf/extensions/astropy/manifests/astropy-1.0",
    legacy_class_names=["astropy.io.misc.asdf.extension.AstropyExtension"],
Пример #4
0
JWST_TRANSFORM_CONVERTERS = [
    CoordsConverter(),
    Gwa2SlitConverter(),
    Slit2MsaConverter(),
    LogicalConverter(),
    NirissSOSSConverter(),
    RefractionIndexConverter(),
    Rotation3DToGWAConverter(),
    MIRI_AB2SliceConverter(),
    NIRCAMGrismDispersionConverter(),
    NIRISSGrismDispersionConverter(),
    GratingEquationConverter(),
    SnellConverter(),
    V23ToSkyConverter(),
]

# The order here is important; asdf will prefer to use extensions
# that occur earlier in the list.
TRANSFORM_MANIFEST_URIS = [
    "asdf://stsci.edu/jwst_pipeline/manifests/jwst_transforms-1.0.0",
    "asdf://stsci.edu/jwst_pipeline/manifests/jwst_transforms-0.7.0"
]

TRANSFORM_EXTENSIONS = [
    ManifestExtension.from_uri(
        uri,
        legacy_class_names=["jwst.transforms.jwextension.JWSTExtension"],
        converters=JWST_TRANSFORM_CONVERTERS,
    ) for uri in TRANSFORM_MANIFEST_URIS
]
Пример #5
0
from asdf.extension import ManifestExtension
from .stnode import TaggedObjectNodeConverter

DATAMODEL_CONVERTERS = [
    TaggedObjectNodeConverter(),
]

DATAMODEL_EXTENSIONS = [
    ManifestExtension.from_uri(
        "asdf://stsci.edu/datamodels/roman/manifests/datamodels-1.0",
        converters=DATAMODEL_CONVERTERS)
]
Пример #6
0
def test_manifest_extension():
    with config_context() as config:
        minimal_manifest = """%YAML 1.1
---
id: asdf://somewhere.org/manifests/foo
extension_uri: asdf://somewhere.org/extensions/foo
...
"""
        config.add_resource_mapping(
            {"asdf://somewhere.org/extensions/foo": minimal_manifest})
        extension = ManifestExtension.from_uri(
            "asdf://somewhere.org/extensions/foo")
        assert isinstance(extension, Extension)
        assert extension.extension_uri == "asdf://somewhere.org/extensions/foo"
        assert extension.legacy_class_names == []
        assert extension.asdf_standard_requirement is None
        assert extension.converters == []
        assert extension.compressors == []
        assert extension.tags == []

        proxy = ExtensionProxy(extension)
        assert proxy.extension_uri == "asdf://somewhere.org/extensions/foo"
        assert proxy.legacy_class_names == set()
        assert proxy.asdf_standard_requirement == SpecifierSet()
        assert proxy.converters == []
        assert proxy.compressors == []
        assert proxy.tags == []

    with config_context() as config:
        full_manifest = """%YAML 1.1
---
id: asdf://somewhere.org/manifests/foo
extension_uri: asdf://somewhere.org/extensions/foo
asdf_standard_requirement:
  gte: 1.6.0
  lt: 2.0.0
tags:
  - asdf://somewhere.org/tags/bar
  - tag_uri: asdf://somewhere.org/tags/baz
    schema_uri: asdf://somewhere.org/schemas/baz
    title: Baz title
    description: Bar description
...
"""
        config.add_resource_mapping(
            {"asdf://somewhere.org/extensions/foo": full_manifest})

        class FooConverter:
            tags = [
                "asdf://somewhere.org/tags/bar",
                "asdf://somewhere.org/tags/baz"
            ]
            types = []

            def select_tag(self, *args):
                pass

            def to_yaml_tree(self, *args):
                pass

            def from_yaml_tree(self, *args):
                pass

        converter = FooConverter()

        extension = ManifestExtension.from_uri(
            "asdf://somewhere.org/extensions/foo",
            legacy_class_names=["foo.extension.LegacyExtension"],
            converters=[converter],
            compressors=[MinimalCompressor],
        )
        assert extension.extension_uri == "asdf://somewhere.org/extensions/foo"
        assert extension.legacy_class_names == [
            "foo.extension.LegacyExtension"
        ]
        assert extension.asdf_standard_requirement == SpecifierSet(
            ">=1.6.0,<2.0.0")
        assert extension.converters == [converter]
        assert extension.compressors == [MinimalCompressor]
        assert len(extension.tags) == 2
        assert extension.tags[0] == "asdf://somewhere.org/tags/bar"
        assert extension.tags[1].tag_uri == "asdf://somewhere.org/tags/baz"
        assert extension.tags[
            1].schema_uri == "asdf://somewhere.org/schemas/baz"
        assert extension.tags[1].title == "Baz title"
        assert extension.tags[1].description == "Bar description"

        proxy = ExtensionProxy(extension)
        assert proxy.extension_uri == "asdf://somewhere.org/extensions/foo"
        assert proxy.legacy_class_names == {"foo.extension.LegacyExtension"}
        assert proxy.asdf_standard_requirement == SpecifierSet(
            ">=1.6.0,<2.0.0")
        assert proxy.converters == [ConverterProxy(converter, proxy)]
        assert proxy.compressors == [MinimalCompressor]
        assert len(proxy.tags) == 2
        assert proxy.tags[0].tag_uri == "asdf://somewhere.org/tags/bar"
        assert proxy.tags[1].tag_uri == "asdf://somewhere.org/tags/baz"
        assert proxy.tags[1].schema_uri == "asdf://somewhere.org/schemas/baz"
        assert proxy.tags[1].title == "Baz title"
        assert proxy.tags[1].description == "Bar description"

    with config_context() as config:
        simple_asdf_standard_manifest = """%YAML 1.1
---
id: asdf://somewhere.org/manifests/foo
extension_uri: asdf://somewhere.org/extensions/foo
asdf_standard_requirement: 1.6.0
...
"""
        config.add_resource_mapping({
            "asdf://somewhere.org/extensions/foo":
            simple_asdf_standard_manifest
        })
        extension = ManifestExtension.from_uri(
            "asdf://somewhere.org/extensions/foo")
        assert extension.asdf_standard_requirement == SpecifierSet("==1.6.0")

        proxy = ExtensionProxy(extension)
        assert proxy.asdf_standard_requirement == SpecifierSet("==1.6.0")
Пример #7
0
    SellmeierZemaxConverter(),
    Snell3DConverter(),
    DirectionCosinesConverter(),
    SphericalCartesianConverter(),
]

# The order here is important; asdf will prefer to use extensions
# that occur earlier in the list.
WCS_MANIFEST_URIS = [
    "asdf://asdf-format.org/astronomy/gwcs/manifests/gwcs-1.0.0",
]

TRANSFORM_EXTENSIONS = [
    ManifestExtension.from_uri(
        uri,
        legacy_class_names=["gwcs.extension.GWCSExtension"],
        converters=WCS_MODEL_CONVERTERS,
    ) for uri in WCS_MANIFEST_URIS
]


def get_extensions():
    """
    Get the gwcs.converters extension.
    This method is registered with the asdf.extensions entry point.
    Returns
    -------
    list of asdf.extension.Extension
    """
    return TRANSFORM_EXTENSIONS