filter
- filter(gpt, cond)
Returns a subset of
gptaccording to the filter conditions defined incond.- Parameters
- Return type
The actual filtering is based on the type of
cond:if
condis aGeopointsit must have the same number of values asgpt. The result will contain the values ofgptwhere the value ofcondis non-zero. It is usually combined with the comparison operators.- Example
This code shows how to filter the negative values in a
Geopointscontaining temperature in K.import metview as mv t = mv.read("temp.gpt") freeze = mv.filter(t,t < 273.16)
if
condis an ndarray it must have the same number of values asgpt. The result will contain the values ofgptwhere the value ofcondis 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
condis 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 ofgptwhere the level equals tocond(if it is a number) or in the interval specified bycond(if it is a list).if
condis 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 ofgptwhere the date equals tocond(if it is a datetime.datetime) or in the interval specified bycond(if it is a list).if
condis 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 ofgptwhere the locations are withincond.