PyAVM

Simple pure-python AVM meta-data parsing
Download

PyAVM Ranking & Summary

Advertisement

  • Rating:
  • License:
  • MIT/X Consortium Lic...
  • Publisher Name:
  • Thomas Robitaille
  • Publisher web site:

PyAVM Tags


PyAVM Description

Simple pure-python AVM meta-data parsing PyAVM is a Python module that provides the AVM() class to represent AVM metadata: >>> from pyavm import AVMParsing filesTo parse AVM meta-data from an existing file, simply create an instance of the AVM class using the filename of the image (or any file-like object): >>> avm = AVM('myexample.jpg')Accessing the meta-dataYou can view the contents of the avm object by using >>> print avmThe AVM meta-data can be accessed using the attribute notation: >>> avm.Spatial.Equinox 'J2000' >>> avm.Publisher 'Chandra X-ray Observatory'Creating and Updating tagsTags can be modified in place: >>> avm.Spatial.Equinox = "B1950"If the tag does not already exist, it is created.Tag groups can be created using: >>> avm.create_group("Spatial")after which tags can be created in the group: >>> avm.Spatial.Notes = "The WCS information was updated on 04/02/2010"Creating an AVM object from scratchTo create an empty AVM meta-data holder, simply call AVM() without any arguments: >>> avm = AVM()Converting to a WCS objectIt is possible to create a pywcs.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 headerTo create an AVM meta-data object from a FITS header, simply pass the header (as a pyfits.Header instance) instead of a filename when initializing the AVM object: >>> import pyfits >>> header = pyfits.getheader('image.fits') >>> avm = AVM(header)By default, the AVM tag Spatial.FITSheader will be created, containing the full header (in addition to the other Spatial.* keywords). This can be disabled with: >>> avm = AVM(header, include_full_header=False)Initializing from a WCS objectSimilarly, it is possible to create an AVM meta-data object from a pywcs.WCS instance: >>> import pyfits >>> import pywcs >>> from pyavm import AVM >>> wcs = pywcs.WCS(pyfits.getheader('image.fits')) >>> avm = AVM(wcs)Tagging images with AVM meta-dataIt is possible to embed AVM meta-data into an image file: >>> avm.embed('original_image.jpg', 'tagged_image.jpg')At this time, only JPG, PNG, and TIFF files are supported. Requirements: · Python


PyAVM Related Software