cfdm.Constructs.unfilter

Constructs.unfilter(depth=None)[source]

Return the constructs from before the previous filter.

The unfiltered constructs are all of those that existed before the last filter was applied. If no filters have been applied then all of the constructs are 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.

Returns:
Constructs

The constructs, and their construct keys, that existed before the last filter was applied. If no filters have been applied then all of the constructs are 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)>}
>>> 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 >}
>>> d.unfilter().equals(c)
True
>>> e = d.filter_by_method('mean')
>>> print(e)
Constructs:
{'cellmethod0': <CellMethod: area: mean>}
>>> e.unfilter().equals(d)
True
>>> e.unfilter().unfilter().equals(c)
True

If no filters have been applied then the unfiltered constructs are unchanged:

>>> c.filters_applied()
()
>>> c.unfilter().equals(c)
True