<jupyter_start><jupyter_text>Activity 3.2: Observation Localisation  1. IntroductionIn this activity, we will explore the concept of localisation, where an effect of observation is restricted to some spatial area. We will use the same setup as in Activity 3.1.<jupyter_code>import numpy as np
from tools.common_misc import gen_obs, rmse_spread, createH
from tools.common_plots import plotRMSP
from tools.L96_model import lorenz96
from tools.L96_kfs import kfs_lor96
from tools.L96_plots import plotL96, plotL96obs, plotL96DA_kf<jupyter_output><empty_output><jupyter_text>2. Compute the Nature RunAs before, we run the Lorenz 96 dynamical model with 12 variables to generate the truth.<jupyter_code>model = 'L96'
x0 = None # let it spin from rest (x_n(t=0) = F, forall n )
tmax = 5
Nx = 12
t, xt = lorenz96(tmax, x0, Nx) # Nx>=12
plotL96(t, xt, Nx)

# imperfect initial guess for our DA experiments
forc = 8.0
aux1 = forc * np.ones(Nx)
aux2 = range(Nx)
x0guess = aux1 + ((-1)*np.ones(Nx))**aux2<jupyter_output><empty_output><jupyter_text>3. Generate observationsAgain, as before, we generate observations (red dots) for every second variable at every 10 time steps.<jupyter_code># Decide what variables to observe
obsgrid = '1010'
H, observed_vars = createH(obsgrid, model, Nx)
period_obs = 10
var_obs = 2
# Generating the observations
seed = 1
tobs, y, R = gen_obs(t, xt, period_obs, H, var_obs, seed)
plotL96obs(t, xt, Nx, tobs, y, observed_vars)<jupyter_output><empty_output><jupyter_text>4. Observation localisationSet the ensemble size M=10. The localisation parameter `lam` limits the use of observations that are far away in space.An assimilation is performed at every observation time and background is generated for every assimilation. We show the analysis for each ensemble member, their mean, and ensemble spread. Run the experiments with `lam=2` and `lam=None`, where None means that all the observations are used. How does the analysis change? What is the effect on the ensemble spread?<jupyter_code>### 3. Data assimilation using KFa (SEnKF, LSEnKF and ETKF)
# No LETKF since R-localisation is extremely slow without parallel implementation    
rho = 0.1
M = 10
lam = 2
loctype = 'GC'
met = 'SEnKF' 
Xb,xb,Xa,xa,locmatrix = kfs_lor96(x0guess,t,tobs,y,H,R,rho,M,met,lam,loctype)
plotL96DA_kf(t,xt,tobs,y,Nx,observed_vars,Xb,xb,Xa,xa)

rmse_step=1
rmseb,spreadb = rmse_spread(xt,xb,Xb,rmse_step)
rmsea,spreada = rmse_spread(xt,xa,Xa,rmse_step)
plotRMSP(t,rmseb,rmsea,spreadb,spreada)
lam = None

Xb,xb,Xa,xa,locmatrix = kfs_lor96(x0guess,t,tobs,y,H,R,rho,M,met,lam,loctype)
plotL96DA_kf(t,xt,tobs,y,Nx,observed_vars,Xb,xb,Xa,xa)

rmse_step=1
rmseb,spreadb = rmse_spread(xt,xb,Xb,rmse_step)
rmsea,spreada = rmse_spread(xt,xa,Xa,rmse_step)
plotRMSP(t,rmseb,rmsea,spreadb,spreada)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.099361249112846, 'fraction_numerical': 0.029453513129879347, 'mean_word_length': 6.477453580901857, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '656163', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1133, 'n_tokens_neox': 1052, 'n_words': 304, 'path': '3-2_ensemble_activity_observation_localisation.ipynb', 'repo_name': 'the-iea/dare-da-notebooks', 'size': '2818'}