pds4_tools.reader.read_headers module

Functions

read_header(full_label, header_label, ...[, ...])

Create the HeaderStructure, containing label, data and meta data for a PDS4 Header from a file.

read_header_data(header_structure)

Reads the data for a single PDS4 header structure, modifies header_structure to contain said data.

new_header(input, **structure_kwargs)

Create an header structure from PDS-compliant data.

Details

read_header(full_label, header_label, data_filename, lazy_load=False, decode_strings=False)[source]

Create the HeaderStructure, containing label, data and meta data for a PDS4 Header from a file.

Headers refer to PDS4 header data structures, which typically describe a portion of the data that serves as a header for some other data format.

Parameters
full_labelLabel

The entire label for a PDS4 product, from which header_label originated.

header_labelLabel

Portion of label that defines the PDS4 header data structure.

data_filenamestr or unicode

Filename, including the full path, of the data file that contains the data for this header.

lazy_loadbool, optional

If True, does not read-in the data of this header until the first attempt to access it. Defaults to False.

decode_stringsbool, optional

If True, the header data will be decoded to the unicode type in Python 2, and to the str type in Python 3. If False, leaves said data as a byte string. Defaults to False.

Returns
HeaderStructure

An object representing the header; contains its label, data and meta data

Raises
TypeError

Raised if called on a non-header according to header_label.

read_header_data(header_structure)[source]

Reads the data for a single PDS4 header structure, modifies header_structure to contain said data.

Parameters
header_structureHeaderStructure

The PDS4 Header data structure to which the data should be added.

Returns
None
new_header(input, **structure_kwargs)[source]

Create an header structure from PDS-compliant data.

Parameters
inputbytes, str or unicode

A string or bytes containing the data for header.

structure_kwargsdict, optional

Keywords that are passed directly to the HeaderStructure constructor.

Returns
HeaderStructure

An object representing the PDS4 header structure. The data attribute will contain input. Other attributes may be specified via structure_kwargs.