datamodel Package

datamodel Package

abstractfeature Module

Abstract class for all data feature objects

copyright:Copyright 2013 Ifremer / Cersat.
license:Released under GPL v3 license, see license.
class cerbere.datamodel.abstractfeature.AbstractFeature(identifier=None, title=None, description=None, source=None, metadata=None, fields=None, longitudes=None, latitudes=None, depths=None, times=None, bbox=None, spatial_resolution=None)[source]

Bases: object

Abstract class for all feature objects

Parameters:
  • fields (OrderedDict) – a dictionary of Field objects to be added to the feature content, where the key is a field identifier
  • bbox (tuple) – describes the limites of the covered geographical area as a tuple (lonmin,latmin,lonmax,latmax)
  • times – must be either an array of datetime objects or a tuple (values, units) where values is an array of numbers and units is expressed in CF convention (ex: ‘seconds since 1981-01-01 00:00:00’)
add_field(field, new=True)[source]

Add a field to the feature.

Parameters:
  • field (Field) – the field is described by a Field object, containing the actual array of data values (or only a storage descriptor when the data have not yet been read from the files) and the description of the observed quantity.
  • new (boolean) – True if is a new field (default), False if it is already saved on disk. For internal usage only as from user perspective you will add new fields only to a feature.
append(feature, prefix, fields=None)[source]

Append the fields of another feature

It is assumed the two features do not share any dimension. The appended feature (child) is considered as ancillary fields and looses its model properties. The feature model is the one of the receiving (parent) feature.

Parameters:
  • feature (AbstractFeature derived class) – the feature to append.
  • prefix (str) – prefix to use for naming the fields of the appended feature (to avoid conflicts with the existing fields of the current feature).
  • fields (list of str) – a list of fieldnames specifying which fields are to be appended. By default, all fields of the feature are appended.
check_storage_matching()[source]

Check that the data storage fits the feature.

Verify the existence of required geolocation fields and dimensions.

extract_field(fieldname, slices=None, indices=None, padding=False, prefix=None)[source]

Create a copy of an field, limiting to a set of slices or indices, and padding out as required.

Args

fieldname: The name of the field to extract

slices: slices of the geolocation dimensions, in case
sub-setting is required

indices: indices to pe passed to the extraction method.

padding: True to pad out feature with fill values to the extent
of the dimensions.
prefix (str): add a prefix string to the field names of the
extracted subset.
extract_subset(boundaries=None, slices=None, fields=None, prefix=None)[source]

Extract a subset feature from the feature.

The created subset is a new feature object of the same class without any reference to the source.

