Skip to article frontmatterSkip to article content

Anomalies in EO

CSIC
UCM
IGEO

Climatology

Climatology Equation:yˉc(t)=1Nsn=1Nsy(xn,t)Climatology Function:yˉc:ΩGlobe×TReferenceRDySpatial Domain:xΩGlobeRDsTemporal Domain:tTReferenceR+\begin{aligned} \text{Climatology Equation}: && && \bar{y}_c(t) &= \frac{1}{N_s}\sum_{n=1}^{Ns}\boldsymbol{y}(\mathbf{x}_n,t) \\ \text{Climatology Function}: && && \bar{y}_c&: \Omega_\text{Globe}\times\mathcal{T}_\text{Reference} \rightarrow \mathbb{R}^{D_y} \\ \text{Spatial Domain}: && && \mathbf{x}&\in\Omega_\text{Globe}\subseteq\mathbb{R}^{D_s}\\ \text{Temporal Domain}: && && t&\in\mathcal{T}_\text{Reference}\subseteq\mathbb{R}^+ \end{aligned}

Anomalies

There is an error in this formulation because you cannot subtract the climatology from the global time series because they are on different temporal domains.

Climatology:yˉ=yˉc(t)tTReferenceR+Data:y=y(x,t)tTGlobeR+xΩRDs\begin{aligned} \text{Climatology}: && && \boldsymbol{\bar{y}} &= \boldsymbol{\bar{y}}_c(t) && && t\in\mathcal{T}_\text{Reference}\subseteq\mathbb{R}^+ \\ \text{Data}: && && \boldsymbol{y} &= \boldsymbol{y}(\mathbf{x},t) && && t\in\mathcal{T}_\text{Globe}\subseteq\mathbb{R}^+ && && \mathbf{x}\in\Omega\subseteq\mathbb{R}^{D_s} \end{aligned}

From a code perspective, this can be stated where the global data is

# global data
data_globe: Array["Nx Ny Nt"] = ...
# climatology reference period
data_climatology: Array["Nc"] = ...
# IMPOSSIBLE to subtract one timeseries from another (even with broadcasting)
data_anomaly: Array["Nx Ny Nt"] = data_globe - data_climatology

TODO: Need to figure out how this works.

PsuedoCode

https://xcdat.readthedocs.io/en/latest/examples/climatology-and-departures.html

Example 1: Monthly Mean

This example was taken from the xarray documentation.

# calculate monthly mean
climatology: xr.Dataset = ds.groupby("time.month").mean("time")

# calculate anomalies
anomalies: xr.Dataset = ds.groupby("time.month") - climatology

Example 2: Monthly Standardization

We can also calculate the standardized monthly means. This implies calculating the monthly mean and standard deviation.

# calculate monthly mean
climatology_mean: xr.Dataset = ds.groupby("time.month").mean("time")
climatology_std: xr.Dataset = ds.groupby("time.month").std("time")

# create standardization function
std_fn = lambda x, mean, std: (x - mean) / std

# calculate anomalies
anomalies: xr.Dataset = xr.apply_ufunc(
    std_fn,
    ds.groupby("time.month"),
    climatology_mean,
    climatology_std
)

Example 3: Seasonal