示例#1
0
def test_transect_contour():
    tran=xr.open_dataset('data/temp-transect.nc')

    plt.figure(10).clf()
    fig,axs=plt.subplots(2,1,num=10,sharex=True,sharey=True)
    xr_transect.plot_scalar(tran,'temp',ax=axs[0])
    xr_transect.plot_scalar_pcolormesh(tran,'temp',ax=axs[1])

    xr_transect.contour(tran,'temp',np.linspace(5,27,28),
                        ax=axs[1],colors='k',linewidths=0.5)
示例#2
0
def test_transect():
    """
    Test loading a 'section_hydro' formatted transect, and resample to evenly
    spaced z.
    """
    untrim_sec=xr_transect.section_hydro_to_transect("data/section_hydro.txt",name="7B")

    new_z=np.linspace( untrim_sec.z_bed.values.min(),
                       untrim_sec.z_surf.values.max(),
                       100)

    untrim_sec_eq=xr_transect.resample_z(untrim_sec,new_z)

    plt.figure(22).clf()
    fig,axs=plt.subplots(2,1,num=22,sharex=True,sharey=True)

    xr_transect.plot_scalar(untrim_sec,'Ve',ax=axs[0])
    xr_transect.plot_scalar(untrim_sec_eq,'Ve',ax=axs[1])

    axs[0].text(0.02,0.9,'Original',transform=axs[0].transAxes)
    axs[1].text(0.02,0.9,'Resample',transform=axs[1].transAxes)
示例#3
0
utils.path("../../field/adcp")
from stompy import xr_transect
import summarize_xr_transects

##
six.moves.reload_module(dflow_model)
six.moves.reload_module(sun_driver)

# plot a few a sections
run_dir = "runs/steady_036"
model = sun_driver.SuntansModel.load(run_dir)

tran_shp = "../../gis/model_transects.shp"
tran_geoms = wkb2shp.shp2geom(tran_shp)

for ti, t in enumerate(tran_geoms):
    if t['name'] not in ['2018_05']:
        continue  # Focus on transect 5
    break

xy = np.array(t['geom'])
tran = model.extract_transect(
    xy=xy, time=-1, dx=2, vars=['uc', 'vc', 'Ac', 'dv', 'dzz', 'eta', 'nu_v'])
wet_samples = np.nonzero(np.abs(tran.z_dz.sum(dim='layer').values) > 0.01)[0]
sample_slice = slice(wet_samples[0], wet_samples[-1] + 1)
tran = tran.isel(sample=sample_slice)

plt.figure(2).clf()
coll = xr_transect.plot_scalar(tran, tran.nu_v, cmap='jet')
plt.colorbar(coll, label=r'$\nu_T$')
示例#4
0
"""
import six
from stompy import xr_transect
six.moves.reload_module(xr_transect)

##

tran = xr.open_dataset('040518_BT/040518_5BTref-avg.nc')

##
xr_transect.add_rozovski(tran)

##

plt.figure(1).clf()
xr_transect.plot_scalar(tran, tran.Uroz.sel(roz='downstream'))

plt.plot(tran.d_sample, z_sgn * tran.z_bed, 'k-', lw=0.5)

##

six.moves.reload_module(xr_transect)

var_methods = [('Uroz', dict(roz=0), 'linear', 'constant'),
               ('Uroz', dict(roz=1), 'linear', 'constant'),
               ('U', dict(xy=0), 'linear', 'constant'),
               ('U', dict(xy=1), 'linear', 'constant')]

ds = xr_transect.extrapolate_vertical(tran, var_methods, eta=0)

##
示例#5
0
# Choose 2, because it has the matlab output which is richer and has
# RiverSurveyor computed flows.
adcp_data_dir="040518_BT/040518_2BTref"

rivr_fns=glob.glob('%s/*.rivr'%adcp_data_dir)

all_ds=[ read_sontek.surveyor_to_xr(fn,proj='EPSG:26910',positive='up')
         for fn in rivr_fns]

##
ds=all_ds[1]

plt.figure(1).clf()
fig,ax=plt.subplots(1,1,num=1)

coll=xr_transect.plot_scalar(ds,ds.Ve,ax=ax)

ax.plot(ds.d_sample,ds.z_bed,'k-')

##

@memoize()
def bathy():
    from stompy.spatial import field
    return field.GdalGrid('../bathy/OldRvr_at_SanJoaquinRvr2012_0104-utm-m_NAVD.tif')

##

# Transect averaging:

def transects_to_segment(trans,unweight=True,ax=None):
## 
tr=xr.Dataset()
cc=g.cells_center()
tr['x_sample']=('sample',),cc[cells,0]
tr['y_sample']=('sample',),cc[cells,1]
tr['eta']=('sample',),ei[cells]
tr['z_dz']=('sample','layer'), (ei[cells]+sim.zi[cells])[:,None]
tr['z_ctr']=tr.eta-0.5*tr.z_dz
tr['U']=('sample','layer','xy'), ui[cells,:][:,None,:]

##
from stompy import xr_transect
xr_transect.add_rozovski(tr)

plt.figure(2).clf()
fig,axs=plt.subplots(2,1,sharex=True,num=2)

xr_transect.plot_scalar(tr,tr.Uroz.isel(roz=0),ax=axs[0])
axs[1].plot( tr.d_sample, tr.Uroz.isel(roz=0,layer=0) )
axs[0].set_title('SWAMPY transect 5.  Downstream velocity. n=0.025')
axs[1].axis(ymin=0)
axs[1].set_ylabel('m/s')
fig.savefig('swampy-n0.025-transect_05.png')

##
fig=plt.figure(1)
fig.savefig('swampy-n0.025-planview.png')