Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workbench #162

Merged
merged 3 commits into from
Oct 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 11 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Triangular plotting and diagnostics for FESOM2 + command line utility similar to
fdiag using plotting suite of [email protected] (former fesom2/view_pscholz folder).
Data reading got updated to xarray, plotting got updated to cartopy, actually works well for
python=3.9, 3.10, 3.11 and 3.12 (python 3.8 made recently some problems to resolve all the cartopy dependencies).
It is tested upto dart mesh size (3M surface vertices) where it allows for a decend
It is tested up to dart mesh size (3M surface vertices) where it allows for a decent
working speed (but only when used in parallel)
<br />
version: 0.3.0
Expand All @@ -32,17 +32,13 @@ make sure your conda environment uses python 3.9, 3.10, 3.11 or 3.12
# gets one thread
# -install libstdcxx-ng with conda since there is no pip package for it is needed
# so that pyvista is able to plot interactively
# -all other packages will be automatically installed by pip
conda install -c conda-forge libstdcxx-ng
cd tripyview
pip install -e .

# If you want to use the interactive features in tools/do_topo@elem_or_node.ipynb
# due to python issues you will need jupyter_server=1.23.6, jupyter_client=7.3.2,
# tornad=6.1 --> its the only combination where this features works in moment!!!
(pip install jupyter_server==1.23.6 jupyter_client==7.3.2 tornado==6.1)

