NamedAxis object reference

class pygeode.NamedAxis[source]

Inherits from Axis

Generic axis identified by the instances name. Unlike other axes classes, NamedAxis objects must have the same name in order for two axes to be mapped to one another.

New or Overridden Methods

NamedAxis.__init__(values, name, **kwargs)

Create a new Axis object with the given values.

NamedAxis.map_to(other)

Returns indices of this axis which correspond to the axis other.

NamedAxis.__init__(values, name, **kwargs)[source]

Create a new Axis object with the given values.

Parameters
valuesnumpy.ndarray

A one-dimensional coordinate defining the axis grid.

namestring (optional)

What to call the axis (i.e. for plot titles & when saving to file)

attsdict (optional)

Any additional metadata to associate with the axis. The dictionary keys should be strings.

plotattsdict (optional)

Parameters that control plotting behaviour; default values are available. The dictionary keys should be strings.

rtolfloat

A relative tolerance used for identifying an element of this axis.

Notes

All subclasses of Axis need to call this __init__ method within their own __init__, to properly initialize all attributes.

NamedAxis.map_to(other)[source]

Returns indices of this axis which correspond to the axis other.

Parameters
otherAxis

Axis to find mapping to

Returns
mappinginteger array or None

Notes

Returns an ordered indices of the elements of this axis that correspond to those of the axis other, if one exists, otherwise None. This axis must be a parent class of other or vice versa in order for the mapping to exist. The mapping may include only a subset of this axis object, but must be as long as the other axis, if it is not None. The mapping identifies equivalent elements based on equality up to a tolerance specified by self.rtol.

class pygeode.NonCoordinateAxis[source]

Inherits from Axis

An axis for non-coordinate dimensions (e.g. categorical data such as stations, etc.).

New or Overridden Methods

NonCoordinateAxis.__init__(*args, **kwargs)

Create a new Axis object with the given values.

NonCoordinateAxis.map_to(other)

Returns indices of this axis which correspond to the axis other.

NonCoordinateAxis.str_as_val(key, s)

str_as_val(self, key, s) - converts string s to a value corresponding to this axis.

NonCoordinateAxis.formatvalue(value[, fmt, ...])

Returns formatted string representation of value.

NonCoordinateAxis.__eq__(other)

override Var's ufunc stuff here this is a weak comparison, in that we only require the other axis to be a subclass of this one.

NonCoordinateAxis.__init__(*args, **kwargs)[source]

Create a new Axis object with the given values.

Parameters
valuesnumpy.ndarray

A one-dimensional coordinate defining the axis grid.

namestring (optional)

What to call the axis (i.e. for plot titles & when saving to file)

attsdict (optional)

Any additional metadata to associate with the axis. The dictionary keys should be strings.

plotattsdict (optional)

Parameters that control plotting behaviour; default values are available. The dictionary keys should be strings.

rtolfloat

A relative tolerance used for identifying an element of this axis.

Notes

All subclasses of Axis need to call this __init__ method within their own __init__, to properly initialize all attributes.

NonCoordinateAxis.map_to(other)[source]

Returns indices of this axis which correspond to the axis other.

Parameters
otherAxis

Axis to find mapping to

Returns
mappinginteger array or None

Notes

Returns an ordered indices of the elements of this axis that correspond to those of the axis other, if one exists, otherwise None. This axis must be a parent class of other or vice versa in order for the mapping to exist. The mapping may include only a subset of this axis object, but must be as long as the other axis, if it is not None. The mapping identifies equivalent elements based on equality up to a tolerance specified by self.rtol.

NonCoordinateAxis.str_as_val(key, s)[source]

str_as_val(self, key, s) - converts string s to a value corresponding to this axis. Default implementation returns float(s); derived classes can return different conversions depending on whether key corresponds to the axis itself or an auxiliary array.

NonCoordinateAxis.formatvalue(value, fmt=None, units=False, unitstr=None)[source]

Returns formatted string representation of value.

Parameters
valuefloat or int

Value to format.

fmtstring (optional)

Format specification. If the default None is specified, self.formatstr is used.

unitsboolean (optional)

If True, will include the units in the string returned. Default is True.

unitstrstring (optional)

String to use for the units; default is self.units.

Returns
If units is True, fmt % value + ‘ ‘ + unitstr. Otherwise fmt % value.

Notes

This is overridden in a number of Axis classes for more sophisticated formatting.

NonCoordinateAxis.__eq__(other)[source]

override Var’s ufunc stuff here this is a weak comparison, in that we only require the other axis to be a subclass of this one. this allows things like “lat in [time,gausslat,lev]” to evaluate to True If you want a more strict comparison, then check the classes explicitly yourself.