Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
2,367 changes: 1,467 additions & 900 deletions examples/adcp_example.ipynb

Large diffs are not rendered by default.

225 changes: 142 additions & 83 deletions examples/adv_example.ipynb

Large diffs are not rendered by default.

20,056 changes: 0 additions & 20,056 deletions examples/data/dolfyn/AWAC_test01.log

This file was deleted.

87,802 changes: 0 additions & 87,802 deletions examples/data/dolfyn/RDI_withBT.log

This file was deleted.

Binary file modified examples/data/dolfyn/test_data/AWAC_test01.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/AWAC_test01_clean.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/AWAC_test01_earth2inst.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/AWAC_test01_earth2principal.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/AWAC_test01_inst2beam.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/AWAC_test01_ud.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/BenchFile01.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/BenchFile01_avg.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/BenchFile01_func.nc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/H-AWAC_test01.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/RDI_7f79.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/RDI_test01.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/RDI_test01_ofilt.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/RDI_test01_rotate_beam2inst.nc
Binary file not shown.
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/RDI_test01_rotate_inst2earth.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/RDI_withBT.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/RiverPro_test01.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/Sig1000_BadTime01.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/Sig1000_IMU.nc
Binary file not shown.
Binary file added examples/data/dolfyn/test_data/Sig1000_IMU_bin.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/Sig1000_IMU_ofilt.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/Sig1000_IMU_rotate_beam2inst.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/Sig1000_IMU_rotate_inst2earth.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/Sig1000_IMU_ud.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/Sig1000_tidal.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/Sig1000_tidal_clean.nc
Binary file not shown.
30 changes: 0 additions & 30 deletions examples/data/dolfyn/test_data/Sig500_Echo.log

This file was deleted.

Binary file modified examples/data/dolfyn/test_data/Sig500_Echo.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/Sig500_Echo_clean.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/Sig500_Echo_crop.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/Sig500_Echo_earth2inst.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/Sig500_Echo_inst2beam.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/Sig500_last_ensemble_is_whole.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/Sig_SkippedPings01.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/VelEchoBT01.nc
Binary file not shown.
Binary file not shown.
Binary file removed examples/data/dolfyn/test_data/burst_mode01.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/dat_rdi_bt.mat
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/dat_vec.mat
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/dat_vm.mat
Binary file not shown.
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/vector_data01.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/vector_data01_GN.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/vector_data01_avg.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/vector_data01_bin.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/vector_data01_func.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/vector_data01_rclean.nc
Binary file not shown.
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/vector_data01_rotate_inst2beam.nc
Binary file not shown.
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/vector_data01_sclean.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/vector_data01_u.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/vector_data_imu01-json.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/vector_data_imu01-json_mc.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/vector_data_imu01.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/vector_data_imu01_GN.nc
Binary file not shown.
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/vector_data_imu01_mc.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/vector_data_imu01_mcDeclin10.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/vector_data_imu01_mcsp.nc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/vmdas01_wh.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/vmdas02_os.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/winriver01.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/winriver02.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/winriver02_rotate_ship2earth.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/winriver02_transect.nc
Binary file not shown.
113,102 changes: 0 additions & 113,102 deletions examples/data/dolfyn/vector_data_imu01.log

This file was deleted.

3 changes: 2 additions & 1 deletion mhkit/dolfyn/adp/api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from ..io.api import read, load
from ..rotate.api import rotate2
from ..rotate.api import rotate2, calc_principal_heading
from . import clean
from ..velocity import VelBinner
from .turbulence import ADPBinner
81 changes: 50 additions & 31 deletions mhkit/dolfyn/adp/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,12 @@ def find_surface(ds, thresh=10, nfilt=None):
dfilt[dfilt == 0] = np.NaN
d = dfilt

ds['depth'] = xr.DataArray(d, dims=['time'], attrs={
'units': 'm'}).astype('float32')

ds['depth'] = xr.DataArray(d.astype('float32'),
dims=['time'],
attrs={'units': 'm',
'long_name': 'Depth',
'standard_name': 'depth',
'positive': 'down'})

