%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= irene6086.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 irene6086.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= 06 outputpath= ../results/SEDNA_DELTA_MONITOR/ daskreport= ../results/dask/6476203irene6086.c-irene.mg1.tgcc.ccc.cea.fr_SEDNA_DELTA_MONITOR_06M_AWTMD/ CPU times: user 542 ms, sys: 147 ms, total: 688 ms Wall time: 20.2 s
Client-635f3f65-1977-11ed-ba12-080038b93a19
Connection method: Cluster object | Cluster type: distributed.LocalCluster |
Dashboard: http://127.0.0.1:8787/status |
ad7a556a
Dashboard: http://127.0.0.1:8787/status | Workers: 16 |
Total threads: 128 | Total memory: 251.06 GiB |
Status: running | Using processes: True |
Scheduler-95ba392c-2e25-47e5-ab32-08ed05800def
Comm: tcp://127.0.0.1:44975 | 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:41716 | Total threads: 8 |
Dashboard: http://127.0.0.1:46574/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:38433 | |
Local directory: /tmp/dask-worker-space/worker-6a8n6f26 |
Comm: tcp://127.0.0.1:35846 | Total threads: 8 |
Dashboard: http://127.0.0.1:42738/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:35752 | |
Local directory: /tmp/dask-worker-space/worker-709trq_8 |
Comm: tcp://127.0.0.1:46330 | Total threads: 8 |
Dashboard: http://127.0.0.1:44948/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:44741 | |
Local directory: /tmp/dask-worker-space/worker-ag7c5g7b |
Comm: tcp://127.0.0.1:34829 | Total threads: 8 |
Dashboard: http://127.0.0.1:36711/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:35158 | |
Local directory: /tmp/dask-worker-space/worker-d25iyqq4 |
Comm: tcp://127.0.0.1:40869 | Total threads: 8 |
Dashboard: http://127.0.0.1:38783/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:38772 | |
Local directory: /tmp/dask-worker-space/worker-yarurzsq |
Comm: tcp://127.0.0.1:42862 | Total threads: 8 |
Dashboard: http://127.0.0.1:38713/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:37307 | |
Local directory: /tmp/dask-worker-space/worker-1bvxois7 |
Comm: tcp://127.0.0.1:37969 | Total threads: 8 |
Dashboard: http://127.0.0.1:39698/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:43752 | |
Local directory: /tmp/dask-worker-space/worker-l3yxw7lj |
Comm: tcp://127.0.0.1:40258 | Total threads: 8 |
Dashboard: http://127.0.0.1:38552/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:35507 | |
Local directory: /tmp/dask-worker-space/worker-b84np11h |
Comm: tcp://127.0.0.1:35791 | Total threads: 8 |
Dashboard: http://127.0.0.1:46744/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:38479 | |
Local directory: /tmp/dask-worker-space/worker-zzm5803p |
Comm: tcp://127.0.0.1:46791 | Total threads: 8 |
Dashboard: http://127.0.0.1:46540/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:36033 | |
Local directory: /tmp/dask-worker-space/worker-s1jh8ldw |
Comm: tcp://127.0.0.1:35177 | Total threads: 8 |
Dashboard: http://127.0.0.1:34558/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:41813 | |
Local directory: /tmp/dask-worker-space/worker-69tuu0f4 |
Comm: tcp://127.0.0.1:40564 | Total threads: 8 |
Dashboard: http://127.0.0.1:33479/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:37675 | |
Local directory: /tmp/dask-worker-space/worker-2uz6aj63 |
Comm: tcp://127.0.0.1:40581 | Total threads: 8 |
Dashboard: http://127.0.0.1:41548/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:41083 | |
Local directory: /tmp/dask-worker-space/worker-5hxn8rl2 |
Comm: tcp://127.0.0.1:46774 | Total threads: 8 |
Dashboard: http://127.0.0.1:33221/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:38965 | |
Local directory: /tmp/dask-worker-space/worker-rk_eetdo |
Comm: tcp://127.0.0.1:33037 | Total threads: 8 |
Dashboard: http://127.0.0.1:38263/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:37418 | |
Local directory: /tmp/dask-worker-space/worker-yi0wli84 |
Comm: tcp://127.0.0.1:38757 | Total threads: 8 |
Dashboard: http://127.0.0.1:41225/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:42816 | |
Local directory: /tmp/dask-worker-space/worker-mfxbqav0 |
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 | |
---|---|---|---|---|---|---|---|---|---|---|
AW_maxtemp_depth | gridT.votemper,gridS.vosaline,param.mask,param... | calc.AWTD4(data) | ALL | AWTD_map | jet | (0,800) | m | M-5 |
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= False df.Inputs != nothing True lazy= False CPU times: user 0 ns, sys: 350 µs, total: 350 µs Wall time: 345 µs
0
%%time
monitor.auto(df,data,savefig,daskreport,outputpath,file_exp='SEDNA'
)
#calc= False #save= False #plot= True Value='AW_maxtemp_depth' Zone='ALL' Plot='AWTD_map' cmap='jet' clabel='m' clim= (0, 800) outputpath='../results/SEDNA_DELTA_MONITOR/' nc_outputpath='../nc_results/SEDNA_DELTA_MONITOR/' filename='SEDNA_AWTD_map_ALL_AW_maxtemp_depth' #3 no computing , loading starts data=save.load_data(plot=Plot,path=nc_outputpath,filename=filename) start loading data filename= ../nc_results/SEDNA_DELTA_MONITOR/SEDNA_AWTD_map_ALL_AW_maxtemp_depth/t_*/y_*/x_*.nc dim ('x', 'y', 't')
--------------------------------------------------------------------------- KeyError Traceback (most recent call last) File /ccc/cont003/home/ra5563/ra5563/monitor/lib/python3.10/site-packages/xarray/core/dataset.py:1317, in Dataset._construct_dataarray(self, name) 1316 try: -> 1317 variable = self._variables[name] 1318 except KeyError: KeyError: 'time_centered' During handling of the above exception, another exception occurred: KeyError Traceback (most recent call last) File /ccc/cont003/home/ra5563/ra5563/monitor/lib/python3.10/site-packages/xarray/core/concat.py:556, in _dataset_concat(datasets, dim, data_vars, coords, compat, positions, fill_value, join, combine_attrs) 555 try: --> 556 vars = ensure_common_dims([ds[name].variable for ds in datasets]) 557 except KeyError: File /ccc/cont003/home/ra5563/ra5563/monitor/lib/python3.10/site-packages/xarray/core/concat.py:556, in <listcomp>(.0) 555 try: --> 556 vars = ensure_common_dims([ds[name].variable for ds in datasets]) 557 except KeyError: File /ccc/cont003/home/ra5563/ra5563/monitor/lib/python3.10/site-packages/xarray/core/dataset.py:1410, in Dataset.__getitem__(self, key) 1409 if utils.hashable(key): -> 1410 return self._construct_dataarray(key) 1411 if utils.iterable_of_hashable(key): File /ccc/cont003/home/ra5563/ra5563/monitor/lib/python3.10/site-packages/xarray/core/dataset.py:1319, in Dataset._construct_dataarray(self, name) 1318 except KeyError: -> 1319 _, name, variable = _get_virtual_variable(self._variables, name, self.dims) 1321 needed_dims = set(variable.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) 174 if len(split_key) != 2: --> 175 raise KeyError(key) 177 ref_name, var_name = split_key KeyError: 'time_centered' During handling of the above exception, another exception occurred: ValueError Traceback (most recent call last) File <timed eval>:1, in <module> File /ccc/work/cont003/gen7420/odakatin/monitor-sedna/notebook/core/monitor.py:79, in auto(df, val, savefig, daskreport, outputpath, file_exp) 77 print('data=save.load_data(plot=Plot,path=nc_outputpath,filename=filename)' ) 78 with performance_report(filename=daskreport+"_calc_"+step.Value+".html"): ---> 79 data=save.load_data(plot=Plot,path=nc_outputpath,filename=filename) 80 #saveswitch=False 82 display(data) 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,'dim',dim) ---> 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:1000, in open_mfdataset(paths, chunks, concat_dim, compat, preprocess, engine, data_vars, coords, combine, parallel, join, attrs_file, combine_attrs, **kwargs) 987 combined = _nested_combine( 988 datasets, 989 concat_dims=concat_dim, (...) 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, 1003 data_vars=data_vars, 1004 coords=coords, 1005 join=join, 1006 combine_attrs=combine_attrs, 1007 ) 1008 else: 1009 raise ValueError( 1010 "{} is an invalid option for the keyword argument" 1011 " ``combine``".format(combine) 1012 ) File /ccc/cont003/home/ra5563/ra5563/monitor/lib/python3.10/site-packages/xarray/core/combine.py:982, in combine_by_coords(data_objects, compat, data_vars, coords, fill_value, join, combine_attrs, datasets) 980 concatenated_grouped_by_data_vars = [] 981 for vars, datasets_with_same_vars in grouped_by_vars: --> 982 concatenated = _combine_single_variable_hypercube( 983 list(datasets_with_same_vars), 984 fill_value=fill_value, 985 data_vars=data_vars, 986 coords=coords, 987 compat=compat, 988 join=join, 989 combine_attrs=combine_attrs, 990 ) 991 concatenated_grouped_by_data_vars.append(concatenated) 993 return merge( 994 concatenated_grouped_by_data_vars, 995 compat=compat, (...) 998 combine_attrs=combine_attrs, 999 ) File /ccc/cont003/home/ra5563/ra5563/monitor/lib/python3.10/site-packages/xarray/core/combine.py:640, in _combine_single_variable_hypercube(datasets, fill_value, data_vars, coords, compat, join, combine_attrs) 637 _check_dimension_depth_tile_ids(combined_ids) 639 # Concatenate along all of concat_dims one by one to create single ds --> 640 concatenated = _combine_nd( 641 combined_ids, 642 concat_dims=concat_dims, 643 data_vars=data_vars, 644 coords=coords, 645 compat=compat, 646 fill_value=fill_value, 647 join=join, 648 combine_attrs=combine_attrs, 649 ) 651 # Check the overall coordinates are monotonically increasing 652 for dim in concat_dims: File /ccc/cont003/home/ra5563/ra5563/monitor/lib/python3.10/site-packages/xarray/core/combine.py:239, in _combine_nd(combined_ids, concat_dims, data_vars, coords, compat, fill_value, join, combine_attrs) 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: --> 239 combined_ids = _combine_all_along_first_dim( 240 combined_ids, 241 dim=concat_dim, 242 data_vars=data_vars, 243 coords=coords, 244 compat=compat, 245 fill_value=fill_value, 246 join=join, 247 combine_attrs=combine_attrs, 248 ) 249 (combined_ds,) = combined_ids.values() 250 return combined_ds File /ccc/cont003/home/ra5563/ra5563/monitor/lib/python3.10/site-packages/xarray/core/combine.py:275, in _combine_all_along_first_dim(combined_ids, dim, data_vars, coords, compat, fill_value, join, combine_attrs) 273 combined_ids = dict(sorted(group)) 274 datasets = combined_ids.values() --> 275 new_combined_ids[new_id] = _combine_1d( 276 datasets, dim, compat, data_vars, coords, fill_value, join, combine_attrs 277 ) 278 return new_combined_ids File /ccc/cont003/home/ra5563/ra5563/monitor/lib/python3.10/site-packages/xarray/core/combine.py:298, in _combine_1d(datasets, concat_dim, compat, data_vars, coords, fill_value, join, combine_attrs) 296 if concat_dim is not None: 297 try: --> 298 combined = concat( 299 datasets, 300 dim=concat_dim, 301 data_vars=data_vars, 302 coords=coords, 303 compat=compat, 304 fill_value=fill_value, 305 join=join, 306 combine_attrs=combine_attrs, 307 ) 308 except ValueError as err: 309 if "encountered unexpected variable" in str(err): File /ccc/cont003/home/ra5563/ra5563/monitor/lib/python3.10/site-packages/xarray/core/concat.py:243, in concat(objs, dim, data_vars, coords, compat, positions, fill_value, join, combine_attrs) 231 return _dataarray_concat( 232 objs, 233 dim=dim, (...) 240 combine_attrs=combine_attrs, 241 ) 242 elif isinstance(first_obj, Dataset): --> 243 return _dataset_concat( 244 objs, 245 dim=dim, 246 data_vars=data_vars, 247 coords=coords, 248 compat=compat, 249 positions=positions, 250 fill_value=fill_value, 251 join=join, 252 combine_attrs=combine_attrs, 253 ) 254 else: 255 raise TypeError( 256 "can only concatenate xarray Dataset and DataArray " 257 f"objects, got {type(first_obj)}" 258 ) File /ccc/cont003/home/ra5563/ra5563/monitor/lib/python3.10/site-packages/xarray/core/concat.py:558, in _dataset_concat(datasets, dim, data_vars, coords, compat, positions, fill_value, join, combine_attrs) 556 vars = ensure_common_dims([ds[name].variable for ds in datasets]) 557 except KeyError: --> 558 raise ValueError(f"{name!r} is not present in all datasets.") 560 # Try concatenate the indexes, concatenate the variables when no index 561 # is found on all datasets. 562 indexes: list[Index] = list(get_indexes(name)) ValueError: 'time_centered' is not present in all datasets.