cf.Constructs.unfilter

Constructs.unfilter(depth=None)[source]

Return the constructs that existed prior to previous filters.

By default, the unfiltered constructs are those that existed before all previously applied filters.

If the depth parameter is set to N then the unfiltered constructs are those that existed before the N-th most recently applied filter.

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

If set to N then return the constructs selected by the N-th most recently applied filter. By default the constructs from before all previously applied filters are returned. N may be larger than the total number of filters applied, which results in the default bahaviour.

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>}
>>> c.unfilter().equals(c)
True
>>> c.unfilter(0).equals(c)
True
>>> e.unfilter().equals(c)
True
>>> e.unfilter(1).equals(d)
True
>>> e.unfilter(2).equals(c)
True

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

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