%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'>
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= irene4988.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 irene4988.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= 04 outputpath= ../results/SEDNA_DELTA_MONITOR/ daskreport= ../results/dask/6419611irene4988.c-irene.mg1.tgcc.ccc.cea.fr_SEDNA_DELTA_MONITOR_04M_FWC_integrals/ CPU times: user 512 ms, sys: 135 ms, total: 647 ms Wall time: 19.7 s
Client-cd2a6b97-13ec-11ed-8af8-080038b940e9
Connection method: Cluster object | Cluster type: distributed.LocalCluster |
Dashboard: http://127.0.0.1:8787/status |
32fbfab4
Dashboard: http://127.0.0.1:8787/status | Workers: 16 |
Total threads: 128 | Total memory: 251.06 GiB |
Status: running | Using processes: True |
Scheduler-843d7adf-2bae-424a-938c-c8f3b6bb5533
Comm: tcp://127.0.0.1:39629 | 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:39341 | Total threads: 8 |
Dashboard: http://127.0.0.1:40719/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:43280 | |
Local directory: /tmp/dask-worker-space/worker-zt48jzh5 |
Comm: tcp://127.0.0.1:34594 | Total threads: 8 |
Dashboard: http://127.0.0.1:43830/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:45450 | |
Local directory: /tmp/dask-worker-space/worker-8x054ww1 |
Comm: tcp://127.0.0.1:43766 | Total threads: 8 |
Dashboard: http://127.0.0.1:45943/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:41085 | |
Local directory: /tmp/dask-worker-space/worker-ys_8s3w5 |
Comm: tcp://127.0.0.1:39918 | Total threads: 8 |
Dashboard: http://127.0.0.1:46683/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:46210 | |
Local directory: /tmp/dask-worker-space/worker-sbis90i0 |
Comm: tcp://127.0.0.1:40328 | Total threads: 8 |
Dashboard: http://127.0.0.1:33416/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:42453 | |
Local directory: /tmp/dask-worker-space/worker-z42nwl_r |
Comm: tcp://127.0.0.1:38975 | Total threads: 8 |
Dashboard: http://127.0.0.1:39919/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:41304 | |
Local directory: /tmp/dask-worker-space/worker-iicdglbd |
Comm: tcp://127.0.0.1:36621 | Total threads: 8 |
Dashboard: http://127.0.0.1:40790/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:36866 | |
Local directory: /tmp/dask-worker-space/worker-jalkhwwy |
Comm: tcp://127.0.0.1:35245 | Total threads: 8 |
Dashboard: http://127.0.0.1:43610/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:39308 | |
Local directory: /tmp/dask-worker-space/worker-gr194bfd |
Comm: tcp://127.0.0.1:38521 | Total threads: 8 |
Dashboard: http://127.0.0.1:43984/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:46414 | |
Local directory: /tmp/dask-worker-space/worker-a7xv56ey |
Comm: tcp://127.0.0.1:39879 | Total threads: 8 |
Dashboard: http://127.0.0.1:35071/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:40212 | |
Local directory: /tmp/dask-worker-space/worker-ggoh1u2g |
Comm: tcp://127.0.0.1:40094 | Total threads: 8 |
Dashboard: http://127.0.0.1:46313/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:45211 | |
Local directory: /tmp/dask-worker-space/worker-51kug790 |
Comm: tcp://127.0.0.1:40856 | Total threads: 8 |
Dashboard: http://127.0.0.1:40452/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:37495 | |
Local directory: /tmp/dask-worker-space/worker-01pk0ais |
Comm: tcp://127.0.0.1:36909 | Total threads: 8 |
Dashboard: http://127.0.0.1:33895/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:40815 | |
Local directory: /tmp/dask-worker-space/worker-pn_sjviv |
Comm: tcp://127.0.0.1:34077 | Total threads: 8 |
Dashboard: http://127.0.0.1:45843/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:43763 | |
Local directory: /tmp/dask-worker-space/worker-ir8zuyql |
Comm: tcp://127.0.0.1:38097 | Total threads: 8 |
Dashboard: http://127.0.0.1:45387/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:37984 | |
Local directory: /tmp/dask-worker-space/worker-t8w7yjmt |
Comm: tcp://127.0.0.1:33869 | Total threads: 8 |
Dashboard: http://127.0.0.1:36128/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:34532 | |
Local directory: /tmp/dask-worker-space/worker-zvt2p0f7 |
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 | |
---|---|---|---|---|---|---|---|---|---|---|
FWC_integrals | calc.FWC_load_integrals(data,nc_outputpath) | BBFG | FWC_integrals | (12000,24000) | Km^3 | I-1 |
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 False lazy= False CPU times: user 312 µs, sys: 46 µs, total: 358 µs Wall time: 350 µs
0
%%time
monitor.auto(df,data,savefig,daskreport,outputpath,file_exp='SEDNA'
)
#calc= True #save= True #plot= False Value='FWC_integrals' Zone='BBFG' Plot='FWC_integrals' cmap='' clabel='Km^3' clim= (12000, 24000) outputpath='../results/SEDNA_DELTA_MONITOR/' nc_outputpath='../nc_results/SEDNA_DELTA_MONITOR/' filename='SEDNA_FWC_integrals_BBFG_FWC_integrals' #3 Start computing data= calc.FWC_load_integrals(data,nc_outputpath) monitor.optimize_dataset(data) start saving data filename= ../nc_results/SEDNA_DELTA_MONITOR/SEDNA_maps_BBFG_FWC_2D/t_*/y_*/x_*.nc
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) File <timed eval>:1, in <module> File /ccc/work/cont003/gen7420/odakatin/monitor-sedna/notebook/core/monitor.py:67, in auto(df, val, savefig, daskreport, outputpath, file_exp) 65 #print('count:',data.count()) 66 with performance_report(filename=daskreport+"_calc_"+step.Value+".html"): ---> 67 data=eval(command) 68 #print('persist ') 69 #data=data.persist() 70 print('add optimise here once otimise can recognise') File <string>:1, in <module> File /ccc/work/cont003/gen7420/odakatin/monitor-sedna/notebook/core/calc.py:214, in FWC_load_integrals(data, nc_outputpath) 212 import xarray as xr 213 filename='SEDNA_maps_BBFG_FWC_2D' --> 214 data=save.load_data(plot='map',path=nc_outputpath,filename=filename) 215 ds=xr.Dataset({"FWC_Arctic":(data.FWC2D*data.e1te2t).sum(dim=('x','y'))}) 216 ds['FWC_CRF']=zoom.BFG((data.FWC2D*data.e1te2t)).sum(dim=('x','y')) File /ccc/work/cont003/gen7420/odakatin/monitor-sedna/notebook/core/save.py:38, in load_data(plot, path, filename) 36 data=load_twoD(path,filename,nested=False) 37 else: ---> 38 data=load_twoD(path,filename) 39 print('load computed data completed') 40 return data File /ccc/work/cont003/gen7420/odakatin/monitor-sedna/notebook/core/save.py:48, in load_twoD(path, filename, nested) 46 dim=('x','y','t') if nested else ('t') 47 print ('filename=',filename) ---> 48 return xr.open_mfdataset(filename,parallel=True 49 ,compat='override' 50 ,data_vars='minimal' 51 ,concat_dim=dim 52 ,combine='nested' #param_xios 53 ,coords='minimal') File /ccc/cont003/home/ra5563/ra5563/monitor/lib/python3.10/site-packages/xarray/backends/api.py:987, in open_mfdataset(paths, chunks, concat_dim, compat, preprocess, engine, data_vars, coords, combine, parallel, join, attrs_file, combine_attrs, **kwargs) 983 try: 984 if combine == "nested": 985 # Combined nested list by successive concat and merge operations 986 # along each dimension, using structure given by "ids" --> 987 combined = _nested_combine( 988 datasets, 989 concat_dims=concat_dim, 990 compat=compat, 991 data_vars=data_vars, 992 coords=coords, 993 ids=ids, 994 join=join, 995 combine_attrs=combine_attrs, 996 ) 997 elif combine == "by_coords": 998 # Redo ordering from coordinates, ignoring how they were ordered 999 # previously 1000 combined = combine_by_coords( 1001 datasets, 1002 compat=compat, (...) 1006 combine_attrs=combine_attrs, 1007 ) File /ccc/cont003/home/ra5563/ra5563/monitor/lib/python3.10/site-packages/xarray/core/combine.py:365, in _nested_combine(datasets, concat_dims, compat, data_vars, coords, ids, fill_value, join, combine_attrs) 362 _check_shape_tile_ids(combined_ids) 364 # Apply series of concatenate or merge operations along each dimension --> 365 combined = _combine_nd( 366 combined_ids, 367 concat_dims, 368 compat=compat, 369 data_vars=data_vars, 370 coords=coords, 371 fill_value=fill_value, 372 join=join, 373 combine_attrs=combine_attrs, 374 ) 375 return combined File /ccc/cont003/home/ra5563/ra5563/monitor/lib/python3.10/site-packages/xarray/core/combine.py:228, in _combine_nd(combined_ids, concat_dims, data_vars, coords, compat, fill_value, join, combine_attrs) 226 n_dims = len(example_tile_id) 227 if len(concat_dims) != n_dims: --> 228 raise ValueError( 229 "concat_dims has length {} but the datasets " 230 "passed are nested in a {}-dimensional structure".format( 231 len(concat_dims), n_dims 232 ) 233 ) 235 # Each iteration of this loop reduces the length of the tile_ids tuples 236 # by one. It always combines along the first dimension, removing the first 237 # element of the tuple 238 for concat_dim in concat_dims: ValueError: concat_dims has length 3 but the datasets passed are nested in a 1-dimensional structure