filter
- filter(gpt, cond)
Returns a subset of
gpt
according to the filter conditions defined incond
.- Parameters
- Return type
The actual filtering is based on the type of
cond
:if
cond
is aGeopoints
it must have the same number of values asgpt
. The result will contain the values ofgpt
where the value ofcond
is non-zero. It is usually combined with the comparison operators.- Example
This code shows how to filter the negative values in a
Geopoints
containing temperature in K.import metview as mv t = mv.read("temp.gpt") freeze = mv.filter(t,t < 273.16)
if
cond
is an ndarray it must have the same number of values asgpt
. The result will contain the values ofgpt
where the value ofcond
is non-zero. It is usually combined with the comparison operators.- Example
import metview as mv gpt = mv.read("my_date.gpt") # "gpt["precip"] > 5" returns a vector of 1s and 0s new_gpt = mv.filter(gpt, gpt["precip"] > 5)
if
cond
is number or list of numbers in the format of [min_level, max_level] it defines a filter on the level column ofgpt
. The result will contain the values ofgpt
where the level equals tocond
(if it is a number) or in the interval specified bycond
(if it is a list).if
cond
is datetime.datetime or list of it in the format of [min_date, max_date] it defines a filter on the date column ofgpt
. The result will contain the values ofgpt
where the date equals tocond
(if it is a datetime.datetime) or in the interval specified bycond
(if it is a list).if
cond
is a list in the format of [North, West, South, East] format it defines a filter with a geographical area. The result will contain the values ofgpt
where the locations are withincond
.