geocat.comp.climatologies.anomaly
geocat.comp.climatologies.anomaly#
- geocat.comp.climatologies.anomaly(dset, freq, time_coord_name=None)#
Compute anomalies for a specified time frequency.
- Parameters
dset (
xarray.Dataset
,xarray.DataArray
) – The data on which to operatefreq (
str
) –Anomaly frequency alias. Accepted alias:
‘day’: for daily anomalies
‘month’: for monthly anomalies
‘year’: for annual anomalies
‘season’: for seasonal anomalies
time_coord_name (
str
) – Name for time coordinate to use. Defaults to None and infers the name from the data.
- Returns
computed_dset (
xarray.Dataset
,xarray.DataArray
) – The computed anomaly data
Examples
>>> import xarray as xr >>> import pandas as pd >>> import numpy as np >>> import geocat.comp >>> dates = pd.date_range(start="2000/01/01", freq="M", periods=24) >>> ts = xr.DataArray(np.arange(24).reshape(24, 1, 1), dims=["time", "lat", "lon"], coords={"time": dates}) >>> ts <xarray.DataArray (time: 24, lat: 1, lon: 1)> array([[[ 0]], [[ 1]], [[ 2]], [[21]], [[22]], [[23]]]) Coordinates: * time (time) datetime64[ns] 2000-01-31 2000-02-29 ... 2001-12-31 Dimensions without coordinates: lat, lon >>> geocat.comp.anomaly(ts, 'season') <xarray.DataArray (time: 24, lat: 1, lon: 1)> array([[[-10.]], [[ -9.]], [[ -7.]], [[ 6.]], [[ 7.]], [[ 13.]]]) Coordinates: * time (time) datetime64[ns] 2000-01-31 2000-02-29 ... 2001-12-31 season (time) <U3 'DJF' 'DJF' 'MAM' 'MAM' ... 'SON' 'SON' 'SON' 'DJF' Dimensions without coordinates: lat, lon
See also
Related NCL Functions: clmDayAnomTLL, clmDayAnomTLLL, clmMonAnomLLLT, clmMonAnomLLT, clmMonAnomTLL, clmMonAnomTLLL