From f9064effa0bfb1ce28229e3e37e71f2acaa900c5 Mon Sep 17 00:00:00 2001 From: cgrudz Date: Thu, 17 Mar 2022 12:51:18 -0700 Subject: [PATCH 1/4] Just a quicky tidying --- dapper/mods/QG/illust_obs.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dapper/mods/QG/illust_obs.py b/dapper/mods/QG/illust_obs.py index b6027147..cf7cb59d 100644 --- a/dapper/mods/QG/illust_obs.py +++ b/dapper/mods/QG/illust_obs.py @@ -5,8 +5,7 @@ import dapper as dpr from dapper.mods.QG import square -from dapper.mods.QG.sakov2008 import HMM -from dapper.mods.QG.sakov2008 import obs_inds +from dapper.mods.QG.sakov2008 import HMM, obs_inds import dapper.tools.progressbar as pb From 3f8a7ec15fddd2f40c9821e01862ee2501c91797 Mon Sep 17 00:00:00 2001 From: cgrudz Date: Thu, 17 Mar 2022 15:15:58 -0700 Subject: [PATCH 2/4] Uploading initial ensemble perturbation solution demonstration This is a rough draft to demonstrate the effects of perturbing initial conditions on the subsequent solution of the QG system. More work to come, to clarify, simplify and add the observation model --- dapper/mods/QG/illust_ensemble.py | 80 +++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 dapper/mods/QG/illust_ensemble.py diff --git a/dapper/mods/QG/illust_ensemble.py b/dapper/mods/QG/illust_ensemble.py new file mode 100644 index 00000000..4bd18516 --- /dev/null +++ b/dapper/mods/QG/illust_ensemble.py @@ -0,0 +1,80 @@ +"""Ensemble generation for stream function time series for QG (quasi-geostrophic) model.""" + +from matplotlib import pyplot as plt +import numpy as np +import dapper.mods as modelling +import dapper as dpr +from dapper.mods.QG import square, model_config, default_prms, shape +import dapper.tools.progressbar as pb + +########### +# Auxiliary plotting function +########### +def show(x0, ax=None): + if ax == None: + fig, ax = plt.subplots() + + im = ax.imshow(square(x0)) + im.set_clim(-30, 30) + + def update(x): + im.set_data(square(x)) + return update + + +######################### +# Free ensemble run +######################### +def gen_ensemble_sample(model, nSamples, nEnsemble, SpinUp, Spacing): + simulator = modelling.with_recursion(model.step, prog="Simulating") + K = SpinUp + nSamples*Spacing + Nx = np.prod(shape) # total state length + init = np.random.normal(loc=0.0, scale=0.1, size=[nEnsemble, Nx]) + sample = simulator(init, K, 0.0, model.prms["dtout"]) + return sample[SpinUp::Spacing,:, :] + + +########### +# Main +########### +# Load or generate time-series data of a simulated state and obs: +fname = dpr.rc.dirs.data / "QG-ts-en.npz" +np.random.seed(123) + +# ensemble size needs to be at least Ne=2 for plotting to be true +plotting = True +Ne = 2 + +try: + with np.load(fname) as data: + E1 = np.squeeze(data['ens'][:, 0, :]) + E2 = np.squeeze(data['ens'][:, 1, :]) +except FileNotFoundError: + sample = gen_ensemble_sample(model_config("sample_generation", {}), + 400, Ne, 10, 10) + E1 = np.squeeze(sample[:, 0, :]) + E2 = np.squeeze(sample[:, 1, :]) + np.savez(fname, ens=sample) + +if plotting == True: + # Create figure + fig, (ax1, ax2) = plt.subplots(ncols=2, sharex=True, sharey=True, figsize=(12, 6)) + for ax in (ax1, ax2): + ax.set_aspect('equal', 'box') + ax1.set_title(r'Ensemble member 1') + ax2.set_title(r'Ensemble member 2') + + # Define plot updating functions + setter1 = show(E1[0], ax=ax1) + setter2 = show(E2[0], ax=ax2) + + # Create double iterable for the animation + ts = zip(E1, E2) + + # Animate + for k, (E1, E2) in pb.progbar(list(enumerate(ts)), "Animating"): + if k % 2 == 0: + fig.suptitle("k: "+str(k)) + setter1(E1) + setter2(E2) + plt.pause(0.01) From e7a90fe753adaa702714815f4adaa4e8f1f03577 Mon Sep 17 00:00:00 2001 From: cgrudz Date: Fri, 18 Mar 2022 08:50:16 -0700 Subject: [PATCH 3/4] Uploading static doc files? --- .DS_Store | Bin 0 -> 6148 bytes dapper/.DS_Store | Bin 0 -> 6148 bytes docs/.DS_Store | Bin 0 -> 6148 bytes 3 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 .DS_Store create mode 100644 dapper/.DS_Store create mode 100644 docs/.DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..c2ca084336d6dc052521bd370e78fd963269de20 GIT binary patch literal 6148 zcmeHKF;5gh6#m9r^&&A|A%Q|=V`ri$jV&u4#>ND_RuVl950X3gf=5DPvz-lF1MP1e>+dZEd&7FhR9xJzizTe0sj8#4UXBPk+#dZiIrr0YI5JN+KV&jI zO7X!x;d22kyhM+mMXV?`*DJS<`a>=scb+`{@XK;hbA(KW#V8&(cZJ85kOwtd7e380UD!0Zv+T|VX@LJc$*84#*A&=jC(+~acyfjzH=eRh<3%kPW zJo>_hy=GKdmM1RohFlt-KTUW|RK($LeQ<=TpVXxOzVXZ!tByE~eN-SS5EVF3K=y}} zO)&FVIJ8>_JNpViOgL6HN&%D98}%73$)ByI y#mQNlvb|svleog6O=0JcV|yV-@i?0``ck3$SD_F&iaI!LU z^yz^5G^9gH3ehqk3Wx%~O#xoJ4XoCL#&m|YJ72%a=&04{>vU`=tIfB?k*SX3-bnWl zQMeYy?&f=EuAyf zbEaR#=6EhKO$xxU$Zcg~+4uQ;_AmABWNNgV<@y}T{JFZTrfwCgX#7SWR0(cx;PLNvz6VP?^69q7yz z02pA{7@ql)f^$NLk;BX)JTPTbfi_jSD~7V^7!O@si9 lO$s`99GeF|ir3JL!58uaFmjk##0X421dI&Qi2^^Wz&kSOnDqbv literal 0 HcmV?d00001 diff --git a/docs/.DS_Store b/docs/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..4c26e6ca6aff42a5945223d5477bd9a3cd8833e8 GIT binary patch literal 6148 zcmeHKu};G<5Ixfjfp%!c!bZLTseD0Ng@Fy!AAqz~L25{((iLS!NQjM%l>zYu3`qSL zR#rCN*;Z?l&=H~PE;>KQcjvo2DY=-4RDV9|619magfa#@7;1#=tQFa^D;%tNkM3ZY zXGO(N7K8y|;D0i}?{0%qx}zNs>U2L^ov00vmrf;s`#84(2>yh<~EtUpNI4OJhP&Tu&ClsZ#WB*9IlZp+>C=3V#J_8MN+vfg%^!xeW z50X1!Kp5C422_v?l0F{E_SVY7aj%V_XHXXQD-G%p47MHX3Af@ss212Fo&aNur9rGf P Date: Fri, 18 Mar 2022 09:26:22 -0700 Subject: [PATCH 4/4] Removing Mac junk --- .DS_Store | Bin 6148 -> 0 bytes dapper/.DS_Store | Bin 6148 -> 0 bytes docs/.DS_Store | Bin 6148 -> 0 bytes 3 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .DS_Store delete mode 100644 dapper/.DS_Store delete mode 100644 docs/.DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index c2ca084336d6dc052521bd370e78fd963269de20..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKF;5gh6#m9r^&&A|A%Q|=V`ri$jV&u4#>ND_RuVl950X3gf=5DPvz-lF1MP1e>+dZEd&7FhR9xJzizTe0sj8#4UXBPk+#dZiIrr0YI5JN+KV&jI zO7X!x;d22kyhM+mMXV?`*DJS<`a>=scb+`{@XK;hbA(KW#V8&(cZJ85kOwtd7e380UD!0Zv+T|VX@LJc$*84#*A&=jC(+~acyfjzH=eRh<3%kPW zJo>_hy=GKdmM1RohFlt-KTUW|RK($LeQ<=TpVXxOzVXZ!tByE~eN-SS5EVF3K=y}} zO)&FVIJ8>_JNpViOgL6HN&%D98}%73$)ByI y#mQNlvb|svleog6O=0JcV|yV-@i?0``ck3$SD_F&iaI!LU z^yz^5G^9gH3ehqk3Wx%~O#xoJ4XoCL#&m|YJ72%a=&04{>vU`=tIfB?k*SX3-bnWl zQMeYy?&f=EuAyf zbEaR#=6EhKO$xxU$Zcg~+4uQ;_AmABWNNgV<@y}T{JFZTrfwCgX#7SWR0(cx;PLNvz6VP?^69q7yz z02pA{7@ql)f^$NLk;BX)JTPTbfi_jSD~7V^7!O@si9 lO$s`99GeF|ir3JL!58uaFmjk##0X421dI&Qi2^^Wz&kSOnDqbv diff --git a/docs/.DS_Store b/docs/.DS_Store deleted file mode 100644 index 4c26e6ca6aff42a5945223d5477bd9a3cd8833e8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKu};G<5Ixfjfp%!c!bZLTseD0Ng@Fy!AAqz~L25{((iLS!NQjM%l>zYu3`qSL zR#rCN*;Z?l&=H~PE;>KQcjvo2DY=-4RDV9|619magfa#@7;1#=tQFa^D;%tNkM3ZY zXGO(N7K8y|;D0i}?{0%qx}zNs>U2L^ov00vmrf;s`#84(2>yh<~EtUpNI4OJhP&Tu&ClsZ#WB*9IlZp+>C=3V#J_8MN+vfg%^!xeW z50X1!Kp5C422_v?l0F{E_SVY7aj%V_XHXXQD-G%p47MHX3Af@ss212Fo&aNur9rGf P