tams.data_in_contours#
- tams.data_in_contours(data, contours, *, agg=('mean', 'std', 'count'), method='sjoin', merge=False)#
Compute statistics on data within the shapes of contours.
With the default settings, we calculate, for each shape (row) in the contours dataframe:
the mean value of data within the shape
the standard deviation of data within the shape
the count of non-null values of data within the shape
- Parameters
data (xarray.DataArray | xarray.Dataset) – It should have
'lat'
and'lon'
coordinates.contours (geopandas.GeoDataFrame) – For example, dataframe of CE or MCS shapes, e.g. from
identify()
ortrack()
.agg (sequence of
str
orcallable()
) – Suitable for passing topandas.DataFrame.aggregate()
.method (
{'sjoin', 'regionmask'}
) – The regionmask method is suited for data on a structured grid, while the GeoPandas sjoin method works for scattered point data as well. The sjoin method is the default since it is more general and currently often faster.merge (bool) – Whether to merge the new data with contours or return a separate frame.
- Return type
See also
- Identify CEs using different CTT thresholds
A usage example.