ccplot

CloudSat and CALIPSO plotting tool

API reference

ccplot.hdf

class HDF(filename, encoding=’utf-8’, mode=None)

This is a class for reading HDF files. The class supports reading of:

The constructor accepts a filename, text encoding and mode. Mode signifies if the file should be opened in a binary or text mode: None (automatic), binary (binary mode) or text (text mode). If mode is None, it is equivalent to binary if the type of filename is bytes and text if the type is str.

from ccplot.hdf import HDF
product = HDF('CAL_LID_L1-ValStage1-V3-02.2013-01-01T11-55-23ZN.hdf')

The file can be closed with HDF.close(), or by using the Context Manager interface:

with HDF('CAL_LID_L1-ValStage1-V3-02.2013-01-01T11-55-23ZN.hdf') as product:
    # Work with the file.

Reading datasets and Vdata

Datasets and Vdata are accessible as dictionary items of the HDF class instance:

lat = product['Latitude']
print(lat[0])
--> [ 72.14601898]
metadata = product['metadata']
print(metadata['Product_ID'])
--> L1_LIDAR_Science

When accessing datasets, an instance of Dataset class is returned. This instance is turned into a numpy array on index subsetting:

type(lat)
--> <class 'ccplot.hdf.Dataset'>
type(lat[::])
--> <type 'numpy.ndarray'>

Listing datasets

A list of datasets can retrieved with HDF.keys():

print('\n'.join(product.keys()))
--> Profile_Time
    Profile_UTC_Time
    Profile_ID
    Land_Water_Mask
    [...]
    Subsolar_Longitude
    metadata

Attributes

File and dataset attributes are accessible as HDF.attributes and Dataset.attributes, respectively:

print(dict(lat.attributes))
--> {'units': 'degrees', 'valid_range': '-90.0 ... 90.0', 'fillvalue': -9999.0, 'format': 'Float_32'}
print(product.attributes.keys())
--> ['coremetadata', 'archivemetadata']
print(product.attributes['coremetadata'])
--> GROUP                  = INVENTORYMETADATA
    [...]
    END_GROUP              = INVENTORYMETADATA

    END

ccplot.hdfeos

class HDFEOS(filename, encoding=’utf-8’, mode=None)

This is a class for reading HDFEOS-2 files. The class supports reading of:

The constructor accepts a filename, text encoding and mode. Mode signifies if the file should be opened in a binary or text mode: None (automatic), binary (binary mode) or text (text mode). If mode is None, it is equivalent to binary if the type of filename is bytes and text if the type is str.

from ccplot.hdfeos import HDFEOS
product = HDFEOS('2013119200420_37263_CS_2B-GEOPROF_GRANULE_P_R04_E06.hdf')

The file can be closed with HDFEOS.close(), or by using the Context Manager interface:

with HDFEOS('2013119200420_37263_CS_2B-GEOPROF_GRANULE_P_R04_E06.hdf') as product:
    # Work with the file.

Reading swath and datasets

Swaths are available as dictionary items of the HDFEOS instance:

sw = product['2B-GEOPROF']

When accessing swaths, an instance of Swath class is returned.

Datasets are available as dictionary items of a swath:

lat = sw['Latitude']
print(lat[0])
--> -64.9139

When accessing datasets, an instance of Dataset class is returned. This instance is turned into a numpy array on index subsetting:

type(lat)
--> <class 'ccplot.hdfeos.Dataset'>
type(lat[::])
--> <type 'numpy.ndarray'>

Listing swaths and datasets

A list of swaths can retrieved with HDFEOS.keys():

print('\n'.join(product.keys()))
--> 2B-GEOPROF

A list of datasets can be retrieved with Swath.keys():

print('\n'.join(sw.keys()))
--> Profile_time
    UTC_start
    TAI_start
    Latitude
    Longitude
    ...

Attributes

Attributes are accessible as HDFEOS.attributes, Swath.attributes and Dataset.attributes:

print(product.attributes.keys())
--> ['HDFEOSVersion', 'StructMetadata.0']
print(sw.attributes['start_time'])
--> '20130429203541'
print(sw['Radar_Reflectivity'].attributes['long_name'])
--> 'Radar Reflectivity Factor'

ccplot.algorithms

interp2d_12(data, X, Z, x1, x2, nx, z1, z2, nz)

Interpolate 2D data array distributed on coordinates X and Z on a regular grid given by (x1, x2, nx) and (z1, z2, nz).

The interpolation is done by averaging all data points affecting a single element of the regular grid. When the resolution of the regular grid is greater than the resolution of data, this is equivalent to nearest-neighbor interpolation.

ccplot.utils

calipso_time2dt(time)

Convert float in format yymmdd.ffffffff to datetime.

cloudsat_time2dt(time, start_time)

Convert time in seconds since start_time (datetime instance) to datetime.

cmap(filename)

Load ccplot colormap from file filename. Return a dictionary with keys:

RGBA values are represented as integers between 0 and 255.