# Parameters ncfile = "menor.nc" lon = (3.0, 4.5) lat = (42, 42.8) # Imports from vcmq import DS, map2, data_sample from vacumm.diag.thermdyn import mixed_layer_depth # Read temperature and depth ncfile = data_sample(ncfile) ds = DS(ncfile, "mars", lon=lon, lat=lat) temp = ds.get_temp(squeeze=1) depth = ds.get_depth(squeeze=1) # Compute MLD mld = mixed_layer_depth(temp, depth, mode="deltatemp") # Plot map2(mld, proj="merc", figsize=(6, 6), autoresize=0, colorbar_shrink=0.7, right=1, savefigs=__file__, show=False) print "Done"
"""Test :meth:`~vacumm.data.misc.dataset.OceanDataset.get_variable` with level as a string""" # Inits ncfile = "menor.nc" # Imports from vcmq import DS, os, map2, data_sample, code_file_name # Read data ncfile = data_sample(ncfile) ds = DS(ncfile, 'mars', logger_level='critical') tbot = ds.get_temp(level='bottom', squeeze=True) tsurf = ds.get_temp(level='surf', squeeze=True) # Plot bottom figfile = code_file_name(ext='png') if os.path.exists(figfile): os.remove(figfile) kw = dict(contour=True, fill='contourf', colorbar_shrink=0.8, cmap='cmocean_thermal', linewidth=.3) m = map2(tsurf, subplot=211, close=False, show=False, figsize=(5, 7), title='Testing Dataset.get_temp(level="surf")', **kw) map2(tbot, subplot=212, close=True, show=True, m=m, title='Testing Dataset.get_temp(level="bottom")', savefig=figfile, **kw)
"""Test :func:`~vacumm.diag.thermdyn.mixed_layer_depth` on MENOR""" # Inits ncfile = "menor.nc" # Imports from vcmq import DS, data_sample, mixed_layer_depth, rc, map2, os, code_file_name # Read data ds = DS(data_sample(ncfile),'mars', logger_level='critical') temp = ds.get_temp(squeeze=True) sal = ds.get_sal(squeeze=True) depth = ds.get_depth(squeeze=True) kz = ds.get_kz(squeeze=True) # Compute MLD kw = dict(depth=depth, format_axes=True) mld = {} mld['deltatemp'] = mixed_layer_depth(temp, mode='deltatemp',**kw) mld['deltadens'] = mixed_layer_depth((temp,sal), mode='deltadens', **kw) mld['kz'] = mixed_layer_depth(kz, mode='kz', **kw) vmin = min([v.min() for v in mld.values()]) vmax = max([v.max() for v in mld.values()]) # Plot it rc('font', size=8) for i,(mode, var) in enumerate(mld.items()): m = map2(var, fill='pcolormesh', nmax=20, vmin=vmin, vmax=vmax, subplot=(len(mld),1,i+1), figsize=(4.1,8), contour_linewidths=0.7, cmap='vacumm_rnb2_hymex', hspace=0.25, bottom=0.08, title='%%(long_name)s: mode = "%s"'%mode, show=False)
"""Test the asvar keyword of :meth:`~vacumm.data.misc.dataset.Dataset.finalize_object` on MENOR""" # Inits ncfile = "menor.nc" # Imports from vcmq import DS, data_sample # Read data ds = DS(data_sample(ncfile), 'mars', logger_level='critical') temp = ds.get_temp() bathy = ds.get_bathy(asvar=temp) # For unittest result = {'assertTupleEqual': [bathy.shape, temp.shape]}
"""Test the asvar keyword of :meth:`~vacumm.data.misc.dataset.Dataset.finalize_object` on MFS""" # Inits ncfile = "mfs.nc" # Imports from vcmq import DS, data_sample # Read data ds = DS(data_sample(ncfile), 'nemo', logger_level='critical') temp = ds.get_temp() depth = ds.get_depth(asvar=temp) # For unittest result = {'assertTupleEqual':[depth.shape, temp.shape]}
ds = DS(data_sample('menor.nc'), 'mars', lon=(4, 5), lat=(42.5, 43.5), log_level='debug') print ds.dataset # Logging ds.info('Pratique') # -> ESSAYER WARNING ds.set_loglevel('debug') # Coordonnees lon = ds.get_lon() # -> ESSAYER AU POINT U grid = ds.get_grid() # Variables temp = ds.get_temp(level=slice(-1, None), squeeze=True) sst = ds.get_sst(squeeze=True) # -> VERIFIER ATTRIBUTS ds.info('Plot SST') map2(sst) sal = ds.get_sal(lon=(4., 4.5)) print temp.shape, sal.shape # Generique ds2 = DS(data_sample('mfs.nc'), 'nemo', lon=(4, 5), lat=(42.5, 43.5)) sst2 = ds2.get_sst(squeeze=True) # -> VERIFIER ATTRIBUTS # Plus evolue depth = ds.get_depth() # sigma print depth.shape mld = ds.get_mld() ds.plot_transect('temp', lons=(4.1, 4.9), lats=(43.3, 42.6), figsize=(12, 6)) # -> OUTAXIS=
"""Test :meth:`~vacumm.data.misc.dataset.OceanDataset.get_variable` with level as a string""" # Inits ncfile = "menor.nc" # Imports from vcmq import DS, os, map2, data_sample, code_file_name # Read data ncfile = data_sample(ncfile) ds = DS(ncfile, 'mars', logger_level='critical') tbot = ds.get_temp(level='bottom', squeeze=True) tsurf = ds.get_temp(level='surf', squeeze=True) # Plot bottom figfile = code_file_name(ext='png') if os.path.exists(figfile): os.remove(figfile) kw = dict(contour=True, fill='contourf', colorbar_shrink=0.8, cmap='cmocean_thermal', linewidth=.3) m = map2(tsurf, subplot=211, close=False, show=False, figsize=(5, 7), title='Testing Dataset.get_temp(level="surf")', **kw) map2(tbot, subplot=212,
#!/usr/bin/env python # -*- coding: utf8 -*- """Diagnostics thermodynamiques et dynamiques (:mod:`vacumm.diag.thermdyn` et :mod:`vacumm.diag.dynamics`)""" from vcmq import DS, data_sample, map2, density, mixed_layer_depth, barotropic_geostrophic_velocity, kinetic_energy, shapiro2d # Lecture des données de base ds = DS(data_sample('menor.nc')) temp = ds.get_temp(squeeze=1) sal = ds.get_sal(squeeze=1) depth = ds.get_depth(squeeze=1) ssh = ds.get_ssh(squeeze=1) # Densité dens_surf = density(temp[-1], sal[-1]) # -> CALCULER DENSITE 3D map2(dens_surf) # Couche mélangée mld = mixed_layer_depth((temp, sal), depth, mode='deltadens') # -> ESSAYER AUTRES MODES map2(mld, vmax=600.) # Vitesse geostrophique # - vitesses ug, vg = barotropic_geostrophic_velocity(ssh) # - energie cinetique ke = kinetic_energy((ug, vg)) # -> TESTER AVEC SSH ke.long_name = 'Surface geostrophique kinetic energy' ke = shapiro2d(ke)