# On my laptop i had problems with the classic notebook support beyond jupyter_server==2.0.0
# and had to downgrade it to jupyter_server<2.0.0. However on HPC albedo that didnt
# and had to downgrade it to jupyter_server<2.0.0. However on HPC albedo that did not
# seems to be the case.
(pip install "jupyter_server<2.0.0")
```
Expand Down Expand Up @@ -105,9 +101,9 @@ vertice/element- resolution and area)


### General time plots:
* `hovm` - plot hovmöller diagramms for 3d ocean variable over depth and time averaged over
* `hovm` - plot hovmöller diagrams for 3d ocean variable over depth and time averaged over
specific region that is defined by shapefile (see. tripyview/shapefiles/...)
* `hovm_clim` - plot hovmöller diagramms for temperature, salinity and density climatology
* `hovm_clim` - plot hovmöller diagrams for temperature, salinity and density climatology
over depth and time averaged over specific region that is defined by shapefile (see. tripyview/shapefiles/...)

* `var_t` - plots time-series of globally or shapefile (see. tripyview/shapefiles/...) averaged 2d and 3d variables
Expand All @@ -123,11 +119,11 @@ for the: Atlantic(amoc), Atlantic+Arctic(aamoc), Pacific(pmoc), Pacific+Indian O
</p>


* `zmoc_t` - plot time-series of atlantic meridional overturning circulation at specific latitudes
* `zmoc_t` - plot time-series of Atlantic meridional overturning circulation at specific latitudes
(default: which_lats: [26, 40, 'max'])


* `dmoc` - plot meridional overturning circulation in density coordinates using FESOM2 density MOC diagnostics (graditues goes to **[email protected]**), Globally,
* `dmoc` - plot meridional overturning circulation in density coordinates using FESOM2 density MOC diagnostics (gratitude goes to **[email protected]**), Globally,
for the: Atlantic(amoc), Atlantic+Arctic(aamoc), Pacific(pmoc), Pacific+Indian Ocean(ipmoc) and Indian Ocean(imoc)
* `dmoc_srf` - plot surface transformation of meridional overturning circulation in density coordinates
* `dmoc_inner` - plot inner transformation of meridional overturning circulation in density coordinates
Expand All @@ -151,7 +147,7 @@ for the: Atlantic(amoc), Atlantic+Arctic(aamoc), Pacific(pmoc), Pacific+Indian O
* `dmoc_srfcbflx` - plot surface buoyancy flux transformation for specific water-class


* `dmoc_t` - plot time-series of atlantic meridional overturning circulation in density coordinates at specific latitudes
* `dmoc_t` - plot time-series of Atlantic meridional overturning circulation in density coordinates at specific latitudes
(default: which_lats: [26, 55, 'max'])


Expand All @@ -164,7 +160,7 @@ for the: Atlantic(amoc), Atlantic+Arctic(aamoc), Pacific(pmoc), Pacific+Indian O


### 2D automatic multipanel plotting:
* plot automatised figure multipanels depending on number of choosen datasets and number
* plot automatised figure multi-panels depending on number of chosen datasets and number
of panel columns ncol (the panel arrangement uses ideas from **[email protected]**)
<p align="center" width="100%">
<img width=75% src="tripyview/tripyview_multipanel.png">
Expand All @@ -185,15 +181,15 @@ of panel columns ncol (the panel arrangement uses ideas from **Nils.Brueggemann@

## Command line batch diagnostics:
* `tripyrun <workflowfile.yml>` - command line diagnostics similar to fdiag (fdiag, served as a
template, graditues go to **[email protected]**), creates html files with linked plots.
template, gratitude go to **[email protected]**), creates html files with linked plots.

* `tripyrun <workflowfile.yml> -d <driver>` - re-run one specific driver from .yml file

* `tripyrun <workflowfile.yml> -d <driver> -v <var1 var2 ...>` - re-run specific variable
subset of one specific driver driver from .yml file

* `tripyrun <workflowfile.yml> -r` - for the case the diagnostic did not fully finish you can
render the html file from hand based on hte saved json file. The json file is update after each finished
render the html file from hand based on the saved json file. The json file is update after each finished
driver section.

<p align="center" width="100%">
Expand Down
467 changes: 212 additions & 255 deletions notebooks/tripyview_example.ipynb

Large diffs are not rendered by default.

151 changes: 99 additions & 52 deletions tools/do_checkbndidx_cavity_and_bottom.ipynb

Large diffs are not rendered by default.

67 changes: 45 additions & 22 deletions tools/do_topo@elem_or_node.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tripyview/sub_dmoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ def calc_dmoc(mesh, data_dMOC, dlat=1.0, which_moc='gmoc', which_transf=None, do
#___________________________________________________________________________
# create meridional bins --> this trick is from Nils Brückemann (ICON)
lat_bin = xr.DataArray(data=np.round(data_dMOC['lat'].data/dlat)*dlat, dims='elem', name='lat')
lat = np.arange(lat_bin.min(), lat_bin.max()+dlat, dlat)
lat = np.arange(lat_bin.data.min(), lat_bin.data.max()+dlat, dlat)

#___________________________________________________________________________
# define subroutine for binning over latitudes, allows for parallelisation
Expand Down
12 changes: 6 additions & 6 deletions tripyview/sub_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,8 @@ def plot_hmesh( mesh ,

#___________________________________________________________________________
# --> check if input data is a list
if not isinstance(mesh, list): mesh = [mesh]
if not isinstance(mesh , list): mesh = [mesh]
if not isinstance(do_lsm, list): do_lsm = [do_lsm]*len(mesh)
ndat = len(mesh)

#___________________________________________________________________________
Expand Down Expand Up @@ -799,7 +800,6 @@ def plot_hmesh( mesh ,
tri = do_triangulation(hax, mesh[ii], proj_to, box)

#___________________________________________________________________
print(data)
if data != None and data != 'None':
if data in ['resolution', 'resol', 'n_resol', 'nresol']:
if len(mesh[ii].n_resol)==0: mesh[ii]=mesh[ii].compute_n_resol()
Expand All @@ -825,7 +825,6 @@ def plot_hmesh( mesh ,
data_plot = np.abs(mesh[ii].zlev[mesh[ii].e_iz])
cb_label, cb_lunit = 'element depth', 'm'

print(data_plot.shape)
#_______________________________________________________________
cinfo_plot = do_setupcinfo(cinfo, [data_plot], do_rescale, mesh=mesh[ii], tri=tri)
norm_plot = do_data_norm(cinfo_plot, do_rescale)
Expand All @@ -852,7 +851,7 @@ def plot_hmesh( mesh ,

#___________________________________________________________________
# add mesh land-sea mask
h0 = do_plt_lsmask(hax_ii, do_lsm, mesh[ii], lsm_opt=lsm_opt, resolution=lsm_res)
h0 = do_plt_lsmask(hax_ii, do_lsm[ii], mesh[ii], lsm_opt=lsm_opt, resolution=lsm_res)
hlsm.append(h0)

#___________________________________________________________________
Expand All @@ -879,7 +878,7 @@ def plot_hmesh( mesh ,
hcb_ii = do_cbar(hcb_ii, hax_ii, hp, data, cinfo_plot, norm_plot,
cb_label, cb_lunit, cb_ltime, cb_ldep, cb_opt=cb_opt, cbl_opt=cbl_opt, cbtl_opt=cbtl_opt)
else:
hcb_ii.remove()
if hcb_ii != 0: hcb_ii.remove()
#_______________________________________________________________________
# hfig.canvas.draw()

Expand Down Expand Up @@ -5351,7 +5350,8 @@ def inverse_ysig(y, *args):
if xlim is not None:
hax_ii.set_xlim(xlim[0] ,xlim[-1])
elif xlim is None and data_x is not None:
hax_ii.set_xlim(data_x[0], data_x[-1])
if data_x.ndim==1: hax_ii.set_xlim(data_x[0], data_x[-1])
elif data_x.ndim==2: hax_ii.set_xlim(data_x[0,0], data_x[0,-1])

#___________________________________________________________________
# invert y-axis
Expand Down
2 changes: 1 addition & 1 deletion tripyview/sub_zmoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def calc_zmoc(mesh, data, dlat=1.0, which_moc='gmoc', do_onelem=False,
#_______________________________________________________________________
# create meridional bins --> this trick is from Nils Brückemann (ICON)
lat_bin = xr.DataArray(data=np.round(data.lat/dlat)*dlat, dims='nod2', name='lat')
lat = np.arange(lat_bin.min(), lat_bin.max()+dlat, dlat)
lat = np.arange(lat_bin.data.min(), lat_bin.data.max()+dlat, dlat)
warnings.resetwarnings()
#t4 = clock.time()
#print(' --> comp. lat_bin', t4-t3)
Expand Down
Loading