%matplotlib inline
import pandas as pd
import socket
host = socket.getfqdn()
from core import load, zoom, calc, save,plots,monitor
#reload funcs after updating ./core/*.py
import importlib
importlib.reload(load)
importlib.reload(zoom)
importlib.reload(calc)
importlib.reload(save)
importlib.reload(plots)
importlib.reload(monitor)
<module 'core.monitor' from '/ccc/work/cont003/gen7420/talandel/TOOLS/monitor-sedna/notebook/core/monitor.py'>
If you submit the job with job scheduler; below are list of enviroment variable one can pass
local : if True run dask local cluster, if not true, put number of workers setted in the 'local' if no 'local ' given, local will be setted automatically to 'True'
%env ychunk='2', #%env tchunk='2'
controls chunk. 'False' sets no modification from original netcdf file's chunk.
ychunk=10 will group the original netcdf file to 10 by 10
tchunk=1 will chunk the time coordinate one by one
%env file_exp=
'file_exp': Which 'experiment' name is it? this corresopnds to intake catalog name without path and .yaml
#%env year=
for Validation, this correspoinds to path/year/month 's year for monitoring, this corresponids to 'date' having means do all files in the monitoring directory setting it as 0[0-9] &1[0-9]& [2-3][0-9], the job can be separated in three lots. For DELTA experiment, year corresponds to really 'year'
%env month=
for monitoring this corresponds to file path path-XIOS.{month}/
For DELTA experiment, year corresponds to really 'month'
proceed saving? True or False , Default is setted as True
proceed plotting? True or False , Default is setted as True
proceed computation? or just load computed result? True or False , Default is setted as True
save output file used for plotting
using kerchunked file -> False, not using kerhcunk -> True
name of control file to be used for computation/plots/save/ We have number of M_xxx.csv
Monitor.sh calls M_MLD_2D
and AWTD.sh, Fluxnet.sh, Siconc.sh, IceClim.sh, FWC_SSH.sh, Integrals.sh , Sections.sh
M_AWTMD
M_Fluxnet
M_Ice_quantities
M_IceClim M_IceConce M_IceThick
M_FWC_2D M_FWC_integrals M_FWC_SSH M_SSH_anomaly
M_Mean_temp_velo M_Mooring
M_Sectionx M_Sectiony
%%time
# 'savefig': Do we save output in html? or not. keep it true.
savefig=True
client,cluster,control,catalog_url,month,year,daskreport,outputpath = load.set_control(host)
!mkdir -p $outputpath
!mkdir -p $daskreport
client
local True using host= irene8002.c-irene.mg1.tgcc.ccc.cea.fr starting dask cluster on local= True workers 16 10000000000 rome local cluster starting This code is running on irene8002.c-irene.mg1.tgcc.ccc.cea.fr using SEDNA_DELTA_MONITOR file experiment, read from ../lib/SEDNA_DELTA_MONITOR.yaml on year= 2015 on month= 08 outputpath= ../results/SEDNA_DELTA_MONITOR/ daskreport= ../results/dask/7402636irene8002.c-irene.mg1.tgcc.ccc.cea.fr_SEDNA_DELTA_MONITOR_08M_Ice_quantities/ CPU times: user 452 ms, sys: 179 ms, total: 631 ms Wall time: 10.7 s
Client-cba728a5-6da9-11ed-b0e1-080038bfdcae
Connection method: Cluster object | Cluster type: distributed.LocalCluster |
Dashboard: http://127.0.0.1:8787/status |
d9996e0f
Dashboard: http://127.0.0.1:8787/status | Workers: 16 |
Total threads: 128 | Total memory: 2.86 TiB |
Status: running | Using processes: True |
Scheduler-2a97414d-719d-4a8a-a58f-3f2a846fe17c
Comm: tcp://127.0.0.1:41349 | Workers: 16 |
Dashboard: http://127.0.0.1:8787/status | Total threads: 128 |
Started: Just now | Total memory: 2.86 TiB |
Comm: tcp://127.0.0.1:43001 | Total threads: 8 |
Dashboard: http://127.0.0.1:38763/status | Memory: 183.20 GiB |
Nanny: tcp://127.0.0.1:39132 | |
Local directory: /tmp/dask-worker-space/worker-c2ob9o4l |
Comm: tcp://127.0.0.1:36356 | Total threads: 8 |
Dashboard: http://127.0.0.1:33875/status | Memory: 183.20 GiB |
Nanny: tcp://127.0.0.1:40453 | |
Local directory: /tmp/dask-worker-space/worker-rezjtxo7 |
Comm: tcp://127.0.0.1:36040 | Total threads: 8 |
Dashboard: http://127.0.0.1:40513/status | Memory: 183.20 GiB |
Nanny: tcp://127.0.0.1:37183 | |
Local directory: /tmp/dask-worker-space/worker-owj2u2cq |
Comm: tcp://127.0.0.1:39875 | Total threads: 8 |
Dashboard: http://127.0.0.1:32969/status | Memory: 183.20 GiB |
Nanny: tcp://127.0.0.1:33139 | |
Local directory: /tmp/dask-worker-space/worker-979qth9p |
Comm: tcp://127.0.0.1:45804 | Total threads: 8 |
Dashboard: http://127.0.0.1:46555/status | Memory: 183.20 GiB |
Nanny: tcp://127.0.0.1:43791 | |
Local directory: /tmp/dask-worker-space/worker-_n568swm |
Comm: tcp://127.0.0.1:35064 | Total threads: 8 |
Dashboard: http://127.0.0.1:43267/status | Memory: 183.20 GiB |
Nanny: tcp://127.0.0.1:43041 | |
Local directory: /tmp/dask-worker-space/worker-l8jmma3u |
Comm: tcp://127.0.0.1:36832 | Total threads: 8 |
Dashboard: http://127.0.0.1:42644/status | Memory: 183.20 GiB |
Nanny: tcp://127.0.0.1:39081 | |
Local directory: /tmp/dask-worker-space/worker-8pbcc3hm |
Comm: tcp://127.0.0.1:37449 | Total threads: 8 |
Dashboard: http://127.0.0.1:34155/status | Memory: 183.20 GiB |
Nanny: tcp://127.0.0.1:43178 | |
Local directory: /tmp/dask-worker-space/worker-y7ah5f3g |
Comm: tcp://127.0.0.1:33667 | Total threads: 8 |
Dashboard: http://127.0.0.1:44864/status | Memory: 183.20 GiB |
Nanny: tcp://127.0.0.1:35901 | |
Local directory: /tmp/dask-worker-space/worker-a6hg2yy_ |
Comm: tcp://127.0.0.1:42569 | Total threads: 8 |
Dashboard: http://127.0.0.1:46058/status | Memory: 183.20 GiB |
Nanny: tcp://127.0.0.1:36283 | |
Local directory: /tmp/dask-worker-space/worker-0l0x1ggn |
Comm: tcp://127.0.0.1:42328 | Total threads: 8 |
Dashboard: http://127.0.0.1:41439/status | Memory: 183.20 GiB |
Nanny: tcp://127.0.0.1:37144 | |
Local directory: /tmp/dask-worker-space/worker-i1_lex9v |
Comm: tcp://127.0.0.1:41244 | Total threads: 8 |
Dashboard: http://127.0.0.1:41928/status | Memory: 183.20 GiB |
Nanny: tcp://127.0.0.1:40669 | |
Local directory: /tmp/dask-worker-space/worker-0n9811a1 |
Comm: tcp://127.0.0.1:35690 | Total threads: 8 |
Dashboard: http://127.0.0.1:45555/status | Memory: 183.20 GiB |
Nanny: tcp://127.0.0.1:44117 | |
Local directory: /tmp/dask-worker-space/worker-6zor7yxb |
Comm: tcp://127.0.0.1:37447 | Total threads: 8 |
Dashboard: http://127.0.0.1:45309/status | Memory: 183.20 GiB |
Nanny: tcp://127.0.0.1:40000 | |
Local directory: /tmp/dask-worker-space/worker-gxlhgrog |
Comm: tcp://127.0.0.1:41062 | Total threads: 8 |
Dashboard: http://127.0.0.1:46358/status | Memory: 183.20 GiB |
Nanny: tcp://127.0.0.1:37086 | |
Local directory: /tmp/dask-worker-space/worker-uki83e05 |
Comm: tcp://127.0.0.1:38272 | Total threads: 8 |
Dashboard: http://127.0.0.1:39866/status | Memory: 183.20 GiB |
Nanny: tcp://127.0.0.1:34943 | |
Local directory: /tmp/dask-worker-space/worker-9vs5knqx |
df=load.controlfile(control)
#Take out 'later' tagged computations
#df=df[~df['Value'].str.contains('later')]
df
Value | Inputs | Equation | Zone | Plot | Colourmap | MinMax | Unit | Oldname | Unnamed: 10 | |
---|---|---|---|---|---|---|---|---|---|---|
Ice_quantities | param.e1te2t,icemod.sivelo,icemod.sivolu,icemo... | calc.Ice_quant(data) | ALL | Ice_intquant | None | (0,20) | cm s^(-1) | I-2 |
Each computation consists of
%%time
import os
calcswitch=os.environ.get('calc', 'True')
lazy=os.environ.get('lazy','False' )
loaddata=((df.Inputs != '').any())
print('calcswitch=',calcswitch,'df.Inputs != nothing',loaddata, 'lazy=',lazy)
data = load.datas(catalog_url,df.Inputs,month,year,daskreport,lazy=lazy) if ((calcswitch=='True' )*loaddata) else 0
data
calcswitch= True df.Inputs != nothing True lazy= False ../lib/SEDNA_DELTA_MONITOR.yaml using param_xios reading ../lib/SEDNA_DELTA_MONITOR.yaml using param_xios reading <bound method DataSourceBase.describe of sources: param_xios: args: combine: nested concat_dim: y urlpath: /ccc/work/cont003/gen7420/odakatin/CONFIGS/SEDNA/SEDNA-I/SEDNA_Domain_cfg_Tgt_20210423_tsh10m_L1/param_f32/x_*.nc xarray_kwargs: compat: override coords: minimal data_vars: minimal parallel: true description: SEDNA NEMO parameters from MPI output nav_lon lat fails driver: intake_xarray.netcdf.NetCDFSource metadata: catalog_dir: /ccc/work/cont003/gen7420/talandel/TOOLS/monitor-sedna/notebook/../lib/ > {'name': 'param_xios', 'container': 'xarray', 'plugin': ['netcdf'], 'driver': ['netcdf'], 'description': 'SEDNA NEMO parameters from MPI output nav_lon lat fails', 'direct_access': 'forbid', 'user_parameters': [{'name': 'path', 'description': 'file coordinate', 'type': 'str', 'default': '/ccc/work/cont003/gen7420/odakatin/CONFIGS/SEDNA/MESH/SEDNA_mesh_mask_Tgt_20210423_tsh10m_L1/param'}], 'metadata': {}, 'args': {'urlpath': '/ccc/work/cont003/gen7420/odakatin/CONFIGS/SEDNA/SEDNA-I/SEDNA_Domain_cfg_Tgt_20210423_tsh10m_L1/param_f32/x_*.nc', 'combine': 'nested', 'concat_dim': 'y'}} 0 read icemod ['sivelo', 'siconc', 'sivolu'] lazy= False using load_data_xios_kerchunk reading icemod using load_data_xios_kerchunk reading <bound method DataSourceBase.describe of sources: data_xios_kerchunk: args: consolidated: false storage_options: fo: file:////ccc/cont003/home/ra5563/ra5563/catalogue/DELTA/201508/icemod_0[0-5][0-9][0-9].json target_protocol: file urlpath: reference:// description: CREG025 NEMO outputs from different xios server in kerchunk format driver: intake_xarray.xzarr.ZarrSource metadata: catalog_dir: /ccc/work/cont003/gen7420/talandel/TOOLS/monitor-sedna/notebook/../lib/ >
--------------------------------------------------------------------------- KeyError Traceback (most recent call last) File /ccc/cont003/home/ra5563/ra5563/monitor/lib/python3.10/site-packages/xarray/core/dataset.py:1279, in Dataset._copy_listed(self, names) 1278 try: -> 1279 variables[name] = self._variables[name] 1280 except KeyError: KeyError: 'siconc' During handling of the above exception, another exception occurred: KeyError Traceback (most recent call last) File <timed exec>:6, in <module> File /ccc/work/cont003/gen7420/talandel/TOOLS/monitor-sedna/notebook/core/load.py:681, in datas(catalog_url, dfi, month, year, daskreport, lazy) 676 datadict, paramdict = getdict(dfi) 677 #print('datadict:',datadict) 678 #if datadict == {}: 679 # data=0 680 #else: --> 681 data=outputs(catalog_url,datadict,month,year,daskreport,lazy) 682 for s in paramdict: 683 print('param',s,'will be included in data') File /ccc/work/cont003/gen7420/talandel/TOOLS/monitor-sedna/notebook/core/load.py:499, in outputs(catalog_url, datadict, month, year, daskreport, lazy) 496 with performance_report(filename=daskreport+"_load_output_"+filename+"_"+month+year+".html"): 497 #ds=load_data_xios_patch(cat,filename,month,catalog_url) 498 print("lazy=",lazy) --> 499 ds = load_data_xios(cat,filename,items,month,year) if ('True' in lazy) else load_data_xios_kerchunk(cat,filename,items,month,year,rome=True) 500 extime=time.time() - start 501 print(' took', extime, 'seconds') File /ccc/work/cont003/gen7420/talandel/TOOLS/monitor-sedna/notebook/core/load.py:470, in load_data_xios_kerchunk(cat, filename, items, month, year, rome) 468 desc=cat.data_xios_kerchunk(file=filename,month=month,year=year).describe 469 print('using load_data_xios_kerchunk reading ',desc) --> 470 ds_x= [ prep( 471 cat.data_xios_kerchunk( 472 file=filename,month=month,year=year,eio=f'{xios:04}' 473 ).to_dask().drop_vars(dro,errors='ignore')[items]) 474 for xios in xioss] 476 return xr.concat(ds_x,dim='y',compat="override",coords="minimal") File /ccc/work/cont003/gen7420/talandel/TOOLS/monitor-sedna/notebook/core/load.py:471, in <listcomp>(.0) 468 desc=cat.data_xios_kerchunk(file=filename,month=month,year=year).describe 469 print('using load_data_xios_kerchunk reading ',desc) 470 ds_x= [ prep( --> 471 cat.data_xios_kerchunk( 472 file=filename,month=month,year=year,eio=f'{xios:04}' 473 ).to_dask().drop_vars(dro,errors='ignore')[items]) 474 for xios in xioss] 476 return xr.concat(ds_x,dim='y',compat="override",coords="minimal") File /ccc/cont003/home/ra5563/ra5563/monitor/lib/python3.10/site-packages/xarray/core/dataset.py:1412, in Dataset.__getitem__(self, key) 1410 return self._construct_dataarray(key) 1411 if utils.iterable_of_hashable(key): -> 1412 return self._copy_listed(key) 1413 raise ValueError(f"Unsupported key-type {type(key)}") File /ccc/cont003/home/ra5563/ra5563/monitor/lib/python3.10/site-packages/xarray/core/dataset.py:1281, in Dataset._copy_listed(self, names) 1279 variables[name] = self._variables[name] 1280 except KeyError: -> 1281 ref_name, var_name, var = _get_virtual_variable( 1282 self._variables, name, self.dims 1283 ) 1284 variables[var_name] = var 1285 if ref_name in self._coord_names or ref_name in self.dims: File /ccc/cont003/home/ra5563/ra5563/monitor/lib/python3.10/site-packages/xarray/core/dataset.py:175, in _get_virtual_variable(variables, key, dim_sizes) 173 split_key = key.split(".", 1) 174 if len(split_key) != 2: --> 175 raise KeyError(key) 177 ref_name, var_name = split_key 178 ref_var = variables[ref_name] KeyError: 'siconc'
%%time
monitor.auto(df,data,savefig,daskreport,outputpath,file_exp='SEDNA'
)
--------------------------------------------------------------------------- NameError Traceback (most recent call last) File <timed eval>:1, in <module> NameError: name 'data' is not defined