Skip to content

Commit

Permalink
make sure that the example notebook in the notebook folder everything…
Browse files Browse the repository at this point in the history
… works
  • Loading branch information
patrickscholz committed Oct 20, 2024
1 parent c06e81e commit df31bf3
Show file tree
Hide file tree
Showing 4 changed files with 220 additions and 263 deletions.
467 changes: 212 additions & 255 deletions notebooks/tripyview_example.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

0 comments on commit df31bf3

Please sign in to comment.