Skip to main content

Routines for converting to and from VICAR image files

Project description

GitHub release; latest by date GitHub Release Date Test Status Documentation Status Code coverage
PyPI - Version PyPI - Format PyPI - Downloads PyPI - Python Version
GitHub commits since latest release GitHub commit activity GitHub last commit
Number of GitHub open issues Number of GitHub closed issues Number of GitHub open pull requests Number of GitHub closed pull requests
GitHub License Number of GitHub stars GitHub forks

Introduction

vicar is a Python module that supports reading and writing of JPL's VICAR file format. It supports the definition of the VICAR file format as found here: https://pds-rings.seti.org/help/VICAR_file_fmt.pdf

Installation

The vicar module is available via the rms-vicar package on PyPI and can be installed with:

pip install rms-vicar

Getting Started

The vicar module provides these classes:

  • VicarLabel: Class for reading, writing, and parsing of VICAR labels.
  • VicarImage: Class for handling VICAR image (and other) data files.
  • VicarError: Extension of class ValueError to contain exceptions.

Details of each class are available in the module documentation.

To read a VICAR image file:

import vicar
vic = vicar.VicarImage("path/to/file")

(The file path can be any URL accepted by FCPath.)

The resulting object contains:

  • vic.array: The 3-D data array converted to native format.
  • vic.array2d: Same as above, but with leading dimension (typically, bands) stripped.
  • vic.prefix: The array prefix bytes as a 3-D array of unsigned bytes.
  • vic.prefix2d: Same as above, but with the leading dimension stripped.
  • vic.binheader: The binary header as a bytes object; use vic.binheader_array() to extract information.
  • vic.label: The internal VicarLabel object that manages the VICAR label information, if direct access is needed.

VICAR parameter values can be extracted from the label using dictionary-like syntax:

  • len(vic): The number of parameters in the VICAR label.
  • vic['LBLSIZE']: The value of the LBLSIZE parameter (an integer).
  • vic[0]: The value of the first parameter.
  • vic[-1]: The value of the last parameter.
  • vic['LBLSIZE',-1]: The value of the last occurrence of the LBLSIZE parameter.
  • vic.get(('LBLSIZE',2), 99): The value of the third occurrence of the LBLSIZE parameter, or 99 if there are fewer than 3 occurrences.
  • vic.arg('LBLSIZE'): The numeric index of "LBLSIZE" among the VICAR parameters.

You can also use dictionary-like syntax to modify and insert header values:

  • vic['SOLDIST'] = 1.e9: Set SOLDICT to this value.
  • del vic['SOLDIST',0]: Remove the first occurrence of SOLDIST from the label.
  • vic['LBLSIZE+'] = 2000: Insert a new LBLSIZE parameter instead of modifying an existing one.

Note that certain required VICAR parameters contain structural information about the file; these cannot generally be modified directly.

Numerous methods are available to iterate over the VICAR label parameters:

for (name,value) in vic.items(): ...
for key in vic.keys(): ...
for name in vic.names(): ...
for value in vic.values(): ...

Iterators can take a regular expression as input to restrict the items returned:

for value in vic.values(r'LAB\d\d'): ...

Use str(vic) to get the VICAR label content represented as a string.

Here are the steps to create and write a VICAR image file:

import vicar
vic = vicar.VicarImage()
vic.array = array
vic.prefix = prefix
vic.binheader = binheader
vic['NOTES'] = ['add as many more VICAR parameters', 'as you wish']
vic.write_file("path/to/file")

Contributing

Information on contributing to this package can be found in the Contributing Guide.

Links

Licensing

This code is licensed under the Apache License v2.0.

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

rms_vicar-1.2.1.tar.gz (5.6 MB view details)

Uploaded Source

Built Distribution

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

rms_vicar-1.2.1-py3-none-any.whl (41.4 kB view details)

Uploaded Python 3

File details

Details for the file rms_vicar-1.2.1.tar.gz.

File metadata

  • Download URL: rms_vicar-1.2.1.tar.gz
  • Upload date:
  • Size: 5.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rms_vicar-1.2.1.tar.gz
Algorithm Hash digest
SHA256 3a8e3347f5edc84030248cbacba75d56601085d63db2e1c4c408f4978910d9c5
MD5 e5bc359a78965544b3f551e0d5d76b42
BLAKE2b-256 c50622258182287400fcaa7bc7f247c7cf238aa26d1a1c90576ef571123921d2

See more details on using hashes here.

File details

Details for the file rms_vicar-1.2.1-py3-none-any.whl.

File metadata

  • Download URL: rms_vicar-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 41.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rms_vicar-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3b4b30415b30b54fc35f99a52cbe1a3fbd700a8de21298e84bd82245517910e0
MD5 e46f03f10d8d4087677221dc5919e03d
BLAKE2b-256 4fd899caf1f11394068b23c02f78ebe6228ed388c7bdd7ba85a811d52b219d7b

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