Пример #1
0
    def read_transect(transect):
        """
        Find and load transects from a folder, calling tweak_sontek on each.
        return list of xr.Dataset
        """
        rivr_fns = glob.glob('%s/*.rivr' % transect) + glob.glob(
            '%s/*.riv' % transect)

        tran_dss = [
            tweak_sontek(read_sontek.surveyor_to_xr(fn, proj='EPSG:26910'))
            for fn in rivr_fns
        ]
        return tran_dss
    def convert_sontek(self, rivr_file):
        self.ds = read_sontek.surveyor_to_xr(rivr_file)

        # Set ADCPData members from self.ds

        # Starts with z as a positive-down quantity
        # use round(...,4) to drop some FP roundoff trash
        z_in = self.ds.location.values
        min_z = round(np.nanmin(z_in), 4)
        min_dz = np.round(np.nanmin(np.diff(z_in, axis=1)), 4)
        max_z = round(np.nanmax(z_in), 4)

        nbins = 1 + int(round((max_z - min_z) / min_dz))
        new_z = np.linspace(min_z, max_z, nbins)

        def resamp(orig, axis=-1):
            """ orig: [samples,cells].
            interpolate each sample to from z_in[sample,:] to new_z
            """
            n_samples = orig.shape[0]
            new_A = np.zeros((n_samples, len(new_z)), np.float64)
            for sample in range(n_samples):
                new_A[sample, :] = np.interp(new_z,
                                             z_in[sample, :],
                                             orig[sample, :],
                                             left=np.nan,
                                             right=np.nan)
            return new_A

        self.n_ensembles = len(self.ds.sample)
        self.velocity = np.array(
            (resamp(self.ds.Ve.values), resamp(self.ds.Vn.values),
             resamp(self.ds.Vu.values))).transpose(1, 2, 0)
        self.bin_center_elevation = -new_z  # make it negative downward
        self.n_bins = len(new_z)
        self.mtime = utils.to_dnum(self.ds.time.values)
        self.rotation_angle = 0
        self.rotation_axes = 0
        self.lonlat = np.c_[self.ds.lon.values, self.ds.lat.values]
        self.source = rivr_file
        self.references = "Sontek M9"
# First go, just use the bottom track depth, not the per-beam data.
# Assemble a set of xyz from all above data.
# will add in progressive complexity:
#  1. all relative to transducer
#  2. Offset for transducer depth below water
#  3. Timeseries of water surface elevation
#  4. Multiple beams?

all_xyz = []
all_t = []

surface_to_transducer = 0.20  # [m]

for rivr_fn in rivr_fns:
    print(rivr_fn)
    ds = read_sontek.surveyor_to_xr(rivr_fn, proj="EPSG:26910")

    x = ds.x_sample.values
    y = ds.y_sample.values
    z = -ds.depth_bt.values  # positive up, relative to transducer
    z -= surface_to_transducer
    all_xyz.append(np.c_[x, y, z])

    all_t.append(ds.time.values)

xyz_samples = np.concatenate(all_xyz)
t_samples = np.concatenate(all_t)

##

# Assume that the ADCP is in PST (that's probably an hour wrong, but
Пример #4
0
##

#fig_dir="figs-20180514"
#os.path.exists(fig_dir) or os.mkdir(fig_dir)

##

bt_dir = '040518_7_BTref'
gps_dir = '040518_7_GPSref'
rivr_fns = [os.path.basename(f) for f in glob.glob('%s/*.rivr' % bt_dir)]

all_bt = []

for fn in rivr_fns:
    ds = read_sontek.surveyor_to_xr('%s/%s' % (bt_dir, fn), proj='EPSG:26910')
    all_bt.append(ds)

##


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


##

# x-z of a single transect:
Пример #5
0
import six
from stompy import xr_transect

six.moves.reload_module(xr_transect)
six.moves.reload_module(read_sontek)

#---

# 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()