API reference

This page provides a summary of cerbere’s API. For more details and examples, refer to the relevant chapters in the main part of the documentation.

Dataset

The base class for Dataset objects, than can be imported from cerbere.dataset.dataset module. All other classes in cerbere.dataset package are derived from this class.

Creating a dataset

Dataset([dataset, mode, view, dim_matching, …])

The cerbere dataset base class.

Attributes

Dataset.dims

Mapping from dimension names to lengths.

Dataset.sizes

Mapping from dimension names to lengths.

Dataset.dimnames

Tuple of the dataset’s dimension names

Dataset.dimsizes

Tuple of the dataset’s dimension sizes

Dataset.fieldnames

The names of the geophysical fields of the mapper.

Dataset.coordnames

List of names of the coordinate fields of the dataset.

Dataset.geocoordnames

List of names of the geospatial coordinate fields of the dataset.

Dataset.geocoords

List of geolocation coordinates (as Field objects)

Dataset.get_field(fieldname)

Return the Field object corresponding to the requested field name.

Dataset.get_field_dims(fieldname)

Tuple of the dimension names of a field in the dataset

Dataset.add_field(field)

Add a field to the feature.

Dataset.attrs

Mapping from global attribute names to value.

Dataset.bbox

The bounding box, e.g.

Dataset.wkt_bbox

The bounding box in WKT format.

Dataset.time_coverage_start

Minimum sensing time of the data contained in the dataset

Dataset.time_coverage_end

Maximum sensing time of the data contained in the dataset

Dataset.url

Return the url of the file storing the dataset

Dataset.basename

Return the basename of the file storing the dataset

Dataset.filesize

The dataset file size, in octets

Dataset.file_creation_date

The date the dataset file was generated

Dataset contents

Dataset.exists(url)

Returns True if url is an existing resource

Dataset.has_field(fieldname)

Return True if the field fieldname exists in the dataset.

Dataset.rename_field(name, newname)

Rename a field.

Dataset.get_values(fieldname[, index, …])

Read the data of a field.

Dataset.set_values(fieldname, values[, index])

set the values of a field.

Dataset.get_lat(**kwargs)

Return the latitude values of a feature.

Dataset.get_lon(**kwargs)

Return the longitude values of a feature.

Dataset.get_times(**kwargs)

Return the times of a feature.

Dataset.get_datetimes([slices, indices])

Return the time values of a feature as datetime objects.

Dataset.to_xarray()

returns the Dataset as a xarray dataset object.

Dataset subsetting

Dataset.extract([index, fields, padding, …])

Extract a subset of the dataset.

Dataset.clip(geometry[, masked, …])

Return the dataset subsets within a geographical area.

Dataset.clip_values(fieldname, geometry[, …])

Return the data of a field within a geographical area.

Other built-in datasets

ncdataset.NCDataset(*args[, format])

CF compliant NetCDF Dataset

ghrsstncdataset.GHRSSTNCDataset(*args, **kwargs)

GHRSST GDS 2.x compliant NetCDF Dataset.

Field

Creating a field

Field(data[, name, dims, dtype, components, …])

A Field describes a scientific data array.

Field.to_field(data)

Cast a xarray DataArray to a cerbere.datamodel.field.Field object

Attributes

Field.name

Name of the field

Field.dims

A tuple of the field dimensions name and size

Field.dimnames

Tuple of the field’s dimension names

Field.dtype

The type of the field data

Field.description

The field description (long_name CF attribute)

Field.standard_name

The field standard name (standard_name CF attribute)

Field.fill_value

The value for missing data in the field

Field.valid_min

The minimum valid value in the field data

Field.valid_max

The maximum valid value in the field data

Field.units

The field data units (units CF attribute)

Field.attrs

A dict of the field attributes

Field contents

Field.clone([index, padding, prefix])

Create a copy of a field, or a subset defined by index, and padding out as required.

Field.rename(newname)

Rename the field inplace.

Field.bitmask_or(meanings[, index])

helper function to test specific bits in a CF compliant mask

Field.get_values([index, padding])

Return the field values as a numpy.ma.MaskedArray object.

Field.set_values(values[, index])

set the values of a field.

Field.to_dataarray()

Return the field values a xarray DataArray

Field.compute(func, field1[, field2])

Apply a function to a field (possibly combining with a second one)

Field.module()

Return the module field from its eastward and northward components.

Feature

A Feature object inherits all the attributes and methods of a Dataset object. It provides in addition the following methods and attributes.

Creating a feature

The generic method to create or open from a file a feature is cerbere.open_as_feature(). It allows to instantiate any of the following features.

point.Point(*args, **kwargs)

Feature class for a set of randomly sampled points.

profile.Profile(*args, **kwargs)

Feature class for the profile observation patterns.

trajectory.Trajectory(*args[, force_reorder])

Feature class for the trajectory observation patterns.

timeseries.TimeSeries(*args, **kwargs)

Feature class for the time series observation patterns.

timeseriesprofile.TimeSeriesProfile(*args, …)

Feature class for the time series of profiles observation pattern.

trajectoryprofile.TrajectoryProfile(*args, …)

Feature class for the section observation patterns.

swath.Swath(*args, **kwargs)

Feature class for representing a swath, a two-dimensional irregular grid along the satellite track.

grid.Grid(*args[, projection])

Model class for the grid feature, ie a two-dimensional array on fixed projection, resolution and boundaries.

gridtimeseries.GridTimeSeries(*args[, …])

Class implementing a time series of grids

Additional collection feature class, as defined by CF convention:

cracollection.CRACollection imdcollection.IMDCollection omdcollection.OMDCollection

Attributes

Feature.feature_type

Return the type of the feature

Feature.geodims

Returns the names and sizes of the geolocation dimensions.

Feature.geodimnames

A tuple of the dataset geolocation dimension names

Feature.geodimsizes

A tuple of the dataset geolocation dimension sizes

Feature contents

Feature.extract(*args[, bbox, footprint])

Extract a subset as a new Feature object.

Feature.append(feature, prefix[, fields])

Append the fields from another feature