#%load_ext autoreload
#%autoreload 2
Tutorial: Lorenz-96#
This notebook runs the Lorenz96 example using ICESEE’s data assimilation driver.
import os, sys
import platform
import numpy as np
from pathlib import Path
from IPython.display import HTML
# Setup and preprocessing:
# Current path
Path = os.path.realpath(".")
#print ('Path: %s\n' %Path)
# Parent path
Parentpath = os.path.dirname(Path)
#print ('Parentpath: %s\n' %Parentpath)
# Add to PYTHONPATH
sys.path.append(Parentpath)
# Tool path
Toolpath = os.path.dirname(Parentpath)
#print ('Toolpath: %s\n' %Toolpath)
import utils
from utils.configuration import VERBOSE
if VERBOSE:
print ("Operating System Platform: " + platform.system(), platform.release())
print ("\n")
print ("os.environ['PATH']: ", os.environ['PATH'])
print ("sys.path: ", sys.path)
print ("\n")
#https://api.jquery.com/ready/
HTML('''
<script>
function scroll_to_top() {
Jupyter.notebook.scroll_to_top();
}
$( window ).on( "load", scroll_to_top() );
</script>
''')
%%javascript
IPython.OutputArea.prototype._should_scroll = function(lines) {
return false;
}
print ('\nDirectory tree of\n%s:\n' %Toolpath)
from utils.Tree import Tree
results_tree = Tree(Toolpath)
# results_tree.print_tree()
Directory tree of
/home/bkyanjo3/CryoLauncher:
from _bootstrap._bootstrap import enable_icesee
enable_icesee()
[ICESEE bootstrap] external path enabled: /home/bkyanjo3/CryoLauncher/external
[ICESEE bootstrap] ICESEE loaded from: /home/bkyanjo3/CryoLauncher/external/ICESEE/__init__.py
PosixPath('/home/bkyanjo3/CryoLauncher/external')
# --- call the lorenz96 data assimilation example ---
# go to external/ICESEE
# os.system('cd ../../external/ICESEE/applications/lorenz_model/examples/lorenz96')
import os
os.system('python3 -m ICESEE.applications.lorenz_model.examples.lorenz96.run_da_lorenz96')
[ICESEE] Running default parallel mode
[ICESEE] Generating true state ...
[ICESEE] Generating nurged state ...
[ICESEE] Generating synthetic observations ...
[ICESEE] observation times requested: [0.1 0.3 0.5 0.7 0.9 1.1 1.3 1.5 1.7 1.9]
[ICESEE] observation model indices ind_m: [ 10 30 50 70 90 110 130 150 170 190], total m_obs=10
[ICESEE] bed_snaps: []
[ICESEE] bed_snap_cols: []
[ICESEE] Initializing the ensemble ...
[ICESEE] Launching lorenz with data assimilation using the EnKF filter across 1 MPI ranks.
[ICESEE] Assimilation progress (1 ranks): 0%| | 0/1000 [00:00<?, ?it/s]
[ICESEE] Assimilation progress (1 ranks): 1%| | 8/1000 [00:00<00:12, 78.51it/s]
[ICESEE] Assimilation progress (1 ranks): 2%|▏ | 16/1000 [00:00<00:14, 66.45it/s]
[ICESEE] Assimilation progress (1 ranks): 2%|▏ | 24/1000 [00:00<00:14, 69.70it/s]
[ICESEE] Assimilation progress (1 ranks): 3%|▎ | 32/1000 [00:00<00:13, 70.22it/s]
[ICESEE] Assimilation progress (1 ranks): 4%|▍ | 40/1000 [00:00<00:13, 72.19it/s]
[ICESEE] Assimilation progress (1 ranks): 5%|▍ | 49/1000 [00:00<00:12, 75.00it/s]
[ICESEE] Assimilation progress (1 ranks): 6%|▌ | 57/1000 [00:00<00:12, 73.49it/s]
[ICESEE] Assimilation progress (1 ranks): 6%|▋ | 65/1000 [00:00<00:12, 72.75it/s]
[ICESEE] Assimilation progress (1 ranks): 7%|▋ | 73/1000 [00:01<00:12, 72.53it/s]
[ICESEE] Assimilation progress (1 ranks): 8%|▊ | 81/1000 [00:01<00:12, 73.42it/s]
[ICESEE] Assimilation progress (1 ranks): 9%|▉ | 89/1000 [00:01<00:12, 73.97it/s]
[ICESEE] Assimilation progress (1 ranks): 10%|▉ | 97/1000 [00:01<00:12, 74.18it/s]
[ICESEE] Assimilation progress (1 ranks): 10%|█ | 105/1000 [00:01<00:12, 74.48it/s]
[ICESEE] Assimilation progress (1 ranks): 11%|█▏ | 113/1000 [00:01<00:12, 72.80it/s]
[ICESEE] Assimilation progress (1 ranks): 12%|█▏ | 121/1000 [00:01<00:12, 71.11it/s]
[ICESEE] Assimilation progress (1 ranks): 13%|█▎ | 129/1000 [00:01<00:12, 72.47it/s]
[ICESEE] Assimilation progress (1 ranks): 14%|█▎ | 137/1000 [00:01<00:12, 70.81it/s]
[ICESEE] Assimilation progress (1 ranks): 14%|█▍ | 145/1000 [00:02<00:11, 72.19it/s]
[ICESEE] Assimilation progress (1 ranks): 15%|█▌ | 153/1000 [00:02<00:11, 70.88it/s]
[ICESEE] Assimilation progress (1 ranks): 16%|█▌ | 161/1000 [00:02<00:11, 71.27it/s]
[ICESEE] Assimilation progress (1 ranks): 17%|█▋ | 169/1000 [00:02<00:11, 72.15it/s]
[ICESEE] Assimilation progress (1 ranks): 18%|█▊ | 177/1000 [00:02<00:11, 71.65it/s]
[ICESEE] Assimilation progress (1 ranks): 18%|█▊ | 185/1000 [00:02<00:11, 72.81it/s]
[ICESEE] Assimilation progress (1 ranks): 19%|█▉ | 193/1000 [00:02<00:11, 73.14it/s]
[ICESEE] Assimilation progress (1 ranks): 20%|██ | 201/1000 [00:02<00:10, 74.82it/s]
[ICESEE] Assimilation progress (1 ranks): 21%|██ | 209/1000 [00:02<00:10, 75.45it/s]
[ICESEE] Assimilation progress (1 ranks): 22%|██▏ | 217/1000 [00:02<00:10, 75.86it/s]
[ICESEE] Assimilation progress (1 ranks): 22%|██▎ | 225/1000 [00:03<00:10, 76.89it/s]
[ICESEE] Assimilation progress (1 ranks): 23%|██▎ | 233/1000 [00:03<00:09, 76.92it/s]
[ICESEE] Assimilation progress (1 ranks): 24%|██▍ | 241/1000 [00:03<00:09, 77.00it/s]
[ICESEE] Assimilation progress (1 ranks): 25%|██▍ | 249/1000 [00:03<00:09, 75.39it/s]
[ICESEE] Assimilation progress (1 ranks): 26%|██▌ | 257/1000 [00:03<00:09, 74.55it/s]
[ICESEE] Assimilation progress (1 ranks): 26%|██▋ | 265/1000 [00:03<00:09, 74.76it/s]
[ICESEE] Assimilation progress (1 ranks): 27%|██▋ | 273/1000 [00:03<00:09, 75.97it/s]
[ICESEE] Assimilation progress (1 ranks): 28%|██▊ | 281/1000 [00:03<00:09, 75.14it/s]
[ICESEE] Assimilation progress (1 ranks): 29%|██▉ | 289/1000 [00:03<00:09, 73.50it/s]
[ICESEE] Assimilation progress (1 ranks): 30%|██▉ | 297/1000 [00:04<00:09, 73.29it/s]
[ICESEE] Assimilation progress (1 ranks): 30%|███ | 305/1000 [00:04<00:10, 67.61it/s]
[ICESEE] Assimilation progress (1 ranks): 31%|███▏ | 313/1000 [00:04<00:09, 70.20it/s]
[ICESEE] Assimilation progress (1 ranks): 32%|███▏ | 321/1000 [00:04<00:09, 72.69it/s]
[ICESEE] Assimilation progress (1 ranks): 33%|███▎ | 329/1000 [00:04<00:09, 71.22it/s]
[ICESEE] Assimilation progress (1 ranks): 34%|███▎ | 337/1000 [00:04<00:09, 70.28it/s]
[ICESEE] Assimilation progress (1 ranks): 34%|███▍ | 345/1000 [00:04<00:09, 71.67it/s]
[ICESEE] Assimilation progress (1 ranks): 35%|███▌ | 353/1000 [00:04<00:08, 73.37it/s]
[ICESEE] Assimilation progress (1 ranks): 36%|███▌ | 361/1000 [00:04<00:08, 73.46it/s]
[ICESEE] Assimilation progress (1 ranks): 37%|███▋ | 369/1000 [00:05<00:08, 72.47it/s]
[ICESEE] Assimilation progress (1 ranks): 38%|███▊ | 377/1000 [00:05<00:09, 68.48it/s]
[ICESEE] Assimilation progress (1 ranks): 38%|███▊ | 384/1000 [00:05<00:08, 68.83it/s]
[ICESEE] Assimilation progress (1 ranks): 39%|███▉ | 392/1000 [00:05<00:08, 69.91it/s]
[ICESEE] Assimilation progress (1 ranks): 40%|████ | 400/1000 [00:05<00:08, 71.03it/s]
[ICESEE] Assimilation progress (1 ranks): 41%|████ | 408/1000 [00:05<00:09, 62.40it/s]
[ICESEE] Assimilation progress (1 ranks): 42%|████▏ | 416/1000 [00:05<00:08, 66.72it/s]
[ICESEE] Assimilation progress (1 ranks): 42%|████▏ | 424/1000 [00:05<00:08, 70.10it/s]
[ICESEE] Assimilation progress (1 ranks): 43%|████▎ | 432/1000 [00:05<00:07, 71.01it/s]
[ICESEE] Assimilation progress (1 ranks): 44%|████▍ | 440/1000 [00:06<00:07, 71.61it/s]
[ICESEE] Assimilation progress (1 ranks): 45%|████▍ | 448/1000 [00:06<00:07, 71.99it/s]
[ICESEE] Assimilation progress (1 ranks): 46%|████▌ | 456/1000 [00:06<00:07, 73.70it/s]
[ICESEE] Assimilation progress (1 ranks): 46%|████▋ | 464/1000 [00:06<00:07, 72.71it/s]
[ICESEE] Assimilation progress (1 ranks): 47%|████▋ | 472/1000 [00:06<00:07, 71.42it/s]
[ICESEE] Assimilation progress (1 ranks): 48%|████▊ | 480/1000 [00:06<00:07, 70.42it/s]
[ICESEE] Assimilation progress (1 ranks): 49%|████▉ | 488/1000 [00:06<00:07, 71.85it/s]
[ICESEE] Assimilation progress (1 ranks): 50%|████▉ | 496/1000 [00:06<00:06, 73.05it/s]
[ICESEE] Assimilation progress (1 ranks): 50%|█████ | 504/1000 [00:06<00:06, 72.32it/s]
[ICESEE] Assimilation progress (1 ranks): 51%|█████ | 512/1000 [00:07<00:06, 70.61it/s]
[ICESEE] Assimilation progress (1 ranks): 52%|█████▏ | 520/1000 [00:07<00:06, 72.22it/s]
[ICESEE] Assimilation progress (1 ranks): 53%|█████▎ | 528/1000 [00:07<00:06, 73.68it/s]
[ICESEE] Assimilation progress (1 ranks): 54%|█████▎ | 536/1000 [00:07<00:06, 74.21it/s]
[ICESEE] Assimilation progress (1 ranks): 54%|█████▍ | 544/1000 [00:07<00:06, 74.22it/s]
[ICESEE] Assimilation progress (1 ranks): 55%|█████▌ | 552/1000 [00:07<00:05, 74.78it/s]
[ICESEE] Assimilation progress (1 ranks): 56%|█████▌ | 560/1000 [00:07<00:05, 75.28it/s]
[ICESEE] Assimilation progress (1 ranks): 57%|█████▋ | 568/1000 [00:07<00:05, 76.21it/s]
[ICESEE] Assimilation progress (1 ranks): 58%|█████▊ | 576/1000 [00:07<00:05, 75.42it/s]
[ICESEE] Assimilation progress (1 ranks): 58%|█████▊ | 584/1000 [00:08<00:05, 74.30it/s]
[ICESEE] Assimilation progress (1 ranks): 59%|█████▉ | 592/1000 [00:08<00:05, 73.30it/s]
[ICESEE] Assimilation progress (1 ranks): 60%|██████ | 600/1000 [00:08<00:05, 71.54it/s]
[ICESEE] Assimilation progress (1 ranks): 61%|██████ | 608/1000 [00:08<00:05, 71.43it/s]
[ICESEE] Assimilation progress (1 ranks): 62%|██████▏ | 616/1000 [00:08<00:05, 71.37it/s]
[ICESEE] Assimilation progress (1 ranks): 62%|██████▏ | 624/1000 [00:08<00:05, 73.75it/s]
[ICESEE] Assimilation progress (1 ranks): 63%|██████▎ | 632/1000 [00:08<00:04, 74.53it/s]
[ICESEE] Assimilation progress (1 ranks): 64%|██████▍ | 640/1000 [00:08<00:04, 75.28it/s]
[ICESEE] Assimilation progress (1 ranks): 65%|██████▍ | 648/1000 [00:08<00:04, 76.02it/s]
[ICESEE] Assimilation progress (1 ranks): 66%|██████▌ | 656/1000 [00:09<00:04, 75.60it/s]
[ICESEE] Assimilation progress (1 ranks): 66%|██████▋ | 665/1000 [00:09<00:04, 77.01it/s]
[ICESEE] Assimilation progress (1 ranks): 67%|██████▋ | 673/1000 [00:09<00:04, 75.62it/s]
[ICESEE] Assimilation progress (1 ranks): 68%|██████▊ | 681/1000 [00:09<00:04, 76.38it/s]
[ICESEE] Assimilation progress (1 ranks): 69%|██████▉ | 689/1000 [00:09<00:04, 77.09it/s]
[ICESEE] Assimilation progress (1 ranks): 70%|██████▉ | 697/1000 [00:09<00:03, 77.44it/s]
[ICESEE] Assimilation progress (1 ranks): 70%|███████ | 705/1000 [00:09<00:03, 76.77it/s]
[ICESEE] Assimilation progress (1 ranks): 71%|███████▏ | 713/1000 [00:09<00:03, 76.84it/s]
[ICESEE] Assimilation progress (1 ranks): 72%|███████▏ | 721/1000 [00:09<00:03, 76.12it/s]
[ICESEE] Assimilation progress (1 ranks): 73%|███████▎ | 729/1000 [00:09<00:03, 75.84it/s]
[ICESEE] Assimilation progress (1 ranks): 74%|███████▎ | 737/1000 [00:10<00:03, 76.71it/s]
[ICESEE] Assimilation progress (1 ranks): 74%|███████▍ | 745/1000 [00:10<00:03, 76.90it/s]
[ICESEE] Assimilation progress (1 ranks): 75%|███████▌ | 753/1000 [00:10<00:03, 67.14it/s]
[ICESEE] Assimilation progress (1 ranks): 76%|███████▌ | 760/1000 [00:10<00:03, 63.73it/s]
[ICESEE] Assimilation progress (1 ranks): 77%|███████▋ | 768/1000 [00:10<00:03, 67.97it/s]
[ICESEE] Assimilation progress (1 ranks): 78%|███████▊ | 776/1000 [00:10<00:03, 70.32it/s]
[ICESEE] Assimilation progress (1 ranks): 78%|███████▊ | 784/1000 [00:10<00:02, 72.66it/s]
[ICESEE] Assimilation progress (1 ranks): 79%|███████▉ | 792/1000 [00:10<00:02, 74.32it/s]
[ICESEE] Assimilation progress (1 ranks): 80%|████████ | 800/1000 [00:10<00:02, 73.60it/s]
[ICESEE] Assimilation progress (1 ranks): 81%|████████ | 808/1000 [00:11<00:02, 72.15it/s]
[ICESEE] Assimilation progress (1 ranks): 82%|████████▏ | 816/1000 [00:11<00:02, 72.58it/s]
[ICESEE] Assimilation progress (1 ranks): 82%|████████▏ | 824/1000 [00:11<00:02, 70.52it/s]
[ICESEE] Assimilation progress (1 ranks): 83%|████████▎ | 832/1000 [00:11<00:02, 62.40it/s]
[ICESEE] Assimilation progress (1 ranks): 84%|████████▍ | 840/1000 [00:11<00:02, 66.22it/s]
[ICESEE] Assimilation progress (1 ranks): 85%|████████▍ | 848/1000 [00:11<00:02, 69.24it/s]
[ICESEE] Assimilation progress (1 ranks): 86%|████████▌ | 856/1000 [00:11<00:01, 72.06it/s]
[ICESEE] Assimilation progress (1 ranks): 86%|████████▋ | 864/1000 [00:11<00:01, 74.18it/s]
[ICESEE] Assimilation progress (1 ranks): 87%|████████▋ | 872/1000 [00:11<00:01, 75.03it/s]
[ICESEE] Assimilation progress (1 ranks): 88%|████████▊ | 880/1000 [00:12<00:01, 74.04it/s]
[ICESEE] Assimilation progress (1 ranks): 89%|████████▉ | 888/1000 [00:12<00:01, 73.65it/s]
[ICESEE] Assimilation progress (1 ranks): 90%|████████▉ | 896/1000 [00:12<00:01, 75.38it/s]
[ICESEE] Assimilation progress (1 ranks): 90%|█████████ | 904/1000 [00:12<00:01, 75.29it/s]
[ICESEE] Assimilation progress (1 ranks): 91%|█████████ | 912/1000 [00:12<00:01, 75.19it/s]
[ICESEE] Assimilation progress (1 ranks): 92%|█████████▏| 920/1000 [00:12<00:01, 76.15it/s]
[ICESEE] Assimilation progress (1 ranks): 93%|█████████▎| 928/1000 [00:12<00:00, 76.51it/s]
[ICESEE] Assimilation progress (1 ranks): 94%|█████████▎| 936/1000 [00:12<00:00, 77.29it/s]
[ICESEE] Assimilation progress (1 ranks): 94%|█████████▍| 944/1000 [00:12<00:00, 77.78it/s]
[ICESEE] Assimilation progress (1 ranks): 95%|█████████▌| 952/1000 [00:13<00:00, 77.85it/s]
[ICESEE] Assimilation progress (1 ranks): 96%|█████████▌| 960/1000 [00:13<00:00, 76.76it/s]
[ICESEE] Assimilation progress (1 ranks): 97%|█████████▋| 968/1000 [00:13<00:00, 77.27it/s]
[ICESEE] Assimilation progress (1 ranks): 98%|█████████▊| 976/1000 [00:13<00:00, 76.65it/s]
[ICESEE] Assimilation progress (1 ranks): 98%|█████████▊| 984/1000 [00:13<00:00, 77.46it/s]
[ICESEE] Assimilation progress (1 ranks): 99%|█████████▉| 992/1000 [00:13<00:00, 77.32it/s]
[ICESEE] Existing file results/true-wrong-lorenz.h5 removed.
[ICESEE] Writing data to results/true-wrong-lorenz.h5
[ICESEE] Dataset 't' written to file
[ICESEE] Dataset 'b_io' written to file
[ICESEE] Dataset 'Lxy' written to file
[ICESEE] Dataset 'nxy' written to file
[ICESEE] Dataset 'obs_max_time' written to file
[ICESEE] Dataset 'obs_index' written to file
[ICESEE] Dataset 'run_mode' written to file
[ICESEE] Data successfully written to results/true-wrong-lorenz.h5
[ICESEE] Assimilation progress (1 ranks): 100%|██████████| 1000/1000 [00:13<00:00, 74.76it/s]
[ICESEE] Assimilation progress (1 ranks): 100%|██████████| 1000/1000 [00:13<00:00, 73.10it/s]
0
# make read results and postprocess notebook
# from utils.notebook_runner import find_repo_root, run_postprocess_to_wrapper
# root = find_repo_root()
# postprocess_nb = (
# root / "external" / "ICESEE"
# / "applications" / "lorenz_model" / "examples" / "lorenz96"
# / "read_results.ipynb"
# )
# out_nb = run_postprocess_to_wrapper(
# postprocess_nb,
# wrapper_out_dir="icesee_jupyter_book/_static/generated",
# out_name="read_results_report.ipynb",
# )
# print("Executed report notebook:", out_nb)
# print("Mirrored new/changed artifacts into: icesee_jupyter_book/_static/generated/<example>/")
# # Display generated figures
# from pathlib import Path
# from IPython.display import display, Image
# from utils.notebook_runner import find_repo_root
# root = find_repo_root()
# # same convention as runner: _static/generated/<tag>/figures
# tag = Path.cwd().name
# fig_dir = root / "icesee_jupyter_book" / "_static" / "generated" / tag / "figures"
# pngs = sorted(fig_dir.glob("*.png"))
# print(f"Found {len(pngs)} saved figures in:", fig_dir)
# for p in pngs[-12:]:
# display(Image(filename=str(p)))
# from IPython.display import Image, display
# from pathlib import Path
# for f in sorted((Path("results")/"figures").glob("*.png")):
# display(Image(filename=str(f)))