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 #189

Merged
merged 7 commits into from
Dec 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
376 changes: 163 additions & 213 deletions templates_notebooks/template_transect_transp_t.ipynb

Large diffs are not rendered by default.

39 changes: 28 additions & 11 deletions tools/do_shapefile_polygon.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tripyview/shapefiles/moc_basins/Atlantic_MOC.cpg
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ISO-8859-1
UTF-8
Binary file modified tripyview/shapefiles/moc_basins/Atlantic_MOC.dbf
100755 → 100644
Binary file not shown.
Binary file modified tripyview/shapefiles/moc_basins/Atlantic_MOC.shp
100755 → 100644
Binary file not shown.
Binary file modified tripyview/shapefiles/moc_basins/Atlantic_MOC.shx
100755 → 100644
Binary file not shown.
33 changes: 22 additions & 11 deletions tripyview/sub_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -888,25 +888,36 @@ def plot_hmesh( mesh ,
if len(mesh[ii].n_resol)==0: mesh[ii]=mesh[ii].compute_n_resol()
data_plot = mesh[ii].n_resol/1000
#data_plot = mesh[ii].n_resol[0,:]/1000
cb_label, cb_lunit = 'vertice resolution', 'km'
if cb_label is None: cb_label = 'vertice resolution'
if cb_lunit is None: cb_lunit = 'km'

elif data in ['narea', 'n_area', 'clusterarea', 'scalararea']:
if len(mesh[ii].n_area)==0: mesh[ii]=mesh[ii].compute_n_area()
data_plot = mesh[ii].n_area[0,:]
cb_label, cb_lunit = 'vertice area', 'm^2'
if cb_label is None: cb_label = 'vertice area'
if cb_lunit is None: cb_lunit = 'm^2'

elif data in ['eresol', 'e_resol', 'triresolution', 'triresol']:
if len(mesh[ii].e_resol)==0: mesh[ii]=mesh[ii].compute_e_resol()
data_plot = mesh[ii].e_resol/1000
cb_label, cb_lunit = 'element resolution', 'km'
if cb_label is None: cb_label = 'element resolution'
if cb_lunit is None: cb_lunit = 'km'

elif data in ['earea', 'e_area', 'triarea']:
if len(mesh[ii].e_area)==0: mesh[ii]=mesh[ii].compute_e_area()
data_plot = mesh[ii].e_area
cb_label, cb_lunit = 'element area', 'm^2'
if cb_label is None: cb_label = 'element area'
if cb_lunit is None: cb_lunit = 'm^2'

elif data in ['ndepth', 'ntopo', 'n_depth', 'n_topo', 'topography', 'zcoord']:
data_plot = np.abs(mesh[ii].n_z)
cb_label, cb_lunit = 'vertice depth', 'm'
if cb_label is None: cb_label = 'vertice depth'
if cb_lunit is None: cb_lunit = 'm'

elif data in ['edepth', 'etopo', 'e_depth', 'e_topo' ]:
data_plot = np.abs(mesh[ii].zlev[mesh[ii].e_iz])
cb_label, cb_lunit = 'element depth', 'm'
if cb_label is None: cb_label = 'element depth'
if cb_lunit is None: cb_lunit = 'm'

#_______________________________________________________________
cinfo_plot = do_setupcinfo(cinfo, [data_plot], do_rescale, mesh=mesh[ii], tri=tri)
Expand Down Expand Up @@ -4500,10 +4511,10 @@ def do_plt_data(hax_ii, do_plt, tri, data_plot, cinfo_plot, which_norm_plot,
plt_optdefault = dict({'shading':'gouraud', 'zorder':1})
plt_optdefault.update(plt_opt)

# pcolor plot in combination with shading :gouraud and orthographic projection
# leads to an blow up of the plotting therefor change to flat shading
if tri.x.size!=data_plot.size or isinstance(hax_ii.projection, (ccrs.Orthographic, ccrs.NearsidePerspective)):
plt_optdefault.update({'shading':'flat'})
## pcolor plot in combination with shading :gouraud and orthographic projection
## leads to an blow up of the plotting therefor change to flat shading
#if tri.x.size!=data_plot.size or isinstance(hax_ii.projection, (ccrs.Orthographic, ccrs.NearsidePerspective)):
#plt_optdefault.update({'shading':'flat'})

# if which_normplot is specified like in case of log10 and slog10 scaling
# vmin and vmax argumetns are not allows
Expand Down Expand Up @@ -5552,7 +5563,7 @@ def do_plt_gridlines(hax_ii, do_grid, box, ndat,
#_______________________________________________________________________
elif isinstance(hax_ii.projection, ccrs.CRS):
#___________________________________________________________________
grid_optdefault = dict({'color':'black', 'linestyle':'-', 'draw_labels':False, 'alpha':0.25, 'zorder':5})
grid_optdefault = dict({'color':'black', 'linestyle':'-', 'draw_labels':False, 'alpha':0.25, 'zorder':10})
grid_optdefault.update(grid_opt)

#___________________________________________________________________
Expand Down
4 changes: 2 additions & 2 deletions tripyview/sub_transect.py
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ def calc_transect_transp(mesh, data, transects, do_transectattr=False, do_rot=Tr

# here rotate the velocities from roted frame to geo frame
if do_rot:
for nti in range(data.dims['time']):
for nti in range(data.sizes['time']):
vel_u[nti,:,:], vel_v[nti,:,:] = vec_r2g(mesh.abg,
mesh.n_x[transect['path_ni']].sum(axis=1)/3.0,
mesh.n_y[transect['path_ni']].sum(axis=1)/3.0,
Expand Down Expand Up @@ -916,7 +916,7 @@ def calc_transect_transp(mesh, data, transects, do_transectattr=False, do_rot=Tr
# define dimensions
list_dimname, list_dimsize, list_dimval = dict(), dict(), dict()
if 'time' in data.dims:
list_dimname['time'] , list_dimsize['time'] , list_dimval['time'] = 'time', data.dims['time'], data.time.data #pd.to_datetime(data.time)
list_dimname['time'] , list_dimsize['time'] , list_dimval['time'] = 'time', data.sizes['time'], data.time.data #pd.to_datetime(data.time)
if 'nz1' in data.dims:
list_dimname['depth'], list_dimsize['depth'], list_dimval['depth'] = 'nz1' , mesh.zmid.size , mesh.zmid
elif 'nz' in data.dims:
Expand Down
4 changes: 2 additions & 2 deletions tripyview/sub_zmoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def calc_zmoc(mesh,
# create meridional bins --> this trick is from Nils Brückemann (ICON)
lat = mesh.n_y[mesh.e_i].sum(axis=1)/3.0
lat_bin = xr.DataArray(data=np.round(lat[idxin]/dlat)*dlat, dims='elem', name='lat')

#___________________________________________________________________________
# compute area weighted vertical velocities on vertices
else:
Expand Down Expand Up @@ -311,7 +311,7 @@ def calc_zmoc(mesh,
elif which_moc_name=='aamoc': str_region='Atlantic-Arctic '
elif which_moc_name=='pmoc' : str_region='Pacific '
elif which_moc_name=='ipmoc': str_region='Indo-Pacific '
elif which_moc_name=='pmoc' : str_region='Indo '
elif which_moc_name=='imoc' : str_region='Indo '
elif isinstance(which_moc,shp.Reader): str_region=which_moc_region

# for the choice of vertical plotting mode
Expand Down
Loading