Example Python Reader for PDS4 Images
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.
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
- Open the label.
- Find the data product file name.
- Determine the Array_2D_Image data type, shape, and axis order.
- Read in the data array.
- Return the array.
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.