def find_surface_from_P(ds, salinity=35):
"""
Expand All @@ -128,41 +131,56 @@ def find_surface_from_P(ds, salinity=35):
Requires that the instrument's pressure sensor was calibrated/zeroed
before deployment to remove atmospheric pressure.

Calculates seawater density at normal atmospheric pressure according
to the UNESCO 1981 equation of state. Does not include hydrostatic pressure.
Calculates seawater density using a linear approximation of the sea
water equation of state:

.. math:: \\rho - \\rho_0 = -\\alpha (T-T_0) + \\beta (S-S_0) + \\kappa P

Where :math:`\\rho` is water density, :math:`T` is water temperature,
:math:`P` is water pressure, :math:`S` is practical salinity,
:math:`\\alpha` is the thermal expansion coefficient, :math:`\\beta` is
the haline contraction coefficient, and :math:`\\kappa` is adiabatic
compressibility.
"""

# Density calcation
T = ds.temp.values
S = salinity
# standard mean ocean water
rho_smow = 999.842594 + 6.793953e-2*T - 9.095290e-3*T**2 + \
1.001685e-4*T**3 - 1.120083e-6*T**4 + 6.536332e-9*T**5
# at water surface
B1 = 8.2449e-1 - 4.0899e-3*T + 7.6438e-5*T**2 - 8.2467e-7*T**3 + 5.3875e-9*T**4
C1 = -5.7246e-3 + 1.0227e-4*T - 1.6546e-6*T**2
d0 = 4.8314e-4
rho_atm0 = rho_smow + B1*S + C1*S**1.5 + d0*S**2
P = ds.pressure.values
T = ds.temp.values # temperature, degC
S = salinity # practical salinity
rho0 = 1027 # kg/m^3
T0 = 10 # degC
S0 = 35 # psu assumed equivalent to ppt
a = 0.15 # thermal expansion coefficient, kg/m^3/degC
b = 0.78 # haline contraction coefficient, kg/m^3/ppt
k = 4.5e-3 # adiabatic compressibility, kg/m^3/dbar
rho = rho0 - a*(T-T0) + b*(S-S0) + k*P

# Depth = pressure (conversion from dbar to MPa) / water weight
d = (ds.pressure*10000)/(9.81*rho_atm0)
d = (ds.pressure*10000)/(9.81*rho)

if hasattr(ds, 'h_deploy'):
d += ds.h_deploy
description = "Water depth to seafloor"
description = "Depth to Seafloor"
else:
description = "Water depth to ADCP"
description = "Depth to Instrument"

ds['water_density'] = xr.DataArray(
rho_atm0.astype('float32'),
rho.astype('float32'),
dims=['time'],
attrs={'units': 'kg m-3',
'long_name': 'Water Density',
'standard_name': 'sea_water_density',
'description': 'Water density from linear approximation of sea water equation of state'})
ds['depth'] = xr.DataArray(
d.astype('float32'),
dims=['time'],
attrs={'units': 'kg/m^3',
'description': 'Water density according to UNESCO 1981 equation of state'})
ds['depth'] = xr.DataArray(d.astype('float32'), dims=['time'], attrs={
'units': 'm', 'description': description})
attrs={'units': 'm',
'long_name': description,
'standard_name': 'depth',
'positive': 'down'})


def nan_beyond_surface(ds, val=np.nan, inplace=False):
def nan_beyond_surface(ds, val=np.nan, beam_angle=None, inplace=False):
"""
Mask the values of 3D data (vel, amp, corr, echo) that are beyond the surface.

Expand All @@ -172,6 +190,8 @@ def nan_beyond_surface(ds, val=np.nan, inplace=False):
The adcp dataset to clean
val : nan or numeric
Specifies the value to set the bad values to. Default is `numpy.nan`
beam_angle : int
ADCP beam inclination angle. Default = dataset.attrs['beam_angle']
inplace : bool
When True the existing data object is modified. When False
a copy is returned. Default = False
Expand All @@ -194,13 +214,12 @@ def nan_beyond_surface(ds, val=np.nan, inplace=False):
# Get all variables with 'range' coordinate
var = [h for h in ds.keys() if any(s for s in ds[h].dims if 'range' in s)]

if 'nortek' in _make_model(ds):
beam_angle = 25 * (np.pi/180)
else: # TRDI
try:
beam_angle = ds.beam_angle
except:
beam_angle = 20 * (np.pi/180)
if beam_angle is None:
if hasattr(ds, 'beam_angle'):
beam_angle = ds.beam_angle * (np.pi/180)
else:
raise Exception("'beam_angle` not found in dataset attributes. "\
"Please supply the ADCP's beam angle.")

# Surface interference distance calculated from distance of transducers to surface
if hasattr(ds, 'h_deploy'):
Expand Down
Loading