Skip to main content

A package to correct the bias of forecasts/hindcasts. Read the documentation at https://github.com/gouthamnaveen/mva

Project description

Documentation

A python package to adjust the bias of probabilistic forecasts/hindcasts using "Mean and Variance Adjustment" method.

Read documentation at https://github.com/gouthamnaveen/mva

References:

[1] Torralba, V., Doblas-Reyes, F. J., MacLeod, D., Christel, I. & Davis, M. Seasonal Climate Prediction: A New Source of Information for the Management of Wind Energy Resources. Journal of Applied Meteorology and Climatology 56, 1231–1247 (2017).

[2] Manzanas, R. et al. Bias adjustment and ensemble recalibration methods for seasonal forecasting: a comprehensive intercomparison using the C3S dataset. Clim Dyn 53, 1287–1305 (2019).

Installation:

pip install mva

Parameters:

hindcast: numpy.ndarray

The hindcast (or training) data. Kindly maintain the shape of the array as (years/samples,time,ensemble-members,grid-points).

observation: numpy.ndarray

The truth or observations corresponding to the hindcast. Kindly maintain the shape of the array as (years/samples,time,grid-points).

forecast: numpy.ndarray, optional

The forecast (or test) data. Kindly maintain the shape of the array as (time,ensemble-members,grid-points).

Note: Kindly respect the array shapes even if the computation is done for one time/grid point/ensemble member.

Methods:

adjust_hindcast():

This method corrects the bias of the hindcast using hindcast of the remaining years in the set (i.e., leave-one-out approach) and the corresponding observations.

Returns:

bias_adjusted_hindcast (Note: It has the same shape as the hindcast)

adjust_forecast():

This method corrects the bias of the forecast using hindcast and the corresponding observations. This method works only when the forecast parameter is given.

Returns:

bias_adjusted_forecast (Note: It has the same shape as the forecast)

Demonstration:

import numpy as np
import mva.mva as mva

Let's imagine that we have loaded the data of hindcast, forecast, and observation.

Example - 1

In [1]: hcast.shape
Out[1]: (20,46,10,6)
In [2]: fcast.shape
Out[2]: (46,50,6)
In [3]: obs.shape
Out[3]: (20,46,6)
In [4]: bc = mva(hcast,obs,fcast)
In [5]: ad_hcast = bc.adjust_hindcast()
In [6]: ad_hcast.shape
Out[6]: (20,46,10,6)
In [7]: ad_fcast = bc.adjust_forecast()
In [8]: ad_fcast.shape
Out[8]: (46,50,6)

Example - 2

In [1]: hcast.shape
Out[1]: (20,46,10,6)
In [2]: fcast.shape
Out[2]: (48,50,6)
In [3]: obs.shape
Out[3]: (20,46,6)
In [4]: ad_hcast = mva(hcast,obs,fcast).adjust_hindcast()
In [5]: ad_hcast.shape
Out[5]: (20,46,10,6)
In [6]: ad_fcast = mva(hcast,obs,fcast).adjust_forecast()
Out[6]: Please respect the array shapes and try again!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mva-0.0.2.tar.gz (7.1 kB view hashes)

Uploaded Source

Built Distribution

mva-0.0.2-py3-none-any.whl (7.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page