Obtaining the events metrics

Key metrics

The key metrics for MHWs or MCSs as defined by Hobday et al. are contained in a constant const Metrics which is a dictionary of key-value pairs.

These metrics are calculated from the Events which is passed in as an argument to meanmetrics and annualmetrics.

Obtaining the trend requires the output from annualmetrics.

Calculating the metrics

MarineHeatwaves.annualmetricsFunction
annualmets = annualmetrics(evt, mhw_date, evst)

Compute the metrics for each year in the desired period.

MarineHeatwaves.linregFunction
a, b, r2, sigma_a, sigma_b, sigma_e = linreg(x,y)

Linear regression

y ≈ a + b * x

Multi-dimensional linear regression

y ≈ a + X b

a is a scalar and b a vector

y = a + X b + ϵ

Σ ϵ² = (y- (a + X b))^2

y = X beta + ϵ

beta = inv(X*X') * X' * y

Returning and viewing the metrics

MarineHeatwaves.mhmetricsFunction
mhcmetrics = mhmetrics(evt::Events, mhwdate, sts_ends)::MHCMetrics

Return the computed metrics - means, annuals and linear regression outputs as MHCMetrics.

MarineHeatwaves.mymetricFunction
mymetric(evt::Events{Vector{T}})::Matrix{T}

Return the Events of a single pixel as a matrix

mymetric(evt, "means")::Vector{T}

Return all the values of the events of a given metric as a vector.

mymetric(evt, indices, startends, mdate)::Matrix

Return the Events as a matrix to be used as a table (or dataframe).

clima = mymetric(mm::MExtreme, :clim, indices)

Return the climatology mean and threshold as input array.

annual_onset = mymetric(mm::MHCMetrics, field, metric, evst, indices)

Args:
    field: one of annuals, means, pvalues, coeffs, rsquared...
    metric: a single metric or a tuple of metrics

Return a given mean, annual or trend metric.