%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= irene4949.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 irene4949.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/7449107irene4949.c-irene.mg1.tgcc.ccc.cea.fr_SEDNA_DELTA_MONITOR_05M_MLD_2D/ CPU times: user 553 ms, sys: 124 ms, total: 676 ms Wall time: 18.4 s
Client-ea43f27f-6f42-11ed-92de-080038b93709
Connection method: Cluster object | Cluster type: distributed.LocalCluster |
Dashboard: http://127.0.0.1:8787/status |
3985f22c
Dashboard: http://127.0.0.1:8787/status | Workers: 16 |
Total threads: 128 | Total memory: 221.88 GiB |
Status: running | Using processes: True |
Scheduler-c459a819-e6dc-4d33-b5f6-cbd518d88ede
Comm: tcp://127.0.0.1:36278 | 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:37209 | Total threads: 8 |
Dashboard: http://127.0.0.1:40051/status | Memory: 13.87 GiB |
Nanny: tcp://127.0.0.1:33785 | |
Local directory: /tmp/dask-worker-space/worker-9hfmtfgc |
Comm: tcp://127.0.0.1:38109 | Total threads: 8 |
Dashboard: http://127.0.0.1:39437/status | Memory: 13.87 GiB |
Nanny: tcp://127.0.0.1:34155 | |
Local directory: /tmp/dask-worker-space/worker-zqv2o1d3 |
Comm: tcp://127.0.0.1:44341 | Total threads: 8 |
Dashboard: http://127.0.0.1:34144/status | Memory: 13.87 GiB |
Nanny: tcp://127.0.0.1:35839 | |
Local directory: /tmp/dask-worker-space/worker-uyuj28um |
Comm: tcp://127.0.0.1:36172 | Total threads: 8 |
Dashboard: http://127.0.0.1:43753/status | Memory: 13.87 GiB |
Nanny: tcp://127.0.0.1:45257 | |
Local directory: /tmp/dask-worker-space/worker-r5sql29q |
Comm: tcp://127.0.0.1:43279 | Total threads: 8 |
Dashboard: http://127.0.0.1:41705/status | Memory: 13.87 GiB |
Nanny: tcp://127.0.0.1:38221 | |
Local directory: /tmp/dask-worker-space/worker-n05h6due |
Comm: tcp://127.0.0.1:33326 | Total threads: 8 |
Dashboard: http://127.0.0.1:45536/status | Memory: 13.87 GiB |
Nanny: tcp://127.0.0.1:40911 | |
Local directory: /tmp/dask-worker-space/worker-u0y7yopy |
Comm: tcp://127.0.0.1:36047 | Total threads: 8 |
Dashboard: http://127.0.0.1:38674/status | Memory: 13.87 GiB |
Nanny: tcp://127.0.0.1:38641 | |
Local directory: /tmp/dask-worker-space/worker-da7sm52v |
Comm: tcp://127.0.0.1:39508 | Total threads: 8 |
Dashboard: http://127.0.0.1:43002/status | Memory: 13.87 GiB |
Nanny: tcp://127.0.0.1:44600 | |
Local directory: /tmp/dask-worker-space/worker-ngcgd_e_ |
Comm: tcp://127.0.0.1:40348 | Total threads: 8 |
Dashboard: http://127.0.0.1:38408/status | Memory: 13.87 GiB |
Nanny: tcp://127.0.0.1:34322 | |
Local directory: /tmp/dask-worker-space/worker-_2oyaxbp |
Comm: tcp://127.0.0.1:38488 | Total threads: 8 |
Dashboard: http://127.0.0.1:35228/status | Memory: 13.87 GiB |
Nanny: tcp://127.0.0.1:37698 | |
Local directory: /tmp/dask-worker-space/worker-bsakmjd9 |
Comm: tcp://127.0.0.1:36122 | Total threads: 8 |
Dashboard: http://127.0.0.1:35459/status | Memory: 13.87 GiB |
Nanny: tcp://127.0.0.1:40522 | |
Local directory: /tmp/dask-worker-space/worker-jmigs_s3 |
Comm: tcp://127.0.0.1:41784 | Total threads: 8 |
Dashboard: http://127.0.0.1:34830/status | Memory: 13.87 GiB |
Nanny: tcp://127.0.0.1:42081 | |
Local directory: /tmp/dask-worker-space/worker-i0scemur |
Comm: tcp://127.0.0.1:43069 | Total threads: 8 |
Dashboard: http://127.0.0.1:39512/status | Memory: 13.87 GiB |
Nanny: tcp://127.0.0.1:43118 | |
Local directory: /tmp/dask-worker-space/worker-ustnfk5h |
Comm: tcp://127.0.0.1:37273 | Total threads: 8 |
Dashboard: http://127.0.0.1:37847/status | Memory: 13.87 GiB |
Nanny: tcp://127.0.0.1:44763 | |
Local directory: /tmp/dask-worker-space/worker-fwlewz04 |
Comm: tcp://127.0.0.1:42274 | Total threads: 8 |
Dashboard: http://127.0.0.1:33707/status | Memory: 13.87 GiB |
Nanny: tcp://127.0.0.1:36871 | |
Local directory: /tmp/dask-worker-space/worker-fvbnmzef |
Comm: tcp://127.0.0.1:36530 | Total threads: 8 |
Dashboard: http://127.0.0.1:34260/status | Memory: 13.87 GiB |
Nanny: tcp://127.0.0.1:40318 | |
Local directory: /tmp/dask-worker-space/worker-hrpew13v |
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 | |
---|---|---|---|---|---|---|---|---|---|---|
MLD_2D | gridT-2D.samldr1_1 | data.samldr1_1 | ALL | maps | Blues | (0,80) | 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= 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 gridT-2D ['samldr1_1'] lazy= False using load_data_xios_kerchunk reading gridT-2D 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/gridT-2D_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/ > took 18.46770477294922 seconds 0 merging gridT-2D ['samldr1_1'] param mask2d will be included in data param nav_lon will be included in data param nav_lat will be included in data ychunk= 10 calldatas_y_rechunk sum_num (13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12) start rechunking with (130, 122, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 48) end of y_rechunk CPU times: user 21.8 s, sys: 1.7 s, total: 23.5 s Wall time: 39 s
<xarray.Dataset> Dimensions: (t: 31, y: 6540, x: 6560) Coordinates: nav_lat (y, x) float32 dask.array<chunksize=(130, 6560), meta=np.ndarray> nav_lon (y, x) float32 dask.array<chunksize=(130, 6560), meta=np.ndarray> * t (t) object 2015-05-01 12:00:00 ... 2015-05-31 12:00:00 * y (y) int64 1 2 3 4 5 6 7 8 ... 6534 6535 6536 6537 6538 6539 6540 * x (x) int64 1 2 3 4 5 6 7 8 ... 6554 6555 6556 6557 6558 6559 6560 mask2d (y, x) bool dask.array<chunksize=(130, 6560), meta=np.ndarray> Data variables: samldr1_1 (t, y, x) float32 dask.array<chunksize=(1, 130, 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-Aug-13 17:48:16 GMT title: ocean T grid variables uuid: fae82417-44f6-4ee9-a829-1b5daf5575f3
%%time
monitor.auto(df,data,savefig,daskreport,outputpath,file_exp='SEDNA'
)
#calc= True #save= False #plot= True Value='MLD_2D' Zone='ALL' Plot='maps' cmap='Blues' clabel='m' clim= (0, 80) outputpath='../results/SEDNA_DELTA_MONITOR/' nc_outputpath='../nc_results/SEDNA_DELTA_MONITOR/' filename='SEDNA_maps_ALL_MLD_2D' data=monitor.optimize_dataset(data) #3 Start computing data= data.samldr1_1 monitor.optimize_dataset(data) add optimise here once otimise can recognise
<xarray.DataArray 'samldr1_1' (t: 31, y: 6540, x: 6560)> dask.array<rechunk-merge, shape=(31, 6540, 6560), dtype=float32, chunksize=(1, 130, 6560), chunktype=numpy.ndarray> Coordinates: nav_lat (y, x) float32 dask.array<chunksize=(130, 6560), meta=np.ndarray> nav_lon (y, x) float32 dask.array<chunksize=(130, 6560), meta=np.ndarray> * t (t) object 2015-05-01 12:00:00 ... 2015-05-31 12:00:00 * y (y) int64 1 2 3 4 5 6 7 8 ... 6534 6535 6536 6537 6538 6539 6540 * x (x) int64 1 2 3 4 5 6 7 8 ... 6554 6555 6556 6557 6558 6559 6560 mask2d (y, x) bool dask.array<chunksize=(130, 6560), meta=np.ndarray> Attributes: cell_methods: time: mean (interval: 40 s) interval_operation: 40 s interval_write: 1 d long_name: Mixed Layer Depth (dsigma = 0.01 wrt 1m) online_operation: average standard_name: ocean_mixed_layer_thickness_defined_by_sigma_theta units: m
#5 Plotting filename= plots.maps(data,path=outputpath,filename=filename,save=savefig,cmap=cmap,clim=clim,clabel=clabel) ../results/SEDNA_DELTA_MONITOR/SEDNA_maps_ALL_MLD_2D_20150501-20150531.html starts plotting
/ccc/cont003/home/ra5563/ra5563/monitor/lib/python3.10/site-packages/geoviews/operation/projection.py:99: ShapelyDeprecationWarning: __len__ for multi-part geometries is deprecated and will be removed in Shapely 2.0. Check the length of the `geoms` property instead to get the number of parts of a multi-part geometry. if proj_geom.geom_type == 'GeometryCollection' and len(proj_geom) == 0:
../results/SEDNA_DELTA_MONITOR/SEDNA_maps_ALL_MLD_2D_20150501-20150531.html created
CPU times: user 10min 44s, sys: 2min 12s, total: 12min 56s Wall time: 12min 31s