DIYA: A module for doityourself data assimilation¶
Suppose you have an ensemble reanalysis, like 20CR. So you have 56 different estimates of the global meansealevel pressure field at a particular date (say, 19031027:18). There is quite a lot of spread in this ensemble, the pressures are uncertain.
But we’ve also found a previouslyunused observation, a measurement of MSLP at that time a a weather station (say in Fort William). We can use that new observation to improve the reanalysis estimate, with the Ensemble Kalman Filter or something similar.
This module does this. It takes reanalysis data and observations, and assimilates the observations into the reanalysis fields, making improved versions.
import DIYA
new_field=DIYA.constrain_cube(old_field,old_field,obs)

DIYA.
constrain_cube
(target, constraints, obs, obs_error=0.1, random_state=None, model=None, lat_range=(90, 90), lon_range=(180, 360))[source]¶ Constrain the target at each gridpoint.
Generates the constraints at each observation location from the constraints cube, and then runs
constrain_point()
for each grid point in the target cube (inside the lat:lon ranges).Parameters:  target (
iris.cube.Cube
) – Ensemble to be constrained, must have dimensions ‘member’,’latitude’, and ‘longitude’”.  constraints (
iris.cube.Cube
) – Ensemble to constrain the target, must have dimensions (‘member’,’latitude’,’longitude’)”.  obs (
pandas.DataFrame
) – Observations. Dataframe must have columns ‘latitude’, ‘longitude’, and ‘value’, and value should have same units as constraints.  obs_error (
float
) – Uncertainty in each observation value (1 s.d.) . Units as obs.value.  random_state (
int
numpy.random.RandomState
, optional) – Set to produce exactly reproducible results.  model (
sklearn.linear_model
, optional) – Model to use to relate target to constraints. Defaults tosklearn.linear_model.ElasticNet
with default parameters.  lat_range (
list
, optional) – Only do constraint in this range of latitudes.  lon_range (
list
, optional) – Only do constraint in this range of longitudes.
Returns: target, after applying constraints.
Return type: iris.cube.cube
 target (

DIYA.
constrain_point
(target, constraint, model, obs)[source]¶ Constrain the target at a point
Fit a model to the target given the constraint (t=m(c)+r). Then make a predicted ensemble using the observations in the fitted model, and the residuals to the fit (p=m(o)+r). If nE=number of ensemble members, and nP=number of observation points:
Parameters:  target (
numpy.array
) – 1d array size nE  the target ensemble at the target point.  constraint (
numpy.array
) – 2d array size [nE,nP]  the constraint ensemble at each of the observation points.  model (
sklearn.linear_model
) – Model to fit.  obs (
numpy.array
) – 1d array size nP  the observations.
Returns: 1d array size nE  the constrained target ensemble.
Return type:  target (