cfdm.Constructs.inverse_filter

Constructs.inverse_filter(depth=None)[source]

Return the inverse of the previous filter.

The inverse comprises all of the constructs that were not selected by the last filter applied. If no filters have been applied, or the last filter was an inverse filter, then an empty Constructs instance is returned.

A history of the filters that have been applied is returned in a tuple by the filters_applied method. The last element of the tuple describes the last filter applied. If no filters have been applied then the tuple is empty.

New in version 1.7.0.

Parameters:

depth: int, optional

Returns:
Constructs

The constructs, and their construct keys, that were not selected by the last filter applied. If no filtering has been applied, or the last filter was an inverse filter, then an empty Constructs instance is returned.

Examples:

>>> print(c)
Constructs:
{'cellmethod0': <CellMethod: area: mean>,
 'dimensioncoordinate0': <DimensionCoordinate: latitude(5) degrees_north>,
 'dimensioncoordinate1': <DimensionCoordinate: longitude(8) degrees_east>,
 'dimensioncoordinate2': <DimensionCoordinate: time(1) days since 2018-12-01 >,
 'domainaxis0': <DomainAxis: size(5)>,
 'domainaxis1': <DomainAxis: size(8)>,
 'domainaxis2': <DomainAxis: size(1)>}
>>> print(c.inverse_filter())
Constructs:
{}
>>> d = c.filter_by_type('dimension_coordinate', 'cell_method')
>>> print(d)
Constructs:
{'cellmethod0': <CellMethod: area: mean>,
 'dimensioncoordinate0': <DimensionCoordinate: latitude(5) degrees_north>,
 'dimensioncoordinate1': <DimensionCoordinate: longitude(8) degrees_east>,
 'dimensioncoordinate2': <DimensionCoordinate: time(1) days since 2018-12-01 >}
>>> print(d.inverse_filter())
Constructs:
{'domainaxis0': <DomainAxis: size(5)>,
 'domainaxis1': <DomainAxis: size(8)>,
 'domainaxis2': <DomainAxis: size(1)>}
>>> e = d.filter_by_method('mean')
>>> print(e)
Constructs:
{'cellmethod0': <CellMethod: area: mean>}
>>> print(e.inverse_filter())
Constructs:
{'dimensioncoordinate0': <DimensionCoordinate: latitude(5) degrees_north>,
 'dimensioncoordinate1': <DimensionCoordinate: longitude(8) degrees_east>,
 'dimensioncoordinate2': <DimensionCoordinate: time(1) days since 2018-12-01 >}

The inverse filter of the inverse filter always returns no constructs:

>>> d.inverse_filter().inverse_filter()
<Constructs: >