%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= 07 outputpath= ../results/SEDNA_DELTA_MONITOR/ daskreport= ../results/dask/7402633irene8002.c-irene.mg1.tgcc.ccc.cea.fr_SEDNA_DELTA_MONITOR_07M_Ice_quantities/ CPU times: user 469 ms, sys: 191 ms, total: 660 ms Wall time: 11 s
Client-a8c91f72-6da9-11ed-a40a-080038bfdcae
Connection method: Cluster object | Cluster type: distributed.LocalCluster |
Dashboard: http://127.0.0.1:8787/status |
3ac17363
Dashboard: http://127.0.0.1:8787/status | Workers: 16 |
Total threads: 128 | Total memory: 2.86 TiB |
Status: running | Using processes: True |
Scheduler-5ec44649-6a80-42cb-be66-22c44981fb75
Comm: tcp://127.0.0.1:40109 | 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:43097 | Total threads: 8 |
Dashboard: http://127.0.0.1:46556/status | Memory: 183.20 GiB |
Nanny: tcp://127.0.0.1:34764 | |
Local directory: /tmp/dask-worker-space/worker-9x1qsb01 |
Comm: tcp://127.0.0.1:38737 | Total threads: 8 |
Dashboard: http://127.0.0.1:40104/status | Memory: 183.20 GiB |
Nanny: tcp://127.0.0.1:33376 | |
Local directory: /tmp/dask-worker-space/worker-xswn16as |
Comm: tcp://127.0.0.1:45735 | Total threads: 8 |
Dashboard: http://127.0.0.1:45077/status | Memory: 183.20 GiB |
Nanny: tcp://127.0.0.1:37994 | |
Local directory: /tmp/dask-worker-space/worker-1_vm90m_ |
Comm: tcp://127.0.0.1:43764 | Total threads: 8 |
Dashboard: http://127.0.0.1:41780/status | Memory: 183.20 GiB |
Nanny: tcp://127.0.0.1:39641 | |
Local directory: /tmp/dask-worker-space/worker-cnf7vu0h |
Comm: tcp://127.0.0.1:33046 | Total threads: 8 |
Dashboard: http://127.0.0.1:40555/status | Memory: 183.20 GiB |
Nanny: tcp://127.0.0.1:43690 | |
Local directory: /tmp/dask-worker-space/worker-al52abwm |
Comm: tcp://127.0.0.1:46305 | Total threads: 8 |
Dashboard: http://127.0.0.1:46829/status | Memory: 183.20 GiB |
Nanny: tcp://127.0.0.1:41802 | |
Local directory: /tmp/dask-worker-space/worker-v5fk74ge |
Comm: tcp://127.0.0.1:36550 | Total threads: 8 |
Dashboard: http://127.0.0.1:45370/status | Memory: 183.20 GiB |
Nanny: tcp://127.0.0.1:45870 | |
Local directory: /tmp/dask-worker-space/worker-fx5o_9kx |
Comm: tcp://127.0.0.1:39270 | Total threads: 8 |
Dashboard: http://127.0.0.1:33995/status | Memory: 183.20 GiB |
Nanny: tcp://127.0.0.1:39183 | |
Local directory: /tmp/dask-worker-space/worker-ts7euwu0 |
Comm: tcp://127.0.0.1:39658 | Total threads: 8 |
Dashboard: http://127.0.0.1:39967/status | Memory: 183.20 GiB |
Nanny: tcp://127.0.0.1:37915 | |
Local directory: /tmp/dask-worker-space/worker-e8fiwq_1 |
Comm: tcp://127.0.0.1:42792 | Total threads: 8 |
Dashboard: http://127.0.0.1:45707/status | Memory: 183.20 GiB |
Nanny: tcp://127.0.0.1:44928 | |
Local directory: /tmp/dask-worker-space/worker-5ul16slx |
Comm: tcp://127.0.0.1:39391 | Total threads: 8 |
Dashboard: http://127.0.0.1:41145/status | Memory: 183.20 GiB |
Nanny: tcp://127.0.0.1:35856 | |
Local directory: /tmp/dask-worker-space/worker-hwj67a81 |
Comm: tcp://127.0.0.1:33674 | Total threads: 8 |
Dashboard: http://127.0.0.1:42749/status | Memory: 183.20 GiB |
Nanny: tcp://127.0.0.1:35422 | |
Local directory: /tmp/dask-worker-space/worker-h6m_q8g7 |
Comm: tcp://127.0.0.1:32980 | Total threads: 8 |
Dashboard: http://127.0.0.1:40542/status | Memory: 183.20 GiB |
Nanny: tcp://127.0.0.1:43366 | |
Local directory: /tmp/dask-worker-space/worker-6x47bu7o |
Comm: tcp://127.0.0.1:33001 | Total threads: 8 |
Dashboard: http://127.0.0.1:35639/status | Memory: 183.20 GiB |
Nanny: tcp://127.0.0.1:46802 | |
Local directory: /tmp/dask-worker-space/worker-qt6nwrsr |
Comm: tcp://127.0.0.1:38950 | Total threads: 8 |
Dashboard: http://127.0.0.1:45258/status | Memory: 183.20 GiB |
Nanny: tcp://127.0.0.1:45160 | |
Local directory: /tmp/dask-worker-space/worker-yq37ecx6 |
Comm: tcp://127.0.0.1:45577 | Total threads: 8 |
Dashboard: http://127.0.0.1:37984/status | Memory: 183.20 GiB |
Nanny: tcp://127.0.0.1:37933 | |
Local directory: /tmp/dask-worker-space/worker-3rs81_6j |
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 ['siconc', 'sivolu', 'sivelo'] 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/201507/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