Parameters:
  • boundaries (tuple) – area of the subset to extract, defined as llcrnrlon, llcrnrlat, urcrnrlon, urcrnrlat.
  • slices (dict) – indices for /time/ dimension of the subset to extract from the source data. If None, the complete feature is extracted.
  • fields (list) – list of field names to extract. If None, all fields are extracted.
  • padding (bool) – Passed to extract_field method to ensure padding with _FillValues for points outside of the bounds of the this feature (used only in conjuncture with slices.
  • prefix (str) – add a prefix string to the field names of the extracted subset.
get_bbox()[source]

returns the bounding box, e.g. the south/north and east/west limits of the feature.

Returns:the bounding box, always expressed as a tuple (lon min, lat_min, lon_max, lat_max)
Return type:tuple
get_datetimes(slices=None, indices=None, cache=False, **kwargs)[source]

Return the time values of a feature as datetime objects.

Subsets can be returned by using either slices or indices arguments. slices and indices are exclusive and can not be both specified. Both must be provided as dictionaries where keys are the names of the dimensions to subset. Values are slice objects in the case of slice argument and numbers in the case of indices argument. Only the subsetted dimensions need to be provided (the full range s assumed for the other dimensions).

Parameters:
  • slices (dictionary) – a dictionary where keys are the dimensions to slice and values are slice objects.
  • indices (list) – a dictionary where keys are the dimensions to slice and values are slice objects.
  • cache (bool) – if cache is True, the data read from file are kept in memory. The full field data array is kept in cache, slices or indices are ignored by caching (though the result returned by this function will be a subset if slices or indices are provided. Use the view concept in mappers instead if you want frequent accesses to a subset of a file. Default is False.
Returns:

the requested data.

Return type:

numpy.ma.array<datetime>

Warning

To be used with caution as conversion to datetime objects can take a long time. Use only when accessing single elements for instance.

get_end_time()[source]

Return end time of feature’s temporal coverage.

Returns:end time of temporal coverage. None if no valid time was found.
Return type:datetime
get_field(fieldname)[source]

Return a field from the feature

get_fieldnames()[source]

Return the names of the data fields stored in the feature

get_geolocation_dimnames()[source]

Returns the geolocation dimensions defining the feature

Returns:the list of geolocation dimensions, using their standard name.
Return type:list<string>

Note

Abstract function to be overriden.

get_geolocation_dims(fieldname)[source]

Return the dimensions of a geolocation field

Returns:an ordered dictionary where key/values are the dimension names and sizes
Return type:dict
get_geolocation_dimsizes()[source]

Returns the geolocation dimensions defining the feature.

Note

Abstract function to be overriden.

get_geolocation_field(fieldname)[source]

Return a geolocation field from the feature

get_geolocation_field_dimnames(fieldname)[source]

Returns the dimensions of a geolocation field.

Note

Abstract function to be overriden.

get_geolocation_fields()[source]

Return the names of the geolocation fields

get_lat(slices=None, indices=None, cache=True, **kwargs)[source]

Return the latitude values of a feature.

Subsets can be returned by using either slices or indices arguments. slices and indices are exclusive and can not be both specified. Both must be provided as dictionaries where keys are the names of the dimensions to subset. Values are slice objects in the case of slice argument and numbers in the case of indices argument. Only the subsetted dimensions need to be provided (the full range s assumed for the other dimensions).

Parameters:
  • slices (dictionary) – a dictionary where keys are the dimensions to slice and values are slice objects.
  • indices (list) – a dictionary where keys are the dimensions to slice and values are slice objects.
  • cache (bool) – if cache is True, the data read from file are kept in memory. The full field data array is kept in cache, slices or indices are ignored by caching (though the result returned by this function will be a subset if slices or indices are provided. Use the view concept in mappers instead if you want frequent accesses to a subset of a file. Default is False.
Returns:

the requested latitudes.

Return type:

numpy.ma.array<float>

get_lon(slices=None, indices=None, cache=True, **kwargs)[source]

Return the longitude values of a feature.

Subsets can be returned by using either slices or indices arguments. slices and indices are exclusive and can not be both specified. Both must be provided as dictionaries where keys are the names of the dimensions to subset. Values are slice objects in the case of slice argument and numbers in the case of indices argument. Only the subsetted dimensions need to be provided (the full range s assumed for the other dimensions).

Parameters:
  • slices (dictionary) – a dictionary where keys are the dimensions to slice and values are slice objects.
  • indices (list) – a dictionary where keys are the dimensions to slice and values are slice objects.
  • cache (bool) – if cache is True, the data read from file are kept in memory. The full field data array is kept in cache, slices or indices are ignored by caching (though the result returned by this function will be a subset if slices or indices are provided. Use the view concept in mappers instead if you want frequent accesses to a subset of a file. Default is False.
Returns:

the requested longitudes.

Return type:

numpy.ma.array<float>

get_mapper()[source]
Return the handler of the storage resource where feature’s data are
saved.
get_metadata()[source]

returns the global attributes (metadata) of the feature

classmethod get_model_name()[source]

Return the name of the datamodel

get_start_time()[source]

Return start time of feature’s temporal coverage.

Returns:start time of temporal coverage. None if no valid time was found.
Return type:datetime
get_time_units()[source]

Return the time units as a CF convention compliant string

get_times(slices=None, indices=None, cache=True, **kwargs)[source]

Return the times of a feature.

The time values are returned as numbers. Use the get_time_units() function to convert these values to date or time objects.

Subsets can be returned by using either slices or indices arguments. slices and indices are exclusive and can not be both specified. Both must be provided as dictionaries where keys are the names of the dimensions to subset. Values are slice objects in the case of slice argument and numbers in the case of indices argument. Only the subsetted dimensions need to be provided (the full range s assumed for the other dimensions).

Parameters:
  • slices (dictionary) – a dictionary where keys are the dimensions to slice and values are slice objects.
  • indices (list) – a dictionary where keys are the dimensions to slice and values are slice objects.
  • cache (bool) – if cache is True, the data read from file are kept in memory. The full field data array is kept in cache, slices or indices are ignored by caching (though the result returned by this function will be a subset if slices or indices are provided. Use the view concept in mappers instead if you want frequent accesses to a subset of a file. Default is False.
Returns:

the requested data.

Return type:

numpy.ma.array

get_url()[source]

Return the URL of the storage resource where feature’s data are saved.

get_values(fieldname, slices=None, indices=None, cache=False, **kwargs)[source]

Return the data of a field, given its name.

Subsets can be returned by using either slices or indices arguments. slices and indices are exclusive and can not be both specified. Both must be provided as dictionaries where keys are the names of the dimensions to subset. Values are slice objects in the case of slice argument and numbers in the case of indices argument. Only the subsetted dimensions need to be provided (the full range s assumed for the other dimensions).

Parameters:
  • fieldname (string) – shortname of the field.
  • slices (dictionary) – a dictionary where keys are the dimensions to slice and values are slice objects.
  • indices (list) – a dictionary where keys are the dimensions to slice and values are slice objects.
  • cache (bool) – if cache is True, the data read from file are kept in memory. The full field data array is kept in cache, slices or indices are ignored by caching (though the result returned by this function will be a subset if slices or indices are provided. Use the view concept in mappers instead if you want frequent accesses to a subset of a file. Default is False.
Returns:

the requested data.

Return type:

numpy.ma.array

get_wkt_bbox()[source]

Return the bounding box in WKT format.

get_z(slices=None, indices=None, cache=True, **kwargs)[source]

if cache is True, data read from storage are kept in memory

has_field(fieldname)[source]

Return True if the field exists in the feature

load(storage_mapper, readonly=True, view=None)[source]

Restore the feature from a file (or any type of storage.)

It does not read the actual data at this point for memory issues, only the metadata and geolocation information necessary to initialize the feature model. Physical read access to the data from the storage is performed transparently when attempting to get the values of a field.

Parameters:
  • storage_mapper (AbstractMapper) – an instance of mapper class, corresponding to the storage of the feature
  • view (dict, optional) –

    a dictionary where keys are dimension names and values are slices. A view can be set on a file, meaning that only the subset defined by this view will be accessible. This view is expressed as any subset (see get_values()). For example:

    view = {'time':slice(0,0), 'lat':slice(200,300),
       'lon':slice(200,300)}
    
set_datetimes(values, units='seconds since 1981-01-01 00:00:00')[source]

Same as set_times method but providing a list of datetime as input.

set_lat(values)[source]

Set the latitudes

Parameters:values (numpy.ndarray or Field) – longitude values, as a array of floats or a Field object.
set_lon(values)[source]

Set the longitudes

Parameters:values (numpy.ma.MaskedArray or Field) – longitude values, as a array of floats or a Field object
set_times(values, units='seconds since 1981-01-01 00:00:00')[source]

Set the times

Parameters:
  • values (numpy.ma.MaskedArray or Field) – time values, as a array of floats/integers or a Field object
  • units (string) – the time units as a CF convention compliant string. Only used when values is an array of floats/integers.
set_z(values, ztype='depth')[source]

Set the depth(s)

Parameters:
  • values (numpy.ma.MaskedArray or Field) – depth values, as a array of floats or a Field object
  • ztype (string) – type is depth (positive down) or height (positive up)

compositevariable Module

class cerbere.datamodel.compositevariable.CompositeVariable(components=None, shortname=None, description=None, authority=None, standardname=None)[source]

Bases: cerbere.datamodel.variable.Variable

Complex variable that must be described by several quantities or components (such as a vector : (u,v) or (module,direction)

field Module

cerbere.datamodel.field

Classes for the handling the data fields

copyright:Copyright 2013 Ifremer / Cersat.
license:Released under GPL v3 license, see license.
class cerbere.datamodel.field.QCLevel(values=None, dimensions=None, levels=None, meanings=None)[source]

Bases: object

Special layer for the storage of the quality level associated with a field.

class cerbere.datamodel.field.QCDetail(values=None, dimensions=None, mask=None, meanings=None)[source]

Bases: object

Special layer for the storage of the quality control details associated with a field. This is intended to describe which quality steps have been applied and raised a warning/error (bit value = 1)

class cerbere.datamodel.field.Field(variable, dimensions, values=None, datatype=None, fields=None, fillvalue=None, attributes={}, units=None, valid_min=None, valid_max=None, qc_levels=None, qc_details=None, allocate=False)[source]

Bases: object

A Field contains data and associated metadata.

This is equivalent to the notion of variable in netCDF (not to be confused with the definition of Variable used in Cerbere.

Parameters:
  • variable (Variable) – the physical variable measured and stored in the field
  • dimensions (collections.OrderedDict) – an ordered dictionary providing the name and size of each dimension
  • values (numpy.ma.MaskedArray) – the measured data. Optional (the field can be created with default values)
  • datatype (numpy.dtype) – the type of the data to be stored. If values is provided, the datatype does not need to be provided as the field datatype will be the datatype of the provide values
  • fields (Field) – the subfields composing the main field. This is intended to group for instance components of the same variable (such as a vector’s northward and eastward components for wind, currents,...). This allows to relate these components to the same physical variable (e.g wind) and to a single qc_levels and qc_details information.
  • fillvalue – the default value to associate with missing data in the field’s values. The fillvalue must be of the same type as datatype and values
  • attributes (dictionary) – a dictionary of the metadata associated with the field’s values
  • units (string) – the units in which the data are given (if applicable)
  • allocate (bool) – if True, pre-allocate the data arrays to store the values (in case no values are yet provided)
__add__(other)[source]

Return a new field with the sum of current and an other field.

__sub__(other)[source]

Return a new field with the difference of current and an other field.

attach_storage(handler)[source]

Attach a mapper to the field.

When a field is stored in a file, its data are not loaded until they are explicitly requested (call to get_values()). The handler pointer is set by this function to locate where the data have to be read (or saved later for a new or updated file).

Parameters:handler (AbstractMapper) – the file mapper attached to the field.
clone()[source]

Return a copy of the field without any data or reference to the source file

classmethod compute(operator, field1, field2=None, variable=None)[source]

Perform an operation and returns the result as a field

The operator may be for instance a numpy MaskedArray operator such as numpy.ma.anom, numpy.ma.corr,...

To be used with caution.

Parameters:
  • operator (function) – the function to be called (ex: numpy.ma.anom)
  • field1 (Field) – the field argument to the operator
  • field2 (Field) – an optional 2nd field argument to the operator
  • variable (Variable) – variable of the returned module field. If not provided, the returned field is created with a basic variable definition.
Returns:

the result field

Return type:

Field

classmethod format_indices(indices, fielddims)[source]

format the indices to an explicit list of slice matching the list and order of a field dimensions

the indices are provided as a dictionary where keys are the dimensions over which subsetting needs to be performed. Implicit dimensions where no subsetting is requested don’t need to be specified. The completion to a comprehensive ordered list of slices for all field dimensions is performed by this function.

Parameters:
  • indices (dict) – keys are the names and values are the indices of the dimensions in which to subset
  • fielddims (list) – full list of the field dimension names
Returns:

a comprehensive list of slice objects for all field dimensions.

Return type:

list

classmethod format_slices(slices, fielddims)[source]

format the slices to an explicit list matching the list and order of a field dimensions

the slices as provided as a dictionary where keys are the dimensions over which subsetting needs to be performed. Implicit dimensions where no subsetting is requested don’t need to be specified. The completion to a comprehensive ordered list of slices for all field dimensions is performed by this function.

Parameters:
  • slices (dict) – keys are the names and values are the slice object of the dimensions in which to subset
  • fielddims (list) – full list of the field dimension names
Returns:

a comprehensive list of slice objects for all field dimensions.

Return type:

list

get_components()[source]

Return the list of components of the field

Components (or sub fields) are intended for non scalar fields (ex: vector like current or wind, real and imaginary part of a complex,...)

get_dimnames()[source]
get_dimsize(dimname)[source]
get_metadata()[source]

returns all the metadata of the field

get_name()[source]
get_values(slices=None, indices=None, cache=False, padding=False, strong_cache=False, **kwargs)[source]
Args
cache (bool): if cache is True, the data read from file are kept in
memory. The full field data array is kept in cache, slices or indices are ignored by caching (though the result returned by this function will be a subset if slices or indices are provided. Use the view concept in mappers instead if you want frequent accesses to a subset of a file. Default is False.

strong_cache (bool): DEPRECATED - same as cache

padding (bool) : if True, pad the result with fill values where
slices are out of the field size.
is_composite()[source]

return True if the field is a composite field, i.e. it is a composition of sub fields (vector components, real and imaginary part of a complex, ...

is_saved()[source]

Return True is the content of the field is saved on file and was not updated since

metadata

returns all the metadata of the field

name
set_metadata(metadata)[source]

set the metadata of the field

set_name(name)[source]
set_values(values, slices=None, indices=None)[source]

grid Module

cerbere.datamodel.grid

Model class for the grid feature

copyright:Copyright 2013 Ifremer / Cersat.
license:Released under GPL v3 license, see license.
class cerbere.datamodel.grid.Projection(proj4_definition='+proj=eqc +lat_ts=0 +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +a=6378137 +b=6378137 +units=m', identifier='regular')[source]

Bases: object

Definition of a grid projection

is_cylindrical()[source]

return True if the projection is cylindrical

class cerbere.datamodel.grid.Grid(identifier=None, title=None, description=None, source=None, metadata=None, fields=None, longitudes=None, latitudes=None, depths=None, times=None, bbox=None, spatial_resolution=None, projection=<cerbere.datamodel.grid.Projection object>)[source]

Bases: cerbere.datamodel.abstractfeature.AbstractFeature

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

Kwargs: longitudes (tuple or numpy array or Field):

Grid longitudes can be initialized :
  • with a tuple (min, max, step) : only for a regular grid. The
longitudes are automatically generated.
  • a numpy array of float values
  • a Field (for instance copied from another grid object)
latitudes (tuple or numpy array or Field):
Grid latitudes can be initialized :
  • with a tuple (min, max, step) : only for a regular grid. The
latitudes are automatically generated.
  • a numpy array of float values
  • a Field (for instance copied from another grid object)
extract_spatialsection(lat1, lon1, lat2, lon2, fieldnames=None)[source]
extract_subset(boundaries=None, slices=None, fields=None, padding=False, prefix=None)[source]

Extract a subset feature from the grid.

The created subset is a new Grid object without any reference to the source.

Parameters:
  • boundaries (tuple) – area of the subset to extract, defined as llcrnrlon, llcrnrlat, urcrnrlon, urcrnrlat.
  • slices (dict) – indices for /time/ dimension of the subset to extract from the source data. If None, the complete feature is extracted.
  • fields (list) – list of field names to extract. If None, all fields are extracted.
  • padding (bool) – Passed to extract_field method to ensure padding with _FillValues for points outside of the bounds of the this feature (used only in conjuncture with slices.
  • prefix (str) – add a prefix string to the field names of the extracted subset.
get_geolocation_dimnames()[source]

Returns the geolocation dimension names defining a grid

get_geolocation_dimsizes()[source]

Returns the geolocation dimension sizes of the grid object

get_geolocation_field_dimnames(fieldname)[source]

Returns the dimension names of a geolocation field

get_spatial_resolution()[source]

Return the spatial resolution of the feature, in degrees

is_unique_grid_time()[source]

Return True if a unique time is associated with the grid (like in L4 products), False if there is time value per pixel (like in L3)

latlon2slice(lat, lon)[source]

Returns the slice corresponding to the provided lat/lon locations

Parameters:
  • lat (float) – latitude
  • lon (float) – longitude
Returns:

slice

save(output=None, attrs=None)[source]

Save the grid to a storage (file,...)

Parameters:
  • output (AbstractMapper) – storage object where to save the feature data.
  • attrs (dict) – the global metadata (attributes) of the feature, as a dictionary where keys are the attributes names. See STANDARD_ATTRIBUTES_VALUES in abstractmapper class to see a list of standard attributes

gridtimeseries Module

cerbere.datamodel.gridtimeseries

Model class for the time series of grid feature

copyright:Copyright 2013 Ifremer / Cersat.
license:Released under GPL v3 license, see license.
class cerbere.datamodel.gridtimeseries.GridTimeSeries(identifier=None, title=None, description=None, source=None, metadata=None, fields=None, longitudes=None, latitudes=None, depths=None, times=None, bbox=None, projection=<cerbere.datamodel.grid.Projection object>)[source]

Bases: cerbere.datamodel.abstractfeature.AbstractFeature

Class implementing a time series of grids

Constructor for GridTimeSeries

Parameters:
  • longitudes (tuple or numpy array or Field) –

    Grid longitudes can be initialized:

    • with a tuple (min, max, step) : only for a regular grid. The longitudes are automatically generated.
    • a numpy array of float values
    • a Field (for instance copied from another grid object)
  • latitudes (tuple or numpy array or Field) –

    Grid latitudes can be initialized:

    • with a tuple (min, max, step) : only for a regular grid. The latitudes are automatically generated.
    • a numpy array of float values
    • a Field (for instance copied from another grid object)
__iter__()[source]

Returns the iterator

add_grid(grid, step=None)[source]

Add or update a time step to a grid time series.

If the time step already exists, the corresponding values will be replaced.

Parameters:step (int) – specify directly the index whithin the time series where to insert the grid (replacing the current values). If None, the time of the grid is used to search for the corresponding index within the time series.
extract_grid(index=None, time=None)[source]

Extract a grid from a grid time series

The grid to extract is defined either by its time step index or a time value. Both arguments are exclusive

Parameters:
  • index (int) – index of the time step to extract from the grid time series
  • time (datetime) – time of the grid step to extract from the grid time series
Returns:

extracted grid.

Return type:

Grid

get_geolocation_dimnames()[source]

Returns the geolocation dimension names defining a gridTimeSeries

get_geolocation_dimsizes()[source]

Returns the geolocation dimension sizes of the gridTimeSeries object

get_geolocation_field_dimnames(fieldname)[source]

Returns the dimensions of a geolocation field

is_unique_grid_time()[source]

Return True if a unique time is associated with the grid (like in L4 products), False if there is time value per pixel (like in L3)

save(output=None, attrs=None)[source]

Save the gridtimeserie to a storage (file,...)

Parameters:
  • output (AbstractMapper) – storage object where to save the feature data.
  • attrs (dict) – the global metadata (attributes) of the feature, as a dictionary where keys are the attributes names. See STANDARD_ATTRIBUTES_VALUES in abstractmapper class to see a list of standard attributes
time2t(time)[source]

Get the indice of the closest value in the list of time steps

image Module

cerbere.datamodel.image

Model class for the image feature

copyright:Copyright 2013 Ifremer / Cersat.
license:Released under GPL v3 license, see license.
class cerbere.datamodel.image.Image(identifier=None, title=None, description=None, source=None, metadata=None, fields=None, longitudes=None, latitudes=None, depths=None, times=None, spatial_resolution=None)[source]

Bases: cerbere.datamodel.abstractfeature.AbstractFeature

Model class for the image feature, ie a two-dimensional grid along the satellite track.

The main difference with a image is that there is only one time value associated with the feature (instead of a time value per pixel in a image).

extract_section(lat1, lon1, lat2, lon2, fieldnames=None)[source]
extract_subset(boundaries=None, slices=None, fields=None, prefix=None)[source]

extract a subset from the current feature. The created subset is a new object without any reference to the source.

Parameters:
  • boundaries – tuple area of the subset to extract, defined as llcrnrlon, llcrnrlat, urcrnrlon, urcrnrlat
  • slices – list of slices indices for x and y dimensions (or lon, lat) of the subset to extract from the source data
  • fields (list) – list of field names to extract
  • prefix (str) – add a prefix string to the field names of the extracted subset.
get_geolocation_dimnames()[source]

Returns the geolocation dimension names defining a image

get_geolocation_dimsizes()[source]

Returns the geolocation dimension sizes of the image object

get_geolocation_field_dimnames(fieldname)[source]

Returns the dimensions of a geolocation field

get_spatial_resolution()[source]

Return the spatial resolution of the feature

get_values(fieldname, slices=None, indices=None, cache=False)[source]

if cache is True, data read from storage are kept in memory

is_latlon_in_grid(lon, lat)[source]

Indique si le point de coordonnées (lon, lat), donné dans le repère de la grille, appartient à l’espace qu’elle délimite. Tient compte de la rotondité de la Terre.

La grille est vue comme un maillage, donc pour une grille aux longitudes sur [0 359], le point 359,5 est au dehors. Le point 380 est quant à lui inclus.

Voir aussi la fonction intersection() @param lon:longitude @param lat:latitude @return: True si le point est à l’intérieur de la grille (vue comme un maillage)

is_xy_in_grid(x, y, varName=None)[source]

Renvoie False si la valeur est hors zone. Dans le cas où un nom de variable (varName) est précisé, renvoie également False si la valeur à cette position est masquée. @param x:indice de longitude @param y:indice de latitude @param varName: string, optionnel, nom d’une des variables, pour obtenir une précision supplémentaire : l’état (masqué ou non) de la valeur (x,y)

latlon2xy(lat, lon)[source]

Se base sur getNearestIndex pour renvoyer les indices (x pour lon, y pour lat) en un seul appel de fonction.

Si la latitude ou longitude est hors grille, le point bordure est renvoyé @return: (x,y)

save(output, attrs=None)[source]

Save the image to a storage (file,...)

Parameters:
  • output (AbstractMapper) – storage object where to save the feature data.
  • attrs (dict) – the global metadata (attributes) of the feature, as a dictionary where keys are the attributes names. See STANDARD_ATTRIBUTES_VALUES in abstractmapper class to see a list of standard attributes
xy2latlon(x, y)[source]

Renvoie la latitude correspondant à l’indice y et la longitude correspondant à l’indice x.

Pas d’amélioration de précision ici. Une valeur comme -74.589996 signifie -74.59 si la résolution n’est pas de l’ordre de 10^-5 degré. @return: (lat, lon)

pointcollection Module

class cerbere.datamodel.pointcollection.PointCollection(identifier=None, title=None, description=None, source=None, metadata=None, fields=None, longitudes=None, latitudes=None, depths=None, times=None)[source]

Bases: cerbere.datamodel.abstractfeature.AbstractFeature

Implements a set of randomly sampled points

extract_subset(boundaries=None, slices=None, indices=None, prefix=None)[source]

Extract a subset from the trajectory. The created subset is a new object without any reference to the source.

Parameters:
  • boundaries (tuple, optional) – area of the subset to extract, defined as llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat.
  • slices (dict) – dictionary of slices for time dimension of the subset to extract from the source data
  • prefix (str) – add a prefix string to the field names of the extracted subset.
get_geolocation_dimnames()[source]

Returns the geolocation dimension names defining a point collection

get_geolocation_dimsizes()[source]

Returns the geolocation dimension sizes of the grid object

get_geolocation_field_dimnames(fieldname)[source]

Returns the dimensions of a geolocation field

save(output, attrs={})[source]

Save the point collection to a storage mapper (file,...)

Parameters:
  • output (AbstractMapper) – storage object where to save the feature data.
  • attrs (dict) – the global metadata (attributes) of the feature, as a dictionary where keys are the attributes names. See STANDARD_ATTRIBUTES_VALUES in abstractmapper class to see a list of standard attributes

pointtimeseries Module

cerbere.datamodel.pointtimeseries

Model class for the time series at a fixed point feature

copyright:Copyright 2013 Ifremer / Cersat.
license:Released under GPL v3 license, see license.
class cerbere.datamodel.pointtimeseries.PointTimeSeries(identifier=None, title=None, description=None, source=None, metadata=None, fields=None, longitude=None, latitude=None, depth=None, times=None)[source]

Bases: cerbere.datamodel.abstractfeature.AbstractFeature

Model class for the point time series

get_geolocation_dimnames()[source]

Returns the geolocation dimension names defining a grid

get_geolocation_dimsizes()[source]

Returns the geolocation dimension sizes of the grid object

get_geolocation_field_dimnames(dimname)[source]

Returns the dimensions of a geolocation field

save(output, attrs=None)[source]

Save the time series to a storage (file,...)

Parameters:
  • output (AbstractMapper) – storage object where to save the feature data.
  • attrs (dict) – the global metadata (attributes) of the feature, as a dictionary where keys are the attributes names. See STANDARD_ATTRIBUTES_VALUES in abstractmapper class to see a list of standard attributes

swath Module

cerbere.datamodel.swath

Model class for the swath feature

copyright:Copyright 2013 Ifremer / Cersat.
license:Released under GPL v3 license, see license.
class cerbere.datamodel.swath.Swath(identifier=None, title=None, description=None, source=None, metadata=None, fields=None, longitudes=None, latitudes=None, depths=None, times=None, spatial_resolution=None)[source]

Bases: cerbere.datamodel.abstractfeature.AbstractFeature

Model class for the swath feature, ie a two-dimensional grid along the satellite track

extract_section(lat1, lon1, lat2, lon2, fieldnames=None)[source]
extract_subset(boundaries=None, slices=None, fields=None, padding=False, prefix=None)[source]

Extract a subset feature from the swath.

The created subset is a new Swath object without any reference to the source.

Parameters:
  • boundaries (tuple) – area of the subset to extract, defined as llcrnrlon, llcrnrlat, urcrnrlon, urcrnrlat.
  • slices (dict) – indices for /time/ dimension of the subset to extract from the source data. If None, the complete feature is extracted.
  • fields (list) – list of field names to extract. If None, all fields are extracted.
  • padding (bool) – Passed to extract_field method to ensure padding with _FillValues for points outside of the bounds of the this feature (used only in conjuncture with slices.
  • prefix (str) – add a prefix string to the field names of the extracted subset.
get_geolocation_dimnames()[source]

Returns the geolocation dimension names defining a swath

get_geolocation_dimsizes()[source]

Returns the geolocation dimension sizes of the swath object

get_geolocation_field_dimnames(fieldname)[source]

Returns the dimensions of a geolocation field

get_spatial_resolution()[source]

Return the spatial resolution of the feature

is_latlon_in_grid(lon, lat)[source]

Indique si le point de coordonnées (lon, lat), donné dans le repère de la grille, appartient à l’espace qu’elle délimite. Tient compte de la rotondité de la Terre.

La grille est vue comme un maillage, donc pour une grille aux longitudes sur [0 359], le point 359,5 est au dehors. Le point 380 est quant à lui inclus.

Voir aussi la fonction intersection() @param lon:longitude @param lat:latitude @return: True si le point est à l’intérieur de la grille (vue comme un maillage)

is_xy_in_grid(x, y, varName=None)[source]

Renvoie False si la valeur est hors zone. Dans le cas où un nom de variable (varName) est précisé, renvoie également False si la valeur à cette position est masquée. @param x:indice de longitude @param y:indice de latitude @param varName: string, optionnel, nom d’une des variables, pour obtenir une précision supplémentaire : l’état (masqué ou non) de la valeur (x,y)

latlon2xy(lat, lon)[source]

Se base sur getNearestIndex pour renvoyer les indices (x pour lon, y pour lat) en un seul appel de fonction.

Si la latitude ou longitude est hors grille, le point bordure est renvoyé @return: (x,y)

save(output, attrs=None)[source]

Save the swath to a storage (file,...)

Parameters:
  • output (AbstractMapper) – storage object where to save the feature data.
  • attrs (dict) – the global metadata (attributes) of the feature, as a dictionary where keys are the attributes names. See STANDARD_ATTRIBUTES_VALUES in abstractmapper class to see a list of standard attributes
xy2latlon(x, y)[source]

Renvoie la latitude correspondant à l’indice y et la longitude correspondant à l’indice x.

Pas d’amélioration de précision ici. Une valeur comme -74.589996 signifie -74.59 si la résolution n’est pas de l’ordre de 10^-5 degré. @return: (lat, lon)

trajectory Module

cerbere.datamodel.trajectory

Model class for the trajectory feature

copyright:Copyright 2013 Ifremer / Cersat.
license:Released under GPL v3 license, see license.
class cerbere.datamodel.trajectory.Trajectory(identifier=None, title=None, description=None, source=None, metadata=None, fields=None, longitudes=None, latitudes=None, depths=None, times=None)[source]

Bases: cerbere.datamodel.abstractfeature.AbstractFeature

Model class for the trajectory feature

extract_subset(boundaries=None, slices=None, fields=None, padding=False, prefix=None)[source]

Extract a subset feature from the trajectory.

The created subset is a new Trajectory object without any reference to the source.

Parameters:
  • boundaries (tuple) – area of the subset to extract, defined as llcrnrlon, llcrnrlat, urcrnrlon, urcrnrlat.
  • slices (dict) – indices for /time/ dimension of the subset to extract from the source data. If None, the complete feature is extracted.
  • fields (list) – list of field names to extract. If None, all fields are extracted.
  • padding (bool) – Passed to extract_field method to ensure padding with _FillValues for points outside of the bounds of the this feature (used only in conjuncture with slices.
  • prefix (str) – add a prefix string to the field names of the extracted subset.
get_geolocation_dimnames()[source]

Returns the geolocation dimension names defining a swath

get_geolocation_dimsizes()[source]

Returns the geolocation dimension sizes of the trajectory object

get_geolocation_field_dimnames(dimname)[source]

Returns the dimensions of a geolocation field

save(output=None, attrs=None)[source]

Save the trajectory to a storage (file,...).

Parameters:
  • output (AbstractMapper) – storage object where to save the feature data.
  • attrs (dict) – the global metadata (attributes) of the feature, as a dictionary where keys are the attributes names. See STANDARD_ATTRIBUTES_VALUES in abstractmapper class to see a list of standard attributes

variable Module

cerbere.datamodel.variable

Classes for defining a geophysical quantity

copyright:Copyright 2013 Ifremer / Cersat.
license:Released under GPL v3 license, see license.
class cerbere.datamodel.variable.Variable(shortname, description=None, authority=None, standardname=None)[source]

Bases: object

Description of the phenomenon (or measured quantity) related to a measure (temperature, salinity,...)

Parameters:
  • shortname (string) – the label of the variable (don’t use any white space). This corresponds to the variable name in a netcdf file
  • description (string) – full name of the phenomenon. This corresponds to a long_name in attribute in a netCDF file.
  • authority (string) – naming authority referencing the provided standard name
  • standardname (string) – standard label for a phenomenon, with respect to the convention stated in authority argument. This corresponds to a standard_name attribute in a CF compliant NetCDF file.