asdf

ASDF (Advanced Scientific Data Format) is a next generation interchange format for scientific data

https://github.com/asdf-format/asdf

Science Score: 64.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: zenodo.org
  • Committers with academic emails
    16 of 53 committers (30.2%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (14.6%) to scientific vocabulary

Keywords

advanced-scientific-data-format asdf astronomy astropy jwst

Keywords from Contributors

astrophysics astropy-affiliated photometry source-detection closember ccd wx tk qt gtk
Last synced: 6 months ago · JSON representation ·

Repository

ASDF (Advanced Scientific Data Format) is a next generation interchange format for scientific data

Basic Info
  • Host: GitHub
  • Owner: asdf-format
  • License: bsd-3-clause
  • Language: Python
  • Default Branch: main
  • Homepage: http://asdf.readthedocs.io/
  • Size: 6.48 MB
Statistics
  • Stars: 540
  • Watchers: 26
  • Forks: 61
  • Open Issues: 86
  • Releases: 57
Topics
advanced-scientific-data-format asdf astronomy astropy jwst
Created almost 12 years ago · Last pushed 6 months ago
Metadata Files
Readme Changelog Contributing License Citation Codeowners

README.rst

ASDF - Advanced Scientific Data Format
======================================

.. _begin-badges:

.. image:: https://github.com/asdf-format/asdf/workflows/CI/badge.svg
    :target: https://github.com/asdf-format/asdf/actions
    :alt: CI Status

.. image:: https://github.com/asdf-format/asdf/workflows/Downstream/badge.svg
    :target: https://github.com/asdf-format/asdf/actions
    :alt: Downstream CI Status

.. image:: https://readthedocs.org/projects/asdf/badge/?version=latest
    :target: https://asdf.readthedocs.io/en/latest/

.. image:: https://codecov.io/gh/asdf-format/asdf/branch/main/graphs/badge.svg
    :target: https://codecov.io/gh/asdf-format/asdf

.. _begin-zenodo:

.. image:: https://zenodo.org/badge/18112754.svg
    :target: https://zenodo.org/badge/latestdoi/18112754

.. _end-zenodo:

.. image:: https://img.shields.io/pypi/l/asdf.svg
    :target: https://img.shields.io/pypi/l/asdf.svg

.. image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white
    :target: https://github.com/pre-commit/pre-commit
    :alt: pre-commit

.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
    :target: https://github.com/psf/black

.. _end-badges:

.. _begin-summary-text:

The **A**\ dvanced **S**\ cientific **D**\ ata **F**\ ormat (ASDF) is a
next-generation interchange format for scientific data. This package
contains the Python implementation of the ASDF specification. More
information on the ASDF file format including the specification can be found
`here `__.

The ASDF format has the following features:

* Hierarchical and human-readable metadata in `YAML `__ format
* Efficient binary array storage with support for memory mapping
  and flexible compression.
* Content validation using schemas (using `JSON Schema `__)
* Native and transparent support for most basic Python data types,
  with an extension API to add support for any custom Python object.

.. _end-summary-text:

ASDF is under active development `on github
`__. More information on contributing
can be found `below <#contributing>`__.

Overview
--------

This section outlines basic use cases of the ASDF package for creating
and reading ASDF files.

Creating a file
~~~~~~~~~~~~~~~

.. _begin-create-file-text:

We're going to store several `numpy` arrays and other data to an ASDF file. We
do this by creating a "tree", which is simply a `dict`, and we provide it as
input to the constructor of `AsdfFile`:

.. code:: python

    import asdf
    import numpy as np

    # Create some data
    sequence = np.arange(100)
    squares = sequence**2
    random = np.random.random(100)

    # Store the data in an arbitrarily nested dictionary
    tree = {
        "foo": 42,
        "name": "Monty",
        "sequence": sequence,
        "powers": {"squares": squares},
        "random": random,
    }

    # Create the ASDF file object from our data tree
    af = asdf.AsdfFile(tree)

    # Write the data to a new file
    af.write_to("example.asdf")

If we open the newly created file's metadata section, we can see some of the key features
of ASDF on display:

.. _begin-example-asdf-metadata:

.. code:: yaml

    #ASDF 1.0.0
    #ASDF_STANDARD 1.2.0
    %YAML 1.1
    %TAG ! tag:stsci.edu:asdf/
    --- !core/asdf-1.1.0
    asdf_library: !core/software-1.0.0 {author: The ASDF Developers, homepage: 'http://github.com/asdf-format/asdf',
      name: asdf, version: 2.0.0}
    history:
      extensions:
      - !core/extension_metadata-1.0.0
        extension_class: asdf.extension.BuiltinExtension
        software: {name: asdf, version: 2.0.0}
    foo: 42
    name: Monty
    powers:
      squares: !core/ndarray-1.0.0
        source: 1
        datatype: int64
        byteorder: little
        shape: [100]
    random: !core/ndarray-1.0.0
      source: 2
      datatype: float64
      byteorder: little
      shape: [100]
    sequence: !core/ndarray-1.0.0
      source: 0
      datatype: int64
      byteorder: little
      shape: [100]
    ...

.. _end-example-asdf-metadata:

The metadata in the file mirrors the structure of the tree that was stored. It
is hierarchical and human-readable. Notice that metadata has been added to the
tree that was not explicitly given by the user. Notice also that the numerical
array data is not stored in the metadata tree itself. Instead, it is stored as
binary data blocks below the metadata section (not shown above).

.. _end-create-file-text:
.. _begin-compress-file:

It is possible to compress the array data when writing the file:

.. code:: python

    af.write_to("compressed.asdf", all_array_compression="zlib")

The built-in compression algorithms are ``'zlib'``, and ``'bzp2'``.  The
``'lz4'`` algorithm becomes available when the `lz4 `__ package
is installed.  Other compression algorithms may be available via extensions.

.. _end-compress-file:

Reading a file
~~~~~~~~~~~~~~

.. _begin-read-file-text:

To read an existing ASDF file, we simply use the top-level `open` function of
the `asdf` package:

.. code:: python

    import asdf

    af = asdf.open("example.asdf")

The `open` function also works as a context handler:

.. code:: python

    with asdf.open("example.asdf") as af:
        ...

.. warning::
    The ``memmap`` argument replaces ``copy_arrays`` as of ASDF 4.0
    (``memmap == not copy_arrays``).

To get a quick overview of the data stored in the file, use the top-level
`AsdfFile.info()` method:

.. code:: pycon

    >>> import asdf
    >>> af = asdf.open("example.asdf")
    >>> af.info()
    root (AsdfObject)
    ├─asdf_library (Software)
    │ ├─author (str): The ASDF Developers
    │ ├─homepage (str): http://github.com/asdf-format/asdf
    │ ├─name (str): asdf
    │ └─version (str): 2.8.0
    ├─history (dict)
    │ └─extensions (list)
    │   └─[0] (ExtensionMetadata)
    │     ├─extension_class (str): asdf.extension.BuiltinExtension
    │     └─software (Software)
    │       ├─name (str): asdf
    │       └─version (str): 2.8.0
    ├─foo (int): 42
    ├─name (str): Monty
    ├─powers (dict)
    │ └─squares (NDArrayType): shape=(100,), dtype=int64
    ├─random (NDArrayType): shape=(100,), dtype=float64
    └─sequence (NDArrayType): shape=(100,), dtype=int64

The `AsdfFile` behaves like a Python `dict`, and nodes are accessed like
any other dictionary entry:

.. code:: pycon

    >>> af["name"]
    'Monty'
    >>> af["powers"]
    {'squares': }

Array data remains unloaded until it is explicitly accessed:

.. code:: pycon

    >>> af["powers"]["squares"]
    array([   0,    1,    4,    9,   16,   25,   36,   49,   64,   81,  100,
            121,  144,  169,  196,  225,  256,  289,  324,  361,  400,  441,
            484,  529,  576,  625,  676,  729,  784,  841,  900,  961, 1024,
           1089, 1156, 1225, 1296, 1369, 1444, 1521, 1600, 1681, 1764, 1849,
           1936, 2025, 2116, 2209, 2304, 2401, 2500, 2601, 2704, 2809, 2916,
           3025, 3136, 3249, 3364, 3481, 3600, 3721, 3844, 3969, 4096, 4225,
           4356, 4489, 4624, 4761, 4900, 5041, 5184, 5329, 5476, 5625, 5776,
           5929, 6084, 6241, 6400, 6561, 6724, 6889, 7056, 7225, 7396, 7569,
           7744, 7921, 8100, 8281, 8464, 8649, 8836, 9025, 9216, 9409, 9604,
           9801])

    >>> import numpy as np
    >>> expected = [x**2 for x in range(100)]
    >>> np.equal(af["powers"]["squares"], expected).all()
    True

Memory mapping can be enabled by providing ``memmap=True``
to `open`:

.. code:: python

    af = asdf.open("example.asdf", memmap=True)

.. _end-read-file-text:

For more information and for advanced usage examples, see the
`documentation <#documentation>`__.

Extending ASDF
~~~~~~~~~~~~~~

Out of the box, the ``asdf`` package automatically serializes and
deserializes native Python types. It is possible to extend ``asdf`` by
implementing custom tags that correspond to custom user types. More
information on extending ASDF can be found in the `official
documentation `__.

Installation
------------

.. _begin-pip-install-text:

Stable releases of the ASDF Python package are registered `at
PyPi `__. The latest stable version
can be installed using ``pip``:

::

    $ pip install asdf

.. _begin-source-install-text:

The latest development version of ASDF is available from the ``main`` branch
`on github `__. To clone the project:

::

    $ git clone https://github.com/asdf-format/asdf

To install:

::

    $ cd asdf
    $ pip install .

To install in `development
mode `__::

    $ pip install -e .

.. _end-source-install-text:

Testing
-------

.. _begin-testing-text:

To install the test dependencies from a source checkout of the repository:

::

    $ pip install -e ".[tests]"

To run the unit tests from a source checkout of the repository:

::

    $ pytest

It is also possible to run the test suite from an installed version of
the package.

::

    $ pip install "asdf[tests]"
    $ pytest --pyargs asdf

It is also possible to run the tests using `tox
`__.

::

   $ pip install tox

To list all available environments:

::

   $ tox -va

To run a specific environment:

::

   $ tox -e 


.. _end-testing-text:

Documentation
-------------

More detailed documentation on this software package can be found
`here `__.

More information on the ASDF file format itself can be found
`here `__.

There are two mailing lists for ASDF:

* `asdf-users `_
* `asdf-developers `_

    If you are looking for the **A**\ daptable **S**\ eismic **D**\ ata
    **F**\ ormat, information can be found
    `here `__.

License
-------

ASDF is licensed under a BSD 3-clause style license. See `LICENSE.rst `_
for the `licenses folder `_ for
licenses for any included software.

Contributing
------------

We welcome feedback and contributions to the project. Contributions of
code, documentation, or general feedback are all appreciated. Please
follow the `contributing guidelines `__ to submit an
issue or a pull request.

We strive to provide a welcoming community to all of our users by
abiding to the `Code of Conduct `__.

Owner

  • Name: asdf-format
  • Login: asdf-format
  • Kind: organization

Citation (CITATION.rst)

If you use ASDF for work/research presented in a publication (whether directly,
as a dependency to another package), please cite the Zenodo DOI for the appropriate
version of ASDF.  The versions (and their BibTeX entries) can be found at:

.. only:: html

    .. include:: ../../README.rst
        :start-after: begin-zenodo:
        :end-before: end-zenodo:

.. only:: latex

    .. admonition:: Zenodo DOI

        https://zenodo.org/badge/latestdoi/18112754

We also recommend and encourage you to cite the general ASDF paper and/or its update:

.. code:: bibtex

    @article{GREENFIELD2015240,
    title = {ASDF: A new data format for astronomy},
    journal = {Astronomy and Computing},
    volume = {12},
    pages = {240-251},
    year = {2015},
    issn = {2213-1337},
    doi = {https://doi.org/10.1016/j.ascom.2015.06.004},
    url = {https://www.sciencedirect.com/science/article/pii/S2213133715000645},
    author = {P. Greenfield and M. Droettboom and E. Bray},
    keywords = {FITS, File formats, Standards, World coordinate system},
    abstract = {We present the case for developing a successor format for the immensely successful FITS format. We first review existing alternative formats and discuss why we do not believe they provide an adequate solution. The proposed format is called the Advanced Scientific Data Format (ASDF) and is based on an existing text format, YAML, that we believe removes most of the current problems with the FITS format. An overview of the capabilities of the new format is given along with specific examples. This format has the advantage that it does not limit the size of attribute names (akin to FITS keyword names) nor place restrictions on the size or type of values attributes have. Hierarchical relationships are explicit in the syntax and require no special conventions. Finally, it is capable of storing binary data within the file in its binary form. At its basic level, the format proposed has much greater applicability than for just astronomical data.}
    }

    @InProceedings{ 00_greenfield-proc-scipy-2022,
    author    = { {P}erry {G}reenfield and {E}dward {S}lavich and {W}illiam {J}amieson and {N}adia {D}encheva },
    title     = { {T}he {A}dvanced {S}cientific {D}ata {F}ormat ({A}{S}{D}{F}): {A}n {U}pdate },
    booktitle = { {P}roceedings of the 21st {P}ython in {S}cience {C}onference },
    pages     = { 1 - 6 },
    year      = { 2022 },
    editor    = { {M}eghann {A}garwal and {C}hris {C}alloway and {D}illon {N}iederhut and {D}avid {S}hupe },
    doi       = { 10.25080/majora-212e5952-000 }
    }

GitHub Events

Total
  • Create event: 13
  • Release event: 5
  • Issues event: 106
  • Watch event: 19
  • Delete event: 1
  • Issue comment event: 97
  • Push event: 34
  • Pull request review comment event: 44
  • Pull request review event: 73
  • Pull request event: 94
  • Fork event: 2
Last Year
  • Create event: 13
  • Release event: 5
  • Issues event: 106
  • Watch event: 19
  • Delete event: 1
  • Issue comment event: 97
  • Push event: 34
  • Pull request review comment event: 44
  • Pull request review event: 73
  • Pull request event: 94
  • Fork event: 2

Committers

Last synced: almost 3 years ago

All Time
  • Total Commits: 2,531
  • Total Committers: 53
  • Avg Commits per committer: 47.755
  • Development Distribution Score (DDS): 0.764
Past Year
  • Commits: 629
  • Committers: 12
  • Avg Commits per committer: 52.417
  • Development Distribution Score (DDS): 0.491
Top Committers
Name Email Commits
Daniel D'Avella d****a@s****u 597
William Jamieson w****n@s****u 407
Michael Droettboom m****m@g****m 368
Ed Slavich e****h@s****u 268
Brett b****m@g****m 209
Dan D'Avella d****a@g****m 127
Nadia Dencheva n****a@g****m 64
Thomas Robitaille t****e@g****m 62
pre-commit-ci[bot] 6****]@u****m 50
perrygreenfield p****y@s****u 36
Ken MacDonald k****d@s****u 31
Bernie Simon b****n@s****u 26
zacharyburnett z****t@s****u 26
James Davies j****s@s****u 26
Erik M. Bray e****y@s****u 25
Stuart Mumford s****t@c****m 21
Brigitta Sipocz b****z@g****m 16
Edward Slavich e****h@u****m 15
Vadim Markovtsev v****m@s****h 14
Erik Tollerud e****d@g****m 13
Larry Bradley l****y@g****m 13
Cagtay Fabry 4****y@u****m 12
Ben Greiner c****e@b****e 10
Edward Slavich e****h@j****m 10
Miguel de Val-Borro m****l@a****t 10
Lehman Garrison l****n@f****g 9
P. L. Lim 2****m@u****m 6
Matthew Craig m****g@g****m 6
Christoph Deil D****h@g****m 5
Justin Ely e****y@s****u 4
and 23 more...

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 211
  • Total pull requests: 407
  • Average time to close issues: about 2 years
  • Average time to close pull requests: 25 days
  • Total issue authors: 39
  • Total pull request authors: 15
  • Average comments per issue: 1.59
  • Average comments per pull request: 0.98
  • Merged pull requests: 291
  • Bot issues: 0
  • Bot pull requests: 30
Past Year
  • Issues: 58
  • Pull requests: 117
  • Average time to close issues: about 1 month
  • Average time to close pull requests: 8 days
  • Issue authors: 10
  • Pull request authors: 5
  • Average comments per issue: 0.62
  • Average comments per pull request: 0.68
  • Merged pull requests: 78
  • Bot issues: 0
  • Bot pull requests: 2
Top Authors
Issue Authors
  • braingram (131)
  • WilliamJamieson (14)
  • drdavella (13)
  • eslavich (5)
  • ketozhang (4)
  • Cadair (4)
  • pllim (2)
  • allefeld (2)
  • mdboom (2)
  • eschnett (2)
  • vmarkovtsev (2)
  • CagtayFabry (2)
  • Vital-Fernandez (2)
  • keflavich (1)
  • zacharyburnett (1)
Pull Request Authors
  • braingram (304)
  • zacharyburnett (28)
  • pre-commit-ci[bot] (23)
  • meeseeksmachine (12)
  • WilliamJamieson (9)
  • eslavich (8)
  • dependabot[bot] (7)
  • neutrinoceros (4)
  • alphasentaurii (2)
  • pllim (2)
  • zonca (2)
  • sunpoet (2)
  • mspacek (2)
  • wdconinc (1)
  • eschnett (1)
Top Labels
Issue Labels
feature request (10) bug (10) deprecation (7) enhancement (6) Docs (3) treeutil (3) low priority (1) compression (1) idea (1) good-first-issue (1)
Pull Request Labels
no-changelog-entry-needed (197) Downstream CI (158) development (60) backport-2.15.x (31) dependencies (7) s390x (6) github_actions (5) Manual Backport (3) jsonschema (3) python (2) Benchmarks (2) testing (1)

Packages

  • Total packages: 2
  • Total downloads:
    • pypi 368,702 last-month
  • Total docker downloads: 3,339
  • Total dependent packages: 61
    (may contain duplicates)
  • Total dependent repositories: 101
    (may contain duplicates)
  • Total versions: 109
  • Total maintainers: 8
pypi.org: asdf

Python implementation of the ASDF Standard

  • Versions: 72
  • Dependent Packages: 50
  • Dependent Repositories: 90
  • Downloads: 368,702 Last month
  • Docker Downloads: 3,339
Rankings
Dependent packages count: 0.3%
Downloads: 1.2%
Average: 1.2%
Dependent repos count: 1.6%
Docker downloads count: 1.6%
Last synced: 6 months ago
conda-forge.org: asdf

Python library for reading and writing ASDF files. The Advanced Scientific Data Format (ASDF) is a next generation interchange format for scientific data.

  • Versions: 37
  • Dependent Packages: 11
  • Dependent Repositories: 11
Rankings
Dependent packages count: 5.5%
Dependent repos count: 10.7%
Average: 14.8%
Stargazers count: 18.1%
Forks count: 24.9%
Last synced: 6 months ago

Dependencies

pyproject.toml pypi
  • asdf-standard >=1.0.1
  • asdf-transform-schemas >=0.3
  • asdf-unit-schemas >=0.1
  • importlib-metadata >=4.11.4
  • importlib_resources >=3; python_version < "3.9"
  • jmespath >=0.6.2
  • jsonschema >=4.0.1
  • numpy >=1.20
  • numpy <1.25,>=1.20; python_version < "3.9"
  • packaging >=19
  • pyyaml >=5.4.1
  • semantic_version >=2.8
.github/workflows/changelog.yml actions
  • actions/checkout v2 composite
.github/workflows/s390x.yml actions
  • actions/checkout v3 composite
  • uraimo/run-on-arch-action v2 composite
requirements-dev.txt pypi
  • numpy >=0.0.dev0 development
  • scipy >=0.0.dev0 development
.github/workflows/ci.yml actions
.github/workflows/downstream.yml actions
.github/workflows/publish-to-pypi.yml actions
.github/workflows/scheduled.yml actions
asdf/_jsonschema/json/package.json npm