././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1639520324.2580123 asdf_astropy-0.1.2/0000755000446400020070000000000000000000000015145 5ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1639520324.166497 asdf_astropy-0.1.2/.github/0000755000446400020070000000000000000000000016505 5ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1639520324.206954 asdf_astropy-0.1.2/.github/workflows/0000755000446400020070000000000000000000000020542 5ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1638286988.0 asdf_astropy-0.1.2/.github/workflows/ci.yml0000644000446400020070000000533700000000000021670 0ustar00eslavichSTSCI\sciencename: CI on: push: branches: - main tags: - "*" pull_request: branches: schedule: # Run every Monday at 6am UTC - cron: '0 6 * * 1' jobs: tox_pytest: name: ${{ matrix.name }} runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: include: - name: Python 3.10 Tests python-version: "3.10" os: ubuntu-latest toxenv: py310-test - name: Python 3.9 Tests python-version: "3.9" os: ubuntu-latest toxenv: py39-test - name: Python 3.8 with code coverage python-version: "3.8" os: ubuntu-latest toxenv: py38-cov - name: Python 3.8, Development Dependencies python-version: "3.8" os: ubuntu-latest toxenv: py38-test-devdeps - name: Python 3.8, Numpy 1.18 python-version: "3.8" os: ubuntu-latest toxenv: py38-test-numpy118 - name: Python 3.8, Numpy 1.19 python-version: "3.8" os: ubuntu-latest toxenv: py38-test-numpy119 - name: Code Style Checks python-version: "3.8" os: ubuntu-latest toxenv: codestyle - name: Python 3.7, MacOS python-version: "3.7" os: macos-latest toxenv: py37-test - name: Build Documents python-version: "3.8" os: ubuntu-latest toxenv: build_docs - name: Code Style Checks python-version: "3.8" os: ubuntu-latest toxenv: codestyle # Fails: asdf_astropy/converters/transform/tests/test_transform.py::test_deserialize_compound_user_inverse # Failes asdf_astropy/converters/transform/tests/test_transform.py: 528 - name: Python 3.8 with Astropy LTS python-version: "3.8" os: ubuntu-latest toxenv: py38-astropylts - name: Bandit Checks python-version: "3.8" os: ubuntu-latest toxenv: bandit steps: - name: Checkout code uses: actions/checkout@v2 with: fetch-depth: 0 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - name: Install tox run: | export SETUP_XVFB=True python -m pip install tox - name: Run tox run: tox -e ${{ matrix.toxenv }} - name: Upload Code Coverage if: ${{ contains(matrix.toxenv,'-cov') }} uses: codecov/codecov-action@v2 with: file: ./coverage.xml ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1639520183.0 asdf_astropy-0.1.2/CHANGES.rst0000644000446400020070000000042700000000000016752 0ustar00eslavichSTSCI\science0.1.2 (2021-12-14) ------------------ - Fix bug in Table deserializer when meta is absent from the ASDF. [#36] 0.1.1 (2021-12-04) ------------------ - Retrieve coordinates schemas from asdf-coordinates-schemas. [#35] 0.1.0 (2021-12-01) ------------------ - Initial release. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1601406442.0 asdf_astropy-0.1.2/MANIFEST.in0000644000446400020070000000010300000000000016675 0ustar00eslavichSTSCI\scienceprune docs/_build prune docs/api global-exclude *.pyc exclude .* ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1639520324.2582457 asdf_astropy-0.1.2/PKG-INFO0000644000446400020070000000353300000000000016246 0ustar00eslavichSTSCI\scienceMetadata-Version: 2.1 Name: asdf_astropy Version: 0.1.2 Summary: ASDF serialization support for astropy Home-page: https://github.com/astropy/asdf-astropy Author: The ASDF Developers Author-email: help@stsci.edu License: BSD-3-Clause Platform: UNKNOWN Requires-Python: >=3.6 Description-Content-Type: text/x-rst Provides-Extra: test Provides-Extra: docs License-File: licenses/LICENSE.rst ASDF serialization support for astropy -------------------------------------- .. image:: https://github.com/astropy/asdf-astropy/workflows/CI/badge.svg :target: https://github.com/astropy/asdf-astropy/actions :alt: CI Status .. image:: https://codecov.io/gh/astropy/asdf-astropy/branch/master/graph/badge.svg :target: https://codecov.io/gh/astropy/asdf-astropy/branch=main :alt: Code coverage .. image:: http://img.shields.io/badge/powered%20by-AstroPy-orange.svg?style=flat :target: http://www.astropy.org :alt: Powered by Astropy Badge This package includes plugins that provide ASDF serialization support for astropy objects. The plugins are automatically enabled when the package is installed. The plugins in this package supercede those in the ``astropy.io.misc.asdf`` module; when this package is installed, the astropy plugins will be ignored. The ``astropy.io.misc.asdf`` module will be removed in a future version of astropy. License ------- This project is Copyright (c) Association of Universities for Research in Astronomy (AURA) and licensed under the terms of the BSD 3-Clause license. This package is based upon the `Astropy package template `_ which is licensed under the BSD 3-clause license. See the licenses folder for more information. Contributing ------------ We love contributions! asdf-astropy is open source, built on open source, and we'd love to have you hang out in our community. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1638394479.0 asdf_astropy-0.1.2/README.rst0000644000446400020070000000272300000000000016640 0ustar00eslavichSTSCI\scienceASDF serialization support for astropy -------------------------------------- .. image:: https://github.com/astropy/asdf-astropy/workflows/CI/badge.svg :target: https://github.com/astropy/asdf-astropy/actions :alt: CI Status .. image:: https://codecov.io/gh/astropy/asdf-astropy/branch/master/graph/badge.svg :target: https://codecov.io/gh/astropy/asdf-astropy/branch=main :alt: Code coverage .. image:: http://img.shields.io/badge/powered%20by-AstroPy-orange.svg?style=flat :target: http://www.astropy.org :alt: Powered by Astropy Badge This package includes plugins that provide ASDF serialization support for astropy objects. The plugins are automatically enabled when the package is installed. The plugins in this package supercede those in the ``astropy.io.misc.asdf`` module; when this package is installed, the astropy plugins will be ignored. The ``astropy.io.misc.asdf`` module will be removed in a future version of astropy. License ------- This project is Copyright (c) Association of Universities for Research in Astronomy (AURA) and licensed under the terms of the BSD 3-Clause license. This package is based upon the `Astropy package template `_ which is licensed under the BSD 3-clause license. See the licenses folder for more information. Contributing ------------ We love contributions! asdf-astropy is open source, built on open source, and we'd love to have you hang out in our community. ././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1639520324.211597 asdf_astropy-0.1.2/asdf_astropy/0000755000446400020070000000000000000000000017643 5ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1601406442.0 asdf_astropy-0.1.2/asdf_astropy/__init__.py0000644000446400020070000000044300000000000021755 0ustar00eslavichSTSCI\science# Packages may add whatever they like to this file, but # should keep this content at the top. # ---------------------------------------------------------------------------- from ._astropy_init import * # noqa # ---------------------------------------------------------------------------- ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1621458452.0 asdf_astropy-0.1.2/asdf_astropy/_astropy_init.py0000644000446400020070000000044400000000000023102 0ustar00eslavichSTSCI\scienceimport os from astropy.tests.runner import TestRunner __all__ = ['__version__', 'test'] try: from .version import version as __version__ except ImportError: __version__ = '' # Create the test function for self test test = TestRunner.make_test_runner_in(os.path.dirname(__file__)) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1621458452.0 asdf_astropy-0.1.2/asdf_astropy/conftest.py0000644000446400020070000000432200000000000022043 0ustar00eslavichSTSCI\science# This file is used to configure the behavior of pytest when using the Astropy # test infrastructure. It needs to live inside the package in order for it to # get picked up when running the tests inside an interpreter using # packagename.test import os import asdf from astropy.version import version as astropy_version import pytest # For Astropy 3.0 and later, we can use the standalone pytest plugin if astropy_version < '3.0': from astropy.tests.pytest_plugins import * # noqa del pytest_report_header ASTROPY_HEADER = True else: try: from pytest_astropy_header.display import PYTEST_HEADER_MODULES, TESTED_VERSIONS ASTROPY_HEADER = True except ImportError: ASTROPY_HEADER = False def pytest_configure(config): if ASTROPY_HEADER: config.option.astropy_header = True # Customize the following lines to add/remove entries from the list of # packages for which version numbers are displayed when running the tests. PYTEST_HEADER_MODULES.pop('Pandas', None) PYTEST_HEADER_MODULES['scikit-image'] = 'skimage' from . import __version__ packagename = os.path.basename(os.path.dirname(__file__)) TESTED_VERSIONS[packagename] = __version__ # Uncomment the last two lines in this block to treat all DeprecationWarnings as # exceptions. For Astropy v2.0 or later, there are 2 additional keywords, # as follow (although default should work for most cases). # To ignore some packages that produce deprecation warnings on import # (in addition to 'compiler', 'scipy', 'pygments', 'ipykernel', and # 'setuptools'), add: # modules_to_ignore_on_import=['module_1', 'module_2'] # To ignore some specific deprecation warning messages for Python version # MAJOR.MINOR or later, add: # warnings_to_ignore_by_pyver={(MAJOR, MINOR): ['Message to ignore']} # from astropy.tests.helper import enable_deprecations_as_exceptions # noqa # enable_deprecations_as_exceptions() @pytest.fixture(autouse=True) def remove_astropy_extensions(): """ Disable the old astropy extension so that it doesn't confuse our test results. """ with asdf.config_context() as config: config.remove_extension(package="astropy") yield ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1639520324.2165554 asdf_astropy-0.1.2/asdf_astropy/converters/0000755000446400020070000000000000000000000022035 5ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1601406442.0 asdf_astropy-0.1.2/asdf_astropy/converters/__init__.py0000644000446400020070000000000000000000000024134 0ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1639520324.2214851 asdf_astropy-0.1.2/asdf_astropy/converters/coordinates/0000755000446400020070000000000000000000000024347 5ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1621458452.0 asdf_astropy-0.1.2/asdf_astropy/converters/coordinates/__init__.py0000644000446400020070000000000000000000000026446 0ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1621458452.0 asdf_astropy-0.1.2/asdf_astropy/converters/coordinates/angle.py0000644000446400020070000000227200000000000026012 0ustar00eslavichSTSCI\sciencefrom ..unit.quantity import QuantityConverter class AngleConverter(QuantityConverter): tags = ["tag:astropy.org:astropy/coordinates/angle-*"] types = ["astropy.coordinates.angles.Angle"] def from_yaml_tree(self, node, tag, ctx): from astropy.coordinates.angles import Angle return Angle(super().from_yaml_tree(node, tag, ctx)) class LatitudeConverter(QuantityConverter): tags = ["tag:astropy.org:astropy/coordinates/latitude-*"] types = ["astropy.coordinates.angles.Latitude"] def from_yaml_tree(self, node, tag, ctx): from astropy.coordinates.angles import Latitude return Latitude(super().from_yaml_tree(node, tag, ctx)) class LongitudeConverter(QuantityConverter): tags = ["tag:astropy.org:astropy/coordinates/longitude-*"] types = ["astropy.coordinates.angles.Longitude"] def to_yaml_tree(self, obj, tag, ctx): tree = super().to_yaml_tree(obj, tag, ctx) tree["wrap_angle"] = obj.wrap_angle return tree def from_yaml_tree(self, node, tag, ctx): from astropy.coordinates.angles import Longitude return Longitude(super().from_yaml_tree(node, tag, ctx), wrap_angle=node["wrap_angle"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1621458452.0 asdf_astropy-0.1.2/asdf_astropy/converters/coordinates/earth_location.py0000644000446400020070000000071600000000000027720 0ustar00eslavichSTSCI\sciencefrom asdf.extension import Converter class EarthLocationConverter(Converter): tags = ["tag:astropy.org:astropy/coordinates/earthlocation-*"] types = ["astropy.coordinates.earth.EarthLocation"] def to_yaml_tree(self, obj, tag, ctx): return obj.info._represent_as_dict() def from_yaml_tree(self, node, tag, ctx): from astropy.coordinates.earth import EarthLocation return EarthLocation.info._construct_from_dict(node) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1621458452.0 asdf_astropy-0.1.2/asdf_astropy/converters/coordinates/frame.py0000644000446400020070000000462500000000000026022 0ustar00eslavichSTSCI\sciencefrom asdf.extension import Converter from ..utils import import_type class FrameConverter(Converter): def __init__(self, tag, frame_type_name): self._tag = tag self._frame_type_name = frame_type_name self._frame_type = None @property def tags(self): return [self._tag] @property def types(self): return [self._frame_type_name] @property def frame_type(self): # Delay import until the frame class is needed to improve speed # of loading the extension. if self._frame_type is None: self._frame_type = import_type(self._frame_type_name) return self._frame_type def to_yaml_tree(self, obj, tag, ctx): node = {} if obj.has_data: node["data"] = obj.data # TODO: Figure out why we can't use the frame_attributes # values and document. frame_attributes = {} for attr in obj.frame_attributes.keys(): value = getattr(obj, attr, None) if value is not None: frame_attributes[attr] = value node["frame_attributes"] = frame_attributes return node def from_yaml_tree(self, node, tag, ctx): data = node.get("data", None) if data is not None: return self.frame_type(node["data"], **node["frame_attributes"]) return self.frame_type(**node["frame_attributes"]) class LegacyICRSConverter(Converter): tags = ["tag:astropy.org:astropy/coordinates/frames/icrs-1.0.0"] # Leave the types list empty so that the 1.1.0 ICRS converter # is used on write. types = [] def to_yaml_tree(self, obj, tag, ctx): from astropy.units import Quantity return { "ra": { "value": obj.ra.value, "unit": obj.ra.unit.to_string(), "wrap_angle": Quantity(obj.ra.wrap_angle), }, "dec": { "value": obj.dec.value, "unit": obj.dec.unit.to_string(), }, } def from_yaml_tree(self, node, tag, ctx): from astropy.coordinates import Angle, Longitude, Latitude, ICRS ra = Longitude( node["ra"]["value"], unit=node["ra"]["unit"], wrap_angle=Angle(node["ra"]["wrap_angle"]) ) dec = Latitude(node["dec"]["value"], unit=node["dec"]["unit"]) return ICRS(ra=ra, dec=dec) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1621458452.0 asdf_astropy-0.1.2/asdf_astropy/converters/coordinates/representation.py0000644000446400020070000000336200000000000027767 0ustar00eslavichSTSCI\sciencefrom asdf.extension import Converter class RepresentationConverter(Converter): tags = ["tag:astropy.org:astropy/coordinates/representation-*"] types = [ "astropy.coordinates.representation.CartesianDifferential", "astropy.coordinates.representation.CartesianRepresentation", "astropy.coordinates.representation.CylindricalDifferential", "astropy.coordinates.representation.CylindricalRepresentation", "astropy.coordinates.representation.PhysicsSphericalDifferential", "astropy.coordinates.representation.PhysicsSphericalRepresentation", "astropy.coordinates.representation.RadialDifferential", "astropy.coordinates.representation.RadialRepresentation", "astropy.coordinates.representation.SphericalCosLatDifferential", "astropy.coordinates.representation.SphericalDifferential", "astropy.coordinates.representation.SphericalRepresentation", "astropy.coordinates.representation.UnitSphericalCosLatDifferential", "astropy.coordinates.representation.UnitSphericalDifferential", "astropy.coordinates.representation.UnitSphericalRepresentation", ] def to_yaml_tree(self, obj, tag, ctx): from astropy.coordinates.distances import Distance from astropy.units import Quantity components = {} for c in obj.components: value = getattr(obj, "_" + c, None) if value is not None: components[c] = value return { "type": type(obj).__name__, "components": components, } def from_yaml_tree(self, node, tag, ctx): from astropy.coordinates import representation return getattr(representation, node["type"])(**node["components"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1621458452.0 asdf_astropy-0.1.2/asdf_astropy/converters/coordinates/sky_coord.py0000644000446400020070000000070700000000000026721 0ustar00eslavichSTSCI\sciencefrom asdf.extension import Converter class SkyCoordConverter(Converter): tags = ["tag:astropy.org:astropy/coordinates/skycoord-*"] types = ["astropy.coordinates.sky_coordinate.SkyCoord"] def to_yaml_tree(self, obj, tag, ctx): return obj.info._represent_as_dict() def from_yaml_tree(self, node, tag, ctx): from astropy.coordinates.sky_coordinate import SkyCoord return SkyCoord.info._construct_from_dict(node) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1621458452.0 asdf_astropy-0.1.2/asdf_astropy/converters/coordinates/spectral_coord.py0000644000446400020070000000215700000000000027731 0ustar00eslavichSTSCI\science from asdf.extension import Converter from asdf.tags.core.ndarray import NDArrayType class SpectralCoordConverter(Converter): tags = ["tag:astropy.org:astropy/coordinates/spectralcoord-*"] types = ["astropy.coordinates.spectral_coordinate.SpectralCoord"] def to_yaml_tree(self, obj, tag, ctx): node = { "value": obj.value, "unit": obj.unit, } if obj.observer is not None: node["observer"] = obj.observer if obj.target is not None: node["target"] = obj.target return node def from_yaml_tree(self, node, tag, ctx): from astropy.coordinates.spectral_coordinate import SpectralCoord value = node["value"] if isinstance(value, NDArrayType): # TODO: Why doesn't NDArrayType work? This needs some research # and documentation. See similar note in QuantityConverter. value = value._make_array() return SpectralCoord( value, unit=node["unit"], observer=node.get("observer"), target=node.get("target"), ) ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1639520324.2268758 asdf_astropy-0.1.2/asdf_astropy/converters/coordinates/tests/0000755000446400020070000000000000000000000025511 5ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1621458452.0 asdf_astropy-0.1.2/asdf_astropy/converters/coordinates/tests/__init__.py0000644000446400020070000000000000000000000027610 0ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1638382953.0 asdf_astropy-0.1.2/asdf_astropy/converters/coordinates/tests/helpers.py0000644000446400020070000000170400000000000027527 0ustar00eslavichSTSCI\sciencefrom astropy.tests.helper import assert_quantity_allclose def assert_representation_equal(a, b): __tracebackhide__ = True assert type(a) is type(b) assert a.components == b.components for component in a.components: assert u.allclose(getattr(a, component), getattr(b, component)) def assert_sky_coord_equal(a, b): __tracebackhide__ = True assert a.is_equivalent_frame(b) assert a.representation_type is b.representation_type assert a.shape == b.shape assert_representation_equal(a.data, b.data) def assert_frame_equal(a, b): __tracebackhide__ = True assert type(a) is type(b) if a is None: return assert_representation_equal(a.data, b.data) def assert_spectral_coord_equal(a, b): __tracebackhide__ = True assert type(a) is type(b) assert_quantity_allclose(a.quantity, b.quantity) assert_frame_equal(a.observer, b.observer) assert_frame_equal(a.target, b.target) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1638382953.0 asdf_astropy-0.1.2/asdf_astropy/converters/coordinates/tests/test_angle.py0000644000446400020070000000135400000000000030213 0ustar00eslavichSTSCI\scienceimport pytest import asdf from astropy import units as u from astropy.coordinates import Angle, Latitude, Longitude import numpy as np def create_angles(): return [ Angle(100, u.deg), Angle([100, 120, 150], u.deg), Angle([[90, 100, 110], [100, 120, 150]], u.deg), Angle(np.arange(100).reshape(5, 2, 10), u.deg), Latitude(10, u.deg), Longitude(-100, u.deg, wrap_angle=180 * u.deg), ] @pytest.mark.parametrize("angle", create_angles()) def test_serialization(angle, tmp_path): file_path = tmp_path / "test.asdf" with asdf.AsdfFile() as af: af["angle"] = angle af.write_to(file_path) with asdf.open(file_path) as af: assert (af["angle"] == angle).all() ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1638382953.0 asdf_astropy-0.1.2/asdf_astropy/converters/coordinates/tests/test_earth_location.py0000644000446400020070000000353200000000000032120 0ustar00eslavichSTSCI\scienceimport pytest import asdf from astropy import units as u from astropy.units import Quantity from astropy.coordinates import EarthLocation, Longitude, Latitude from astropy.coordinates.earth import ELLIPSOIDS from asdf_astropy.testing.helpers import assert_earth_location_equal def create_earth_locations(): longitude = Longitude([0., 45., 90., 135., 180., -180, -90, -45], u.deg, wrap_angle=180 * u.deg) latitude = Latitude([+0., 30., 60., +90., -90., -60., -30., 0.], u.deg) height = Quantity([0.1, 0.5, 1.0, -0.5, -1.0, +4.2, -11., -.1], u.m) position = (longitude, latitude, height) result = [ EarthLocation(lat=34.4900 * u.deg, lon=-104.221800 * u.deg, height=40 * u.km), EarthLocation(*EarthLocation.from_geodetic(*position).to_geocentric()), ] result.extend([EarthLocation.from_geodetic(*position, ellipsoid=e) for e in ELLIPSOIDS]) return result @pytest.mark.parametrize("earth_location", create_earth_locations()) def test_serialization(earth_location, tmp_path): file_path = tmp_path / "test.asdf" with asdf.AsdfFile() as af: af["earth_location"] = earth_location af.write_to(file_path) with asdf.open(file_path) as af: assert (af["earth_location"] == earth_location).all() @pytest.fixture def builtin_site_registry(): orig_sites = getattr(EarthLocation, "_site_registry", None) EarthLocation._get_site_registry(force_builtin=True) yield EarthLocation._site_registry = orig_sites def test_earthlocation_site(tmp_path, builtin_site_registry): earth_location = EarthLocation.of_site("greenwich") file_path = tmp_path / "test.asdf" with asdf.AsdfFile() as af: af["earth_location"] = earth_location af.write_to(file_path) with asdf.open(file_path) as af: assert_earth_location_equal(af["earth_location"], earth_location) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1638382953.0 asdf_astropy-0.1.2/asdf_astropy/converters/coordinates/tests/test_frame.py0000644000446400020070000000402400000000000030214 0ustar00eslavichSTSCI\science import pytest import asdf from astropy import units as u from astropy.coordinates import ( Angle, CartesianRepresentation, CIRS, FK4, FK4NoETerms, FK5, Galactic, Galactocentric, GCRS, ICRS, ITRS, Latitude, Longitude, PrecessedGeocentric, SphericalRepresentation, ) from astropy.time import Time import numpy as np from asdf_astropy.testing.helpers import assert_frame_equal def create_frames(): test_data = { "ra": 1 * u.deg, "dec": 2 * u.deg, } return [ CIRS(**test_data), CIRS(**test_data, obstime=Time("J2005")), FK4(**test_data), FK4(**test_data, obstime=Time("B1950")), FK4NoETerms(**test_data), FK4NoETerms(**test_data, obstime= Time("J1975")), FK5(**test_data), FK5(**test_data, equinox="J2005"), FK5(**test_data, equinox="2011-01-01T00:00:00"), Galactic(l=47.37 * u.degree, b=+6.32 * u.degree), Galactocentric( x=np.linspace(-10., 10., 100) * u.kpc, y=np.linspace(-10., 10., 100) * u.kpc, z=np.zeros(100) * u.kpc, z_sun=15 * u.pc ), GCRS(**test_data), GCRS(**test_data, obsgeoloc=CartesianRepresentation([1, 2, 3], unit=u.m)), ICRS(**test_data), ICRS(ra=Longitude(25, unit=u.deg), dec=Latitude(45, unit=u.deg)), ICRS(ra=Longitude(25, unit=u.deg, wrap_angle=Angle(1.5, unit=u.rad)), dec=Latitude(45, unit=u.deg)), ICRS(ra=[0, 1, 2] * u.deg, dec=[3, 4, 5] * u.deg), ITRS(SphericalRepresentation(lon=12.3 * u.deg, lat=45.6 * u.deg, distance=1 * u.km)), PrecessedGeocentric(**test_data), PrecessedGeocentric(**test_data, equinox="B1975"), ] @pytest.mark.parametrize("frame", create_frames()) def test_serialization(frame, tmp_path): file_path = tmp_path / "test.asdf" with asdf.AsdfFile() as af: af["frame"] = frame af.write_to(file_path) with asdf.open(file_path) as af: assert_frame_equal(af["frame"], frame) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1622838200.0 asdf_astropy-0.1.2/asdf_astropy/converters/coordinates/tests/test_representation.py0000644000446400020070000000203400000000000032163 0ustar00eslavichSTSCI\scienceimport pytest import asdf import astropy.units as u from astropy.coordinates import Angle, representation from numpy.random import random from asdf_astropy.testing.helpers import assert_representation_equal REPRESENTATION_CLASSES = [ getattr(representation, class_name) for class_name in representation.__all__ if "Base" not in class_name ] def create_representation(rep_class): kwargs = {} for attr_name, attr_type in rep_class.attr_classes.items(): if issubclass(attr_type, Angle): value = random((100,)) * u.deg else: value = random((100,)) * u.km kwargs[attr_name] = value return rep_class(**kwargs) @pytest.mark.parametrize("rep_class", REPRESENTATION_CLASSES) def test_serialization(rep_class, tmp_path): rep = create_representation(rep_class) file_path = tmp_path / "test.asdf" with asdf.AsdfFile() as af: af["rep"] = rep af.write_to(file_path) with asdf.open(file_path) as af: assert_representation_equal(af["rep"], rep) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1638382953.0 asdf_astropy-0.1.2/asdf_astropy/converters/coordinates/tests/test_sky_coord.py0000644000446400020070000000526500000000000031126 0ustar00eslavichSTSCI\scienceimport pytest import asdf import astropy.units as u from astropy.coordinates import SkyCoord, FK4, Galactic, ICRS, Longitude import numpy as np from asdf_astropy.testing.helpers import assert_sky_coord_equal def create_sky_coords(): # These are cribbed directly from the Examples section of # https://docs.astropy.org/en/stable/api/astropy.coordinates.SkyCoord.html return [ # Defaults to ICRS frame SkyCoord(10, 20, unit="deg"), # Vector of 3 coords SkyCoord([1, 2, 3], [-30, 45, 8], frame="icrs", unit="deg"), # FK4 frame SkyCoord( ["1:12:43.2 +1:12:43", "1 12 43.2 +1 12 43"], frame=FK4, unit=(u.deg, u.hourangle), obstime="J1992.21", ), # Galactic frame SkyCoord("1h12m43.2s +1d12m43s", frame=Galactic), SkyCoord(frame="galactic", l="1h12m43.2s", b="+1d12m43s"), # With ra and dec SkyCoord( Longitude([1, 2, 3], unit=u.deg), np.array([4.5, 5.2, 6.3]) * u.deg, frame="icrs", ), SkyCoord( frame=ICRS, ra=Longitude([1, 2, 3], unit=u.deg), dec=np.array([4.5, 5.2, 6.3]) * u.deg, obstime="2001-01-02T12:34:56" ), # With overridden frame defaults SkyCoord(FK4(1 * u.deg, 2 * u.deg), obstime="J2010.11", equinox="B1965"), # Cartesian SkyCoord(w=0, u=1, v=2, unit="kpc", frame="galactic", representation_type="cartesian"), # Vector frame SkyCoord([ICRS(ra=1 * u.deg, dec=2 * u.deg), ICRS(ra=3 * u.deg, dec=4 * u.deg)]), # 2D obstime SkyCoord([1, 2], [3, 4], [5, 6], unit="deg,deg,m", frame="fk4", obstime=["J1990.5", "J1991.5"]), # Radial velocity SkyCoord(ra=1 * u.deg, dec=2 * u.deg, radial_velocity=10 * u.km / u.s), # Proper motion SkyCoord(ra=1 * u.deg, dec=2 * u.deg, pm_ra_cosdec=2 * u.mas / u.yr, pm_dec=1 * u.mas / u.yr), ] @pytest.mark.parametrize("coord", create_sky_coords()) def test_serialization(coord, tmp_path): file_path = tmp_path / "test.asdf" with asdf.AsdfFile() as af: af["coord"] = coord af.write_to(file_path) with asdf.open(file_path) as af: assert_sky_coord_equal(af["coord"], coord) def test_serializaton_extra_attribute(tmp_path): coord = SkyCoord(10 * u.deg, 20 * u.deg, equinox="2011-01-01T00:00", frame="fk4").transform_to("icrs") file_path = tmp_path / "test.asdf" with asdf.AsdfFile() as af: af["coord"] = coord af.write_to(file_path) with asdf.open(file_path) as af: assert_sky_coord_equal(af["coord"], coord) assert hasattr(af["coord"], "equinox") ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1638382953.0 asdf_astropy-0.1.2/asdf_astropy/converters/coordinates/tests/test_spectral_coord.py0000644000446400020070000000316100000000000032126 0ustar00eslavichSTSCI\scienceimport warnings import pytest # No spectral_coordinate module in astropy 4.0.x pytest.importorskip("astropy.coordinates.spectral_coordinate") import asdf from astropy import units as u from astropy.coordinates import SpectralCoord, ICRS, Galactic from astropy.coordinates.spectral_coordinate import NoVelocityWarning from astropy.tests.helper import assert_quantity_allclose from asdf_astropy.testing.helpers import assert_frame_equal def create_spectral_coords(): result = [ # Scalar SpectralCoord(565 * u.nm), # Vector SpectralCoord([100, 200, 300] * u.GHz), ] with warnings.catch_warnings(): warnings.simplefilter("ignore", NoVelocityWarning) result.append( # With observer and target SpectralCoord( 10 * u.GHz, observer=ICRS(1 * u.km, 2 * u.km, 3 * u.km, representation_type="cartesian"), target=Galactic(10 * u.deg, 20 * u.deg, distance=30 * u.pc) ) ) return result @pytest.mark.filterwarnings("ignore::astropy.coordinates.spectral_coordinate.NoVelocityWarning") @pytest.mark.parametrize("coord", create_spectral_coords()) def test_serialization(coord, tmp_path): file_path = tmp_path / "test.asdf" with asdf.AsdfFile() as af: af["coord"] = coord af.write_to(file_path) with asdf.open(file_path) as af: assert type(af["coord"]) is type(coord) assert_quantity_allclose(af["coord"].quantity, coord.quantity) assert_frame_equal(af["coord"].observer, coord.observer) assert_frame_equal(af["coord"].target, coord.target) ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1639520324.2279284 asdf_astropy-0.1.2/asdf_astropy/converters/fits/0000755000446400020070000000000000000000000023002 5ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1638282379.0 asdf_astropy-0.1.2/asdf_astropy/converters/fits/__init__.py0000644000446400020070000000000000000000000025101 0ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1638282379.0 asdf_astropy-0.1.2/asdf_astropy/converters/fits/fits.py0000644000446400020070000000410000000000000024314 0ustar00eslavichSTSCI\sciencefrom asdf.extension import Converter from asdf.tags.core.ndarray import NDArrayType def _card_to_node(card): from astropy.io.fits import Undefined if isinstance(card.value, Undefined): value = "" else: value = card.value if card.comment: return [card.keyword, value, card.comment] elif value: return [card.keyword, value] elif card.keyword: return [card.keyword] else: return [] class FitsConverter(Converter): def to_yaml_tree(self, obj, tag, ctx): from astropy.table import Table node = [] for hdu in obj: header_node = [_card_to_node(c) for c in hdu.header.cards] hdu_node = {"header": header_node} if hdu.data is not None: if hdu.data.dtype.names is not None: hdu_node["data"] = Table(hdu.data) else: hdu_node["data"] = hdu.data node.append(hdu_node) return node def from_yaml_tree(self, node, tag, ctx): from astropy.io import fits hdus = [] first = True for hdu_node in node: header = fits.Header([fits.Card(*x) for x in hdu_node["header"]]) data = hdu_node.get("data") if isinstance(data, NDArrayType): # TODO: Why doesn't NDArrayType work? This needs some research # and documentation. data = data._make_array() if first: hdu = fits.PrimaryHDU(data=data, header=header) first = False elif data.dtype.names is not None: hdu = fits.BinTableHDU(data=data, header=header) else: hdu = fits.ImageHDU(data=data, header=header) hdus.append(hdu) return fits.HDUList(hdus) class AsdfFitsConverter(FitsConverter): tags = ["tag:stsci.edu:asdf/fits/fits-*"] types = [] class AstropyFitsConverter(FitsConverter): tags = ["tag:astropy.org:astropy/fits/fits-*"] types = ["astropy.io.fits.hdu.hdulist.HDUList"] ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1639520324.2289858 asdf_astropy-0.1.2/asdf_astropy/converters/fits/tests/0000755000446400020070000000000000000000000024144 5ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1638282379.0 asdf_astropy-0.1.2/asdf_astropy/converters/fits/tests/__init__.py0000644000446400020070000000000000000000000026243 0ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1638382953.0 asdf_astropy-0.1.2/asdf_astropy/converters/fits/tests/test_fits.py0000644000446400020070000000613100000000000026523 0ustar00eslavichSTSCI\scienceimport asdf from asdf.tests.helpers import yaml_to_asdf from astropy.io import fits import numpy as np from numpy.testing import assert_array_equal import pytest from asdf_astropy.testing.helpers import assert_hdu_list_equal def create_hduls(): hdul = fits.HDUList() header = fits.Header([ ("FOO", "BAR", "BAZ"), ("SOMENUM", "11.0"), ("EMPTY",) ]) hdul.append(fits.PrimaryHDU(header=header)) hdul.append(fits.ImageHDU(data=np.arange(100))) hdul_with_table = fits.HDUList() hdul_with_table.append( fits.BinTableHDU.from_columns( np.array([(0, 1), (2, 3)], dtype=[("A", int), ("B", int)]) ) ) return [hdul, hdul_with_table] @pytest.mark.parametrize("hdul", create_hduls()) def test_serialization(hdul, tmp_path): file_path = tmp_path / "test.asdf" with asdf.AsdfFile() as af: af["hdul"] = hdul af.write_to(file_path) with asdf.open(file_path) as af: assert_hdu_list_equal(af["hdul"], hdul) def test_asdf_tag(): yaml = """ hdul: !fits/fits-1.0.0 - header: - [SIMPLE, true, conforms to FITS standard] - [BITPIX, 8, array data type] - [NAXIS, 0, number of array dimensions] - [EXTEND, true] - [] - ['', Top Level MIRI Metadata] - [] - [DATE, '2013-08-30T10:49:55.070373', The date this file was created (UTC)] - [FILENAME, MiriDarkReferenceModel_test.fits, The name of the file] - [TELESCOP, JWST, The telescope used to acquire the data] - [] - ['', Information about the observation] - [] - [DATE-OBS, '2013-08-30T10:49:55.000000', The date the observation was made (UTC)] - data: !core/ndarray-1.0.0 data: [2, 3, 3, 4] datatype: float32 shape: [4] header: - [XTENSION, IMAGE, Image extension] - [BITPIX, -32, array data type] - [NAXIS, 4, number of array dimensions] - [NAXIS1, 4] - [NAXIS2, 3] - [NAXIS3, 3] - [NAXIS4, 2] - [PCOUNT, 0, number of parameters] - [GCOUNT, 1, number of groups] - [EXTNAME, SCI, extension name] - [BUNIT, DN, Units of the data array] - data: !core/ndarray-1.0.0 data: [5, 6, 7, 8] datatype: int64 shape: [4] header: - [XTENSION, IMAGE, Image extension] - [BITPIX, -32, array data type] - [NAXIS, 4, number of array dimensions] - [NAXIS1, 4] - [NAXIS2, 3] - [NAXIS3, 3] - [NAXIS4, 2] - [PCOUNT, 0, number of parameters] - [GCOUNT, 1, number of groups] - [EXTNAME, ERR, extension name] - [BUNIT, DN, Units of the error array] """ buff = yaml_to_asdf(yaml) with asdf.open(buff) as af: hdul = af["hdul"] assert len(hdul) == 3 assert hdul[0].header["FILENAME"] == "MiriDarkReferenceModel_test.fits" assert hdul[0].data is None assert hdul[1].header["EXTNAME"] == "SCI" assert_array_equal(hdul[1].data, np.array([2, 3, 3, 4], dtype=np.float32)) assert hdul[2].header["EXTNAME"] == "ERR" assert_array_equal(hdul[2].data, np.array([5, 6, 7, 8], dtype=np.int64)) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1620856446.0 asdf_astropy-0.1.2/asdf_astropy/converters/helpers.py0000644000446400020070000000103500000000000024050 0ustar00eslavichSTSCI\sciencefrom packaging.version import parse as parse_version def parse_tag_version(tag): """ Parse the version portion of the tag into a comparable version object. Parameters ---------- tag : str Returns ------- packaging.version.Version """ return parse_version(tag[tag.rfind("-") + 1:]) def get_tag_name(tag): """ Extract the name portion of a tag URI. Parameters ---------- tag : str Returns ------- str """ return tag[tag.rfind("/") + 1:tag.rfind("-")] ././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1639520324.229857 asdf_astropy-0.1.2/asdf_astropy/converters/table/0000755000446400020070000000000000000000000023124 5ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1638282379.0 asdf_astropy-0.1.2/asdf_astropy/converters/table/__init__.py0000644000446400020070000000000000000000000025223 0ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1639520172.0 asdf_astropy-0.1.2/asdf_astropy/converters/table/table.py0000644000446400020070000000512300000000000024566 0ustar00eslavichSTSCI\sciencefrom asdf.extension import Converter from asdf.tags.core.ndarray import NDArrayType class ColumnConverter(Converter): tags = ["tag:stsci.edu:asdf/core/column-*"] types = [ "astropy.table.column.Column", "astropy.table.column.MaskedColumn", ] def to_yaml_tree(self, obj, tag, ctx): node = { "data": obj.data, "name": obj.name } if obj.description: node["description"] = obj.description if obj.unit: node["unit"] = obj.unit if obj.meta: node["meta"] = obj.meta return node def from_yaml_tree(self, node, tag, ctx): from astropy.table import Column, MaskedColumn from numpy.ma.core import MaskedArray data = node["data"] if isinstance(data, NDArrayType): # TODO: Why doesn't NDArrayType work? This needs some research # and documentation. data = data._make_array() if isinstance(data, MaskedArray): column_class = MaskedColumn else: column_class = Column return column_class( data=data, name=node["name"], description=node.get("description"), unit=node.get("unit"), meta=node.get("meta"), ) class AsdfTableConverter(Converter): tags = ["tag:stsci.edu:asdf/core/table-*"] types = [] def to_yaml_tree(self, obj, tag, ctx): raise NotImplementedError("astropy does not support writing astropy.table.Table with the ASDF table-1.0.0 tag") def from_yaml_tree(self, node, tag, ctx): from astropy.table import Table return Table(node["columns"], meta=node.get("meta")) class AstropyTableConverter(Converter): tags = ["tag:astropy.org:astropy/table/table-*"] types = [ "astropy.table.table.Table", "astropy.table.table.QTable", ] def to_yaml_tree(self, obj, tag, ctx): from astropy.table import QTable node = { "columns": [obj[name] for name in obj.colnames], "colnames": obj.colnames, "qtable": isinstance(obj, QTable) } if obj.meta: node["meta"] = obj.meta return node def from_yaml_tree(self, node, tag, ctx): from astropy.table import Table, QTable if node.get("qtable", False): table = QTable(meta=node.get("meta")) else: table = Table(meta=node.get("meta")) for name, column in zip(node["colnames"], node["columns"]): table[name] = column return table ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1639520324.2305434 asdf_astropy-0.1.2/asdf_astropy/converters/table/tests/0000755000446400020070000000000000000000000024266 5ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1638282379.0 asdf_astropy-0.1.2/asdf_astropy/converters/table/tests/__init__.py0000644000446400020070000000000000000000000026365 0ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1638282379.0 asdf_astropy-0.1.2/asdf_astropy/converters/table/tests/test_table.py0000644000446400020070000001754400000000000027001 0ustar00eslavichSTSCI\scienceimport asdf from asdf.tests.helpers import yaml_to_asdf from astropy.coordinates import SkyCoord, EarthLocation from astropy.table import Table, NdarrayMixin, QTable, Column, MaskedColumn from astropy.time import Time, TimeDelta import astropy.units as u import numpy as np from numpy.testing import assert_array_equal import pytest from asdf_astropy.testing.helpers import ( assert_earth_location_equal, assert_sky_coord_equal, assert_time_equal, assert_time_delta_equal, ) def assert_description_equal(a, b): if a in ("", None) and b in ("", None): return assert a == b def assert_table_equal(a, b): assert type(a) == type(b) assert a.meta == b.meta assert len(a) == len(b) for row_a, row_b in zip(a, b): assert_array_equal(row_a, row_b) assert a.colnames == b.colnames for column_name in a.colnames: col_a = a[column_name] col_b = b[column_name] if isinstance(col_a, (Column, MaskedColumn)) and isinstance(col_b, (Column, MaskedColumn)): assert_description_equal(col_a.description, col_b.description) assert col_a.unit == col_b.unit assert col_a.meta == col_b.meta assert_array_equal(col_a.data, col_b.data) assert_array_equal( getattr(col_a, "mask", [False] * len(col_a)), getattr(col_b, "mask", [False] * len(col_b)), ) def assert_table_roundtrip(table, tmp_path): """ Assert that a table can be written to an ASDF file and read back in without losing any of its essential properties. """ file_path = tmp_path / "testable.asdf" with asdf.AsdfFile({"table": table}) as af: af.write_to(file_path) with asdf.open(file_path) as af: assert_table_equal(table, af["table"]) return af["table"] def test_table(tmp_path): rows = [(1, 2.0, "x"), (4, 5.0, "y"), (5, 8.2, "z")] table = Table(rows=rows, names=("a", "b", "c"), dtype=("i4", "f8", "S1")) table.columns["a"].description = "RA" table.columns["a"].unit = "degree" table.columns["a"].meta = {"foo": "bar"} table.columns["c"].description = "Some description of some sort" assert_table_roundtrip(table, tmp_path) def test_array_columns(tmp_path): data = np.array( [ ([[1, 2], [3, 4]], 2.0, "x"), ([[5, 6], [7, 8]], 5.0, "y"), ([[9, 10], [11, 12]], 8.2, "z") ], dtype=[("a", " columns: - !core/column-1.0.0 data: !core/ndarray-1.0.0 data: [0, 1, 2] name: a - !core/column-1.0.0 data: !core/ndarray-1.0.0 data: [0, 1, 2, 3] name: b colnames: [a, b] """ buff = yaml_to_asdf(yaml) with pytest.raises(ValueError, match="Inconsistent data column lengths"): with asdf.open(buff): pass def test_masked_table(tmp_path): rows = [(1, 2.0, "x"), (4, 5.0, "y"), (5, 8.2, "z")] table = Table(rows=rows, names=("a", "b", "c"), dtype=("i4", "f8", "S1"), masked=True) table.columns["a"].description = "RA" table.columns["a"].unit = "degree" table.columns["a"].meta = {"foo": "bar"} table.columns["a"].mask = [True, False, True] table.columns["c"].description = "Some description of some sort" assert_table_roundtrip(table, tmp_path) def test_quantity_mixin(tmp_path): table = QTable() table["a"] = [1, 2, 3] table["b"] = ["x", "y", "z"] table["c"] = [2.0, 5.0, 8.2] * u.m assert_table_roundtrip(table, tmp_path) def test_time_mixin(tmp_path): table = Table() table["a"] = [1, 2] table["b"] = ["x", "y"] table["c"] = Time(["2001-01-02T12:34:56", "2001-02-03T00:01:02"]) result = assert_table_roundtrip(table, tmp_path) assert_time_equal(result["c"], table["c"]) def test_timedelta_mixin(tmp_path): table = Table() table["a"] = [1, 2] table["b"] = ["x", "y"] table["c"] = TimeDelta([1, 2] * u.day) result = assert_table_roundtrip(table, tmp_path) assert_time_delta_equal(result["c"], table["c"]) def test_skycoord_mixin(tmp_path): table = Table() table["a"] = [1, 2] table["b"] = ["x", "y"] table["c"] = SkyCoord([1, 2], [3, 4], unit="deg,deg", frame="fk4", obstime="J1990.5") # We can't use our assert_table_roundtrip helper because # astropy 4.0.x does not include an __eq__ method for SKyCoord. file_path = tmp_path / "test.asdf" with asdf.AsdfFile() as af: af["table"] = table af.write_to(file_path) with asdf.open(file_path) as af: assert_sky_coord_equal(af["table"]["c"], table["c"]) def test_earthlocation_mixin(tmp_path): table = Table() table["a"] = [1, 2] table["b"] = ["x", "y"] table["c"] = EarthLocation(x=[1, 2] * u.km, y=[3, 4] * u.km, z=[5, 6] * u.km) result = assert_table_roundtrip(table, tmp_path) assert_earth_location_equal(result["c"], table["c"]) def test_ndarray_mixin(tmp_path): table = Table() table["a"] = [1, 2] table["b"] = ["x", "y"] table["c"] = NdarrayMixin([5, 6]) assert_table_roundtrip(table, tmp_path) def test_asdf_table(): yaml = """ table: !core/table-1.0.0 columns: - !core/column-1.0.0 data: !core/ndarray-1.0.0 data: [1, 2, 3] datatype: float64 shape: [3] description: RA meta: {foo: bar} name: a unit: !unit/unit-1.0.0 deg - !core/column-1.0.0 data: !core/ndarray-1.0.0 data: [4, 5, 6] datatype: float64 shape: [3] description: DEC name: b - !core/column-1.0.0 data: !core/ndarray-1.0.0 data: [d, e, f] datatype: [ascii, 1] shape: [3] description: The target name name: c """ buff = yaml_to_asdf(yaml) with asdf.open(buff) as af: table = af["table"] assert isinstance(table, Table) assert table["a"].name == "a" assert table["a"].description == "RA" assert table["a"].meta == {"foo": "bar"} assert table["a"].unit == u.deg assert_array_equal(table["a"].data, np.array([1, 2, 3], dtype=np.float64)) assert table["b"].name == "b" assert table["b"].description == "DEC" assert_array_equal(table["b"].data, np.array([4, 5, 6], dtype=np.float64)) assert table["c"].name == "c" assert table["c"].description == "The target name" assert_array_equal(table["c"].data, np.array([b"d", b"e", b"f"])) ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1639520324.2322397 asdf_astropy-0.1.2/asdf_astropy/converters/time/0000755000446400020070000000000000000000000022773 5ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1621458452.0 asdf_astropy-0.1.2/asdf_astropy/converters/time/__init__.py0000644000446400020070000000000000000000000025072 0ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1639520324.2337098 asdf_astropy-0.1.2/asdf_astropy/converters/time/tests/0000755000446400020070000000000000000000000024135 5ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1621458452.0 asdf_astropy-0.1.2/asdf_astropy/converters/time/tests/__init__.py0000644000446400020070000000000000000000000026234 0ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1638382953.0 asdf_astropy-0.1.2/asdf_astropy/converters/time/tests/test_time.py0000644000446400020070000000213200000000000026502 0ustar00eslavichSTSCI\scienceimport pytest import asdf from astropy.coordinates import EarthLocation from astropy.time import Time from astropy import units as u import numpy as np from asdf_astropy.testing.helpers import assert_time_equal def create_times(): return [ Time(np.arange(100), format="unix"), Time( [1, 2], location=EarthLocation(x=[1, 2] * u.m, y=[3, 4] * u.m, z=[5, 6] * u.m), format="cxcsec", ), Time( "J2000.000", location=EarthLocation(x=6378100 * u.m, y=0 * u.m, z=0 * u.m), format="jyear_str", ), Time("2000-01-01T00:00:00.000"), Time(["2001-01-02T12:34:56", "2001-02-03T00:01:02"]), ] @pytest.mark.parametrize("time", create_times()) @pytest.mark.parametrize("version", asdf.versioning.supported_versions) def test_serialization(time, version, tmp_path): file_path = tmp_path / "test.asdf" with asdf.AsdfFile(version=version) as af: af["time"] = time af.write_to(file_path) with asdf.open(file_path) as af: assert_time_equal(af["time"], time) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1638382953.0 asdf_astropy-0.1.2/asdf_astropy/converters/time/tests/test_time_delta.py0000644000446400020070000000151100000000000027653 0ustar00eslavichSTSCI\science import pytest import asdf from asdf_astropy.testing.helpers import assert_time_delta_equal from astropy import units as u from astropy.time import Time, TimeDelta def create_time_deltas(): result = [ TimeDelta([1, 2] * u.day), ] for format in TimeDelta.FORMATS.keys(): result.append(TimeDelta(Time.now() - Time.now(), format=format)) for scale in list(TimeDelta.SCALES) + [None]: result.append(TimeDelta(0.125, scale=scale)) return result @pytest.mark.parametrize("time_delta", create_time_deltas()) def test_serialization(time_delta, tmp_path): file_path = tmp_path / "test.asdf" with asdf.AsdfFile() as af: af["time_delta"] = time_delta af.write_to(file_path) with asdf.open(file_path) as af: assert_time_delta_equal(af["time_delta"], time_delta) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1621458452.0 asdf_astropy-0.1.2/asdf_astropy/converters/time/time.py0000644000446400020070000000674000000000000024312 0ustar00eslavichSTSCI\sciencefrom asdf.extension import Converter from asdf.tags.core.ndarray import NDArrayType import numpy as np _GUESSABLE_FORMATS = {"iso", "byear", "jyear", "yday"} _ASTROPY_FORMAT_TO_ASDF_FORMAT = { "isot": "iso", "byear_str": "byear", "jyear_str": "jyear", } class TimeConverter(Converter): tags = ["tag:stsci.edu:asdf/time/time-*"] types = ["astropy.time.core.Time"] def to_yaml_tree(self, obj, tag, ctx): from astropy.time import Time if obj.format == "byear": obj = Time(obj, format="byear_str") elif obj.format == "jyear": obj = Time(obj, format="jyear_str") elif obj.format in ("fits", "datetime", "plot_date"): obj = Time(obj, format="isot") asdf_format = _ASTROPY_FORMAT_TO_ASDF_FORMAT.get(obj.format, obj.format) guessable_format = asdf_format in _GUESSABLE_FORMATS if obj.scale == "utc" and guessable_format and obj.isscalar: return obj.value node = { "value": obj.value, } if not guessable_format: node["format"] = asdf_format if obj.scale != "utc": node["scale"] = obj.scale if obj.location is not None: # The 1.0.0 and 1.1.0 tags differ in how location is represented. # In 1.0.0, there is a single "unit" property that is shared among # x, y, and z, and in 1.1.0 each is a quantity with its own unit. if tag.endswith("1.0.0"): location = { "x": obj.location.x.value, "y": obj.location.y.value, "z": obj.location.z.value, "unit": obj.location.unit, } else: location = { "x": obj.location.x, "y": obj.location.y, "z": obj.location.z, } node["location"] = location return node def from_yaml_tree(self, node, tag, ctx): from astropy.time import Time from astropy import units from astropy.coordinates import EarthLocation if isinstance(node, (str, list, np.ndarray, NDArrayType)): time = Time(node) asdf_format = _ASTROPY_FORMAT_TO_ASDF_FORMAT.get(time.format, time.format) if asdf_format not in _GUESSABLE_FORMATS: raise ValueError(f"ASDF time '{node}' is not one of the recognized implicit formats") return time location = node.get("location") if location is not None: # The 1.0.0 and 1.1.0 tags differ in how location is represented. # In 1.0.0, there is a single "unit" property that is shared among # x, y, and z, and in 1.1.0 each is a quantity with its own unit. if tag.endswith("1.0.0"): unit = location.get("unit", units.m) location = EarthLocation.from_geocentric( units.Quantity(location["x"], unit=unit), units.Quantity(location["y"], unit=unit), units.Quantity(location["z"], unit=unit), ) else: location = EarthLocation.from_geocentric( location["x"], location["y"], location["z"], ) return Time( node["value"], format=node.get("format"), scale=node.get("scale"), location=location, ) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1621458452.0 asdf_astropy-0.1.2/asdf_astropy/converters/time/time_delta.py0000644000446400020070000000064200000000000025456 0ustar00eslavichSTSCI\sciencefrom asdf.extension import Converter class TimeDeltaConverter(Converter): tags = ["tag:astropy.org:astropy/time/timedelta-*"] types = ["astropy.time.core.TimeDelta"] def to_yaml_tree(self, obj, tag, ctx): return obj.info._represent_as_dict() def from_yaml_tree(self, node, tag, ctx): from astropy.time.core import TimeDelta return TimeDelta.info._construct_from_dict(node) ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1639520324.2397897 asdf_astropy-0.1.2/asdf_astropy/converters/transform/0000755000446400020070000000000000000000000024050 5ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1601406442.0 asdf_astropy-0.1.2/asdf_astropy/converters/transform/__init__.py0000644000446400020070000000000000000000000026147 0ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1637332890.0 asdf_astropy-0.1.2/asdf_astropy/converters/transform/compound.py0000644000446400020070000000527600000000000026260 0ustar00eslavichSTSCI\sciencefrom .core import TransformConverterBase from ..helpers import get_tag_name __all__ = ["CompoundConverter"] _OPERATOR_TO_TAG_NAME = { "+": "add", "-": "subtract", "*": "multiply", "/": "divide", "**": "power", "|": "compose", "&": "concatenate", "fix_inputs": "fix_inputs" } _TAG_NAME_TO_MODEL_METHOD = { "add": "__add__", "subtract": "__sub__", "multiply": "__mul__", "divide": "__truediv__", "power": "__pow__", "compose": "__or__", "concatenate": "__and__", "fix_inputs": "fix_inputs" } class CompoundConverter(TransformConverterBase): """ ASDF serialization support for CompoundModel. """ tags = [ "tag:stsci.edu:asdf/transform/add-*", "tag:stsci.edu:asdf/transform/subtract-*", "tag:stsci.edu:asdf/transform/multiply-*", "tag:stsci.edu:asdf/transform/divide-*", "tag:stsci.edu:asdf/transform/power-*", "tag:stsci.edu:asdf/transform/compose-*", "tag:stsci.edu:asdf/transform/concatenate-*", "tag:stsci.edu:asdf/transform/fix_inputs-*", ] types = ["astropy.modeling.core.CompoundModel"] def select_tag(self, model, tags, ctx): tag_name = _OPERATOR_TO_TAG_NAME[model.op] # The extension will never include two tags with the # same name but different version, so we can just # return the first matching tag that we discover in # the list: return next(t for t in tags if get_tag_name(t) == tag_name) def to_yaml_tree_transform(self, model, tag, ctx): left = model.left if isinstance(model.right, dict): right = { "keys": list(model.right.keys()), "values": list(model.right.values()) } else: right = model.right return { "forward": [left, right] } def from_yaml_tree_transform(self, node, tag, ctx): from astropy.modeling.core import Model, CompoundModel oper = _TAG_NAME_TO_MODEL_METHOD[get_tag_name(tag)] left = node["forward"][0] if not isinstance(left, Model): raise TypeError("Unknown model type '{0}'".format( node["forward"][0]._tag)) right = node["forward"][1] if (not isinstance(right, Model) and not (oper == "fix_inputs" and isinstance(right, dict))): raise TypeError("Unknown model type '{0}'".format( node["forward"][1]._tag)) if oper == "fix_inputs": right = dict(zip(right["keys"], right["values"])) model = CompoundModel("fix_inputs", left, right) else: model = getattr(left, oper)(right) return model ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1638286988.0 asdf_astropy-0.1.2/asdf_astropy/converters/transform/core.py0000644000446400020070000002102100000000000025346 0ustar00eslavichSTSCI\scienceimport abc import warnings import numpy as np from asdf.extension import Converter from ..utils import import_type def parameter_to_value(param): """ Convert a model parameter to a Quantity or number, depending on the presence of a unit. Parameters ---------- param : astropy.modeling.Parameter Returns ------- astropy.units.Quantity or float """ from astropy import units as u if param.unit is not None: return u.Quantity(param) else: return param.value # One converter, UnitsMappingConverter, does not inherit # this class. When adding features here consider also # updating UnitsMappingConverter. # This class is used by other packages, e.g., gwcs, to implement # converters for custom models. Keep that in mind when modifying # this code. class TransformConverterBase(Converter): """ ABC for transform/model converters. Handles common properties after concrete converter sets model-specific properties. """ @abc.abstractmethod def to_yaml_tree_transform(self, model, tag, ctx): """ Convert a model's parameters into a dict suitable for ASDF serialization. Common model properties such as name and inverse will be handled by this base class. Parameters ---------- model : astropy.modeling.Model The model instance to convert. tag : str The tag identifying the YAML type that `model` should be converted into. ctx : asdf.asdf.SerializationContext The context of the current serialization request. Returns ------- dict ASDF node. """ pass # pragma: no cover @abc.abstractmethod def from_yaml_tree_transform(self, node, tag, ctx): """ Convert an ASDF node into an instance of the appropriate model class. The implementing class need only instantiate the model and set parameter values; common model properties such as name and inverse will be handled by this base class. Parameters ---------- node : dict The ASDF node to convert. tag : str The tag identifying the YAML type of the node. ctx : asdf.asdf.SerializationContext The context of the current serialization request. Returns ------- astropy.modeling.Model The resulting model instance. """ pass # pragma: no cover def to_yaml_tree(self, model, tag, ctx): from astropy.modeling.core import CompoundModel node = self.to_yaml_tree_transform(model, tag, ctx) if model.name is not None: node["name"] = model.name node["inputs"] = list(model.inputs) node["outputs"] = list(model.outputs) # Don't bother serializing analytic inverses provided # by the model: if getattr(model, "_user_inverse", None) is not None: node["inverse"] = model._user_inverse self._serialize_bounding_box(model, node) # model / parameter constraints if not isinstance(model, CompoundModel): fixed_nondefaults = {k: f for k, f in model.fixed.items() if f} if fixed_nondefaults: node['fixed'] = fixed_nondefaults bounds_nondefaults = {k: b for k, b in model.bounds.items() if any(b)} if bounds_nondefaults: node['bounds'] = bounds_nondefaults return node def _serialize_bounding_box(self, model, node): from packaging.version import Version import astropy if Version(astropy.__version__) > Version('4.999.999'): self._serialize_bounding_box_astropy_5(model, node) else: self._serialize_bounding_box_astropy_4(model, node) def _serialize_bounding_box_astropy_4(self, model, node): try: bb = model.bounding_box except NotImplementedError: bb = None if bb is not None: if model.n_inputs == 1: bb = list(bb) else: bb = [list(item) for item in model.bounding_box] node['bounding_box'] = bb def _serialize_bounding_box_astropy_5(self, model, node): from astropy.modeling.bounding_box import ModelBoundingBox, CompoundBoundingBox try: bb = model.bounding_box except NotImplementedError: bb = None if isinstance(bb, ModelBoundingBox): bb = bb.bounding_box(order='C') if model.n_inputs == 1: bb = list(bb) else: bb = [list(item) for item in bb] node['bounding_box'] = bb elif isinstance(bb, CompoundBoundingBox): selector_args = [[sa.index, sa.ignore] for sa in bb.selector_args] node['selector_args'] = selector_args node['cbbox_keys'] = list(bb.bounding_boxes.keys()) bounding_boxes = list(bb.bounding_boxes.values()) if len(model.inputs) - len(selector_args) == 1: node['cbbox_values'] = [list(sbbox.bounding_box()) for sbbox in bounding_boxes] else: node['cbbox_values'] = [[list(item) for item in sbbox.bounding_box() if np.isfinite(item[0])] for sbbox in bounding_boxes] def from_yaml_tree(self, node, tag, ctx): model = self.from_yaml_tree_transform(node, tag, ctx) if 'name' in node: model.name = node['name'] self._deserialize_bounding_box(model, node) if 'inputs' in node: model.inputs = tuple(node['inputs']) if 'outputs' in node: model.outputs = tuple(node['outputs']) param_and_model_constraints = {} for constraint in ['fixed', 'bounds']: if constraint in node: param_and_model_constraints[constraint] = node[constraint] model._initialize_constraints(param_and_model_constraints) yield model if 'inverse' in node: model.inverse = node['inverse'] def _deserialize_bounding_box(self, model, node): from packaging.version import Version import astropy if Version(astropy.__version__) > Version('4.999.999'): self._deserialize_bounding_box_astropy_5(model, node) else: self._deserialize_bounding_box_astropy_4(model, node) def _deserialize_bounding_box_astropy_4(self, model, node): if 'bounding_box' in node: model.bounding_box = node['bounding_box'] elif 'selector_args' in node: warnings.warn("This version of astropy does not support compound bounding boxes.") def _deserialize_bounding_box_astropy_5(self, model, node): from astropy.modeling.bounding_box import CompoundBoundingBox if 'bounding_box' in node: model.bounding_box = node['bounding_box'] elif 'selector_args' in node: cbbox_keys = [tuple(key) for key in node['cbbox_keys']] bbox_dict = dict(zip(cbbox_keys, node['cbbox_values'])) selector_args = node['selector_args'] model.bounding_box = CompoundBoundingBox.validate(model, bbox_dict, selector_args) class SimpleTransformConverter(TransformConverterBase): """ Class for converters that serialize all of a model's parameters and do not require special behavior based on tag version. Parameters ---------- tags : list of str Tag patterns. model_type_name Fully-qualified model type name. """ def __init__(self, tags, model_type_name): self._tags = tags self._model_type_name = model_type_name self._model_type = None @property def tags(self): return self._tags @property def types(self): return [self._model_type_name] @property def model_type(self): # Delay import until the model class is needed to improve speed # of loading the extension. if self._model_type is None: self._model_type = import_type(self._model_type_name) return self._model_type def to_yaml_tree_transform(self, model, tag, ctx): return {p: parameter_to_value(getattr(model, p)) for p in model.param_names} def from_yaml_tree_transform(self, node, tag, ctx): model_type = self.model_type model_kwargs = {} for param in model_type.param_names: if param in node: model_kwargs[param] = node[param] return model_type(**model_kwargs) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1637771238.0 asdf_astropy-0.1.2/asdf_astropy/converters/transform/functional_models.py0000644000446400020070000000330400000000000030127 0ustar00eslavichSTSCI\sciencefrom packaging.version import parse as parse_version from .core import TransformConverterBase, parameter_to_value from ..helpers import parse_tag_version class ConstantConverter(TransformConverterBase): """ ASDF support for serializing the Const1D and Const2D models. """ # The 'dimensions' property was added in 1.4.0, # previously all values were 1D. _2D_MIN_VERSION = parse_version("1.4.0") tags = ["tag:stsci.edu:asdf/transform/constant-*"] types = [ "astropy.modeling.functional_models.Const1D", "astropy.modeling.functional_models.Const2D", ] def to_yaml_tree_transform(self, model, tag, ctx): from astropy.modeling.functional_models import Const1D, Const2D if parse_tag_version(tag) < self._2D_MIN_VERSION: if not isinstance(model, Const1D): raise TypeError( f"{tag} does not support models with > 1 dimension") return { "value": parameter_to_value(model.amplitude) } else: if isinstance(model, Const1D): dimension = 1 elif isinstance(model, Const2D): dimension = 2 return { "value": parameter_to_value(model.amplitude), "dimensions": dimension } def from_yaml_tree_transform(self, node, tag, ctx): from astropy.modeling.functional_models import Const1D, Const2D if parse_tag_version(tag) < self._2D_MIN_VERSION: return Const1D(node["value"]) elif node["dimensions"] == 1: return Const1D(node["value"]) elif node["dimensions"] == 2: return Const2D(node["value"]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1601406442.0 asdf_astropy-0.1.2/asdf_astropy/converters/transform/mappings.py0000644000446400020070000000653000000000000026244 0ustar00eslavichSTSCI\sciencefrom .core import TransformConverterBase from asdf.extension import Converter class IdentityConverter(TransformConverterBase): """ ASDF support for serializing the Identity model. """ tags = ["tag:stsci.edu:asdf/transform/identity-*"] types = ["astropy.modeling.mappings.Identity"] def to_yaml_tree_transform(self, model, tag, ctx): node = {} if model.n_inputs != 1: node['n_dims'] = model.n_inputs return node def from_yaml_tree_transform(self, node, tag, ctx): from astropy.modeling.mappings import Identity return Identity(node.get('n_dims', 1)) class RemapAxesConverter(TransformConverterBase): """ ASDF support for serializing the Mapping model """ tags = ["tag:stsci.edu:asdf/transform/remap_axes-*"] types = ["astropy.modeling.mappings.Mapping"] def to_yaml_tree_transform(self, model, tag, ctx): node = {"mapping": list(model.mapping)} if model.n_inputs > max(model.mapping) + 1: node["n_inputs"] = model.n_inputs return node def from_yaml_tree_transform(self, node, tag, ctx): from astropy.modeling.models import Mapping return Mapping(tuple(node["mapping"]), node.get("n_inputs")) class UnitsMappingConverter(Converter): """ ASDF support for serializing the UnitsMapping model. Note that this converter does not inherit from TransformConverterBase, because the inputs and outputs are written differently from other models. """ tags = ["tag:astropy.org:astropy/transform/units_mapping-*"] types = ["astropy.modeling.mappings.UnitsMapping"] def to_yaml_tree(self, model, tag, ctx): node = {} if model.name is not None: node["name"] = model.name inputs = [] outputs = [] for i, o, m in zip(model.inputs, model.outputs, model.mapping): input = { "name": i, "allow_dimensionless": model.input_units_allow_dimensionless[i], } if m[0] is not None: input["unit"] = m[0] if model.input_units_equivalencies is not None and i in model.input_units_equivalencies: input["equivalencies"] = model.input_units_equivalencies[i] inputs.append(input) output = { "name": o, } if m[-1] is not None: output["unit"] = m[-1] outputs.append(output) node["inputs"] = inputs node["outputs"] = outputs return node def from_yaml_tree(self, node, tag, ctx): from astropy.modeling.mappings import UnitsMapping mapping = tuple((i.get("unit"), o.get("unit")) for i, o in zip(node["inputs"], node["outputs"])) equivalencies = None for i in node["inputs"]: if "equivalencies" in i: if equivalencies is None: equivalencies = {} equivalencies[i["name"]] = i["equivalencies"] kwargs = { "input_units_equivalencies": equivalencies, "input_units_allow_dimensionless": { i["name"]: i.get("allow_dimensionless", False) for i in node["inputs"]}, } if "name" in node: kwargs["name"] = node["name"] return UnitsMapping(mapping, **kwargs) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1601406442.0 asdf_astropy-0.1.2/asdf_astropy/converters/transform/math_functions.py0000644000446400020070000000316600000000000027451 0ustar00eslavichSTSCI\sciencefrom .core import TransformConverterBase _MODEL_NAMES = [ "AbsoluteUfunc", "AddUfunc", "ArccosUfunc", "ArccoshUfunc", "ArcsinUfunc", "ArcsinhUfunc", "Arctan2Ufunc", "ArctanUfunc", "ArctanhUfunc", "CbrtUfunc", "CosUfunc", "CoshUfunc", "Deg2radUfunc", # DivideUfunc is an alias for True_divideUfunc "DivmodUfunc", "Exp2Ufunc", "ExpUfunc", "Expm1Ufunc", "FabsUfunc", "Floor_divideUfunc", "FmodUfunc", "HypotUfunc", "Log10Ufunc", "Log1pUfunc", "Log2Ufunc", "LogUfunc", "Logaddexp2Ufunc", "LogaddexpUfunc", # ModUfunc is an alias for RemainderUfunc "MultiplyUfunc", "NegativeUfunc", "PositiveUfunc", "PowerUfunc", "Rad2degUfunc", "ReciprocalUfunc", "RemainderUfunc", "RintUfunc", "SinUfunc", "SinhUfunc", "SqrtUfunc", "SquareUfunc", "SubtractUfunc", "TanUfunc", "TanhUfunc", "True_divideUfunc", ] class MathFunctionsConverter(TransformConverterBase): """ ASDF support for serializing the math functions models, each of which corresponds to a numpy ufunc. """ tags = ["tag:stsci.edu:asdf/transform/math_functions-*"] types = ["astropy.modeling.math_functions." + m for m in _MODEL_NAMES] def to_yaml_tree_transform(self, model, tag, ctx): return {"func_name": model.func.__name__} def from_yaml_tree_transform(self, node, tag, ctx): from astropy.modeling import math_functions klass_name = math_functions._make_class_name(node["func_name"]) klass = getattr(math_functions, klass_name) return klass() ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1601406442.0 asdf_astropy-0.1.2/asdf_astropy/converters/transform/polynomial.py0000644000446400020070000001574600000000000026622 0ustar00eslavichSTSCI\sciencefrom packaging.version import parse as parse_version import numpy as np from .core import TransformConverterBase from ..helpers import parse_tag_version class PolynomialConverter(TransformConverterBase): """ ASDF support for serializing the 1D and 2D polynomial models. """ # Schema versions prior to 1.2 included an unrelated "domain" # property. We can't serialize the new domain values with those # versions because they don't validate. _DOMAIN_WINDOW_MIN_VERSION = parse_version("1.2.0") tags = ["tag:stsci.edu:asdf/transform/polynomial-*"] types = [ "astropy.modeling.polynomial.Polynomial1D", "astropy.modeling.polynomial.Polynomial2D", ] def to_yaml_tree_transform(self, model, tag, ctx): from astropy.modeling.polynomial import Polynomial1D, Polynomial2D if isinstance(model, Polynomial1D): coefficients = np.array(model.parameters) elif isinstance(model, Polynomial2D): degree = model.degree coefficients = np.zeros((degree + 1, degree + 1)) for i in range(degree + 1): for j in range(degree + 1): if i + j < degree + 1: name = "c" + str(i) + "_" + str(j) coefficients[i, j] = getattr(model, name).value node = {"coefficients": coefficients} if parse_tag_version(tag) >= self._DOMAIN_WINDOW_MIN_VERSION: if model.n_inputs == 1: if model.domain is not None: node["domain"] = model.domain if model.window is not None: node["window"] = model.window else: if model.x_domain or model.y_domain is not None: node["domain"] = (model.x_domain, model.y_domain) if model.x_window or model.y_window is not None: node["window"] = (model.x_window, model.y_window) return node def from_yaml_tree_transform(self, node, tag, ctx): from astropy.modeling.polynomial import Polynomial1D, Polynomial2D coefficients = np.asarray(node["coefficients"]) n_dim = coefficients.ndim if n_dim == 1: domain = node.get("domain", None) window = node.get("window", None) model = Polynomial1D(coefficients.size - 1, domain=domain, window=window) model.parameters = coefficients elif n_dim == 2: x_domain, y_domain = tuple(node.get("domain", (None, None))) x_window, y_window = tuple(node.get("window", (None, None))) shape = coefficients.shape degree = shape[0] - 1 if shape[0] != shape[1]: raise TypeError("Coefficients must be an (n+1, n+1) matrix") coeffs = {} for i in range(shape[0]): for j in range(shape[0]): if i + j < degree + 1: name = "c" + str(i) + "_" + str(j) coeffs[name] = coefficients[i, j] model = Polynomial2D(degree, x_domain=x_domain, y_domain=y_domain, x_window=x_window, y_window=y_window, **coeffs) else: raise NotImplementedError("astropy supports only 1D or 2D polynomial models") return model class OrthoPolynomialConverter(TransformConverterBase): """ ASDF support for serializing models that inherit OrthoPolyomialBase. """ # Map of model class name to (polynomial type, number of dimensions) tuple: _CLASS_NAME_TO_POLY_INFO = { "Legendre1D": ("legendre", 1), "Legendre2D": ("legendre", 2), "Chebyshev1D": ("chebyshev", 1), "Chebyshev2D": ("chebyshev", 2), "Hermite1D": ("hermite", 1), "Hermite2D": ("hermite", 2), } _POLY_INFO_TO_CLASS_NAME = {v: k for k, v in _CLASS_NAME_TO_POLY_INFO.items()} tags = ["tag:stsci.edu:asdf/transform/ortho_polynomial-*"] types = [ "astropy.modeling.polynomial.Legendre1D", "astropy.modeling.polynomial.Legendre2D", "astropy.modeling.polynomial.Chebyshev1D", "astropy.modeling.polynomial.Chebyshev2D", "astropy.modeling.polynomial.Hermite1D", "astropy.modeling.polynomial.Hermite2D", ] def to_yaml_tree_transform(self, model, tag, ctx): poly_type = self._CLASS_NAME_TO_POLY_INFO[model.__class__.__name__][0] if model.n_inputs == 1: coefficients = np.array(model.parameters) else: coefficients = np.zeros((model.x_degree + 1, model.y_degree + 1)) for i in range(model.x_degree + 1): for j in range(model.y_degree + 1): name = f"c{i}_{j}" coefficients[i, j] = getattr(model, name).value node = {"polynomial_type": poly_type, "coefficients": coefficients} if model.n_inputs == 1: if model.domain is not None: node["domain"] = model.domain if model.window is not None: node["window"] = model.window else: if model.x_domain or model.y_domain is not None: node["domain"] = (model.x_domain, model.y_domain) if model.x_window or model.y_window is not None: node["window"] = (model.x_window, model.y_window) return node def from_yaml_tree_transform(self, node, tag, ctx): from astropy.modeling import polynomial coefficients = np.asarray(node["coefficients"]) poly_type = node["polynomial_type"] n_dim = coefficients.ndim class_name = self._POLY_INFO_TO_CLASS_NAME[(poly_type, n_dim)] model_type = getattr(polynomial, class_name) coefficients = np.asarray(node["coefficients"]) if n_dim == 1: domain = node.get("domain", None) window = node.get("window", None) model = model_type(coefficients.size - 1, domain=domain, window=window) model.parameters = coefficients elif n_dim == 2: x_domain, y_domain = tuple(node.get("domain", (None, None))) x_window, y_window = tuple(node.get("window", (None, None))) coeffs = {} shape = coefficients.shape x_degree = shape[0] - 1 y_degree = shape[1] - 1 for i in range(x_degree + 1): for j in range(y_degree + 1): name = f"c{i}_{j}" coeffs[name] = coefficients[i, j] model = model_type( x_degree, y_degree, x_domain=x_domain, y_domain=y_domain, x_window=x_window, y_window=y_window, **coeffs ) else: raise NotImplementedError("astropy supports only 1D or 2D polynomial models") return model ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1601406442.0 asdf_astropy-0.1.2/asdf_astropy/converters/transform/projections.py0000644000446400020070000000474600000000000026774 0ustar00eslavichSTSCI\sciencefrom .core import TransformConverterBase, import_type, parameter_to_value class ProjectionConverter(TransformConverterBase): """ ASDF support for serializing most projection models. An instance of this class must be created for each projection. Parameters ---------- tags : list of str Tag patterns. pix2sky_type_name : str Fully-qualified type name of the projection's Pix2Sky model. sky2pix_type_name : str Fully-qualified type name of the projection's Sky2Pix model. """ def __init__(self, tags, pix2sky_type_name, sky2pix_type_name): self._tags = tags self._pix2sky_type_name = pix2sky_type_name self._sky2pix_type_name = sky2pix_type_name self._pix2sky_type = None self._sky2pix_type = None @property def tags(self): return self._tags @property def types(self): return [self._pix2sky_type_name, self._sky2pix_type_name] @property def pix2sky_type(self): # Delay import until the model class is needed to improve speed # of loading the extension. if self._pix2sky_type is None: self._pix2sky_type = import_type(self._pix2sky_type_name) return self._pix2sky_type @property def sky2pix_type(self): # Delay import until the model class is needed to improve speed # of loading the extension. if self._sky2pix_type is None: self._sky2pix_type = import_type(self._sky2pix_type_name) return self._sky2pix_type def to_yaml_tree_transform(self, model, tag, ctx): if isinstance(model, self.pix2sky_type): direction = "pix2sky" elif isinstance(model, self.sky2pix_type): direction = "sky2pix" else: raise TypeError("Unrecognized projection model type") node = {p: parameter_to_value(getattr(model, p)) for p in model.param_names} node["direction"] = direction return node def from_yaml_tree_transform(self, node, tag, ctx): if node["direction"] == "pix2sky": model_type = self.pix2sky_type elif node["direction"] == "sky2pix": model_type = self.sky2pix_type else: raise ValueError("Unrecognized projection direction: " + node["direction"]) model_kwargs = {} for param in model_type.param_names: if param in node: model_kwargs[param] = node[param] return model_type(**model_kwargs) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1601406442.0 asdf_astropy-0.1.2/asdf_astropy/converters/transform/rotations.py0000644000446400020070000000734300000000000026453 0ustar00eslavichSTSCI\sciencefrom .core import TransformConverterBase, parameter_to_value class Rotate3DConverter(TransformConverterBase): """ ASDF support for serializing rotation models that use the rotate3d tag. """ tags = ["tag:stsci.edu:asdf/transform/rotate3d-*"] types = [ "astropy.modeling.rotations.RotateNative2Celestial", "astropy.modeling.rotations.RotateCelestial2Native", "astropy.modeling.rotations.EulerAngleRotation", ] def to_yaml_tree_transform(self, model, tag, ctx): from astropy.modeling import rotations if isinstance(model, rotations.RotateNative2Celestial): node = { "phi": parameter_to_value(model.lon), "theta": parameter_to_value(model.lat), "psi": parameter_to_value(model.lon_pole), "direction": "native2celestial", } elif isinstance(model, rotations.RotateCelestial2Native): node = { "phi": parameter_to_value(model.lon), "theta": parameter_to_value(model.lat), "psi": parameter_to_value(model.lon_pole), "direction": "celestial2native", } else: node = { "phi": parameter_to_value(model.phi), "theta": parameter_to_value(model.theta), "psi": parameter_to_value(model.psi), "direction": model.axes_order, } return node def from_yaml_tree_transform(self, node, tag, ctx): from astropy.modeling import rotations if node["direction"] == "native2celestial": return rotations.RotateNative2Celestial(node["phi"], node["theta"], node["psi"]) elif node["direction"] == "celestial2native": return rotations.RotateCelestial2Native(node["phi"], node["theta"], node["psi"]) else: return rotations.EulerAngleRotation(node["phi"], node["theta"], node["psi"], axes_order=node["direction"]) class RotationSequenceConverter(TransformConverterBase): """ ASDF support for serializing rotation sequence models. """ tags = ["tag:stsci.edu:asdf/transform/rotate_sequence_3d-*"] types = [ "astropy.modeling.rotations.RotationSequence3D", "astropy.modeling.rotations.SphericalRotationSequence", ] def to_yaml_tree_transform(self, model, tag, ctx): from astropy.modeling import rotations node = {"angles": list(model.angles.value)} node["axes_order"] = model.axes_order if isinstance(model, rotations.SphericalRotationSequence): node["rotation_type"] = "spherical" elif isinstance(model, rotations.RotationSequence3D): node["rotation_type"] = "cartesian" else: raise ValueError(f"Cannot serialize model of type {type(model)}") return node def from_yaml_tree_transform(self, node, tag, ctx): from astropy.modeling import rotations angles = node["angles"] axes_order = node["axes_order"] rotation_type = node["rotation_type"] if rotation_type == "cartesian": return rotations.RotationSequence3D(angles, axes_order=axes_order) elif rotation_type == "spherical": return rotations.SphericalRotationSequence(angles, axes_order=axes_order) else: raise ValueError(f"Unrecognized rotation_type: {rotation_type}") ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1620856446.0 asdf_astropy-0.1.2/asdf_astropy/converters/transform/tabular.py0000644000446400020070000000324100000000000026054 0ustar00eslavichSTSCI\sciencefrom .core import TransformConverterBase __all__ = ["TabularConverter"] class TabularConverter(TransformConverterBase): """ ASDF support for serializing tabular models. """ tags = ["tag:stsci.edu:asdf/transform/tabular-*"] types = [ "astropy.modeling.tabular.Tabular1D", "astropy.modeling.tabular.Tabular2D", ] def to_yaml_tree_transform(self, model, tag, ctx): node = {} if model.fill_value is not None: node["fill_value"] = model.fill_value node["lookup_table"] = model.lookup_table node["points"] = [p for p in model.points] node["method"] = str(model.method) node["bounds_error"] = model.bounds_error return node def from_yaml_tree_transform(self, node, tag, ctx): from astropy.modeling import tabular lookup_table = node.pop("lookup_table") dim = lookup_table.ndim fill_value = node.pop("fill_value", None) if dim == 1: points = (node["points"][0],) model = tabular.Tabular1D(points=points, lookup_table=lookup_table, method=node["method"], bounds_error=node["bounds_error"], fill_value=fill_value) elif dim == 2: points = tuple(node["points"]) model = tabular.Tabular2D(points=points, lookup_table=lookup_table, method=node["method"], bounds_error=node["bounds_error"], fill_value=fill_value) else: raise NotImplementedError("tabular models with ndim > 2 are not supported ") return model ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1639520324.2410862 asdf_astropy-0.1.2/asdf_astropy/converters/transform/tests/0000755000446400020070000000000000000000000025212 5ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1621458452.0 asdf_astropy-0.1.2/asdf_astropy/converters/transform/tests/__init__.py0000644000446400020070000000000000000000000027311 0ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1638382953.0 asdf_astropy-0.1.2/asdf_astropy/converters/transform/tests/test_transform.py0000644000446400020070000005523600000000000030651 0ustar00eslavichSTSCI\scienceimport asdf import pytest import numpy as np import itertools from packaging.version import Version import astropy from astropy.modeling import models as astropy_models import astropy.modeling from astropy import units as u from numpy.testing import assert_array_equal from asdf.tests.helpers import yaml_to_asdf from asdf_astropy import integration try: from astropy.modeling.models import UnitsMapping HAS_NO_UNITS_MAPPING = False except ImportError: HAS_NO_UNITS_MAPPING = True if Version(astropy.__version__) < Version("4.1"): ASTROPY_LT_41 = True else: ASTROPY_LT_41 = False def assert_model_roundtrip(model, tmpdir, version=None): """ Assert that a model can be written to an ASDF file and read back in without losing any of its essential properties. """ path = str(tmpdir / "test.asdf") with asdf.AsdfFile({"model": model}, version=version) as af: af.write_to(path) with asdf.open(path) as af: assert_models_equal(model, af["model"]) return af["model"] def assert_models_equal(a, b): """ Assert that two model instances are equivalent. """ if a is None and b is None: return assert a.__class__ == b.__class__ assert a.name == b.name assert a.inputs == b.inputs assert a.input_units == b.input_units assert a.outputs == b.outputs assert a.input_units_allow_dimensionless == b.input_units_allow_dimensionless for i in a.inputs: if a.input_units_equivalencies is None: a_equiv = None else: a_equiv = a.input_units_equivalencies.get(i) if b.input_units_equivalencies is None: b_equiv = None else: b_equiv = b.input_units_equivalencies.get(i, None) assert a_equiv == b_equiv assert_array_equal(a.parameters, b.parameters) try: a_bounding_box = a.bounding_box except NotImplementedError: a_bounding_box = None try: b_bounding_box = b.bounding_box except NotImplementedError: b_bounding_box = None assert a_bounding_box == b_bounding_box assert a.fixed == b.fixed assert a.bounds == b.bounds assert_models_equal(a._user_inverse, b._user_inverse) def create_single_models(): model_with_bounding_box = astropy_models.Shift(10) model_with_bounding_box.bounding_box = ((1, 7),) model_with_user_inverse = astropy_models.Shift(10) model_with_user_inverse.inverse = astropy_models.Shift(-7) model_with_constraints = astropy_models.Legendre2D( x_degree=1, y_degree=1, c0_0=1, c0_1=2, c1_0=3, fixed={"c1_0": True, "c0_1": True}, bounds={"c0_0": (-10, 10)} ) model_with_custom_inputs_outputs = astropy_models.Gaussian2D() model_with_custom_inputs_outputs.inputs = ("a", "b") model_with_custom_inputs_outputs.outputs = ("c",) result = [ # Generic model features astropy_models.Shift(10, name="some model name"), model_with_bounding_box, model_with_user_inverse, model_with_constraints, model_with_custom_inputs_outputs, # astropy.modeling.functional_models astropy_models.AiryDisk2D(amplitude=10., x_0=0.5, y_0=1.5), astropy_models.Box1D(amplitude=10., x_0=0.5, width=5.), astropy_models.Box2D(amplitude=10., x_0=0.5, x_width=5., y_0=1.5, y_width=7.), astropy_models.Const1D(amplitude=5.), astropy_models.Const2D(amplitude=5.), astropy_models.Disk2D(amplitude=10., x_0=0.5, y_0=1.5, R_0=5.), astropy_models.Ellipse2D(amplitude=10., x_0=0.5, y_0=1.5, a=2., b=4., theta=0.1), astropy_models.Exponential1D(amplitude=10., tau=3.5), astropy_models.Gaussian1D(amplitude=10., mean=5., stddev=3.), astropy_models.Gaussian2D(amplitude=10., x_mean=5., y_mean=5., x_stddev=3., y_stddev=3.), astropy_models.KingProjectedAnalytic1D(amplitude=10., r_core=5., r_tide=2.), astropy_models.Linear1D(slope=2.0, intercept=1.5), astropy_models.Logarithmic1D(amplitude=10., tau=3.5), astropy_models.Lorentz1D(amplitude=10., x_0=0.5, fwhm=2.5), astropy_models.Moffat1D(amplitude=10., x_0=0.5, gamma=1.2, alpha=2.5), astropy_models.Moffat2D(amplitude=10., x_0=0.5, y_0=1.5, gamma=1.2, alpha=2.5), astropy_models.Multiply(3), astropy_models.Multiply(10 * u.m), astropy_models.Planar2D(slope_x=0.5, slope_y=1.2, intercept=2.5), astropy_models.RedshiftScaleFactor(z=2.5), astropy_models.RickerWavelet1D(amplitude=10., x_0=0.5, sigma=1.2), astropy_models.RickerWavelet2D(amplitude=10., x_0=0.5, y_0=1.5, sigma=1.2), astropy_models.Ring2D(amplitude=10., x_0=0.5, y_0=1.5, r_in=5., width=10.), astropy_models.Scale(3.4), astropy_models.Sersic1D(amplitude=10., r_eff=1., n=4.), astropy_models.Sersic2D(amplitude=10., r_eff=1., n=4., x_0=0.5, y_0=1.5, ellip=0.0, theta=0.0), astropy_models.Shift(2.), astropy_models.Shift(2. * u.deg), astropy_models.Scale(3.4 * u.deg), astropy_models.Sine1D(amplitude=10., frequency=0.5, phase=1.), astropy_models.Trapezoid1D(amplitude=10., x_0=0.5, width=5., slope=1.), astropy_models.TrapezoidDisk2D(amplitude=10., x_0=0.5, y_0=1.5, R_0=5., slope=1.), astropy_models.Voigt1D(x_0=0.55, amplitude_L=10., fwhm_L=0.5, fwhm_G=0.9), # astropy.modeling.mappings astropy_models.Identity(2), astropy_models.Mapping((0, 1), n_inputs=3), # astropy.modeling.math_functions astropy.modeling.math_functions.AbsoluteUfunc(), astropy.modeling.math_functions.AddUfunc(), astropy.modeling.math_functions.ArccosUfunc(), astropy.modeling.math_functions.ArccoshUfunc(), astropy.modeling.math_functions.ArcsinUfunc(), astropy.modeling.math_functions.ArcsinhUfunc(), astropy.modeling.math_functions.Arctan2Ufunc(), astropy.modeling.math_functions.ArctanUfunc(), astropy.modeling.math_functions.ArctanhUfunc(), astropy.modeling.math_functions.CbrtUfunc(), astropy.modeling.math_functions.CosUfunc(), astropy.modeling.math_functions.CoshUfunc(), astropy.modeling.math_functions.Deg2radUfunc(), astropy.modeling.math_functions.DivideUfunc(), astropy.modeling.math_functions.DivmodUfunc(), astropy.modeling.math_functions.Exp2Ufunc(), astropy.modeling.math_functions.ExpUfunc(), astropy.modeling.math_functions.Expm1Ufunc(), astropy.modeling.math_functions.FabsUfunc(), astropy.modeling.math_functions.Floor_divideUfunc(), astropy.modeling.math_functions.FmodUfunc(), astropy.modeling.math_functions.HypotUfunc(), astropy.modeling.math_functions.Log10Ufunc(), astropy.modeling.math_functions.Log1pUfunc(), astropy.modeling.math_functions.Log2Ufunc(), astropy.modeling.math_functions.LogUfunc(), astropy.modeling.math_functions.Logaddexp2Ufunc(), astropy.modeling.math_functions.LogaddexpUfunc(), astropy.modeling.math_functions.ModUfunc(), astropy.modeling.math_functions.MultiplyUfunc(), astropy.modeling.math_functions.NegativeUfunc(), astropy.modeling.math_functions.PositiveUfunc(), astropy.modeling.math_functions.PowerUfunc(), astropy.modeling.math_functions.Rad2degUfunc(), astropy.modeling.math_functions.ReciprocalUfunc(), astropy.modeling.math_functions.RemainderUfunc(), astropy.modeling.math_functions.RintUfunc(), astropy.modeling.math_functions.SinUfunc(), astropy.modeling.math_functions.SinhUfunc(), astropy.modeling.math_functions.SqrtUfunc(), astropy.modeling.math_functions.SquareUfunc(), astropy.modeling.math_functions.SubtractUfunc(), astropy.modeling.math_functions.TanUfunc(), astropy.modeling.math_functions.TanhUfunc(), astropy.modeling.math_functions.True_divideUfunc(), # astropy.modeling.physical_models astropy_models.BlackBody(scale=10.0, temperature=6000. * u.K), astropy_models.Drude1D(amplitude=10.0, x_0=0.5, fwhm=2.5), # TODO: NFW # astropy.modeling.polynomial astropy_models.Chebyshev1D(2, c0=2, c1=3, c2=0.5), astropy_models.Chebyshev1D(2, c0=2, c1=3, c2=0.5, domain=(0.0, 1.0), window=(1.5, 2.5)), astropy_models.Chebyshev2D(1, 1, c0_0=1, c0_1=2, c1_0=3), astropy_models.Chebyshev2D(1, 1, c0_0=1, c0_1=2, c1_0=3, x_domain=(1.0, 2.0), y_domain=(3.0, 4.0), x_window=(5.0, 6.0), y_window=(7.0, 8.0)), astropy_models.Hermite1D(2, c0=2, c1=3, c2=0.5), astropy_models.Hermite2D(1, 1, c0_0=1, c0_1=2, c1_0=3), astropy_models.Legendre1D(2, c0=2, c1=3, c2=0.5), astropy_models.Legendre2D(1, 1, c0_0=1, c0_1=2, c1_0=3), astropy_models.Polynomial1D(2, c0=1, c1=2, c2=3), astropy_models.Polynomial2D(1, c0_0=1, c0_1=2, c1_0=3), # astropy.modeling.powerlaws astropy_models.BrokenPowerLaw1D(amplitude=10, x_break=0.5, alpha_1=2.0, alpha_2=3.5), astropy_models.ExponentialCutoffPowerLaw1D(10, 0.5, 2.0, 7.), astropy_models.LogParabola1D(amplitude=10, x_0=0.5, alpha=2., beta=3.,), astropy_models.PowerLaw1D(amplitude=10., x_0=0.5, alpha=2.0), astropy_models.SmoothlyBrokenPowerLaw1D(amplitude=10., x_break=5.0, alpha_1=2.0, alpha_2=3.0, delta=0.5), # astropy.modeling.projections astropy_models.AffineTransformation2D(matrix=np.array([[1.0, 2.0], [3.0, 4.0]]), translation=np.array([5.0, 6.0])), astropy_models.Pix2Sky_Airy(theta_b=75.8), astropy_models.Sky2Pix_Airy(theta_b=75.8), astropy_models.Pix2Sky_BonneEqualArea(theta1=44.3), astropy_models.Sky2Pix_BonneEqualArea(theta1=44.3), astropy_models.Pix2Sky_COBEQuadSphericalCube(), astropy_models.Sky2Pix_COBEQuadSphericalCube(), astropy_models.Pix2Sky_ConicEqualArea(sigma=89.5, delta=0.5), astropy_models.Sky2Pix_ConicEqualArea(sigma=89.5, delta=0.5), astropy_models.Pix2Sky_ConicEquidistant(sigma=89.5, delta=0.5), astropy_models.Sky2Pix_ConicEquidistant(sigma=89.5, delta=0.5), astropy_models.Pix2Sky_ConicOrthomorphic(sigma=89.5, delta=0.5), astropy_models.Sky2Pix_ConicOrthomorphic(sigma=89.5, delta=0.5), astropy_models.Pix2Sky_ConicPerspective(sigma=89.5, delta=0.5), astropy_models.Sky2Pix_ConicPerspective(sigma=89.5, delta=0.5), astropy_models.Pix2Sky_CylindricalEqualArea(lam=0.5), astropy_models.Sky2Pix_CylindricalEqualArea(lam=0.5), astropy_models.Pix2Sky_CylindricalPerspective(mu=1.5, lam=2.4), astropy_models.Sky2Pix_CylindricalPerspective(mu=1.5, lam=2.4), astropy_models.Pix2Sky_Gnomonic(), astropy_models.Sky2Pix_Gnomonic(), astropy_models.Pix2Sky_HEALPixPolar(), astropy_models.Sky2Pix_HEALPixPolar(), astropy_models.Pix2Sky_HEALPix(H=12.0, X=17.0), astropy_models.Sky2Pix_HEALPix(H=12.0, X=17.0), astropy_models.Pix2Sky_HammerAitoff(), astropy_models.Sky2Pix_HammerAitoff(), astropy_models.Pix2Sky_Mercator(), astropy_models.Sky2Pix_Mercator(), astropy_models.Pix2Sky_Molleweide(), astropy_models.Sky2Pix_Molleweide(), astropy_models.Pix2Sky_Parabolic(), astropy_models.Sky2Pix_Parabolic(), astropy_models.Pix2Sky_PlateCarree(), astropy_models.Sky2Pix_PlateCarree(), astropy_models.Pix2Sky_Polyconic(), astropy_models.Sky2Pix_Polyconic(), astropy_models.Pix2Sky_QuadSphericalCube(), astropy_models.Sky2Pix_QuadSphericalCube(), astropy_models.Pix2Sky_SansonFlamsteed(), astropy_models.Sky2Pix_SansonFlamsteed(), astropy_models.Pix2Sky_SlantOrthographic(xi=0.1, eta=0.2), astropy_models.Sky2Pix_SlantOrthographic(xi=0.1, eta=0.2), astropy_models.Pix2Sky_SlantZenithalPerspective(mu=1.5, phi0=15.0, theta0=80.0), astropy_models.Sky2Pix_SlantZenithalPerspective(mu=1.5, phi0=15.0, theta0=80.0), astropy_models.Pix2Sky_Stereographic(), astropy_models.Sky2Pix_Stereographic(), astropy_models.Pix2Sky_TangentialSphericalCube(), astropy_models.Sky2Pix_TangentialSphericalCube(), astropy_models.Pix2Sky_ZenithalEqualArea(), astropy_models.Sky2Pix_ZenithalEqualArea(), astropy_models.Pix2Sky_ZenithalEquidistant(), astropy_models.Sky2Pix_ZenithalEquidistant(), astropy_models.Pix2Sky_ZenithalPerspective(mu=1.5, gamma=15.0), astropy_models.Sky2Pix_ZenithalPerspective(mu=1.5, gamma=15.0), # astropy.modeling.rotations astropy_models.EulerAngleRotation(23, 14, 2.3, axes_order="xzx"), astropy_models.RotateCelestial2Native(5.63, -72.5, 180), astropy_models.RotateCelestial2Native(5.63 * u.deg, -72.5 * u.deg, 180 * u.deg), astropy_models.RotateNative2Celestial(5.63, -72.5, 180), astropy_models.RotateNative2Celestial(5.63 * u.deg, -72.5 * u.deg, 180 * u.deg), astropy_models.Rotation2D(angle=1.51), astropy_models.RotationSequence3D([1.2, 2.3, 3.4, .3], "xyzx"), astropy_models.SphericalRotationSequence([1.2, 2.3, 3.4, .3], "xyzy"), # astropy.modeling.tabular astropy_models.Tabular1D(points=np.arange(0, 5), lookup_table=[1., 10, 2, 45, -3]), astropy_models.Tabular1D(points=np.arange(0, 5) * u.pix, lookup_table=[1., 10, 2, 45, -3] * u.nm), astropy_models.Tabular2D( points=([1, 2, 3], [1, 2, 3]), lookup_table=np.arange(0, 9).reshape(3, 3), bounds_error=False, fill_value=None, method="nearest", ), astropy_models.Tabular2D( points=([1, 2, 3], [1, 2, 3]) * u.pix, lookup_table=np.arange(0, 9).reshape(3, 3) * u.nm, bounds_error=False, fill_value=None, method="nearest", ), ] if Version(astropy.__version__) >= Version("4.1"): result.append(astropy_models.Plummer1D(mass=10.0, r_plum=5.0)) return result UNSUPPORTED_MODELS = [ # FITS-specific and deemed unworthy of ASDF serialization: astropy.modeling.polynomial.InverseSIP, astropy.modeling.polynomial.SIP, # Base classes which should not be directly supported: astropy.modeling.core.Model, astropy.modeling.math_functions._NPUfuncModel, astropy.modeling.polynomial.OrthoPolynomialBase, astropy.modeling.polynomial.PolynomialModel, astropy.modeling.projections.Conic, astropy.modeling.projections.Cylindrical, astropy.modeling.projections.HEALPix, astropy.modeling.projections.Pix2SkyProjection, astropy.modeling.projections.Projection, astropy.modeling.projections.PseudoConic, astropy.modeling.projections.PseudoCylindrical, astropy.modeling.projections.QuadCube, astropy.modeling.projections.Sky2PixProjection, astropy.modeling.projections.Zenithal, ] if Version(astropy.__version__) > Version("4.1"): # https://github.com/astropy/asdf-astropy/issues/6 UNSUPPORTED_MODELS += [astropy.modeling.physical_models.NFW, astropy.modeling.models.UnitsMapping, ] if Version(astropy.__version__) < Version("4.3"): UNSUPPORTED_MODELS.append(astropy.modeling.blackbody.BlackBody1D) else: UNSUPPORTED_MODELS.append(astropy.modeling.physical_models.BlackBody) if Version(astropy.__version__) < Version("4.999.999"): UNSUPPORTED_MODELS.extend([ astropy.modeling.models.MexicanHat1D, astropy.modeling.models.MexicanHat2D, ]) if Version(astropy.__version__) > Version("4.999.999"): # https://github.com/astropy/asdf-astropy/issues/28 UNSUPPORTED_MODELS.extend([ astropy.modeling.functional_models.ArcCosine1D, astropy.modeling.functional_models.ArcSine1D, astropy.modeling.functional_models.ArcTangent1D, astropy.modeling.functional_models.Cosine1D, astropy.modeling.functional_models.Tangent1D, astropy.modeling.spline.Spline1D, ]) @pytest.mark.parametrize("model", create_single_models()) def test_single_model(tmpdir, model): assert_model_roundtrip(model, tmpdir) def test_all_models_supported(): """ Test that all model classes in astropy have serialization support implemented in this package. If this test fails, file an issue on GitHub for each missing model and add the model to the UNSUPPORTED_MODELS list above with a link to the issue in a comment. """ def _iterate_model_classes(): for key, value in itertools.chain(astropy_models.__dict__.items(), astropy.modeling.math_functions.__dict__.items()): if isinstance(value, type) and issubclass(value, astropy.modeling.core.Model) and value not in UNSUPPORTED_MODELS: yield value extensions = integration.get_extensions() extension_manager = asdf.extension.ExtensionManager(extensions) missing = set() for model_class in _iterate_model_classes(): if not extension_manager.handles_type(model_class): missing.add(model_class) if len(missing) > 0: class_names = sorted([f"{m.__module__}.{m.__qualname__}" for m in missing]) message = "Missing support for the following model classes:\n\n" + "\n".join(class_names) assert len(missing) == 0, message @pytest.mark.xfail(reason="Older tag versions are difficult to test until asdf implements new config features") def test_legacy_const(tmpdir): model = astropy_models.Const1D(amplitude=5.) assert_model_roundtrip(model, tmpdir, version="1.3.0") model = astropy_models.Const2D(amplitude=5.) with pytest.raises(TypeError, match="does not support models with > 1 dimension"): assert_model_roundtrip(model, tmpdir, version="1.3.0") COMPOUND_OPERATORS = [ "__add__", "__sub__", "__mul__", "__truediv__", "__pow__", "__or__", "__and__", ] @pytest.mark.parametrize("operator", COMPOUND_OPERATORS) def test_compound_model(tmpdir, operator): left_model = astropy_models.Shift(5) right_model = astropy_models.Shift(-1) model = getattr(left_model, operator)(right_model) result = assert_model_roundtrip(model, tmpdir) assert_models_equal(result.left, left_model) assert_models_equal(result.right, right_model) assert result.op == model.op def test_fix_inputs(tmpdir): model = astropy_models.Gaussian2D(1, 2, 3, 4, 5) fixed_model = astropy_models.fix_inputs(model, {"x": 2.5}) result = assert_model_roundtrip(fixed_model, tmpdir) assert_models_equal(result.left, model) assert result.right == fixed_model.right assert result.op == fixed_model.op @pytest.mark.skipif('HAS_NO_UNITS_MAPPING') def test_units_mapping(tmpdir): # Basic mapping between units: model = astropy_models.UnitsMapping(((u.m, u.dimensionless_unscaled),)) model.name = "foo" result = assert_model_roundtrip(model, tmpdir) assert result.mapping == model.mapping # Remove units: model = astropy_models.UnitsMapping(((u.m, None),)) result = assert_model_roundtrip(model, tmpdir) assert result.mapping == model.mapping # Change a model to accept any units: model = astropy_models.UnitsMapping(((None, u.m),)) result = assert_model_roundtrip(model, tmpdir) assert result.mapping == model.mapping # With equivalencies: model = astropy_models.UnitsMapping(((u.m, u.dimensionless_unscaled),), input_units_equivalencies={"x": u.equivalencies.spectral()}) result = assert_model_roundtrip(model, tmpdir) assert result.mapping == model.mapping # Allow dimensionless on all inputs: model = astropy_models.UnitsMapping(((u.m, u.dimensionless_unscaled), (u.s, u.Hz)), input_units_allow_dimensionless=True) result = assert_model_roundtrip(model, tmpdir) assert result.mapping == model.mapping # Allow dimensionless selectively: model = astropy_models.UnitsMapping(((u.m, u.dimensionless_unscaled), (u.s, u.Hz)), input_units_allow_dimensionless={"x0": True, "x1": False}) result = assert_model_roundtrip(model, tmpdir) assert result.mapping == model.mapping @pytest.mark.parametrize("standard_version", [v for v in asdf.versioning.supported_versions if v >= "1.4.0"]) @pytest.mark.parametrize("model", [ astropy_models.Polynomial1D(1, c0=5, c1=17), astropy_models.Polynomial1D(1, c0=5, c1=17, domain=[-5, 4], window=[-2, 3]), astropy_models.Chebyshev1D(2, c0=2, c1=3, c2=0.5, domain=[-2, 2]), astropy_models.Chebyshev1D(2, c0=2, c1=3, c2=0.5, domain=[-2, 2], window=[-0.5, 0.5]), ]) def test_1d_polynomial_with_asdf_standard_version(tmpdir, standard_version, model): result = assert_model_roundtrip(model, tmpdir, version=standard_version) assert result.domain == model.domain assert result.window == model.window @pytest.mark.parametrize("standard_version", [v for v in asdf.versioning.supported_versions if v >= "1.4.0"]) @pytest.mark.parametrize("model", [ astropy_models.Polynomial2D(2, c0_0=3, c1_0=5, c0_1=7), astropy_models.Polynomial2D( 2, c0_0=3, c1_0=5, c0_1=7, x_domain=[-2, 2], y_domain=[-4, 4], x_window=[-6, 6], y_window=[-8, 8] ), astropy_models.Chebyshev2D(1, 1, c0_0=1, c0_1=2, c1_0=3, x_domain=[-2, 2], y_domain=[-2, 2]), astropy_models.Chebyshev2D(1, 1, c0_0=1, c0_1=2, c1_0=3, x_domain=[-2, 2], y_domain=[-2, 2], x_window=[-0.5, 0.5], y_window=[-0.1, 0.5]), ]) def test_2d_polynomial_with_asdf_standard_version(tmpdir, standard_version, model): result = assert_model_roundtrip(model, tmpdir, version=standard_version) assert result.x_domain == model.x_domain assert result.y_domain == model.y_domain assert result.x_window == model.x_window assert result.y_window == model.y_window @pytest.mark.skip('ASTROPY_LT_41') def test_deserialize_compound_user_inverse(tmpdir): """ Confirm that we are able to correctly reconstruct a compound model with a user inverse set on one of its component models. Due to code in TransformConverter that facilitates circular inverses, the user inverse of the component model is not available at the time that the CompoundModel is constructed. """ yaml = """ model: !transform/concatenate-1.2.0 forward: - !transform/shift-1.2.0 inverse: !transform/shift-1.2.0 {offset: 5.0} offset: -10.0 - !transform/shift-1.2.0 {offset: -20.0} """ buff = yaml_to_asdf(yaml) with asdf.open(buff) as af: model = af["model"] assert model.has_inverse() assert model.inverse(-5, -20) == (0, 0) ././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1639520324.243259 asdf_astropy-0.1.2/asdf_astropy/converters/unit/0000755000446400020070000000000000000000000023014 5ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1621458452.0 asdf_astropy-0.1.2/asdf_astropy/converters/unit/__init__.py0000644000446400020070000000000000000000000025113 0ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1621458452.0 asdf_astropy-0.1.2/asdf_astropy/converters/unit/equivalency.py0000644000446400020070000000224500000000000025716 0ustar00eslavichSTSCI\sciencefrom asdf.extension import Converter class EquivalencyConverter(Converter): tags = ["tag:astropy.org:astropy/units/equivalency-*"] types = ["astropy.units.equivalencies.Equivalency"] def to_yaml_tree(self, obj, tag, ctx): return [ {'name': name, 'kwargs_names': list(kw.keys()), 'kwargs_values': list(kw.values())} for name, kw in zip(obj.name, obj.kwargs) ] def from_yaml_tree(self, node, tag, ctx): from astropy.units import equivalencies components = [] for equivalency_node in node: equivalency_method = getattr(equivalencies, equivalency_node["name"]) kwargs = dict(zip(equivalency_node["kwargs_names"], equivalency_node["kwargs_values"])) components.append(equivalency_method(**kwargs)) # The Equivalency class is a UserList that overrides __add__ to # provide special behavior when combined with another Equivalency. # We're using sum here to add each subsequent Equivalency to the # first so we end up with a single correctly combined Equivalency # object at the end. return sum(components[1:], components[0]) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1621458452.0 asdf_astropy-0.1.2/asdf_astropy/converters/unit/quantity.py0000644000446400020070000000156400000000000025252 0ustar00eslavichSTSCI\sciencefrom asdf.extension import Converter from asdf.tags.core.ndarray import NDArrayType class QuantityConverter(Converter): tags = ["tag:stsci.edu:asdf/unit/quantity-*"] types = [ "astropy.units.quantity.Quantity", # The Distance class has no tag of its own, so we # just serialize it as a quantity. "astropy.coordinates.distances.Distance", ] def to_yaml_tree(self, obj, tag, ctx): return { "value": obj.value, "unit": obj.unit, } def from_yaml_tree(self, node, tag, ctx): from astropy.units import Quantity value = node["value"] if isinstance(value, NDArrayType): # TODO: Why doesn't NDArrayType work? This needs some research # and documentation. value = value._make_array() return Quantity(value, unit=node["unit"]) ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1639520324.2452037 asdf_astropy-0.1.2/asdf_astropy/converters/unit/tests/0000755000446400020070000000000000000000000024156 5ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1621458452.0 asdf_astropy-0.1.2/asdf_astropy/converters/unit/tests/__init__.py0000644000446400020070000000000000000000000026255 0ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1638382953.0 asdf_astropy-0.1.2/asdf_astropy/converters/unit/tests/test_equivalency.py0000644000446400020070000000331200000000000030113 0ustar00eslavichSTSCI\scienceimport pytest import asdf import astropy from astropy import units as u from astropy.units import equivalencies as eq from astropy.cosmology import Planck15 from packaging.version import Version def create_equivalencies(): result = [ eq.plate_scale(.3 * u.deg/u.mm), eq.pixel_scale(.5 * u.deg/u.pix), eq.spectral_density(350 * u.nm, factor=2), eq.spectral_density(350 * u.nm), eq.spectral(), eq.brightness_temperature(500 * u.GHz), eq.brightness_temperature(500 * u.GHz, beam_area=23 * u.sr), eq.with_H0(), eq.temperature_energy(), eq.temperature(), eq.thermodynamic_temperature(300 * u.Hz), eq.thermodynamic_temperature(140 * u.GHz, Planck15.Tcmb0), eq.beam_angular_area(3 * u.sr), eq.mass_energy(), eq.molar_mass_amu(), eq.doppler_relativistic(2 * u.m), eq.doppler_optical(2 * u.nm), eq.doppler_radio(2 * u.Hz), eq.parallax(), eq.logarithmic(), eq.dimensionless_angles(), eq.spectral() + eq.temperature(), (eq.spectral_density(35 * u.nm) + eq.brightness_temperature(5 * u.Hz, beam_area=2 * u.sr)), (eq.spectral() + eq.spectral_density(35 * u.nm) + eq.brightness_temperature(5 * u.Hz, beam_area=2 * u.sr)), ] if Version(astropy.__version__) >= Version("4.1"): result.append(eq.pixel_scale(100. * u.pix/u.cm)) return result @pytest.mark.parametrize("equivalency", create_equivalencies()) def test_serialization(equivalency, tmp_path): file_path = tmp_path / "test.asdf" with asdf.AsdfFile() as af: af["equivalency"] = equivalency af.write_to(file_path) with asdf.open(file_path) as af: assert af["equivalency"] == equivalency ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1638382953.0 asdf_astropy-0.1.2/asdf_astropy/converters/unit/tests/test_quantity.py0000644000446400020070000000347500000000000027456 0ustar00eslavichSTSCI\scienceimport pytest import asdf from asdf.tests import helpers from astropy import units from astropy.units import Quantity import numpy as np from numpy.testing import assert_array_equal def create_quantities(): return [ # Scalar: Quantity(2.71828, units.kpc), # Single element array: Quantity([3.14159], units.kg), # Multiple element array: Quantity([x * 2.3081 for x in range(10)], units.ampere), # Multiple dimension array: Quantity(np.arange(100, dtype=np.float64).reshape(5, 20), units.km), ] @pytest.mark.parametrize("quantity", create_quantities()) def test_serialization(quantity, tmp_path): file_path = tmp_path / "test.asdf" with asdf.AsdfFile() as af: af["quantity"] = quantity af.write_to(file_path) with asdf.open(file_path) as af: assert (af["quantity"] == quantity).all() def test_read_untagged_unit(): yaml = """ quantity: !unit/quantity-1.1.0 value: 2.71828 unit: kpc """ buff = helpers.yaml_to_asdf(yaml) with asdf.open(buff) as af: assert af["quantity"].value == 2.71828 assert af["quantity"].unit.is_equivalent(units.kpc) def test_read_tagged_unit(): yaml = """ quantity: !unit/quantity-1.1.0 value: 2.71828 unit: !unit/unit-1.0.0 kpc """ buff = helpers.yaml_to_asdf(yaml) with asdf.open(buff) as af: assert af["quantity"].value == 2.71828 assert af["quantity"].unit.is_equivalent(units.kpc) def test_read_array_value(): yaml = """ quantity: !unit/quantity-1.1.0 value: !core/ndarray-1.0.0 [1.0, 2.0, 3.0, 4.0] unit: km """ buff = helpers.yaml_to_asdf(yaml) with asdf.open(buff) as af: assert_array_equal(af["quantity"].value, np.array([1.0, 2.0, 3.0, 4.0])) assert af["quantity"].unit.is_equivalent(units.km) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1638382953.0 asdf_astropy-0.1.2/asdf_astropy/converters/unit/tests/test_unit.py0000644000446400020070000000220500000000000026545 0ustar00eslavichSTSCI\science import warnings import asdf from asdf.tests import helpers from astropy import units import pytest def vounit_compatible(unit): with warnings.catch_warnings(): warnings.simplefilter("ignore", category=units.UnitsWarning) try: unit.to_string(format="vounit") return True except Exception: return False def create_units(): return [ u for u in list(units.__dict__.values()) if isinstance(u, units.UnitBase) and vounit_compatible(u) ] @pytest.mark.parametrize("unit", create_units()) # Ignore warnings due to VOUnit deprecations @pytest.mark.filterwarnings("ignore::astropy.units.core.UnitsWarning") def test_serialization(unit, tmp_path): file_path = tmp_path / "test.asdf" with asdf.AsdfFile() as af: af["unit"] = unit af.write_to(file_path) with asdf.open(file_path) as af: assert af["unit"].is_equivalent(unit) def test_read(): yaml = """ unit: !unit/unit-1.0.0 "2.1798721 10-18kg m2 s-2" """ buff = helpers.yaml_to_asdf(yaml) with asdf.open(buff) as af: assert af["unit"].is_equivalent(units.Ry) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1621458452.0 asdf_astropy-0.1.2/asdf_astropy/converters/unit/unit.py0000644000446400020070000000177600000000000024360 0ustar00eslavichSTSCI\sciencefrom asdf.extension import Converter class UnitConverter(Converter): tags = ["tag:stsci.edu:asdf/unit/unit-*"] types = [ "astropy.units.core.CompositeUnit", "astropy.units.core.IrreducibleUnit", "astropy.units.core.NamedUnit", "astropy.units.core.PrefixUnit", "astropy.units.core.Unit", "astropy.units.core.UnitBase", "astropy.units.core.UnrecognizedUnit", "astropy.units.function.mixin.IrreducibleFunctionUnit", "astropy.units.function.mixin.RegularFunctionUnit" ] def to_yaml_tree(self, obj, tag, ctx): from astropy.units import UnitsError try: return obj.to_string(format="vounit") except (UnitsError, ValueError) as e: raise ValueError(f"Unit '{obj}' is not representable as VOUnit and cannot be serialized to ASDF") from e def from_yaml_tree(self, node, tag, ctx): from astropy.units import Unit return Unit(node, format="vounit", parse_strict="silent") ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1621458452.0 asdf_astropy-0.1.2/asdf_astropy/converters/utils.py0000644000446400020070000000071300000000000023550 0ustar00eslavichSTSCI\scienceimport importlib def import_type(type_name): """ Import a Python type from its fully-qualified name. For example, when this method is called with 'builtins.str' it will return the `str` type. Parameters ---------- type_name : str Type name, with module. Returns ------- type """ module_name, class_name = type_name.rsplit(".", 1) return getattr(importlib.import_module(module_name), class_name) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1638645702.0 asdf_astropy-0.1.2/asdf_astropy/extensions.py0000644000446400020070000004431000000000000022416 0ustar00eslavichSTSCI\sciencefrom asdf.extension import ManifestExtension from .converters.transform.compound import CompoundConverter from .converters.transform.core import SimpleTransformConverter from .converters.transform.functional_models import ConstantConverter from .converters.transform.mappings import ( IdentityConverter, RemapAxesConverter, UnitsMappingConverter, ) from .converters.transform.math_functions import MathFunctionsConverter from .converters.transform.polynomial import PolynomialConverter, OrthoPolynomialConverter from .converters.transform.projections import ProjectionConverter from .converters.transform.rotations import Rotate3DConverter, RotationSequenceConverter from .converters.transform.tabular import TabularConverter from .converters.unit.equivalency import EquivalencyConverter from .converters.unit.quantity import QuantityConverter from .converters.unit.unit import UnitConverter from .converters.coordinates.angle import AngleConverter, LatitudeConverter, LongitudeConverter from .converters.coordinates.earth_location import EarthLocationConverter from .converters.coordinates.frame import FrameConverter, LegacyICRSConverter from .converters.coordinates.representation import RepresentationConverter from .converters.coordinates.sky_coord import SkyCoordConverter from .converters.coordinates.spectral_coord import SpectralCoordConverter from .converters.time.time import TimeConverter from .converters.time.time_delta import TimeDeltaConverter from .converters.table.table import ColumnConverter, AsdfTableConverter, AstropyTableConverter from .converters.fits.fits import AstropyFitsConverter, AsdfFitsConverter TRANSFORM_CONVERTERS = [ # astropy.modeling.core CompoundConverter(), # astropy.modeling.functional_models SimpleTransformConverter( ["tag:stsci.edu:asdf/transform/airy_disk2d-*"], "astropy.modeling.functional_models.AiryDisk2D", ), SimpleTransformConverter( ["tag:stsci.edu:asdf/transform/box1d-*"], "astropy.modeling.functional_models.Box1D", ), SimpleTransformConverter( ["tag:stsci.edu:asdf/transform/box2d-*"], "astropy.modeling.functional_models.Box2D", ), ConstantConverter(), SimpleTransformConverter( ["tag:stsci.edu:asdf/transform/disk2d-*"], "astropy.modeling.functional_models.Disk2D", ), SimpleTransformConverter( ["tag:stsci.edu:asdf/transform/ellipse2d-*"], "astropy.modeling.functional_models.Ellipse2D", ), SimpleTransformConverter( ["tag:stsci.edu:asdf/transform/exponential1d-*"], "astropy.modeling.functional_models.Exponential1D", ), SimpleTransformConverter( ["tag:stsci.edu:asdf/transform/gaussian1d-*"], "astropy.modeling.functional_models.Gaussian1D", ), SimpleTransformConverter( ["tag:stsci.edu:asdf/transform/gaussian2d-*"], "astropy.modeling.functional_models.Gaussian2D", ), SimpleTransformConverter( ["tag:stsci.edu:asdf/transform/king_projected_analytic1d-*"], "astropy.modeling.functional_models.KingProjectedAnalytic1D", ), SimpleTransformConverter( ["tag:stsci.edu:asdf/transform/linear1d-*"], "astropy.modeling.functional_models.Linear1D", ), SimpleTransformConverter( ["tag:stsci.edu:asdf/transform/logarithmic1d-*"], "astropy.modeling.functional_models.Logarithmic1D", ), SimpleTransformConverter( ["tag:stsci.edu:asdf/transform/lorentz1d-*"], "astropy.modeling.functional_models.Lorentz1D", ), SimpleTransformConverter( ["tag:stsci.edu:asdf/transform/moffat1d-*"], "astropy.modeling.functional_models.Moffat1D", ), SimpleTransformConverter( ["tag:stsci.edu:asdf/transform/moffat2d-*"], "astropy.modeling.functional_models.Moffat2D", ), SimpleTransformConverter( ["tag:stsci.edu:asdf/transform/multiplyscale-*"], "astropy.modeling.functional_models.Multiply", ), SimpleTransformConverter( ["tag:stsci.edu:asdf/transform/planar2d-*"], "astropy.modeling.functional_models.Planar2D", ), SimpleTransformConverter( ["tag:stsci.edu:asdf/transform/redshift_scale_factor-*"], "astropy.modeling.functional_models.RedshiftScaleFactor", ), SimpleTransformConverter( ["tag:stsci.edu:asdf/transform/ricker_wavelet1d-*"], "astropy.modeling.functional_models.RickerWavelet1D", ), SimpleTransformConverter( ["tag:stsci.edu:asdf/transform/ricker_wavelet2d-*"], "astropy.modeling.functional_models.RickerWavelet2D", ), SimpleTransformConverter( ["tag:stsci.edu:asdf/transform/ring2d-*"], "astropy.modeling.functional_models.Ring2D", ), SimpleTransformConverter( ["tag:stsci.edu:asdf/transform/scale-*"], "astropy.modeling.functional_models.Scale", ), SimpleTransformConverter( ["tag:stsci.edu:asdf/transform/sersic1d-*"], "astropy.modeling.functional_models.Sersic1D", ), SimpleTransformConverter( ["tag:stsci.edu:asdf/transform/sersic2d-*"], "astropy.modeling.functional_models.Sersic2D", ), SimpleTransformConverter( ["tag:stsci.edu:asdf/transform/shift-*"], "astropy.modeling.functional_models.Shift", ), SimpleTransformConverter( ["tag:stsci.edu:asdf/transform/sine1d-*"], "astropy.modeling.functional_models.Sine1D", ), SimpleTransformConverter( ["tag:stsci.edu:asdf/transform/trapezoid1d-*"], "astropy.modeling.functional_models.Trapezoid1D", ), SimpleTransformConverter( ["tag:stsci.edu:asdf/transform/trapezoid_disk2d-*"], "astropy.modeling.functional_models.TrapezoidDisk2D", ), SimpleTransformConverter( ["tag:stsci.edu:asdf/transform/voigt1d-*"], "astropy.modeling.functional_models.Voigt1D", ), # astropy.modeling.mappings IdentityConverter(), RemapAxesConverter(), # UnitsMapping is not represented here because # it is an astropy-specific transform and not # included in the ASDF transform extension. # astropy.modeling.math_functions MathFunctionsConverter(), # astropy.modeling.physical_models SimpleTransformConverter( ["tag:stsci.edu:asdf/transform/blackbody-*"], "astropy.modeling.physical_models.BlackBody", ), SimpleTransformConverter( ["tag:stsci.edu:asdf/transform/drude1d-*"], "astropy.modeling.physical_models.Drude1D", ), # TODO: Implement NFW SimpleTransformConverter( ["tag:stsci.edu:asdf/transform/plummer1d-*"], "astropy.modeling.physical_models.Plummer1D", ), # astropy.modeling.polynomial PolynomialConverter(), OrthoPolynomialConverter(), # SIP and InverseSIP are deliberately excluded because they # are FITS-specific and can be easily represented by a # simple combination of existing models. # astropy.modeling.powerlaws SimpleTransformConverter( ["tag:stsci.edu:asdf/transform/broken_power_law1d-*"], "astropy.modeling.powerlaws.BrokenPowerLaw1D", ), SimpleTransformConverter( ["tag:stsci.edu:asdf/transform/exponential_cutoff_power_law1d-*"], "astropy.modeling.powerlaws.ExponentialCutoffPowerLaw1D", ), SimpleTransformConverter( ["tag:stsci.edu:asdf/transform/log_parabola1d-*"], "astropy.modeling.powerlaws.LogParabola1D", ), SimpleTransformConverter( ["tag:stsci.edu:asdf/transform/power_law1d-*"], "astropy.modeling.powerlaws.PowerLaw1D", ), SimpleTransformConverter( ["tag:stsci.edu:asdf/transform/smoothly_broken_power_law1d-*"], "astropy.modeling.powerlaws.SmoothlyBrokenPowerLaw1D", ), # astropy.modeling.projections SimpleTransformConverter( ["tag:stsci.edu:asdf/transform/affine-*"], "astropy.modeling.projections.AffineTransformation2D", ), ProjectionConverter( ["tag:stsci.edu:asdf/transform/airy-*"], "astropy.modeling.projections.Pix2Sky_Airy", "astropy.modeling.projections.Sky2Pix_Airy", ), ProjectionConverter( ["tag:stsci.edu:asdf/transform/bonne_equal_area-*"], "astropy.modeling.projections.Pix2Sky_BonneEqualArea", "astropy.modeling.projections.Sky2Pix_BonneEqualArea", ), ProjectionConverter( ["tag:stsci.edu:asdf/transform/cobe_quad_spherical_cube-*"], "astropy.modeling.projections.Pix2Sky_COBEQuadSphericalCube", "astropy.modeling.projections.Sky2Pix_COBEQuadSphericalCube", ), ProjectionConverter( ["tag:stsci.edu:asdf/transform/conic_equal_area-*"], "astropy.modeling.projections.Pix2Sky_ConicEqualArea", "astropy.modeling.projections.Sky2Pix_ConicEqualArea", ), ProjectionConverter( ["tag:stsci.edu:asdf/transform/conic_equidistant-*"], "astropy.modeling.projections.Pix2Sky_ConicEquidistant", "astropy.modeling.projections.Sky2Pix_ConicEquidistant", ), ProjectionConverter( ["tag:stsci.edu:asdf/transform/conic_orthomorphic-*"], "astropy.modeling.projections.Pix2Sky_ConicOrthomorphic", "astropy.modeling.projections.Sky2Pix_ConicOrthomorphic", ), ProjectionConverter( ["tag:stsci.edu:asdf/transform/conic_perspective-*"], "astropy.modeling.projections.Pix2Sky_ConicPerspective", "astropy.modeling.projections.Sky2Pix_ConicPerspective", ), ProjectionConverter( ["tag:stsci.edu:asdf/transform/cylindrical_equal_area-*"], "astropy.modeling.projections.Pix2Sky_CylindricalEqualArea", "astropy.modeling.projections.Sky2Pix_CylindricalEqualArea", ), ProjectionConverter( ["tag:stsci.edu:asdf/transform/cylindrical_perspective-*"], "astropy.modeling.projections.Pix2Sky_CylindricalPerspective", "astropy.modeling.projections.Sky2Pix_CylindricalPerspective", ), ProjectionConverter( ["tag:stsci.edu:asdf/transform/gnomonic-*"], "astropy.modeling.projections.Pix2Sky_Gnomonic", "astropy.modeling.projections.Sky2Pix_Gnomonic", ), ProjectionConverter( ["tag:stsci.edu:asdf/transform/hammer_aitoff-*"], "astropy.modeling.projections.Pix2Sky_HammerAitoff", "astropy.modeling.projections.Sky2Pix_HammerAitoff", ), ProjectionConverter( ["tag:stsci.edu:asdf/transform/healpix-*"], "astropy.modeling.projections.Pix2Sky_HEALPix", "astropy.modeling.projections.Sky2Pix_HEALPix", ), ProjectionConverter( ["tag:stsci.edu:asdf/transform/healpix_polar-*"], "astropy.modeling.projections.Pix2Sky_HEALPixPolar", "astropy.modeling.projections.Sky2Pix_HEALPixPolar", ), ProjectionConverter( ["tag:stsci.edu:asdf/transform/mercator-*"], "astropy.modeling.projections.Pix2Sky_Mercator", "astropy.modeling.projections.Sky2Pix_Mercator", ), ProjectionConverter( ["tag:stsci.edu:asdf/transform/molleweide-*"], "astropy.modeling.projections.Pix2Sky_Molleweide", "astropy.modeling.projections.Sky2Pix_Molleweide", ), ProjectionConverter( ["tag:stsci.edu:asdf/transform/parabolic-*"], "astropy.modeling.projections.Pix2Sky_Parabolic", "astropy.modeling.projections.Sky2Pix_Parabolic", ), ProjectionConverter( ["tag:stsci.edu:asdf/transform/plate_carree-*"], "astropy.modeling.projections.Pix2Sky_PlateCarree", "astropy.modeling.projections.Sky2Pix_PlateCarree", ), ProjectionConverter( ["tag:stsci.edu:asdf/transform/polyconic-*"], "astropy.modeling.projections.Pix2Sky_Polyconic", "astropy.modeling.projections.Sky2Pix_Polyconic", ), ProjectionConverter( ["tag:stsci.edu:asdf/transform/quad_spherical_cube-*"], "astropy.modeling.projections.Pix2Sky_QuadSphericalCube", "astropy.modeling.projections.Sky2Pix_QuadSphericalCube", ), ProjectionConverter( ["tag:stsci.edu:asdf/transform/sanson_flamsteed-*"], "astropy.modeling.projections.Pix2Sky_SansonFlamsteed", "astropy.modeling.projections.Sky2Pix_SansonFlamsteed", ), ProjectionConverter( ["tag:stsci.edu:asdf/transform/slant_orthographic-*"], "astropy.modeling.projections.Pix2Sky_SlantOrthographic", "astropy.modeling.projections.Sky2Pix_SlantOrthographic", ), ProjectionConverter( ["tag:stsci.edu:asdf/transform/slant_zenithal_perspective-*"], "astropy.modeling.projections.Pix2Sky_SlantZenithalPerspective", "astropy.modeling.projections.Sky2Pix_SlantZenithalPerspective", ), ProjectionConverter( ["tag:stsci.edu:asdf/transform/stereographic-*"], "astropy.modeling.projections.Pix2Sky_Stereographic", "astropy.modeling.projections.Sky2Pix_Stereographic", ), ProjectionConverter( ["tag:stsci.edu:asdf/transform/tangential_spherical_cube-*"], "astropy.modeling.projections.Pix2Sky_TangentialSphericalCube", "astropy.modeling.projections.Sky2Pix_TangentialSphericalCube", ), ProjectionConverter( ["tag:stsci.edu:asdf/transform/zenithal_equal_area-*"], "astropy.modeling.projections.Pix2Sky_ZenithalEqualArea", "astropy.modeling.projections.Sky2Pix_ZenithalEqualArea", ), ProjectionConverter( ["tag:stsci.edu:asdf/transform/zenithal_equidistant-*"], "astropy.modeling.projections.Pix2Sky_ZenithalEquidistant", "astropy.modeling.projections.Sky2Pix_ZenithalEquidistant", ), ProjectionConverter( ["tag:stsci.edu:asdf/transform/zenithal_perspective-*"], "astropy.modeling.projections.Pix2Sky_ZenithalPerspective", "astropy.modeling.projections.Sky2Pix_ZenithalPerspective", ), # astropy.modeling.rotations SimpleTransformConverter( ["tag:stsci.edu:asdf/transform/rotate2d-*"], "astropy.modeling.rotations.Rotation2D", ), Rotate3DConverter(), RotationSequenceConverter(), # astropy.modeling.tabular TabularConverter(), ] # The order here is important; asdf will prefer to use extensions # that occur earlier in the list. TRANSFORM_MANIFEST_URIS = [ "asdf://asdf-format.org/transform/manifests/transform-1.5.0", "asdf://asdf-format.org/transform/manifests/transform-1.4.0", "asdf://asdf-format.org/transform/manifests/transform-1.3.0", "asdf://asdf-format.org/transform/manifests/transform-1.2.0", "asdf://asdf-format.org/transform/manifests/transform-1.1.0", "asdf://asdf-format.org/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 ] COORDINATES_CONVERTERS = [ FrameConverter( "tag:astropy.org:astropy/coordinates/frames/baseframe-*", "astropy.coordinates.baseframe.BaseCoordinateFrame", ), FrameConverter( "tag:astropy.org:astropy/coordinates/frames/cirs-*", "astropy.coordinates.builtin_frames.cirs.CIRS", ), FrameConverter( "tag:astropy.org:astropy/coordinates/frames/fk4-*", "astropy.coordinates.builtin_frames.fk4.FK4", ), FrameConverter( "tag:astropy.org:astropy/coordinates/frames/fk4noeterms-*", "astropy.coordinates.builtin_frames.fk4.FK4NoETerms", ), FrameConverter( "tag:astropy.org:astropy/coordinates/frames/fk5-*", "astropy.coordinates.builtin_frames.fk5.FK5", ), FrameConverter( "tag:astropy.org:astropy/coordinates/frames/galactic-*", "astropy.coordinates.builtin_frames.galactic.Galactic", ), FrameConverter( "tag:astropy.org:astropy/coordinates/frames/galactocentric-*", "astropy.coordinates.builtin_frames.galactocentric.Galactocentric", ), FrameConverter( "tag:astropy.org:astropy/coordinates/frames/gcrs-*", "astropy.coordinates.builtin_frames.gcrs.GCRS", ), FrameConverter( "tag:astropy.org:astropy/coordinates/frames/icrs-1.1.0", "astropy.coordinates.builtin_frames.icrs.ICRS", ), FrameConverter( "tag:astropy.org:astropy/coordinates/frames/itrs-*", "astropy.coordinates.builtin_frames.itrs.ITRS", ), FrameConverter( "tag:astropy.org:astropy/coordinates/frames/precessedgeocentric-*", "astropy.coordinates.builtin_frames.gcrs.PrecessedGeocentric", ), LegacyICRSConverter(), AngleConverter(), LatitudeConverter(), LongitudeConverter(), EarthLocationConverter(), RepresentationConverter(), SkyCoordConverter(), SpectralCoordConverter(), ] ASTROPY_CONVERTERS = [ EquivalencyConverter(), UnitsMappingConverter(), TimeDeltaConverter(), AstropyTableConverter(), AstropyFitsConverter(), ] COORDINATES_EXTENSION = ManifestExtension.from_uri( "asdf://asdf-format.org/astronomy/coordinates/manifests/coordinates-1.0.0", converters=COORDINATES_CONVERTERS, ) ASTROPY_EXTENSION = ManifestExtension.from_uri( "asdf://astropy.org/astropy/manifests/astropy-1.0.0", # This prevents a warning about a missing extension when opening # files written by older versions of astropy: legacy_class_names=["astropy.io.misc.asdf.extension.AstropyExtension"], converters=ASTROPY_CONVERTERS, ) # These tags are part of the ASDF Standard, # but we want to override serialization here so that users can # work with nice astropy objects for those entities. CORE_CONVERTERS = [ QuantityConverter(), TimeConverter(), UnitConverter(), ColumnConverter(), AsdfTableConverter(), AsdfFitsConverter(), ] CORE_MANIFEST_URIS = [ "asdf://asdf-format.org/core/manifests/core-1.0.0", "asdf://asdf-format.org/core/manifests/core-1.1.0", "asdf://asdf-format.org/core/manifests/core-1.2.0", "asdf://asdf-format.org/core/manifests/core-1.3.0", "asdf://asdf-format.org/core/manifests/core-1.4.0", "asdf://asdf-format.org/core/manifests/core-1.5.0", "asdf://asdf-format.org/core/manifests/core-1.6.0", ] CORE_EXTENSIONS = [ManifestExtension.from_uri(u, converters=CORE_CONVERTERS) for u in CORE_MANIFEST_URIS] ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1638645702.0 asdf_astropy-0.1.2/asdf_astropy/integration.py0000644000446400020070000000224600000000000022544 0ustar00eslavichSTSCI\scienceimport sys from asdf.resource import DirectoryResourceMapping if sys.version_info < (3, 9): import importlib_resources else: import importlib.resources as importlib_resources def get_resource_mappings(): """ Get the resource mapping instances for the astropy schemas and manifests. This method is registered with the asdf.resource_mappings entry point. Returns ------- list of collections.abc.Mapping """ from . import resources resources_root = importlib_resources.files(resources) return [ DirectoryResourceMapping(resources_root / "schemas", "http://astropy.org/schemas/astropy/", recursive=True), DirectoryResourceMapping(resources_root / "manifests", "asdf://astropy.org/astropy/manifests/"), ] def get_extensions(): """ Get the extension instances for the various astropy extensions. This method is registered with the asdf.extensions entry point. Returns ------- list of asdf.extension.Extension """ from . import extensions return [extensions.ASTROPY_EXTENSION, extensions.COORDINATES_EXTENSION] + extensions.TRANSFORM_EXTENSIONS + extensions.CORE_EXTENSIONS ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1639520324.2458572 asdf_astropy-0.1.2/asdf_astropy/resources/0000755000446400020070000000000000000000000021655 5ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1601406442.0 asdf_astropy-0.1.2/asdf_astropy/resources/__init__.py0000644000446400020070000000000000000000000023754 0ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1639520324.2461581 asdf_astropy-0.1.2/asdf_astropy/resources/manifests/0000755000446400020070000000000000000000000023646 5ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1638645702.0 asdf_astropy-0.1.2/asdf_astropy/resources/manifests/astropy-1.0.0.yaml0000644000446400020070000000515300000000000026671 0ustar00eslavichSTSCI\scienceid: asdf://astropy.org/astropy/manifests/astropy-1.0.0 extension_uri: asdf://astropy.org/astropy/extensions/astropy-1.0.0 title: Astropy extension 1.0.0 description: |- A set of tags for serializing astropy objects. This does not include most model classes, which are handled by an implementation of the ASDF transform extension. asdf_standard_requirement: gte: 1.1.0 tags: - tag_uri: tag:astropy.org:astropy/time/timedelta-1.0.0 schema_uri: http://astropy.org/schemas/astropy/time/timedelta-1.0.0 title: Represents an instance of TimeDelta from astropy description: |- Represents the time difference between two times. - tag_uri: tag:astropy.org:astropy/units/equivalency-1.0.0 schema_uri: http://astropy.org/schemas/astropy/units/equivalency-1.0.0 title: Represents unit equivalency. description: |- Supports serialization of equivalencies between units in certain contexts - tag_uri: tag:astropy.org:astropy/fits/fits-1.0.0 schema_uri: http://astropy.org/schemas/astropy/fits/fits-1.0.0 title: A FITS file inside of an ASDF file. description: |- This schema is useful for distributing ASDF files that can automatically be converted to FITS files by specifying the exact content of the resulting FITS file. Not all kinds of data in FITS are directly representable in ASDF. For example, applying an offset and scale to the data using the `BZERO` and `BSCALE` keywords. In these cases, it will not be possible to store the data in the native format from FITS and also be accessible in its proper form in the ASDF file. Only image and binary table extensions are supported. - tag_uri: tag:astropy.org:astropy/table/table-1.0.0 schema_uri: http://astropy.org/schemas/astropy/table/table-1.0.0 title: A table. description: |- A table is represented as a list of columns, where each entry is a [column](ref:http://stsci.edu/schemas/asdf/core/column-1.0.0) object, containing the data and some additional information. The data itself may be stored inline as text, or in binary in either row- or column-major order by use of the `strides` property on the individual column arrays. Each column in the table must have the same first (slowest moving) dimension. - tag_uri: tag:astropy.org:astropy/transform/units_mapping-1.0.0 schema_uri: http://astropy.org/schemas/astropy/transform/units_mapping-1.0.0 title: Mapper that operates on the units of the input. description: |- This transform operates on the units of the input, first converting to the expected input units, then assigning replacement output units without further conversion. ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1639520324.2020242 asdf_astropy-0.1.2/asdf_astropy/resources/schemas/0000755000446400020070000000000000000000000023300 5ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1639520324.2467127 asdf_astropy-0.1.2/asdf_astropy/resources/schemas/fits/0000755000446400020070000000000000000000000024245 5ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1620856446.0 asdf_astropy-0.1.2/asdf_astropy/resources/schemas/fits/fits-1.0.0.yaml0000644000446400020070000000674300000000000026542 0ustar00eslavichSTSCI\science%YAML 1.1 --- $schema: "http://stsci.edu/schemas/yaml-schema/draft-01" id: "http://astropy.org/schemas/astropy/fits/fits-1.0.0" title: > A FITS file inside of an ASDF file. description: | This schema is useful for distributing ASDF files that can automatically be converted to FITS files by specifying the exact content of the resulting FITS file. Not all kinds of data in FITS are directly representable in ASDF. For example, applying an offset and scale to the data using the `BZERO` and `BSCALE` keywords. In these cases, it will not be possible to store the data in the native format from FITS and also be accessible in its proper form in the ASDF file. Only image and binary table extensions are supported. examples: - - A simple FITS file with a primary header and two extensions - | ! - header: - [SIMPLE, true, conforms to FITS standard] - [BITPIX, 8, array data type] - [NAXIS, 0, number of array dimensions] - [EXTEND, true] - [] - ['', Top Level MIRI Metadata] - [] - [DATE, '2013-08-30T10:49:55.070373', The date this file was created (UTC)] - [FILENAME, MiriDarkReferenceModel_test.fits, The name of the file] - [TELESCOP, JWST, The telescope used to acquire the data] - [] - ['', Information about the observation] - [] - [DATE-OBS, '2013-08-30T10:49:55.000000', The date the observation was made (UTC)] - data: !core/ndarray-1.0.0 datatype: float32 shape: [2, 3, 3, 4] source: 0 byteorder: big header: - [XTENSION, IMAGE, Image extension] - [BITPIX, -32, array data type] - [NAXIS, 4, number of array dimensions] - [NAXIS1, 4] - [NAXIS2, 3] - [NAXIS3, 3] - [NAXIS4, 2] - [PCOUNT, 0, number of parameters] - [GCOUNT, 1, number of groups] - [EXTNAME, SCI, extension name] - [BUNIT, DN, Units of the data array] - data: !core/ndarray-1.0.0 datatype: float32 shape: [2, 3, 3, 4] source: 1 byteorder: big header: - [XTENSION, IMAGE, Image extension] - [BITPIX, -32, array data type] - [NAXIS, 4, number of array dimensions] - [NAXIS1, 4] - [NAXIS2, 3] - [NAXIS3, 3] - [NAXIS4, 2] - [PCOUNT, 0, number of parameters] - [GCOUNT, 1, number of groups] - [EXTNAME, ERR, extension name] - [BUNIT, DN, Units of the error array] allOf: - tag: "tag:astropy.org:astropy/fits/fits-1.0.0" - type: array items: type: object properties: # TODO: Why are there no validations for the header here? The # next version of the schema should add them. data: description: "The data part of the HDU." anyOf: - $ref: "http://stsci.edu/schemas/asdf/core/ndarray-1.0.0" - $ref: "../table/table-1.0.0" # Retain backwards compatibility with table defined by ASDF Standard - $ref: "http://stsci.edu/schemas/asdf/core/table-1.0.0" - type: "null" default: null ././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1639520324.247394 asdf_astropy-0.1.2/asdf_astropy/resources/schemas/table/0000755000446400020070000000000000000000000024367 5ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1601406442.0 asdf_astropy-0.1.2/asdf_astropy/resources/schemas/table/table-1.0.0.yaml0000644000446400020070000000723400000000000027002 0ustar00eslavichSTSCI\science%YAML 1.1 --- $schema: "http://stsci.edu/schemas/yaml-schema/draft-01" id: "http://astropy.org/schemas/astropy/table/table-1.0.0" tag: "tag:astropy.org:astropy/table/table-1.0.0" title: > A table. description: | A table is represented as a list of columns, where each entry is a [column](ref:http://stsci.edu/schemas/asdf/core/column-1.0.0) object, containing the data and some additional information. The data itself may be stored inline as text, or in binary in either row- or column-major order by use of the `strides` property on the individual column arrays. Each column in the table must have the same first (slowest moving) dimension. examples: - - A table stored in column-major order, with each column in a separate block - | ! columns: - !core/column-1.0.0 data: !core/ndarray-1.0.0 source: 0 datatype: float64 byteorder: little shape: [3] description: RA meta: {foo: bar} name: a unit: !unit/unit-1.0.0 deg - !core/column-1.0.0 data: !core/ndarray-1.0.0 source: 1 datatype: float64 byteorder: little shape: [3] description: DEC name: b - !core/column-1.0.0 data: !core/ndarray-1.0.0 source: 2 datatype: [ascii, 1] byteorder: big shape: [3] description: The target name name: c colnames: [a, b, c] - - A table stored in row-major order, all stored in the same block - | ! columns: - !core/column-1.0.0 data: !core/ndarray-1.0.0 source: 0 datatype: float64 byteorder: little shape: [3] strides: [13] description: RA meta: {foo: bar} name: a unit: !unit/unit-1.0.0 deg - !core/column-1.0.0 data: !core/ndarray-1.0.0 source: 0 datatype: float64 byteorder: little shape: [3] offset: 4 strides: [13] description: DEC name: b - !core/column-1.0.0 data: !core/ndarray-1.0.0 source: 0 datatype: [ascii, 1] byteorder: big shape: [3] offset: 12 strides: [13] description: The target name name: c colnames: [a, b, c] type: object properties: columns: description: | A list of columns in the table. type: array items: anyOf: - $ref: "http://stsci.edu/schemas/asdf/core/column-1.0.0" - $ref: "http://stsci.edu/schemas/asdf/core/ndarray-1.0.0" - $ref: "http://stsci.edu/schemas/asdf/time/time-1.1.0" - $ref: "http://stsci.edu/schemas/asdf/unit/quantity-1.1.0" - $ref: "../coordinates/skycoord-1.0.0" - $ref: "../coordinates/earthlocation-1.0.0" - $ref: "../time/timedelta-1.0.0" colnames: description: | A list containing the names of the columns in the table (in order). type: array items: - type: string qtable: description: | A flag indicating whether or not the serialized type was a QTable type: boolean default: False meta: description: | Additional free-form metadata about the table. type: object default: {} additionalProperties: false required: [columns, colnames] ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1639520324.2480834 asdf_astropy-0.1.2/asdf_astropy/resources/schemas/time/0000755000446400020070000000000000000000000024236 5ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1601406442.0 asdf_astropy-0.1.2/asdf_astropy/resources/schemas/time/timedelta-1.0.0.yaml0000644000446400020070000000167300000000000027533 0ustar00eslavichSTSCI\science%YAML 1.1 --- $schema: "http://stsci.edu/schemas/asdf/asdf-schema-1.0.0" id: "http://astropy.org/schemas/astropy/time/timedelta-1.0.0" title: Represents an instance of TimeDelta from astropy description: | Represents the time difference between two times. type: object properties: jd1: anyOf: - type: number - $ref: "http://stsci.edu/schemas/asdf/core/ndarray-1.0.0" description: | Value representing first 64 bits of precision jd2: anyOf: - type: number - $ref: "http://stsci.edu/schemas/asdf/core/ndarray-1.0.0" description: | Value representing second 64 bits of precision format: type: string description: | Format of time value representation. scale: type: string description: | Time scale of input value(s). enum: [tdb, tt, ut1, tcg, tcb, tai, local] required: [jd1, jd2, format] additionalProperties: False ... ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1639520324.2487593 asdf_astropy-0.1.2/asdf_astropy/resources/schemas/transform/0000755000446400020070000000000000000000000025313 5ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1601406442.0 asdf_astropy-0.1.2/asdf_astropy/resources/schemas/transform/units_mapping-1.0.0.yaml0000644000446400020070000000520500000000000031510 0ustar00eslavichSTSCI\science%YAML 1.1 --- $schema: "http://stsci.edu/schemas/yaml-schema/draft-01" id: "http://astropy.org/schemas/astropy/transform/units_mapping-1.0.0" tag: "tag:astropy.org:astropy/transform/units_mapping-1.0.0" title: | Mapper that operates on the units of the input. description: | This transform operates on the units of the input, first converting to the expected input units, then assigning replacement output units without further conversion. examples: - - Assign units of seconds to dimensionless input. - | ! inputs: - name: x unit: !unit/unit-1.0.0 outputs: - name: x unit: !unit/unit-1.0.0 s - - Convert input to meters, then assign dimensionless units. - | ! inputs: - name: x unit: !unit/unit-1.0.0 m outputs: - name: x unit: !unit/unit-1.0.0 - - Convert input to meters, then drop units entirely. - | ! inputs: - name: x unit: !unit/unit-1.0.0 m outputs: - name: x - - Accept any units, then replace with meters. - | ! inputs: - name: x outputs: - name: x unit: !unit/unit-1.0.0 m allOf: - $ref: "http://stsci.edu/schemas/asdf/transform/transform-1.2.0" - type: object properties: inputs: description: | Array of input configurations. type: array items: $ref: "#/definitions/value_configuration" outputs: description: | Array of output configurations. type: array items: $ref: "#/definitions/value_configuration" required: [inputs, outputs] definitions: value_configuration: description: | Configuration of a single model value (input or output). type: object properties: name: description: | Value name. type: string unit: description: | Expected unit. $ref: "http://stsci.edu/schemas/asdf/unit/unit-1.0.0" equivalencies: description: | Equivalencies to apply when converting value to expected unit. $ref: "http://astropy.org/schemas/astropy/units/equivalency-1.0.0" allow_dimensionless: description: | Allow this value to receive dimensionless data. type: boolean default: false required: [name] ... ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1639520324.2494144 asdf_astropy-0.1.2/asdf_astropy/resources/schemas/units/0000755000446400020070000000000000000000000024442 5ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1601406442.0 asdf_astropy-0.1.2/asdf_astropy/resources/schemas/units/equivalency-1.0.0.yaml0000644000446400020070000000136600000000000030313 0ustar00eslavichSTSCI\science%YAML 1.1 --- $schema: "http://stsci.edu/schemas/yaml-schema/draft-01" id: "http://astropy.org/schemas/astropy/units/equivalency-1.0.0" tag: "tag:astropy.org:astropy/units/equivalency-1.0.0" title: | Represents unit equivalency. description: | Supports serialization of equivalencies between units in certain contexts definitions: equivalency: type: object properties: name: type: string kwargs_names: type: array items: type: string kwargs_values: type: array items: anyOf: - $ref: "http://stsci.edu/schemas/asdf/unit/quantity-1.1.0" - type: number - type: "null" type: array items: $ref: "#/definitions/equivalency" ... ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1639520324.2503161 asdf_astropy-0.1.2/asdf_astropy/testing/0000755000446400020070000000000000000000000021320 5ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1621458452.0 asdf_astropy-0.1.2/asdf_astropy/testing/__init__.py0000644000446400020070000000000000000000000023417 0ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1638282379.0 asdf_astropy-0.1.2/asdf_astropy/testing/helpers.py0000644000446400020070000000371400000000000023341 0ustar00eslavichSTSCI\sciencefrom astropy.coordinates import EarthLocation from astropy.tests.helper import assert_quantity_allclose from astropy import units from numpy.testing import assert_array_equal def assert_earth_location_equal(a, b): __tracebackhide__ = True assert (a == b).all() def assert_representation_equal(a, b): __tracebackhide__ = True assert type(a) is type(b) assert a.components == b.components for component in a.components: assert units.allclose(getattr(a, component), getattr(b, component)) def assert_sky_coord_equal(a, b): __tracebackhide__ = True assert a.is_equivalent_frame(b) assert a.representation_type is b.representation_type assert a.shape == b.shape assert_representation_equal(a.data, b.data) def assert_frame_equal(a, b): __tracebackhide__ = True assert type(a) is type(b) if a is None: return assert_representation_equal(a.data, b.data) def assert_spectral_coord_equal(a, b): __tracebackhide__ = True assert type(a) is type(b) assert_quantity_allclose(a.quantity, b.quantity) assert_frame_equal(a.observer, b.observer) assert_frame_equal(a.target, b.target) def assert_time_equal(a, b): assert a.format == b.format assert a.scale == b.scale assert type(a.location) == type(b.location) if isinstance(a.location, EarthLocation): assert_earth_location_equal(a.location, b.location) else: assert a.location == b.location assert_array_equal(a, b) def assert_time_delta_equal(a, b): assert_array_equal(a.jd, b.jd) assert_array_equal(a.jd2, b.jd2) assert_array_equal(a.sec, b.sec) def assert_hdu_list_equal(a, b): assert len(a) == len(b) for hdu_a, hdu_b in zip(a, b): assert_array_equal(hdu_a.data, hdu_b.data) assert len(hdu_a.header.cards) == len(hdu_b.header.cards) for card_a, card_b in zip(hdu_a.header.cards, hdu_b.header.cards): assert tuple(card_a) == tuple(card_b) ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1639520324.2508645 asdf_astropy-0.1.2/asdf_astropy/tests/0000755000446400020070000000000000000000000021005 5ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1638282379.0 asdf_astropy-0.1.2/asdf_astropy/tests/test_integration.py0000644000446400020070000000554600000000000024753 0ustar00eslavichSTSCI\sciencefrom pathlib import Path import sys import yaml import asdf def test_resources(): resources_root = Path(__file__).parent.parent / "resources" resource_manager = asdf.get_config().resource_manager for resource_path in resources_root.glob("**/*.yaml"): with resource_path.open("rb") as f: resource_content = f.read() resource = yaml.safe_load(resource_content) resource_uri = resource["id"] assert resource_manager[resource_uri] == resource_content def test_manifests(): manifests_root = ( Path(__file__).parent.parent / "resources" / "manifests" ) resource_manager = asdf.get_config().resource_manager for manifest_path in manifests_root.glob("*.yaml"): with manifest_path.open("rb") as f: manifest_content = f.read() manifest = yaml.safe_load(manifest_content) manifest_schema = asdf.schema.load_schema( "asdf://asdf-format.org/core/schemas/extension_manifest-1.0.0" ) # The manifest must be valid against its own schema: asdf.schema.validate(manifest, schema=manifest_schema) for tag_definition in manifest["tags"]: # The tag's schema must be available: assert tag_definition["schema_uri"] in resource_manager def test_extensions(): package_and_uri_pairs = {(e.package_name, e.extension_uri) for e in asdf.get_config().extensions} assert ("asdf-astropy", "asdf://astropy.org/astropy/extensions/astropy-1.0.0") in package_and_uri_pairs assert ("asdf-astropy", "asdf://asdf-format.org/transform/extensions/transform-1.0.0") in package_and_uri_pairs assert ("asdf-astropy", "asdf://asdf-format.org/transform/extensions/transform-1.1.0") in package_and_uri_pairs assert ("asdf-astropy", "asdf://asdf-format.org/transform/extensions/transform-1.2.0") in package_and_uri_pairs assert ("asdf-astropy", "asdf://asdf-format.org/transform/extensions/transform-1.3.0") in package_and_uri_pairs assert ("asdf-astropy", "asdf://asdf-format.org/transform/extensions/transform-1.4.0") in package_and_uri_pairs assert ("asdf-astropy", "asdf://asdf-format.org/transform/extensions/transform-1.5.0") in package_and_uri_pairs _ASTROPY_MODULES = [ "astropy.coordinates", "astropy.io", "astropy.modeling", "astropy.table", "astropy.time", "astropy.units", ] def test_no_astropy_import(): """ Confirm that none of the ASDF plugins import astropy modules at import time. """ keys = [k for k in sys.modules.keys() if k.startswith("asdf_astropy") or any(k.startswith(m) for m in _ASTROPY_MODULES)] for key in keys: del sys.modules[key] from asdf_astropy import integration integration.get_resource_mappings() integration.get_extensions() assert not any(k for k in sys.modules.keys() if any(k.startswith(m) for m in _ASTROPY_MODULES)) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1639520324.0 asdf_astropy-0.1.2/asdf_astropy/version.py0000644000446400020070000000052100000000000021700 0ustar00eslavichSTSCI\science# Note that we need to fall back to the hard-coded version if either # setuptools_scm can't be imported or setuptools_scm can't determine the # version, so we catch the generic 'Exception'. try: from setuptools_scm import get_version version = get_version(root='..', relative_to=__file__) except Exception: version = '0.1.2' ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1639520324.2148566 asdf_astropy-0.1.2/asdf_astropy.egg-info/0000755000446400020070000000000000000000000021335 5ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1639520324.0 asdf_astropy-0.1.2/asdf_astropy.egg-info/PKG-INFO0000644000446400020070000000353300000000000022436 0ustar00eslavichSTSCI\scienceMetadata-Version: 2.1 Name: asdf-astropy Version: 0.1.2 Summary: ASDF serialization support for astropy Home-page: https://github.com/astropy/asdf-astropy Author: The ASDF Developers Author-email: help@stsci.edu License: BSD-3-Clause Platform: UNKNOWN Requires-Python: >=3.6 Description-Content-Type: text/x-rst Provides-Extra: test Provides-Extra: docs License-File: licenses/LICENSE.rst ASDF serialization support for astropy -------------------------------------- .. image:: https://github.com/astropy/asdf-astropy/workflows/CI/badge.svg :target: https://github.com/astropy/asdf-astropy/actions :alt: CI Status .. image:: https://codecov.io/gh/astropy/asdf-astropy/branch/master/graph/badge.svg :target: https://codecov.io/gh/astropy/asdf-astropy/branch=main :alt: Code coverage .. image:: http://img.shields.io/badge/powered%20by-AstroPy-orange.svg?style=flat :target: http://www.astropy.org :alt: Powered by Astropy Badge This package includes plugins that provide ASDF serialization support for astropy objects. The plugins are automatically enabled when the package is installed. The plugins in this package supercede those in the ``astropy.io.misc.asdf`` module; when this package is installed, the astropy plugins will be ignored. The ``astropy.io.misc.asdf`` module will be removed in a future version of astropy. License ------- This project is Copyright (c) Association of Universities for Research in Astronomy (AURA) and licensed under the terms of the BSD 3-Clause license. This package is based upon the `Astropy package template `_ which is licensed under the BSD 3-clause license. See the licenses folder for more information. Contributing ------------ We love contributions! asdf-astropy is open source, built on open source, and we'd love to have you hang out in our community. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1639520324.0 asdf_astropy-0.1.2/asdf_astropy.egg-info/SOURCES.txt0000644000446400020070000000713100000000000023223 0ustar00eslavichSTSCI\scienceCHANGES.rst MANIFEST.in README.rst pyproject.toml setup.cfg setup.py tox.ini .github/workflows/ci.yml asdf_astropy/__init__.py asdf_astropy/_astropy_init.py asdf_astropy/conftest.py asdf_astropy/extensions.py asdf_astropy/integration.py asdf_astropy/version.py asdf_astropy.egg-info/PKG-INFO asdf_astropy.egg-info/SOURCES.txt asdf_astropy.egg-info/dependency_links.txt asdf_astropy.egg-info/entry_points.txt asdf_astropy.egg-info/requires.txt asdf_astropy.egg-info/top_level.txt asdf_astropy.egg-info/zip-safe asdf_astropy/converters/__init__.py asdf_astropy/converters/helpers.py asdf_astropy/converters/utils.py asdf_astropy/converters/coordinates/__init__.py asdf_astropy/converters/coordinates/angle.py asdf_astropy/converters/coordinates/earth_location.py asdf_astropy/converters/coordinates/frame.py asdf_astropy/converters/coordinates/representation.py asdf_astropy/converters/coordinates/sky_coord.py asdf_astropy/converters/coordinates/spectral_coord.py asdf_astropy/converters/coordinates/tests/__init__.py asdf_astropy/converters/coordinates/tests/helpers.py asdf_astropy/converters/coordinates/tests/test_angle.py asdf_astropy/converters/coordinates/tests/test_earth_location.py asdf_astropy/converters/coordinates/tests/test_frame.py asdf_astropy/converters/coordinates/tests/test_representation.py asdf_astropy/converters/coordinates/tests/test_sky_coord.py asdf_astropy/converters/coordinates/tests/test_spectral_coord.py asdf_astropy/converters/fits/__init__.py asdf_astropy/converters/fits/fits.py asdf_astropy/converters/fits/tests/__init__.py asdf_astropy/converters/fits/tests/test_fits.py asdf_astropy/converters/table/__init__.py asdf_astropy/converters/table/table.py asdf_astropy/converters/table/tests/__init__.py asdf_astropy/converters/table/tests/test_table.py asdf_astropy/converters/time/__init__.py asdf_astropy/converters/time/time.py asdf_astropy/converters/time/time_delta.py asdf_astropy/converters/time/tests/__init__.py asdf_astropy/converters/time/tests/test_time.py asdf_astropy/converters/time/tests/test_time_delta.py asdf_astropy/converters/transform/__init__.py asdf_astropy/converters/transform/compound.py asdf_astropy/converters/transform/core.py asdf_astropy/converters/transform/functional_models.py asdf_astropy/converters/transform/mappings.py asdf_astropy/converters/transform/math_functions.py asdf_astropy/converters/transform/polynomial.py asdf_astropy/converters/transform/projections.py asdf_astropy/converters/transform/rotations.py asdf_astropy/converters/transform/tabular.py asdf_astropy/converters/transform/tests/__init__.py asdf_astropy/converters/transform/tests/test_transform.py asdf_astropy/converters/unit/__init__.py asdf_astropy/converters/unit/equivalency.py asdf_astropy/converters/unit/quantity.py asdf_astropy/converters/unit/unit.py asdf_astropy/converters/unit/tests/__init__.py asdf_astropy/converters/unit/tests/test_equivalency.py asdf_astropy/converters/unit/tests/test_quantity.py asdf_astropy/converters/unit/tests/test_unit.py asdf_astropy/resources/__init__.py asdf_astropy/resources/manifests/astropy-1.0.0.yaml asdf_astropy/resources/schemas/fits/fits-1.0.0.yaml asdf_astropy/resources/schemas/table/table-1.0.0.yaml asdf_astropy/resources/schemas/time/timedelta-1.0.0.yaml asdf_astropy/resources/schemas/transform/units_mapping-1.0.0.yaml asdf_astropy/resources/schemas/units/equivalency-1.0.0.yaml asdf_astropy/testing/__init__.py asdf_astropy/testing/helpers.py asdf_astropy/tests/test_integration.py docs/Makefile docs/conf.py docs/index.rst docs/make.bat docs/asdf-astropy/index.rst licenses/LICENSE.rst licenses/README.rst licenses/TEMPLATE_LICENCE.rst scripts/generate_manifest.py././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1639520324.0 asdf_astropy-0.1.2/asdf_astropy.egg-info/dependency_links.txt0000644000446400020070000000000100000000000025403 0ustar00eslavichSTSCI\science ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1639520324.0 asdf_astropy-0.1.2/asdf_astropy.egg-info/entry_points.txt0000644000446400020070000000024200000000000024631 0ustar00eslavichSTSCI\science[asdf.extensions] asdf-astropy = asdf_astropy.integration:get_extensions [asdf.resource_mappings] asdf-astropy = asdf_astropy.integration:get_resource_mappings ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1639520324.0 asdf_astropy-0.1.2/asdf_astropy.egg-info/requires.txt0000644000446400020070000000035000000000000023733 0ustar00eslavichSTSCI\scienceastropy asdf>=2.8.0 numpy asdf-coordinates-schemas asdf-transform-schemas packaging>=16.0 [:python_version < "3.9"] importlib_resources>=3 [docs] sphinx sphinx-astropy sphinx-automodapi sphinx-asdf [test] pytest-astropy coverage ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1639520324.0 asdf_astropy-0.1.2/asdf_astropy.egg-info/top_level.txt0000644000446400020070000000001500000000000024063 0ustar00eslavichSTSCI\scienceasdf_astropy ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1639520324.0 asdf_astropy-0.1.2/asdf_astropy.egg-info/zip-safe0000644000446400020070000000000100000000000022765 0ustar00eslavichSTSCI\science ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1639520324.2535381 asdf_astropy-0.1.2/docs/0000755000446400020070000000000000000000000016075 5ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1598456526.0 asdf_astropy-0.1.2/docs/Makefile0000644000446400020070000001074500000000000017544 0ustar00eslavichSTSCI\science# Makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = BUILDDIR = _build # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest #This is needed with git because git doesn't create a dir if it's empty $(shell [ -d "_static" ] || mkdir -p _static) help: @echo "Please use \`make ' where is one of" @echo " html to make standalone HTML files" @echo " dirhtml to make HTML files named index.html in directories" @echo " singlehtml to make a single large HTML file" @echo " pickle to make pickle files" @echo " json to make JSON files" @echo " htmlhelp to make HTML files and a HTML help project" @echo " qthelp to make HTML files and a qthelp project" @echo " devhelp to make HTML files and a Devhelp project" @echo " epub to make an epub" @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" @echo " latexpdf to make LaTeX files and run them through pdflatex" @echo " text to make text files" @echo " man to make manual pages" @echo " changes to make an overview of all changed/added/deprecated items" @echo " linkcheck to check all external links for integrity" clean: -rm -rf $(BUILDDIR) -rm -rf api -rm -rf generated html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." dirhtml: $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." singlehtml: $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml @echo @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." pickle: $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle @echo @echo "Build finished; now you can process the pickle files." json: $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json @echo @echo "Build finished; now you can process the JSON files." htmlhelp: $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp @echo @echo "Build finished; now you can run HTML Help Workshop with the" \ ".hhp project file in $(BUILDDIR)/htmlhelp." qthelp: $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp @echo @echo "Build finished; now you can run "qcollectiongenerator" with the" \ ".qhcp project file in $(BUILDDIR)/qthelp, like this:" @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/Astropy.qhcp" @echo "To view the help file:" @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Astropy.qhc" devhelp: $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp @echo @echo "Build finished." @echo "To view the help file:" @echo "# mkdir -p $$HOME/.local/share/devhelp/Astropy" @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/Astropy" @echo "# devhelp" epub: $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub @echo @echo "Build finished. The epub file is in $(BUILDDIR)/epub." latex: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." @echo "Run \`make' in that directory to run these through (pdf)latex" \ "(use \`make latexpdf' here to do that automatically)." latexpdf: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo "Running LaTeX files through pdflatex..." make -C $(BUILDDIR)/latex all-pdf @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." text: $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text @echo @echo "Build finished. The text files are in $(BUILDDIR)/text." man: $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man @echo @echo "Build finished. The manual pages are in $(BUILDDIR)/man." changes: $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes @echo @echo "The overview file is in $(BUILDDIR)/changes." linkcheck: $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck @echo @echo "Link check complete; look for any errors in the above output " \ "or in $(BUILDDIR)/linkcheck/output.txt." doctest: @echo "Run 'python setup.py test' in the root directory to run doctests " \ @echo "in the documentation." ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1639520324.2542148 asdf_astropy-0.1.2/docs/asdf-astropy/0000755000446400020070000000000000000000000020511 5ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1638394479.0 asdf_astropy-0.1.2/docs/asdf-astropy/index.rst0000644000446400020070000000015700000000000022355 0ustar00eslavichSTSCI\science************************** asdf-astropy Documentation ************************** .. toctree:: :maxdepth: 1 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1620856446.0 asdf_astropy-0.1.2/docs/conf.py0000644000446400020070000001652300000000000017403 0ustar00eslavichSTSCI\science# -*- coding: utf-8 -*- # Licensed under a 3-clause BSD style license - see LICENSE.rst # # Astropy documentation build configuration file. # # This file is execfile()d with the current directory set to its containing dir. # # Note that not all possible configuration values are present in this file. # # All configuration values have a default. Some values are defined in # the global Astropy configuration which is loaded here before anything else. # See astropy.sphinx.conf for which values are set there. # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # sys.path.insert(0, os.path.abspath('..')) # IMPORTANT: the above commented section was generated by sphinx-quickstart, but # is *NOT* appropriate for astropy or Astropy affiliated packages. It is left # commented out with this explanation to make it clear why this should not be # done. If the sys.path entry above is added, when the astropy.sphinx.conf # import occurs, it will import the *source* version of astropy instead of the # version installed (if invoked as "make html" or directly with sphinx), or the # version in the build directory (if "python setup.py build_sphinx" is used). # Thus, any C-extensions that are needed to build the documentation will *not* # be accessible, and the documentation will not build correctly. import os import sys import datetime from importlib import import_module from configparser import ConfigParser import sphinx import sphinx_astropy try: from sphinx_astropy.conf.v1 import * # noqa except ImportError: print('ERROR: the documentation requires the sphinx-astropy package to be installed') sys.exit(1) # Get configuration information from setup.cfg conf = ConfigParser() conf.read([os.path.join(os.path.dirname(__file__), '..', 'setup.cfg')]) setup_cfg = dict(conf.items('metadata')) # -- General configuration ---------------------------------------------------- # By default, highlight as Python 3. highlight_language = 'python3' # If your documentation needs a minimal Sphinx version, state it here. needs_sphinx = '1.7' # To perform a Sphinx version check that needs to be more specific than # major.minor, call `check_sphinx_version("x.y.z")` here. # check_sphinx_version("1.2.1") # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns.append('_templates') # This is added to the end of RST files - a good place to put substitutions to # be used globally. # # -- Project information ------------------------------------------------------ # This does not *have* to match the package name, but typically does project = setup_cfg['name'] author = setup_cfg['author'] copyright = '{0}, {1}'.format( datetime.datetime.now().year, setup_cfg['author']) # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. import_module(setup_cfg['name']) package = sys.modules[setup_cfg['name']] # The short X.Y version. version = package.__version__.split('-', 1)[0] # The full version, including alpha/beta/rc tags. release = package.__version__ # -- Options for HTML output -------------------------------------------------- # A NOTE ON HTML THEMES # The global astropy configuration uses a custom theme, 'bootstrap-astropy', # which is installed along with astropy. A different theme can be used or # the options for this theme can be modified by overriding some of the # variables set in the global configuration. The variables set in the # global configuration are listed below, commented out. # Add any paths that contain custom themes here, relative to this directory. # To use a different custom theme, add the directory containing the theme. #html_theme_path = [] # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. To override the custom theme, set this to the # name of a builtin theme or the name of a custom theme in html_theme_path. #html_theme = None html_theme_options = { 'logotext1': 'asdf-astropy', # white, semi-bold 'logotext2': '', # orange, light 'logotext3': ':docs' # white, light } # Custom sidebar templates, maps document names to template names. #html_sidebars = {} # The name of an image file (relative to this directory) to place at the top # of the sidebar. #html_logo = '' # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. #html_favicon = '' # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. #html_last_updated_fmt = '' # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". html_title = '{0} v{1}'.format(project, release) # Output file base name for HTML help builder. htmlhelp_basename = project + 'doc' # -- Options for LaTeX output ------------------------------------------------- # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [('index', project + '.tex', project + u' Documentation', author, 'manual')] # -- Options for manual page output ------------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [('index', project.lower(), project + u' Documentation', [author], 1)] # extensions = ['sphinx.ext.autodoc', # 'sphinx.ext.autosummary', # 'sphinx_automodapi.automodsumm', # 'sphinx_automodapi.autodoc_enhancements', # 'sphinx_automodapi.smart_resolver', # 'sphinx_automodapi.automodapi', # ] # -- Options for the edit_on_github extension --------------------------------- # if setup_cfg.get('edit_on_github').lower() == 'true': # # extensions += ['sphinx_astropy.ext.edit_on_github'] # # # edit_on_github_project = setup_cfg['github_project'] # edit_on_github_branch = "main" # # edit_on_github_source_root = "" # edit_on_github_doc_root = "docs" # # # -- Resolving issue number to links in changelog ----------------------------- # github_issues_url = 'https://github.com/{0}/issues/'.format(setup_cfg['github_project']) # -- Turn on nitpicky mode for sphinx (to warn about references not found) ---- # #nitpicky = True #nitpick_ignore = [] # # Some warnings are impossible to suppress, and you can list specific references # that should be ignored in a nitpick-exceptions file which should be inside # the docs/ directory. The format of the file should be: # # # # for example: # # py:class astropy.io.votable.tree.Element # py:class astropy.io.votable.tree.SimpleElement # py:class astropy.io.votable.tree.SimpleElementWithContent # # Uncomment the following lines to enable the exceptions: # # for line in open('nitpick-exceptions'): # if line.strip() == "" or line.startswith("#"): # continue # dtype, target = line.split(None, 1) # target = target.strip() # nitpick_ignore.append((dtype, six.u(target))) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1616424498.0 asdf_astropy-0.1.2/docs/index.rst0000644000446400020070000000020000000000000017726 0ustar00eslavichSTSCI\scienceDocumentation ============= This is the documentation for asdf-astropy. .. toctree:: :maxdepth: 2 asdf-astropy/index.rst ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1598456526.0 asdf_astropy-0.1.2/docs/make.bat0000644000446400020070000001070500000000000017505 0ustar00eslavichSTSCI\science@ECHO OFF REM Command file for Sphinx documentation if "%SPHINXBUILD%" == "" ( set SPHINXBUILD=sphinx-build ) set BUILDDIR=_build set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . if NOT "%PAPER%" == "" ( set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% ) if "%1" == "" goto help if "%1" == "help" ( :help echo.Please use `make ^` where ^ is one of echo. html to make standalone HTML files echo. dirhtml to make HTML files named index.html in directories echo. singlehtml to make a single large HTML file echo. pickle to make pickle files echo. json to make JSON files echo. htmlhelp to make HTML files and a HTML help project echo. qthelp to make HTML files and a qthelp project echo. devhelp to make HTML files and a Devhelp project echo. epub to make an epub echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter echo. text to make text files echo. man to make manual pages echo. changes to make an overview over all changed/added/deprecated items echo. linkcheck to check all external links for integrity echo. doctest to run all doctests embedded in the documentation if enabled goto end ) if "%1" == "clean" ( for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i del /q /s %BUILDDIR%\* del /q /s api del /q /s generated goto end ) if "%1" == "html" ( %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/html. goto end ) if "%1" == "dirhtml" ( %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. goto end ) if "%1" == "singlehtml" ( %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. goto end ) if "%1" == "pickle" ( %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can process the pickle files. goto end ) if "%1" == "json" ( %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can process the JSON files. goto end ) if "%1" == "htmlhelp" ( %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can run HTML Help Workshop with the ^ .hhp project file in %BUILDDIR%/htmlhelp. goto end ) if "%1" == "qthelp" ( %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can run "qcollectiongenerator" with the ^ .qhcp project file in %BUILDDIR%/qthelp, like this: echo.^> qcollectiongenerator %BUILDDIR%\qthelp\Astropy.qhcp echo.To view the help file: echo.^> assistant -collectionFile %BUILDDIR%\qthelp\Astropy.ghc goto end ) if "%1" == "devhelp" ( %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp if errorlevel 1 exit /b 1 echo. echo.Build finished. goto end ) if "%1" == "epub" ( %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub if errorlevel 1 exit /b 1 echo. echo.Build finished. The epub file is in %BUILDDIR%/epub. goto end ) if "%1" == "latex" ( %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex if errorlevel 1 exit /b 1 echo. echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. goto end ) if "%1" == "text" ( %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text if errorlevel 1 exit /b 1 echo. echo.Build finished. The text files are in %BUILDDIR%/text. goto end ) if "%1" == "man" ( %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man if errorlevel 1 exit /b 1 echo. echo.Build finished. The manual pages are in %BUILDDIR%/man. goto end ) if "%1" == "changes" ( %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes if errorlevel 1 exit /b 1 echo. echo.The overview file is in %BUILDDIR%/changes. goto end ) if "%1" == "linkcheck" ( %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck if errorlevel 1 exit /b 1 echo. echo.Link check complete; look for any errors in the above output ^ or in %BUILDDIR%/linkcheck/output.txt. goto end ) if "%1" == "doctest" ( %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest if errorlevel 1 exit /b 1 echo. echo.Testing of doctests in the sources finished, look at the ^ results in %BUILDDIR%/doctest/output.txt. goto end ) :end ././@PaxHeader0000000000000000000000000000003300000000000010211 xustar0027 mtime=1639520324.256411 asdf_astropy-0.1.2/licenses/0000755000446400020070000000000000000000000016752 5ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1638394479.0 asdf_astropy-0.1.2/licenses/LICENSE.rst0000644000446400020070000000276000000000000020573 0ustar00eslavichSTSCI\scienceCopyright 2021 Association of Universities for Research in Astronomy (AURA) Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1598456526.0 asdf_astropy-0.1.2/licenses/README.rst0000644000446400020070000000056400000000000020446 0ustar00eslavichSTSCI\scienceLicenses ======== This directory holds license and credit information for the package, works the package is derived from, and/or datasets. Ensure that you pick a package license which is in this folder and it matches the one mentioned in the top level README.rst file. If you are using the pre-rendered version of this template check for the word 'Other' in the README. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1598456526.0 asdf_astropy-0.1.2/licenses/TEMPLATE_LICENCE.rst0000644000446400020070000000317300000000000022045 0ustar00eslavichSTSCI\scienceThis project is based upon the Astropy package template (https://github.com/astropy/package-template/) which is licensed under the terms of the following license. --- Copyright (c) 2018, Astropy Developers All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the Astropy Team nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1621874756.0 asdf_astropy-0.1.2/pyproject.toml0000644000446400020070000000036400000000000020064 0ustar00eslavichSTSCI\science[build-system] requires = ["setuptools", "setuptools_scm", "wheel", #"extension-helpers", "oldest-supported-numpy", #"cython==0.29.14" ] build-backend = 'setuptools.build_meta' ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1639520324.2573295 asdf_astropy-0.1.2/scripts/0000755000446400020070000000000000000000000016634 5ustar00eslavichSTSCI\science././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1601406442.0 asdf_astropy-0.1.2/scripts/generate_manifest.py0000644000446400020070000000344700000000000022676 0ustar00eslavichSTSCI\science""" Script that creates initial astropy manifest from the schemas in the resources directory. This file can be removed once the format of the manifest files has been finalized. """ import argparse from pathlib import Path import yaml def parse_args(): parser = argparse.ArgumentParser() parser.add_argument("schemas_path") parser.add_argument("output_path") return parser.parse_args() class MultilineString(str): pass def represent_multiline_string(dumper, data): return dumper.represent_scalar("tag:yaml.org,2002:str", data, style="|") yaml.add_representer(MultilineString, represent_multiline_string) args = parse_args() manifest = {} manifest["id"] = "http://astropy.org/asdf/extensions/astropy/manifests/astropy-1.0" manifest["extension_uri"] = "http://astropy.org/asdf/extensions/astropy-1.0" manifest["title"] = f"Astropy extension 1.0" manifest["description"] = MultilineString( "A set of tags for serializing astropy objects. This does not include most\n" "model classes, which are handled by an implementation of the ASDF\n" "transform extension." ) manifest["asdf_standard_requirement"] = { "gte": "1.1.0", } manifest["tags"] = [] for schema_path in Path(args.schemas_path).glob("**/*.yaml"): schema = yaml.safe_load(schema_path.read_bytes()) tag_def = { "tag_uri": schema["id"].replace("http://astropy.org/schemas/astropy/", "tag:astropy.org:astropy/"), "schema_uri": schema["id"], "title": schema["title"].strip(), } if "tag" in schema: assert tag_def["tag_uri"] == schema["tag"] if "description" in schema: tag_def["description"] = MultilineString(schema["description"].strip()) manifest["tags"].append(tag_def) with open(args.output_path, "w") as f: yaml.dump(manifest, f, sort_keys=False) ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1639520324.2594714 asdf_astropy-0.1.2/setup.cfg0000644000446400020070000000452000000000000016767 0ustar00eslavichSTSCI\science[metadata] name = asdf_astropy author = The ASDF Developers author_email = help@stsci.edu license = BSD-3-Clause license_file = licenses/LICENSE.rst url = https://github.com/astropy/asdf-astropy description = ASDF serialization support for astropy long_description = file: README.rst long_description_content_type = text/x-rst edit_on_github = False github_project = astropy/asdf-astropy [options] zip_safe = True packages = find: python_requires = >=3.6 setup_requires = setuptools_scm install_requires = astropy asdf>=2.8.0 numpy asdf-coordinates-schemas asdf-transform-schemas importlib_resources>=3;python_version<"3.9" packaging>=16.0 [options.entry_points] asdf.extensions = asdf-astropy = asdf_astropy.integration:get_extensions asdf.resource_mappings = asdf-astropy = asdf_astropy.integration:get_resource_mappings [options.extras_require] test = pytest-astropy coverage docs = sphinx sphinx-astropy sphinx-automodapi sphinx-asdf [options.package_data] asdf_astropy.resources = manifests/*.yaml, schemas/*.yaml, schemas/**/*.yaml, schemas/**/**/*.yaml [tool:pytest] testpaths = "asdf_astropy" "docs" astropy_header = true doctest_plus = enabled text_file_format = rst addopts = --doctest-rst asdf_schema_root = asdf_astropy/resources/schemas asdf_schema_tests_enabled = true asdf_schema_xfail_tests = asdf_astropy/resources/schemas/transform/units_mapping-1.0.0.yaml::test_schema asdf_astropy/resources/schemas/transform/units_mapping-1.0.0.yaml::test_example_0 asdf_astropy/resources/schemas/transform/units_mapping-1.0.0.yaml::test_example_1 asdf_astropy/resources/schemas/transform/units_mapping-1.0.0.yaml::test_example_2 asdf_astropy/resources/schemas/transform/units_mapping-1.0.0.yaml::test_example_3 [coverage:run] omit = asdf_astropy/_astropy_init* asdf_astropy/conftest.py asdf_astropy/*setup_package* asdf_astropy/tests/* asdf_astropy/*/tests/* asdf_astropy/extern/* asdf_astropy/version* */asdf_astropy/_astropy_init* */asdf_astropy/conftest.py */asdf_astropy/*setup_package* */asdf_astropy/tests/* */asdf_astropy/*/tests/* */asdf_astropy/extern/* */asdf_astropy/version* [coverage:report] exclude_lines = pragma: no cover except ImportError raise AssertionError raise NotImplementedError def main\(.*\): pragma: py{ignore_python_version} def _ipython_key_completions_ [egg_info] tag_build = tag_date = 0 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1598456526.0 asdf_astropy-0.1.2/setup.py0000755000446400020070000000365200000000000016670 0ustar00eslavichSTSCI\science#!/usr/bin/env python # Licensed under a 3-clause BSD style license - see LICENSE.rst # NOTE: The configuration for the package, including the name, version, and # other information are set in the setup.cfg file. import os import sys from setuptools import setup # First provide helpful messages if contributors try and run legacy commands # for tests or docs. TEST_HELP = """ Note: running tests is no longer done using 'python setup.py test'. Instead you will need to run: tox -e test If you don't already have tox installed, you can install it with: pip install tox If you only want to run part of the test suite, you can also use pytest directly with:: pip install -e .[test] pytest For more information, see: http://docs.astropy.org/en/latest/development/testguide.html#running-tests """ if 'test' in sys.argv: print(TEST_HELP) sys.exit(1) DOCS_HELP = """ Note: building the documentation is no longer done using 'python setup.py build_docs'. Instead you will need to run: tox -e build_docs If you don't already have tox installed, you can install it with: pip install tox You can also build the documentation with Sphinx directly using:: pip install -e .[docs] cd docs make html For more information, see: http://docs.astropy.org/en/latest/install.html#builddocs """ if 'build_docs' in sys.argv or 'build_sphinx' in sys.argv: print(DOCS_HELP) sys.exit(1) VERSION_TEMPLATE = """ # Note that we need to fall back to the hard-coded version if either # setuptools_scm can't be imported or setuptools_scm can't determine the # version, so we catch the generic 'Exception'. try: from setuptools_scm import get_version version = get_version(root='..', relative_to=__file__) except Exception: version = '{version}' """.lstrip() setup(use_scm_version={'write_to': os.path.join('asdf_astropy', 'version.py'), 'write_to_template': VERSION_TEMPLATE}) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1638286988.0 asdf_astropy-0.1.2/tox.ini0000644000446400020070000000476700000000000016476 0ustar00eslavichSTSCI\science[tox] envlist = py{37,39,310}-test{,-alldeps} py38-test-devdeps py38-cov py{38,}-test-numpy{117,118,119} build_docs codestyle py38-astropylts bandit requires = setuptools >= 30.3.0 pip >= 19.3.1 isolated_build = true [testenv] # Pass through the following environment variables which may be needed for the CI passenv = HOME WINDIR LC_ALL LC_CTYPE CC CI TRAVIS # tox environments are constructed with so-called 'factors' (or terms) # separated by hyphens, e.g. test-devdeps-cov. Lines below starting with factor: # will only take effect if that factor is included in the environment name. To # see a list of example environments that can be run, along with a description, # run: # # tox -l -v # description = run tests alldeps: with all optional dependencies devdeps: with the latest developer version of key dependencies cov: and test coverage numpy117: with numpy 1.17.* numpy119: with numpy 1.19.* astropylts: with astropy LTS # The following provides some specific pinnings for key packages deps = cov: coverage numpy117: numpy==1.17.* numpy118: numpy==1.18.* numpy119: numpy==1.19.* astropylts: astropy==4.0.* devdeps: git+https://github.com/numpy/numpy devdeps: git+https://github.com/astropy/astropy.git#egg=astropy devdeps: git+https://github.com/asdf-format/asdf devdeps: git+https://github.com/asdf-format/asdf-transform-schemas#egg=asdf_transform_schemas py310: git+https://github.com/pytest-dev/pytest # The following indicates which extras_require from setup.cfg will be installed extras = test alldeps: all commands = pip freeze !cov: pytest {posargs} cov: pytest --cov-report xml --cov asdf_astropy {posargs} [testenv:build_docs] changedir = docs description = invoke sphinx-build to build the HTML docs extras = docs commands = pip freeze sphinx-build -W . _build/html [testenv:codestyle] skip_install = true changedir = . description = check code style, e.g. with flake8 deps = flake8 commands = flake8 asdf_astropy --count --max-line-length=110 --select=E101,W191,W291,W292,W293,W391,E111,E112,E113,E30,E502,E722,E901,E902,E999,F822,F823 [testenv:bandit] deps= bandit commands= bandit asdf_astropy -r \ -x asdf_astropy/testing,asdf_astropy/tests,asdf_astropy/converters/coordinates/tests,asdf_astropy/converters/time/tests,asdf_astropy/converters/transform/tests,asdf_astropy/converters/unit/tests,asdf_astropy/converters/table/tests,asdf_astropy/converters/fits/tests