Example Python Reader for PDS4 Images

From The SBN Wiki
Revision as of 22:01, 19 May 2015 by Kelley (talk | contribs) (Created page with " == Introduction == This document describes how to use Python to read in an image from a PDS4 data product. The code will not validate the label, but will read the data base...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Introduction

This document describes how to use Python to read in an image from a PDS4 data product. The code will not validate the label, but will read the data based on the label keywords. The code below is limited to reading BOPPS BIRC images, but can be used as an example for other arrays.

Requirements

This example assumes the user is running Python 2.7, with a recent NumPy package installed. The visualization example uses matplotlib.

Goal and Method

The goal is to read in an image from a BOPPS BIRC data product into a Numpy array. We will provide the script with the name of the label, the script will then

  1. Open the label.
  2. Find the data product file name.
  3. Determine the Array_2D_Image data type, shape, and axis order.
  4. Read in the data array.
  5. Return the array.

Implementation

For this basic example, we designed the reader as a function in a module named birc. The user calls a single function, birc.read_image(), passing the name of the label as the first argument. The function will load the label using the ElementTree module.

The