cf.Field.equals

Field.equals(other, rtol=None, atol=None, traceback=False)

True if two fields are logically equal, False otherwise.

The Conventions CF property is ignored in the comparison.

Parameters :
other :

The object to compare for equality.

atol : float, optional

The absolute tolerance for all numerical comparisons, By default the value returned by the ATOL function is used.

rtol : float, optional

The relative tolerance for all numerical comparisons, By default the value returned by the RTOL function is used.

traceback : bool, optional

If True then print a traceback highlighting where the two instances differ.

Returns :
out : bool

Whether or not the two instances are equal.

Examples

>>> f.Conventions
'CF-1.0'
>>> g = f.copy()
>>> g.Conventions = 'CF-1.5'
>>> f.equals(g)
True

In the following example, two fields differ only by the long name of their time coordinates. The traceback shows that they differ in their spaces, that they differ in their time coordinates and that the long name could not be matched.

>>> g = f.copy()
>>> g.coord('time').long_name = 'something_else'
>>> f.equals(g, traceback=True)
Coordinate: Different long_name: 'time', 'something else'
Coordinate: Different long_name: 'time', 'latitude in rotated pole grid'
Coordinate: Different long_name: 'time', 'longitude in rotated pole grid'
Space: Different coordinate: <CF Coordinate: time(12)>
Field: Different 'space': <CF Space: (73, 96, 12)>, <CF Space: (73, 96, 12)>
False

Previous topic

cf.Field.dump

Next topic

cf.Field.expand_dims

This Page