icartt

icartt is an ICARTT file format reader and writer

The ICARTT data format is described here: https://www-air.larc.nasa.gov/missions/etc/IcarttDataFormat.htm

Installation

pip install icartt

Example

import icartt

# load a new dataset from an existing file
ict = icartt.Dataset('path/to/example.ict')

# list variable names
ict.varnames
# e.g. ['Fractional_Day', 'UTC', 'JDAY', 'INDEX', 'FLIGHT', 'LOCAL_SUN_TIME', ...

# get data for variable 'UTC':
ict['UTC']

# some metadata
ict.organization
ict.dataSource
ict.mission

# write to (other) file:
with open('path/to/output.ict', 'wb') as f:
   ict.write(f)

API

Variable

class icartt.Variable(name, units, scale=1.0, miss=-9999999)

A Variable is a ICARTT variable description with name, units, scale and missing value.

desc

Return variable description string as it appears in an ICARTT file

miss = None

Missing value (string, just as it appears in the ICARTT file)

name = None

Name

scale = None

Scale factor

splitChar = None

Split character for description string

units = None

Units

Dataset

class icartt.Dataset(f=None, loadData=True, splitChar=', ')

An ICARTT dataset that can be created from scratch or read from a file, manipulated, and then written to a file.

index(name)

Index of variable <name> in data array

make_filename()

Create ICARTT-compliant file name based on the information contained in the dataset

read()

Read ICARTT data and header

read_data()

Read ICARTT data (from file)

read_first_and_last()

Read first and last ICARTT data line (from file). Useful for quick estimates e.g. of the time extent of big ICARTT files, without having to read the whole thing, which would be slow.

read_header()

Read the ICARTT header (from file)

units(name)

Units of variable <name>

write(f=<open file '<stdout>', mode 'w'>)

Write to file handle <f>

VAR

Variables (independent and dependent)

nauxvar

Auxiliary variables count

ndvar

Dependent variable count

nheader

Header line count

nncom

Normal comments count

nscom

Special comments count

nvar

Variable count (independent + dependent)

times

Time steps of the data contained.

varnames

Names of variables (independent and dependent)