%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= irene5654.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 irene5654.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= 05 outputpath= ../results/SEDNA_DELTA_MONITOR/ daskreport= ../results/dask/7449067irene5654.c-irene.mg1.tgcc.ccc.cea.fr_SEDNA_DELTA_MONITOR_05M_Ice_quantities/ CPU times: user 542 ms, sys: 132 ms, total: 674 ms Wall time: 21.8 s
Client-c285aaf1-6f42-11ed-a2ae-080038b935f5
Connection method: Cluster object | Cluster type: distributed.LocalCluster |
Dashboard: http://127.0.0.1:8787/status |
8df47aa8
Dashboard: http://127.0.0.1:8787/status | Workers: 16 |
Total threads: 128 | Total memory: 221.88 GiB |
Status: running | Using processes: True |
Scheduler-5d8d1819-057e-4ecb-8300-c2a6fa61ce72
Comm: tcp://127.0.0.1:32982 | Workers: 16 |
Dashboard: http://127.0.0.1:8787/status | Total threads: 128 |
Started: Just now | Total memory: 221.88 GiB |
Comm: tcp://127.0.0.1:34498 | Total threads: 8 |
Dashboard: http://127.0.0.1:35788/status | Memory: 13.87 GiB |
Nanny: tcp://127.0.0.1:46303 | |
Local directory: /tmp/dask-worker-space/worker-zhz_k66p |
Comm: tcp://127.0.0.1:45414 | Total threads: 8 |
Dashboard: http://127.0.0.1:38212/status | Memory: 13.87 GiB |
Nanny: tcp://127.0.0.1:34481 | |
Local directory: /tmp/dask-worker-space/worker-qeo_7oc1 |
Comm: tcp://127.0.0.1:38535 | Total threads: 8 |
Dashboard: http://127.0.0.1:42368/status | Memory: 13.87 GiB |
Nanny: tcp://127.0.0.1:39024 | |
Local directory: /tmp/dask-worker-space/worker-9rt8rqk5 |
Comm: tcp://127.0.0.1:44389 | Total threads: 8 |
Dashboard: http://127.0.0.1:46811/status | Memory: 13.87 GiB |
Nanny: tcp://127.0.0.1:35551 | |
Local directory: /tmp/dask-worker-space/worker-ybchurc2 |
Comm: tcp://127.0.0.1:33801 | Total threads: 8 |
Dashboard: http://127.0.0.1:43916/status | Memory: 13.87 GiB |
Nanny: tcp://127.0.0.1:44841 | |
Local directory: /tmp/dask-worker-space/worker-f0zznpwu |
Comm: tcp://127.0.0.1:40216 | Total threads: 8 |
Dashboard: http://127.0.0.1:43053/status | Memory: 13.87 GiB |
Nanny: tcp://127.0.0.1:41667 | |
Local directory: /tmp/dask-worker-space/worker-rucm5y1a |
Comm: tcp://127.0.0.1:44463 | Total threads: 8 |
Dashboard: http://127.0.0.1:36204/status | Memory: 13.87 GiB |
Nanny: tcp://127.0.0.1:44822 | |
Local directory: /tmp/dask-worker-space/worker-5q4hzwdl |
Comm: tcp://127.0.0.1:32845 | Total threads: 8 |
Dashboard: http://127.0.0.1:42605/status | Memory: 13.87 GiB |
Nanny: tcp://127.0.0.1:36993 | |
Local directory: /tmp/dask-worker-space/worker-a9nyy3xo |
Comm: tcp://127.0.0.1:40421 | Total threads: 8 |
Dashboard: http://127.0.0.1:40626/status | Memory: 13.87 GiB |
Nanny: tcp://127.0.0.1:33125 | |
Local directory: /tmp/dask-worker-space/worker-tyboqfau |
Comm: tcp://127.0.0.1:41597 | Total threads: 8 |
Dashboard: http://127.0.0.1:33077/status | Memory: 13.87 GiB |
Nanny: tcp://127.0.0.1:40664 | |
Local directory: /tmp/dask-worker-space/worker-799iarhs |
Comm: tcp://127.0.0.1:35333 | Total threads: 8 |
Dashboard: http://127.0.0.1:44737/status | Memory: 13.87 GiB |
Nanny: tcp://127.0.0.1:41319 | |
Local directory: /tmp/dask-worker-space/worker-2lfajyjp |
Comm: tcp://127.0.0.1:33610 | Total threads: 8 |
Dashboard: http://127.0.0.1:44315/status | Memory: 13.87 GiB |
Nanny: tcp://127.0.0.1:33786 | |
Local directory: /tmp/dask-worker-space/worker-db74skqd |
Comm: tcp://127.0.0.1:37871 | Total threads: 8 |
Dashboard: http://127.0.0.1:41965/status | Memory: 13.87 GiB |
Nanny: tcp://127.0.0.1:38204 | |
Local directory: /tmp/dask-worker-space/worker-pe37t167 |
Comm: tcp://127.0.0.1:46481 | Total threads: 8 |
Dashboard: http://127.0.0.1:33087/status | Memory: 13.87 GiB |
Nanny: tcp://127.0.0.1:39199 | |
Local directory: /tmp/dask-worker-space/worker-j40u0hrb |
Comm: tcp://127.0.0.1:34593 | Total threads: 8 |
Dashboard: http://127.0.0.1:38544/status | Memory: 13.87 GiB |
Nanny: tcp://127.0.0.1:39311 | |
Local directory: /tmp/dask-worker-space/worker-w11y_1un |
Comm: tcp://127.0.0.1:34372 | Total threads: 8 |
Dashboard: http://127.0.0.1:37454/status | Memory: 13.87 GiB |
Nanny: tcp://127.0.0.1:37019 | |
Local directory: /tmp/dask-worker-space/worker-y59y26mb |
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', 'sivelo', '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/201505/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