1.5.3. CF conventions usage and extensions

The module vacumm.data.cf defines and exploits specifications inspired from CF conventions. These specifications are separated in two dictionaries: - one for variables: var_specs, - one for axes: axis_specs.

These specifications are used in the library to search and format variables or axes.

1.5.3.1. Structure of the specification dictionaries

Here is an example:

u3d = dict(
    names=['uz', 'u3d'],
    standard_names=['sea_water_x_velocity', 'eastward_sea_water_velocity'],
    long_names = "Sea water velocity along X",
    units = "m s-1",
    axes = dict(x=['lon_u'], y=['lat_u']),
    physloc = 'u',
    atlocs = ['t', 'u', 'v'],
),

Each entry has a key that is a short name that will be used as a generic netcdf name (here u3d). The value of an entry is a dictionary that can define de following specifications:

  • names: A list of lower case short name that can be found in netcdf files. The short name the entry (u3d) is insert automatically at the beginning of this list.
  • standard_names: A list of possible standard_names to search for the variable in a netcdf file. The first one is used to format variables.
  • long_names: One or several long_names. The first one is used to format variables.
  • units: One or several long_names. The first one is used to format variables.
  • axes: A dictionary of axis names used to format axes when they are recongnized as geographic axes (xyzt). Each axis name must be an entry of vacumm.data.cf.axis_specs.
  • physloc: The physical grid location of this variable on an Arakawa grid.
  • atlocs: A list of grid locations (see locations) that will be used to deplicate this entry to match another location (with dupl_loc_specs()). For instance u3d entry will create u3d_t, u3d_u and u3d_v entries. Then u3d entry is merged with these new entries to be more generic.
  • inherit: It can be used to inherit the specifications from another entry.
  • i/jaxis: Name of elemental axis for 2D axes.
  • The other key/val are used as attributes when formatting a variable.

1.5.3.2. Searching for variables and axes

You can search for variables and axes in netcdf files with the ncfind_obj() function. The main search argument can be a simple tuple of netcdf names, or a dictionary of names, standard_names, or even long_names and units. This dictionary can be automatically formed by the cf2search() function for a given generic name (such as “sst”). This way of searching is used by the Dataset classes.

1.5.3.3. Formatting variables and axes

You can format variables and axes to make sure they meet CF standards, with the functions format_var() and format_axis(). The attributes are defined by the cf2atts() function.