geocat.comp.climatologies.anomaly#
- geocat.comp.climatologies.anomaly(dset, freq, time_coord_name=None)#
Deprecated since version 2023.02.0: The
anomaly
function is deprecated due to inaccuracies in monthly anomaly calculations and when using monthly data to calculate seasonal or yearly anomalies. Use climate_anomaly instead.- 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
, optional) – Name for time coordinate to use. Defaults toNone
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 >>> # Create toy data >>> dates = pd.date_range(start="2000/01/01", ... freq="M", ... dates=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
>>> # Compute seasonal anomalies >>> 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 GeoCAT Functions:
climate_anomaly()
Related NCL Functions: clmDayAnomTLL, clmDayAnomTLLL, clmMonAnomLLLT, clmMonAnomLLT, clmMonAnomTLL, clmMonAnomTLLL