Skip to main content

Simple pure-python AVM meta-data handling

Project description

Build Status Coverage Status

About

PyAVM is a module to represent, read, and write metadata following the *Astronomy Visualization Metadata* (AVM) standard.

Requirements

PyAVM supports Python 3.8 and later. No other dependencies are needed simply to read and embed AVM meta-data.

However, the following optional dependencies are needed for more advanced functionality:

Installing and Reporting issues

PyAVM can be installed with pip:

pip install pyavm

Please report any issues you encounter via the issue tracker on GitHub.

Using PyAVM

Importing

PyAVM provides the AVM class to represent AVM meta-data, and is imported as follows:

>>> 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):

>>> 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

>>> print(avm)

The AVM meta-data can be accessed using the attribute notation:

>>> avm.Spatial.Equinox
'J2000'
>>> avm.Publisher
'Chandra X-ray Observatory'

Tags can be modified:

>>> 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:

>>> 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:

>>> avm = AVM(version=1.1)

Converting to a WCS object

It is possible to create an Astropy WCS object from the AVM meta-data:

>>> 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:

>>> 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:

>>> 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:

>>> 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:

>>> 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:

>>> avm.embed('original_image.jpg', 'tagged_image.jpg')

At this time, only JPG and PNG files are supported for embedding.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyavm-0.9.8.tar.gz (223.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyavm-0.9.8-py3-none-any.whl (378.8 kB view details)

Uploaded Python 3

File details

Details for the file pyavm-0.9.8.tar.gz.

File metadata

  • Download URL: pyavm-0.9.8.tar.gz
  • Upload date:
  • Size: 223.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pyavm-0.9.8.tar.gz
Algorithm Hash digest
SHA256 ce11c279ec75bdf823d0c386124a1528a5e7b36fa5dd4d26499227939f117f88
MD5 f8e2fe2339b1c88f855fb20de1c8e30e
BLAKE2b-256 13eb67cf343cb6b6a6048eab9ecde6bc9dfdbbeea3e4ec60639ca2b1ffcd6cf6

See more details on using hashes here.

File details

Details for the file pyavm-0.9.8-py3-none-any.whl.

File metadata

  • Download URL: pyavm-0.9.8-py3-none-any.whl
  • Upload date:
  • Size: 378.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pyavm-0.9.8-py3-none-any.whl
Algorithm Hash digest
SHA256 fba0f6cd43e729cb50509ffcf54d7abd2aeb3ce3dd3b1ea40b3e0f6e6eb3d917
MD5 cb090eb78fb5485e0878aea51a02a93a
BLAKE2b-256 53d3b00f483c5e6ec7a6fc70dcd8198443dc5f0ffd914f2925f3b89e3319630f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page