About
-----
PyAVM is a module to represent, read, and write metadata following the
`*Astronomy Visualization
Metadata* <http://www.virtualastronomy.org/avm_metadata.php>`__ (AVM)
standard.
Requirements
------------
PyAVM supports Python 2.7 and 3.5+. No other dependencies are needed
simply to read and embed AVM meta-data.
However, the following optional dependencies are needed for more
advanced functionality:
- `Astropy <http://www.astropy.org>`__ to handle WCS objects and FITS
headers
- `py.test <http://www.pytest.org>`__ and
`PIL <http://www.pythonware.com/products/pil/>`__ for tests
Installing and Reporting issues
-------------------------------
PyAVM can be installed with pip::
pip install pyavm
Please report any issues you encounter via the `issue
tracker <https://github.com/astrofrog/pyavm/issues>`__ on GitHub.
Using PyAVM
-----------
Importing
~~~~~~~~~
PyAVM provides the ``AVM`` class to represent AVM meta-data, and is
imported as follows:
.. code:: python
>>> from pyavm import AVM
Parsing files
~~~~~~~~~~~~~
To parse AVM meta-data from an existing image, simply call the
``from_image`` class method using the filename of the image (or any
file-like object):
.. code:: python
>>> avm = AVM.from_image('myexample.jpg')
Only JPEG and PNG files are properly supported in that the parsing
follows the JPEG and PNG specification. For other file formats, PyAVM
will simply scan the contents of the file, looking for an XMP packet.
This method is less reliable, but should work in most real-life cases.
Accessing and setting the meta-data
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You can view the contents of the AVM object by using
.. code:: python
>>> print(avm)
The AVM meta-data can be accessed using the attribute notation:
.. code:: python
>>> avm.Spatial.Equinox
'J2000'
>>> avm.Publisher
'Chandra X-ray Observatory'
Tags can be modified:
.. code:: python
>>> avm.Spatial.Equinox = "B1950"
>>> avm.Spatial.Notes = "The WCS information was updated on 04/02/2010"
Creating an AVM object from scratch
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To create an empty AVM meta-data holder, simply call ``AVM()`` without
any arguments:
.. code:: python
>>> avm = AVM()
Note that this will create an AVM object following the 1.2
specification. If necessary, you can specify which version of the
standard to use:
.. code:: python
>>> avm = AVM(version=1.1)
Converting to a WCS object
~~~~~~~~~~~~~~~~~~~~~~~~~~
It is possible to create an Astropy WCS object from the AVM meta-data:
.. code:: python
>>> wcs = avm.to_wcs()
By default, ``Spatial.FITSheader`` will be used if available, but if
not, the WCS information is extracted from the other ``Spatial.*`` tags.
To force PyAVM to not try ``Spatial.FITSheader``, use:
.. code:: python
>>> wcs = avm.to_wcs(use_full_header=False)
Initializing from a FITS header
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To create an AVM meta-data object from a FITS header, simply pass the
header (as an Astropy Header instance) to the ``from_header`` class
method:
.. code:: python
>>> from astropy.io import fits
>>> header = fits.getheader('image.fits')
>>> avm = AVM.from_header(header)
By default, the AVM tag ``Spatial.FITSheader`` will be created,
containing the full header (in addition to the other ``Spatial.*``
tags). This can be disabled with:
.. code:: python
>>> avm = AVM.from_header(header, include_full_header=False)
Initializing from a WCS object
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Similarly, it is possible to create an AVM meta-data object from an
Astropy WCS instance:
.. code:: python
>>> from astropy.wcs import WCS
>>> from pyavm import AVM
>>> wcs = WCS('image.fits')
>>> avm = AVM.from_wcs(wcs)
Tagging images with AVM meta-data
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
It is possible to embed AVM meta-data into an image file:
.. code:: python
>>> avm.embed('original_image.jpg', 'tagged_image.jpg')
At this time, only JPG and PNG files are supported for embedding.
.. |Build Status| image:: https://travis-ci.org/astrofrog/pyavm.svg?branch=master
:target: https://travis-ci.org/astrofrog/pyavm
.. |Coverage Status| image:: https://coveralls.io/repos/astrofrog/pyavm/badge.svg?branch=master
:target: https://coveralls.io/r/astrofrog/pyavm?branch=master
Metadata
Release files for PyAVM 0.9.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| PyAVM-0.9.3.tar.gz | 220.8 kB | Without provenance | Details for PyAVM-0.9.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| PyAVM-0.9.3-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for PyAVM-0.9.3-py2.py3-none-any.whl |
Total release size: 598.6 kB
Release files / PyAVM-0.9.3.tar.gz
| Download URL | PyAVM-0.9.3.tar.gz |
|---|---|
| Size | 220.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ea90ddfbc3c8705f21ca24e205dc0208510905b5b69829db38c7d0e53928873a
|
|
BLAKE2b-256 checksum How to use checksums |
90d56baa5efffc59b626038e4eebdd4d70ae11d68eb5439cdd9cbd951910458b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / PyAVM-0.9.3-py2.py3-none-any.whl
| Download URL | PyAVM-0.9.3-py2.py3-none-any.whl |
|---|---|
| Size | 377.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
1fe364233367885b2de5bcee81eb13414303c3c73348185ff7d6263c16b2c7d4
|
|
BLAKE2b-256 checksum How to use checksums |
6fbe3296859eedef19cdb2857f855e349e2b7cccb1a7c4d7c50ae9ed7c04cb3e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for PyAVM 0.9.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.