%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/odakatin/monitor-sedna/notebook/core/monitor.py'>
# 'month': = 'JOBID' almost month but not really,
# If you submit the job with job scheduler, above
#below are list of enviroment variable one can pass
#%env local='2"
# 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 control=FWC_SSH
# name of control file to be used for computation/plots/save/
#%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.
#%env month=
# for monitoring this corresponds to file path path-XIOS.{month}/
#
#%env save= proceed saving? True or False , Default is setted as True
#%env plot= proceed plotting? True or False , Default is setted as True
#%env calc= proceed computation? or just load computed result? True or False , Default is setted as True
#%env save=False
#%env lazy=False
%%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= irene4453.c-irene.mg1.tgcc.ccc.cea.fr starting dask cluster on local= True workers 16 10000000000 False rome local cluster starting This code is running on irene4453.c-irene.mg1.tgcc.ccc.cea.fr using SEDNA_DELTA_MONITOR file experiment, read from ../lib/SEDNA_DELTA_MONITOR.yaml on year= 2012 on month= 02 outputpath= ../results/SEDNA_DELTA_MONITOR/ daskreport= ../results/dask/6413748irene4453.c-irene.mg1.tgcc.ccc.cea.fr_SEDNA_DELTA_MONITOR_02M_IceConce/ CPU times: user 519 ms, sys: 143 ms, total: 663 ms Wall time: 19.9 s
Client-975b7d4f-1344-11ed-a4e4-080038b93255
Connection method: Cluster object | Cluster type: distributed.LocalCluster |
Dashboard: http://127.0.0.1:8787/status |
4715edf9
Dashboard: http://127.0.0.1:8787/status | Workers: 16 |
Total threads: 128 | Total memory: 251.06 GiB |
Status: running | Using processes: True |
Scheduler-d5f82587-285b-462c-b3e8-746e0f9c8a1c
Comm: tcp://127.0.0.1:33995 | Workers: 16 |
Dashboard: http://127.0.0.1:8787/status | Total threads: 128 |
Started: Just now | Total memory: 251.06 GiB |
Comm: tcp://127.0.0.1:41206 | Total threads: 8 |
Dashboard: http://127.0.0.1:32869/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:44965 | |
Local directory: /tmp/dask-worker-space/worker-hrc9s_mz |
Comm: tcp://127.0.0.1:44940 | Total threads: 8 |
Dashboard: http://127.0.0.1:36856/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:36217 | |
Local directory: /tmp/dask-worker-space/worker-kvod5848 |
Comm: tcp://127.0.0.1:34066 | Total threads: 8 |
Dashboard: http://127.0.0.1:46033/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:42168 | |
Local directory: /tmp/dask-worker-space/worker-ktditasa |
Comm: tcp://127.0.0.1:35929 | Total threads: 8 |
Dashboard: http://127.0.0.1:39417/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:46345 | |
Local directory: /tmp/dask-worker-space/worker-vpuyd3qp |
Comm: tcp://127.0.0.1:41102 | Total threads: 8 |
Dashboard: http://127.0.0.1:44418/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:39089 | |
Local directory: /tmp/dask-worker-space/worker-z97xpzlz |
Comm: tcp://127.0.0.1:41209 | Total threads: 8 |
Dashboard: http://127.0.0.1:46642/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:46557 | |
Local directory: /tmp/dask-worker-space/worker-ghwcgk89 |
Comm: tcp://127.0.0.1:36676 | Total threads: 8 |
Dashboard: http://127.0.0.1:45823/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:45593 | |
Local directory: /tmp/dask-worker-space/worker-tpsiqn9f |
Comm: tcp://127.0.0.1:46001 | Total threads: 8 |
Dashboard: http://127.0.0.1:35213/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:45430 | |
Local directory: /tmp/dask-worker-space/worker-2jjd0k7_ |
Comm: tcp://127.0.0.1:33404 | Total threads: 8 |
Dashboard: http://127.0.0.1:41310/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:42755 | |
Local directory: /tmp/dask-worker-space/worker-3r18xa7i |
Comm: tcp://127.0.0.1:36957 | Total threads: 8 |
Dashboard: http://127.0.0.1:45102/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:35919 | |
Local directory: /tmp/dask-worker-space/worker-2rhdu5hk |
Comm: tcp://127.0.0.1:36876 | Total threads: 8 |
Dashboard: http://127.0.0.1:39017/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:42314 | |
Local directory: /tmp/dask-worker-space/worker-k0i4crj0 |
Comm: tcp://127.0.0.1:46307 | Total threads: 8 |
Dashboard: http://127.0.0.1:46747/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:40220 | |
Local directory: /tmp/dask-worker-space/worker-ni3pp_sf |
Comm: tcp://127.0.0.1:40033 | Total threads: 8 |
Dashboard: http://127.0.0.1:45397/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:35799 | |
Local directory: /tmp/dask-worker-space/worker-2ycmtxab |
Comm: tcp://127.0.0.1:45538 | Total threads: 8 |
Dashboard: http://127.0.0.1:44592/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:42455 | |
Local directory: /tmp/dask-worker-space/worker-6pt5t7zq |
Comm: tcp://127.0.0.1:35745 | Total threads: 8 |
Dashboard: http://127.0.0.1:46055/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:35222 | |
Local directory: /tmp/dask-worker-space/worker-nai85h3q |
Comm: tcp://127.0.0.1:33971 | Total threads: 8 |
Dashboard: http://127.0.0.1:41098/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:34091 | |
Local directory: /tmp/dask-worker-space/worker-f58s3vr8 |
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 | |
---|---|---|---|---|---|---|---|---|---|---|
IceConce | icemod.siconc | (data.siconc.where(data.siconc >0)).to_dataset... | ALL | maps | Blues | None | M-4 |
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/odakatin/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'] 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/201202/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/odakatin/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/odakatin/monitor-sedna/notebook/core/load.py:629, in datas(catalog_url, dfi, month, year, daskreport, lazy) 624 datadict, paramdict = getdict(dfi) 625 #print('datadict:',datadict) 626 #if datadict == {}: 627 # data=0 628 #else: --> 629 data=outputs(catalog_url,datadict,month,year,daskreport,lazy) 630 for s in paramdict: 631 print('param',s,'will be included in data') File /ccc/work/cont003/gen7420/odakatin/monitor-sedna/notebook/core/load.py:452, in outputs(catalog_url, datadict, month, year, daskreport, lazy) 448 start = time.time() 449 with performance_report(filename=daskreport+"_load_output_"+filename+"_"+month+year+".html"): 450 #ds=load_data_xios_patch(cat,filename,month,catalog_url) --> 452 ds = load_data_xios(cat,filename,items,month,year) if not ('False' in lazy) else load_data_xios_kerchunk(cat,filename,items,month,year,rome=True) 453 extime=time.time() - start 454 print(' took', extime, 'seconds') File /ccc/work/cont003/gen7420/odakatin/monitor-sedna/notebook/core/load.py:423, in load_data_xios_kerchunk(cat, filename, items, month, year, rome) 421 desc=cat.data_xios_kerchunk(file=filename,month=month,year=year).describe 422 print('using load_data_xios_kerchunk reading ',desc) --> 423 ds_x= [ prep( 424 cat.data_xios_kerchunk( 425 file=filename,month=month,year=year,eio=f'{xios:04}' 426 ).to_dask().drop_vars(dro,errors='ignore'))[items] 427 for xios in xioss] 429 return xr.concat(ds_x,dim='y',compat="override",coords="minimal") File /ccc/work/cont003/gen7420/odakatin/monitor-sedna/notebook/core/load.py:423, in <listcomp>(.0) 421 desc=cat.data_xios_kerchunk(file=filename,month=month,year=year).describe 422 print('using load_data_xios_kerchunk reading ',desc) --> 423 ds_x= [ prep( 424 cat.data_xios_kerchunk( 425 file=filename,month=month,year=year,eio=f'{xios:04}' 426 ).to_dask().drop_vars(dro,errors='ignore'))[items] 427 for xios in xioss] 429 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