epygram.formats.netCDF — Interface-Class to the netCDF format

Contains classes for netCDF4 resource.

class epygram.formats.netCDF.netCDF(*args, **kwargs)[source]

Bases: epygram.resources.FileResource.FileResource

Class implementing all specificities for netCDF (4) resource format.

Footprint:

dict(
    attr = dict(
        behaviour = dict(
            access = 'rxx', 
            alias = set([]), 
            default = dict(
                H2D_dimensions_names = ('X', 'Y'), 
                flatten_non_rectangular_grids = True, 
                transpose_data_ordering = False, 
                variable_name_for_latitudes = 'lats', 
                variable_name_for_longitudes = 'lons', 
                variable_name_for_validity = 'time',
            ), 
            info = 'Describes how fields are defined in resource.', 
            optional = True, 
            outcast = set([]), 
            remap = dict(), 
            type = footprints.stdtypes.FPDict, 
            values = set([]),
        ), 
        filename = dict(
            access = 'rxx', 
            alias = set([]), 
            default = None, 
            info = 'File name (absolute or relative) of the resource.', 
            optional = False, 
            outcast = set([]), 
            remap = dict(), 
            values = set([]),
        ), 
        fmtdelayedopen = dict(
            access = 'rxx', 
            alias = set([]), 
            default = False, 
            info = 'Opening of the resource delayed (not at time of construction).', 
            optional = True, 
            outcast = set([]), 
            remap = dict(), 
            type = bool, 
            values = set([]),
        ), 
        format = dict(
            access = 'rxx', 
            alias = set([]), 
            default = 'netCDF', 
            info = 'Format of the resource.', 
            optional = True, 
            outcast = set([]), 
            remap = dict(), 
            values = set(['netCDF']),
        ), 
        openmode = dict(
            access = 'rxx', 
            alias = set([]), 
            default = None, 
            info = 'Opening mode.', 
            optional = False, 
            outcast = set([]), 
            remap = dict(
                append = 'a', 
                read = 'r', 
                write = 'w',
            ), 
            values = set(['a', 'write', 'r', 'w', 'read', 'append']),
        ),
    ), 
    bind = [], 
    info = 'Not documented', 
    only = dict(), 
    priority = dict(
        level = footprints.priorities.PriorityLevel::DEFAULT,
    ),
)
behave(**kwargs)[source]

Set-up the given arguments in self.behaviour, for the purpose of building fields from netCDF.

close()[source]

Closes a netCDF.

find_fields_in_resource(seed=None, generic=False, **kwargs)

Returns a list of the fields from resource whose name match the given seed.

Args:

  • seed: might be a regular expression, a list of regular expressions or None. If None (default), returns the list of all fields in resource.
  • fieldtype: optional, among (‘H2D’, ‘Misc’) or a list of these strings. If provided, filters out the fields not of the given types.
  • generic: if True, returns complete fid’s, union of {‘FORMATname’:fieldname} and the according generic fid of the fields.
open(openmode=None)[source]

Opens a netCDF and initializes some attributes.

  • openmode: optional, to open with a specific openmode, eventually different from the one specified at initialization.
readfield(*args, **kwargs)[source]

Reads one field, given its netCDF name, and returns a Field instance.

Args:

  • fid: netCDF field identifier
  • getdata: if False, only metadata are read, the field do not contain data.
variables_number()[source]

Return the number of variables in resource.

what(out=<open file '<stdout>', mode 'w' at 0x7f7b0e24c150>)

Writes in file a summary of the contents of the GRIB.

writefield(field, compression=4, metadata={})[source]

Write a field in resource. Args:

  • compression ranges from 1 (low compression, fast writing) to 9 (high compression, slow writing). 0 is no compression.
  • metadata can be filled by any meta-data, that will be stored as attribute of the netCDF variable.

Previous topic

epygram.formats.TIFFMF — Interface-Class to the TIFFMF format

Next topic

epygram.formats.GRIB — Interface-Class to the GRIB format

This Page