cfdm.core.datum

Classes

Datum([parameters, source, copy])

A datum component of a coordinate reference of the CF data model.

class cfdm.core.datum.Datum(parameters=None, source=None, copy=True)[source]

Bases: Parameters

A datum component of a coordinate reference of the CF data model.

A datum is a complete or partial definition of the zeroes of the dimension and auxiliary coordinate constructs which define a coordinate system.

The datum may contain the definition of a geophysical surface which corresponds to the zero of a vertical coordinate construct, and this may be required for both horizontal and vertical coordinate systems.

Elements of the datum not specified may be implied by the properties of the dimension and auxiliary coordinate constructs referenced by the CoordinateReference instance that contains the datum.

Added in version (cfdm): 1.7.0

Initialisation

Parameters:
parameters: dict, optional

Set parameters. The dictionary keys are parameter names, with corresponding values.

Parameters may also be set after initialisation with the set_parameters and set_parameter methods.

Parameter example:

parameters={'earth_radius': 6371007.}

source: optional

Convert source, which can be any type of object, to a Datum instance.

All other parameters, apart from copy, are ignored and their values are instead inferred from source by assuming that it has the Datum API. Any parameters that can not be retrieved from source in this way are assumed to have their default value.

Note that if x is also a Datum instance then cfdm.core.Datum(source=x) is equivalent to x.copy().

copy: bool, optional

If True (the default) then deep copy the input parameters prior to initialisation. By default the parameters are not deep copied.

clear_parameters()[source]

Remove all parameters.

Added in version (cfdm): 1.7.0

See also

del_parameter, parameters, set_parameters

Returns:
dict

The parameters that have been removed.

Examples

>>> f = cfdm.core.Datum()
>>> f.parameters()
{}
>>> p = {'standard_parallel': 25.0,
...      'longitude_of_central_meridian': 265.0,
...      'latitude_of_projection_origin': 25.0}
>>> f.set_parameters(p)
>>> f.parameters()
{'standard_parallel': 25.0,
 'longitude_of_central_meridian': 265.0,
 'latitude_of_projection_origin': 25.0}
>>> old = f.clear_parameters()
>>> old
{'standard_parallel': 25.0,
 'longitude_of_central_meridian': 265.0,
 'latitude_of_projection_origin': 25.0}
>>> f.set_parameters(old)
copy()[source]

Return a deep copy.

f.copy() is equivalent to copy.deepcopy(f).

Added in version (cfdm): 1.7.0

Returns:
Datum

The deep copy.

Examples

>>> f = cfdm.core.Datum()
>>> g = f.copy()
del_parameter(parameter, default=ValueError())[source]

Delete a parameter.

Added in version (cfdm): 1.7.0

See also

get_parameter, has_parameter, parameters, set_parameter

Parameters:
parameter: str

The name of the parameter to be deleted.

default: optional

Return the value of the default parameter if the parameter has not been set.

If set to an Exception instance then it will be raised instead.

Returns:

The removed parameter value.

Examples

>>> f = cfdm.core.Datum()
>>> f.set_parameter('earth_radius', 6371007)
>>> f.has_parameter('earth_radius')
True
>>> f.get_parameter('earth_radius')
6371007
>>> f.del_parameter('earth_radius')
6371007
>>> f.has_parameter('earth_radius')
False
>>> print(f.del_parameter('earth_radius', None))
None
>>> print(f.get_parameter('earth_radius', None))
None
get_parameter(parameter, default=ValueError())[source]

Get a parameter value.

Added in version (cfdm): 1.7.0

Parameters:
parameter: str

The name of the parameter.

default: optional

Return the value of the default parameter if the parameter has not been set.

If set to an Exception instance then it will be raised instead.

Returns:

The value of the parameter.

Examples

>>> f = cfdm.core.Datum()
>>> f.set_parameter('earth_radius', 6371007)
>>> f.has_parameter('earth_radius')
True
>>> f.get_parameter('earth_radius')
6371007
>>> f.del_parameter('earth_radius')
6371007
>>> f.has_parameter('earth_radius')
False
>>> print(f.del_parameter('earth_radius', None))
None
>>> print(f.get_parameter('earth_radius', None))
None
has_parameter(parameter)[source]

Whether a parameter has been set.

Added in version (cfdm): 1.7.0

See also

del_parameter, get_parameter, parameters, set_parameter

Parameters:
parameter: str

The name of the parameter.

Parameter example:

parameter='geoid_name'

Returns:
bool

True if the parameter has been set, otherwise False.

Examples

>>> f = cfdm.core.Datum()
>>> f.set_parameter('earth_radius', 6371007)
>>> f.has_parameter('earth_radius')
True
>>> f.get_parameter('earth_radius')
6371007
>>> f.del_parameter('earth_radius')
6371007
>>> f.has_parameter('earth_radius')
False
>>> print(f.del_parameter('earth_radius', None))
None
>>> print(f.get_parameter('earth_radius', None))
None
parameters()[source]

Return all parameters.

Added in version (cfdm): 1.7.0

See also

clear_parameters, get_parameter, has_parameter set_parameters

Returns:
dict

The parameters.

Examples

>>> f = cfdm.core.Datum()
>>> f.parameters()
{}
>>> p = {'standard_parallel': 25.0,
...      'longitude_of_central_meridian': 265.0,
...      'latitude_of_projection_origin': 25.0}
>>> f.set_parameters(p)
>>> f.parameters()
{'standard_parallel': 25.0,
 'longitude_of_central_meridian': 265.0,
 'latitude_of_projection_origin': 25.0}
>>> old = f.clear_parameters()
>>> old
{'standard_parallel': 25.0,
 'longitude_of_central_meridian': 265.0,
 'latitude_of_projection_origin': 25.0}
>>> f.set_parameters(old)
set_parameter(term, value, copy=True)[source]

Set a parameter-valued term.

Added in version (cfdm): 1.7.0

See also

parameters

Returns:

None

Examples

>>> f = cfdm.core.Datum()
>>> f.set_parameter('earth_radius', 6371007)
>>> f.has_parameter('earth_radius')
True
>>> f.get_parameter('earth_radius')
6371007
>>> f.del_parameter('earth_radius')
6371007
>>> f.has_parameter('earth_radius')
False
>>> print(f.del_parameter('earth_radius', None))
None
>>> print(f.get_parameter('earth_radius', None))
None
set_parameters(parameters, copy=True)[source]

Set parameters.

Added in version (cfdm): 1.7.0

See also

clear_parameters, parameters, set_parameter

Parameters:
parameters: dict

Store the parameters from the dictionary supplied.

Parameter example:

parameters={'earth_radius': 6371007}

copy: bool, optional

If False then any parameter values provided by the parameters parameter are not copied before insertion. By default they are deep copied.

Returns:

None

Examples

>>> f = cfdm.core.Datum()
>>> f.parameters()
{}
>>> p = {'standard_parallel': 25.0,
...      'longitude_of_central_meridian': 265.0,
...      'latitude_of_projection_origin': 25.0}
>>> f.set_parameters(p)
>>> f.parameters()
{'standard_parallel': 25.0,
 'longitude_of_central_meridian': 265.0,
 'latitude_of_projection_origin': 25.0}
>>> old = f.clear_parameters()
>>> old
{'standard_parallel': 25.0,
 'longitude_of_central_meridian': 265.0,
 'latitude_of_projection_origin': 25.0}
>>> f.set_parameters(old)