%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= irene5350.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 irene5350.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= 01 outputpath= ../results/SEDNA_DELTA_MONITOR/ daskreport= ../results/dask/6412987irene5350.c-irene.mg1.tgcc.ccc.cea.fr_SEDNA_DELTA_MONITOR_01M_Fluxnet/ CPU times: user 475 ms, sys: 139 ms, total: 614 ms Wall time: 20.7 s
Client-ab658d1a-1331-11ed-bfdf-080038b93f97
Connection method: Cluster object | Cluster type: distributed.LocalCluster |
Dashboard: http://127.0.0.1:8787/status |
5e808c12
Dashboard: http://127.0.0.1:8787/status | Workers: 16 |
Total threads: 128 | Total memory: 251.06 GiB |
Status: running | Using processes: True |
Scheduler-ad7a9503-92be-4e9a-8ff1-a075cceaf16f
Comm: tcp://127.0.0.1:33933 | 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:40155 | Total threads: 8 |
Dashboard: http://127.0.0.1:34864/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:39525 | |
Local directory: /tmp/dask-worker-space/worker-z26juiqx |
Comm: tcp://127.0.0.1:41535 | Total threads: 8 |
Dashboard: http://127.0.0.1:43471/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:38651 | |
Local directory: /tmp/dask-worker-space/worker-3a19jas4 |
Comm: tcp://127.0.0.1:42230 | Total threads: 8 |
Dashboard: http://127.0.0.1:42892/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:41883 | |
Local directory: /tmp/dask-worker-space/worker-7jl8hve4 |
Comm: tcp://127.0.0.1:35732 | Total threads: 8 |
Dashboard: http://127.0.0.1:38344/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:42061 | |
Local directory: /tmp/dask-worker-space/worker-8v2pa81r |
Comm: tcp://127.0.0.1:44288 | Total threads: 8 |
Dashboard: http://127.0.0.1:41538/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:38877 | |
Local directory: /tmp/dask-worker-space/worker-k4ci43vm |
Comm: tcp://127.0.0.1:40515 | Total threads: 8 |
Dashboard: http://127.0.0.1:46826/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:37733 | |
Local directory: /tmp/dask-worker-space/worker-1pnmu5et |
Comm: tcp://127.0.0.1:32998 | Total threads: 8 |
Dashboard: http://127.0.0.1:33264/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:43415 | |
Local directory: /tmp/dask-worker-space/worker-y0ru6m76 |
Comm: tcp://127.0.0.1:44345 | Total threads: 8 |
Dashboard: http://127.0.0.1:42798/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:44500 | |
Local directory: /tmp/dask-worker-space/worker-zep8cvml |
Comm: tcp://127.0.0.1:43548 | Total threads: 8 |
Dashboard: http://127.0.0.1:34848/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:39722 | |
Local directory: /tmp/dask-worker-space/worker-o1q5e8ch |
Comm: tcp://127.0.0.1:46341 | Total threads: 8 |
Dashboard: http://127.0.0.1:36894/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:32931 | |
Local directory: /tmp/dask-worker-space/worker-mbig9aiu |
Comm: tcp://127.0.0.1:46101 | Total threads: 8 |
Dashboard: http://127.0.0.1:45647/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:37141 | |
Local directory: /tmp/dask-worker-space/worker-bn3p2fcv |
Comm: tcp://127.0.0.1:40770 | Total threads: 8 |
Dashboard: http://127.0.0.1:41745/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:42964 | |
Local directory: /tmp/dask-worker-space/worker-40c2jbf2 |
Comm: tcp://127.0.0.1:38912 | Total threads: 8 |
Dashboard: http://127.0.0.1:36906/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:46241 | |
Local directory: /tmp/dask-worker-space/worker-60jxexg8 |
Comm: tcp://127.0.0.1:45488 | Total threads: 8 |
Dashboard: http://127.0.0.1:33440/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:40772 | |
Local directory: /tmp/dask-worker-space/worker-srvueml7 |
Comm: tcp://127.0.0.1:33662 | Total threads: 8 |
Dashboard: http://127.0.0.1:46179/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:42647 | |
Local directory: /tmp/dask-worker-space/worker-0p7r91l4 |
Comm: tcp://127.0.0.1:38440 | Total threads: 8 |
Dashboard: http://127.0.0.1:40887/status | Memory: 15.69 GiB |
Nanny: tcp://127.0.0.1:35504 | |
Local directory: /tmp/dask-worker-space/worker-rw1v4i3j |
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 | |
---|---|---|---|---|---|---|---|---|---|---|
Fluxnet | gridV.vomecrty,param.e3v_0,param.e1v,param.mas... | calc.Fluxnet(data) | FramS_All | Fluxnet_integrals | None | ((-10,10),(-10,50) ,(-150,50),(-25,5) ) | (Sv,TW, mSv,10^-2 Sv) | I-6 | ||
Fluxnet | gridV.vomecrty,param.e3v_0,param.e1v,param.mas... | calc.Fluxnet(data) | Davis | Fluxnet_integrals | None | ((-5.0,5.0),(-25,27) ,(-200,50),(-9,5) ) | (Sv,TW, mSv,10^-2 Sv) | I-6 | ||
Fluxnet | gridV.vomecrty,param.e3v_0,param.e1v,param.mas... | calc.Fluxnet(data) | Bering | Fluxnet_integrals | None | ((-2,2),(-10,50) ,(-150,50),(-2,4) ) | (Sv,TW, mSv,10^-2 Sv) | I-6 |
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 gridS ['vosaline'] using load_data_xios_kerchunk reading gridS 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/201201/gridS_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/ > took 36.258007287979126 seconds 0 merging gridS ['vosaline'] 1 read gridT ['votemper'] using load_data_xios_kerchunk reading gridT 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/201201/gridT_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/ > took 36.93924856185913 seconds 1 merging gridT ['votemper'] took 0.8146131038665771 seconds 2 read gridV ['vomecrty'] using load_data_xios_kerchunk reading gridV 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/201201/gridV_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/ > took 40.71440243721008 seconds 2 merging gridV ['vomecrty'] took 0.787360668182373 seconds 3 read icemod ['sivelv', 'sivolu'] 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/201201/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/ > took 31.438934564590454 seconds 3 merging icemod ['sivelv', 'sivolu'] took 0.7660365104675293 seconds param nav_lat will be included in data param e3v_0 will be included in data param mask2d will be included in data param nav_lon will be included in data param e1v will be included in data param mask will be included in data CPU times: user 1min 24s, sys: 9.28 s, total: 1min 33s Wall time: 2min 51s
<xarray.Dataset> Dimensions: (t: 31, z: 150, y: 6540, x: 6560) Coordinates: time_centered (t) object dask.array<chunksize=(1,), meta=np.ndarray> * t (t) object 2012-01-01 12:00:00 ... 2012-01-31 12:00:00 * y (y) int64 1 2 3 4 5 6 7 ... 6535 6536 6537 6538 6539 6540 * x (x) int64 1 2 3 4 5 6 7 ... 6555 6556 6557 6558 6559 6560 nav_lat (y, x) float32 dask.array<chunksize=(13, 6560), meta=np.ndarray> nav_lon (y, x) float32 dask.array<chunksize=(13, 6560), meta=np.ndarray> * z (z) int64 1 2 3 4 5 6 7 8 ... 143 144 145 146 147 148 149 150 e3v_0 (z, y, x) float64 dask.array<chunksize=(150, 13, 6560), meta=np.ndarray> mask2d (y, x) bool dask.array<chunksize=(13, 6560), meta=np.ndarray> e1v (y, x) float64 dask.array<chunksize=(13, 6560), meta=np.ndarray> mask (z, y, x) bool dask.array<chunksize=(150, 13, 6560), meta=np.ndarray> Data variables: vosaline (t, z, y, x) float32 dask.array<chunksize=(1, 150, 13, 6560), meta=np.ndarray> votemper (t, z, y, x) float32 dask.array<chunksize=(1, 150, 13, 6560), meta=np.ndarray> vomecrty (t, z, y, x) float32 dask.array<chunksize=(1, 150, 13, 6560), meta=np.ndarray> sivelv (t, y, x) float32 dask.array<chunksize=(1, 13, 6560), meta=np.ndarray> sivolu (t, y, x) float32 dask.array<chunksize=(1, 13, 6560), meta=np.ndarray> Attributes: (12/26) CASE: DELTA CONFIG: SEDNA Conventions: CF-1.6 DOMAIN_dimensions_ids: [2, 3] DOMAIN_halo_size_end: [0, 0] DOMAIN_halo_size_start: [0, 0] ... ... nj: 13 output_frequency: 1d start_date: 20090101 timeStamp: 2022-Jan-17 19:00:16 GMT title: ocean T grid variables uuid: d8db76f6-a436-451a-9ab1-72dc892753af
%%time
monitor.auto(df,data,savefig,daskreport,outputpath,file_exp='SEDNA'
)
#calc= True #save= True #plot= False monitor.optimize_dataset(data) Value='Fluxnet' Zone='FramS_All' Plot='Fluxnet_integrals' cmap='None' clabel='(Sv,TW, mSv,10^-2 Sv)' clim= ((-10, 10), (-10, 50), (-150, 50), (-25, 5)) outputpath='../results/SEDNA_DELTA_MONITOR/' nc_outputpath='../nc_results/SEDNA_DELTA_MONITOR/' filename='SEDNA_Fluxnet_integrals_FramS_All_Fluxnet' #2 Zooming Data dtaa= zoom.FramS_All(data)
/ccc/cont003/home/ra5563/ra5563/monitor/lib/python3.10/site-packages/pandas/core/indexes/base.py:5055: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[seq]`. In the future this will be interpreted as an array index, `arr[np.array(seq)]`, which will result either in an error or a different result. result = getitem(key)
--------------------------------------------------------------------------- IndexError Traceback (most recent call last) File <timed eval>:1, in <module> File /ccc/work/cont003/gen7420/odakatin/monitor-sedna/notebook/core/monitor.py:54, in auto(df, val, savefig, daskreport, outputpath, file_exp) 52 print('dtaa=',command) 53 with performance_report(filename=daskreport+"_zoom_"+Value+".html"): ---> 54 data=eval(command) 55 display(data) 56 # 3. Compute (or load computed results) File <string>:1, in <module> File /ccc/work/cont003/gen7420/odakatin/monitor-sedna/notebook/core/zoom.py:19, in FramS_All(val) 17 straits_FramS=val.isel(x=slice(xmin-1, xmax),y=slice(yfix-1,yfix+1)) 18 #section_FramS=val.isel(x=slice(xmin-1, xmax),y=yfix) ---> 19 straits_FramS=straits_FramS.where((straits_FramS.mask ), drop=True).chunk({ 'y': -1 }).unify_chunks() 20 return straits_FramS File /ccc/cont003/home/ra5563/ra5563/monitor/lib/python3.10/site-packages/xarray/core/common.py:1078, in DataWithCoords.where(self, cond, other, drop) 1075 for dim in cond.sizes.keys(): 1076 indexers[dim] = _get_indexer(dim) -> 1078 self = self.isel(**indexers) 1079 cond = cond.isel(**indexers) 1081 return ops.where_method(self, cond, other) File /ccc/cont003/home/ra5563/ra5563/monitor/lib/python3.10/site-packages/xarray/core/dataset.py:2387, in Dataset.isel(self, indexers, drop, missing_dims, **indexers_kwargs) 2385 indexers = either_dict_or_kwargs(indexers, indexers_kwargs, "isel") 2386 if any(is_fancy_indexer(idx) for idx in indexers.values()): -> 2387 return self._isel_fancy(indexers, drop=drop, missing_dims=missing_dims) 2389 # Much faster algorithm for when all indexers are ints, slices, one-dimensional 2390 # lists, or zero or one-dimensional np.ndarray's 2391 indexers = drop_dims_from_indexers(indexers, self.dims, missing_dims) File /ccc/cont003/home/ra5563/ra5563/monitor/lib/python3.10/site-packages/xarray/core/dataset.py:2433, in Dataset._isel_fancy(self, indexers, drop, missing_dims) 2430 valid_indexers = dict(self._validate_indexers(indexers, missing_dims)) 2432 variables: dict[Hashable, Variable] = {} -> 2433 indexes, index_variables = isel_indexes(self.xindexes, valid_indexers) 2435 for name, var in self.variables.items(): 2436 if name in index_variables: File /ccc/cont003/home/ra5563/ra5563/monitor/lib/python3.10/site-packages/xarray/core/indexes.py:1357, in isel_indexes(indexes, indexers) 1353 def isel_indexes( 1354 indexes: Indexes[Index], 1355 indexers: Mapping[Any, Any], 1356 ) -> tuple[dict[Hashable, Index], dict[Hashable, Variable]]: -> 1357 return _apply_indexes(indexes, indexers, "isel") File /ccc/cont003/home/ra5563/ra5563/monitor/lib/python3.10/site-packages/xarray/core/indexes.py:1341, in _apply_indexes(indexes, args, func) 1339 index_args = {k: v for k, v in args.items() if k in index_dims} 1340 if index_args: -> 1341 new_index = getattr(index, func)(index_args) 1342 if new_index is not None: 1343 new_indexes.update({k: new_index for k in index_vars}) File /ccc/cont003/home/ra5563/ra5563/monitor/lib/python3.10/site-packages/xarray/core/indexes.py:362, in PandasIndex.isel(self, indexers) 358 if not isinstance(indxr, slice) and is_scalar(indxr): 359 # scalar indexer: drop index 360 return None --> 362 return self._replace(self.index[indxr]) File /ccc/cont003/home/ra5563/ra5563/monitor/lib/python3.10/site-packages/pandas/core/indexes/base.py:5055, in Index.__getitem__(self, key) 5048 if com.is_bool_indexer(key): 5049 # if we have list[bools, length=1e5] then doing this check+convert 5050 # takes 166 µs + 2.1 ms and cuts the ndarray.__getitem__ 5051 # time below from 3.8 ms to 496 µs 5052 # if we already have ndarray[bool], the overhead is 1.4 µs or .25% 5053 key = np.asarray(key, dtype=bool) -> 5055 result = getitem(key) 5056 # Because we ruled out integer above, we always get an arraylike here 5057 if result.ndim > 1: IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed