Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
3fa0350
Initial push
jmcvey3 May 4, 2022
f6b1991
Merge branch 'master' of https://github.com/jmcvey3/MHKiT-Python into…
jmcvey3 May 4, 2022
4dfd720
Latest bugfixes
jmcvey3 May 4, 2022
be4a644
Remove phase-in text
jmcvey3 May 4, 2022
6699c02
Update docstrings
jmcvey3 May 4, 2022
399b9e9
Readability, imports
jmcvey3 May 10, 2022
3d9cc47
Make functions public
jmcvey3 May 12, 2022
3f51015
Docstring updates
jmcvey3 May 12, 2022
b8cec35
Fix test oversight
jmcvey3 May 12, 2022
eb4ca68
Fix docstring
jmcvey3 May 24, 2022
2e3cf20
Missing timestamp fix for classic Nortek
jmcvey3 Jun 16, 2022
2394022
Docstring updates
jmcvey3 Jun 16, 2022
452db83
Renaming functions per mhkit standards
jmcvey3 Jun 16, 2022
8735e1c
Single array vs binned array functions
jmcvey3 Jun 17, 2022
b284e3b
Reorganizing analysis code
jmcvey3 Jun 17, 2022
e9665c1
Update invalid orientation matrix warning
jmcvey3 Jun 28, 2022
3638759
Add config details to dataset attributes
jmcvey3 Jul 8, 2022
088c9b6
Merge branch 'MHKiT-Software:master' into dolfyn
jmcvey3 Jul 18, 2022
a644427
dolfyn bugfixes
jmcvey3 Jul 25, 2022
0619b4a
Merge branch 'dolfyn' of https://github.com/jmcvey3/MHKiT-Python into…
jmcvey3 Jul 25, 2022
f70c1f9
ADV updates
jmcvey3 Aug 16, 2022
b595f2e
Update compression option for netcdf4
jmcvey3 Aug 16, 2022
86bffe6
Merge branch 'Develop' of https://github.com/MHKiT-Software/MHKiT-Pyt…
jmcvey3 Aug 17, 2022
79d6a44
Remove compression options
jmcvey3 Aug 19, 2022
f5941c6
Merge branch 'Develop' of https://github.com/MHKiT-Software/MHKiT-Pyt…
jmcvey3 Aug 19, 2022
ade52ca
Fix clean function
jmcvey3 Aug 24, 2022
17fe3bf
Set functions as private
jmcvey3 Aug 24, 2022
065cab6
Move stress functions to ADV dir
jmcvey3 Aug 24, 2022
0b17acb
Add bottleneck to reqs
jmcvey3 Aug 24, 2022
3439dda
Minor changes
jmcvey3 Sep 2, 2022
d192157
Remove old functions
jmcvey3 Sep 19, 2022
05bf271
Code simplification
jmcvey3 Sep 26, 2022
65399b4
Update examples
jmcvey3 Sep 26, 2022
a403e93
Make functions public
jmcvey3 Sep 26, 2022
ad28fbf
Add bottleneck to dependencies
jmcvey3 Sep 26, 2022
4679454
Fix notebook
jmcvey3 Sep 26, 2022
43159d7
Bugfix for beam vars
jmcvey3 Sep 30, 2022
e4532eb
Merge branch 'Develop' of https://github.com/MHKiT-Software/MHKiT-Pyt…
jmcvey3 Nov 7, 2022
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
20 changes: 10 additions & 10 deletions examples/adcp_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
},
"outputs": [],
"source": [
"from mhkit import dolfyn as dlfn\n",
"from mhkit import dolfyn\n",
"from mhkit.dolfyn.adp import api"
]
},
Expand Down Expand Up @@ -77,7 +77,7 @@
}
],
"source": [
"ds = dlfn.read('data/dolfyn/Sig1000_tidal.ad2cp')"
"ds = dolfyn.read('data/dolfyn/Sig1000_tidal.ad2cp')"
]
},
{
Expand Down Expand Up @@ -1464,8 +1464,8 @@
}
],
"source": [
"dlfn.set_declination(ds, 15.8, inplace=True) # 15.8 deg East\n",
"dlfn.rotate2(ds, 'earth', inplace=True)"
"dolfyn.set_declination(ds, 15.8, inplace=True) # 15.8 deg East\n",
"dolfyn.rotate2(ds, 'earth', inplace=True)"
]
},
{
Expand All @@ -1481,8 +1481,8 @@
"metadata": {},
"outputs": [],
"source": [
"ds.attrs['principal_heading'] = dlfn.calc_principal_heading(ds['vel'].mean('range'))\n",
"ds_streamwise = dlfn.rotate2(ds, 'principal', inplace=False)"
"ds.attrs['principal_heading'] = dolfyn.calc_principal_heading(ds['vel'].mean('range'))\n",
"ds_streamwise = dolfyn.rotate2(ds, 'principal', inplace=False)"
]
},
{
Expand Down Expand Up @@ -3295,7 +3295,7 @@
"ds_avg['U_mag'] = ds_avg.velds.U_mag\n",
"\n",
"ds_avg['U_dir'] = ds_avg.velds.U_dir\n",
"ds_avg['U_dir'].values = dlfn.tools.misc.convert_degrees(ds_avg['U_dir'].values, tidal_mode=True)"
"ds_avg['U_dir'].values = dolfyn.tools.misc.convert_degrees(ds_avg['U_dir'].values, tidal_mode=True)"
]
},
{
Expand Down Expand Up @@ -3347,7 +3347,7 @@
"\n",
"ax = plt.figure(figsize=(12,8)).add_axes([.14, .14, .8, .74])\n",
"# Plot flow speed\n",
"t = dlfn.time.dt642date(ds_avg['time'])\n",
"t = dolfyn.time.dt642date(ds_avg['time'])\n",
"plt.pcolormesh(t, ds_avg['range'], ds_avg['U_mag'], cmap='Blues', shading='nearest')\n",
"# Plot the water surface\n",
"ax.plot(t, ds_avg['depth'])\n",
Expand Down Expand Up @@ -3414,8 +3414,8 @@
"outputs": [],
"source": [
"# Uncomment these lines to save and load to your current working directory\n",
"#dlfn.save(ds, 'your_data.nc')\n",
"#ds_saved = dlfn.load('your_data.nc')"
"#dolfyn.save(ds, 'your_data.nc')\n",
"#ds_saved = dolfyn.load('your_data.nc')"
]
}
],
Expand Down
234 changes: 77 additions & 157 deletions examples/adv_example.ipynb

Large diffs are not rendered by default.

Binary file modified examples/data/dolfyn/test_data/BenchFile01_func.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/VelEchoBT01.nc
Binary file not shown.
Binary file modified examples/data/dolfyn/test_data/VelEchoBT01_rotate_beam2inst.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 not shown.
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.
6 changes: 3 additions & 3 deletions mhkit/dolfyn/adp/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np
import xarray as xr
from scipy.signal import medfilt
from ..tools.misc import medfiltnan
from ..tools.misc import _medfiltnan
from ..rotate.api import rotate2
from ..rotate.base import _make_model, quaternion2orient

Expand Down Expand Up @@ -96,7 +96,7 @@ def find_surface(ds, thresh=10, nfilt=None):
d[ip] = np.NaN

if nfilt:
dfilt = medfiltnan(d, nfilt, thresh=.4)
dfilt = _medfiltnan(d, nfilt, thresh=.4)
dfilt[dfilt == 0] = np.NaN
d = dfilt

Expand Down Expand Up @@ -402,4 +402,4 @@ def fillgaps_depth(var, method='cubic', maxgap=None):

return var.interpolate_na(dim=range_dim, method=method,
use_coordinate=False,
max_gap=maxgap)
max_gap=maxgap)
17 changes: 7 additions & 10 deletions mhkit/dolfyn/adv/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
cos = np.cos


def clean_fill(u, mask, npt=12, method='cubic', max_gap=None):
def clean_fill(u, mask, npt=12, method='cubic', max_gap=6):
"""
Interpolate over mask values in timeseries data using the specified method

Expand All @@ -21,12 +21,12 @@ def clean_fill(u, mask, npt=12, method='cubic', max_gap=None):
Logical tensor of elements to "nan" out (from `spikeThresh`, `rangeLimit`,
or `GN2002`) and replace
npt : int
The number of points on either side of the bad values that
The number of points on either side of the bad values that
interpolation occurs over
method : string
Interpolation scheme to use (linear, cubic, pchip, etc)
max_gap : int
Max number of consective nan's to interpolate across, must be <= npt/2
Max number of consective nan's to interpolate across

Returns
-------
Expand All @@ -39,7 +39,7 @@ def clean_fill(u, mask, npt=12, method='cubic', max_gap=None):

"""
if max_gap:
assert max_gap <= npt, 'Max_gap must be less than half of npt'
max_gap = u.time.diff('time')[0].values * max_gap

# Apply mask
u.values[..., mask] = np.nan
Expand Down Expand Up @@ -126,15 +126,14 @@ def spike_thresh(u, thresh=10):

"""
du = np.diff(u.values, prepend=0)
bds1 = ((du > thresh) & (du < -thresh))
bds2 = ((du < -thresh) & (du > thresh))
mask = (du > thresh) + (du < -thresh)

return bds1 + bds2
return mask


def range_limit(u, range=[-5, 5]):
"""
Returns a logical vector that is True where the values of `u` are
Returns a logical vector that is True where the values of `u` are
outside of `range`.

Parameters
Expand Down Expand Up @@ -186,8 +185,6 @@ def _phaseSpaceThresh(u):
'ignore', category=RuntimeWarning, message='invalid value encountered in ')
for idx, al in enumerate(alpha):
a[idx], b[idx] = _calcab(al, Lu * std_u[idx], Lu * std_d2u[idx])
if np.any(np.isnan(a)) or np.any(np.isnan(a[idx])):
print('Coefficient calculation error')
theta = np.arctan2(du, u)
phi = np.arctan2((du ** 2 + u ** 2) ** 0.5, d2u)
pe = (((sin(phi) * cos(theta) * cos(alpha) +
Expand Down
Loading