Skip to content

Commit

Permalink
NaN => nan
Browse files Browse the repository at this point in the history
  • Loading branch information
ssolson committed Jun 25, 2024
1 parent f649f23 commit 9dc3694
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 25 deletions.
14 changes: 7 additions & 7 deletions examples/metocean_example.ipynb

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions mhkit/dolfyn/adp/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ def find_surface(ds, thresh=10, nfilt=None):
for ip in range(ds.vel.shape[1]):
itmp = np.min(inds[:, ip])
if (edf[itmp:, :, ip] < thresh).all():
d[ip] = np.NaN
d[ip] = np.nan

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

ds["depth"] = xr.DataArray(
Expand Down
2 changes: 1 addition & 1 deletion mhkit/dolfyn/adp/turbulence.py
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ def dissipation_rate_SF(self, vel_raw, r_range=[1, 5]):

# have to insert 0/nan in first bin to match length
spaces = np.empty((i,))
spaces[:] = np.NaN
spaces[:] = np.nan
D[:, i - 1, idx] = np.concatenate((spaces, d))

# find best fit line y = mx + b (aka D(z,r) = A*r^2/3 + N) to solve
Expand Down
2 changes: 1 addition & 1 deletion mhkit/dolfyn/io/nortek.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def read_nortek(
t_list = [t for t in coords if "time" in t]
for ky in t_list:
tdat = coords[ky]
tdat[tdat == 0] = np.NaN
tdat[tdat == 0] = np.nan
if np.isnan(tdat).any():
tag = ky.lstrip("time")
warnings.warn(
Expand Down
2 changes: 1 addition & 1 deletion mhkit/dolfyn/io/nortek2.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def read_signature(
t_list = [t for t in coords if "time" in t]
for ky in t_list:
tdat = coords[ky]
tdat[tdat == 0] = np.NaN
tdat[tdat == 0] = np.nan
if np.isnan(tdat).any():
tag = ky.lstrip("time")
warnings.warn(
Expand Down
2 changes: 1 addition & 1 deletion mhkit/dolfyn/io/nortek2_defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
def _nans(*args, **kwargs):
out = np.empty(*args, **kwargs)
if out.dtype.kind == "f":
out[:] = np.NaN
out[:] = np.nan
else:
out[:] = 0
return out
Expand Down
2 changes: 1 addition & 1 deletion mhkit/dolfyn/io/nortek_defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def shape(self, **kwargs):
def _empty_array(self, **kwargs):
out = np.zeros(self.shape(**kwargs), dtype=self.dtype)
try:
out[:] = np.NaN
out[:] = np.nan
except:
pass
if self.view_type is not None:
Expand Down
10 changes: 5 additions & 5 deletions mhkit/dolfyn/io/rdi.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ def load_data(self, nens=None):
int(self.ensemble.number[0])
)
)
dat["coords"]["time"][iens] = np.NaN
dat["coords"]["time"][iens] = np.nan
else:
dat["coords"]["time"][iens] = np.median(dates)

Expand Down Expand Up @@ -1007,7 +1007,7 @@ def read_bottom(self):
fd.seek(6, 1)
ens.latitude_gps[k] = fd.read_i32(1) * self._cfac
if ens.latitude_gps[k] == 0:
ens.latitude_gps[k] = np.NaN
ens.latitude_gps[k] = np.nan
else:
fd.seek(14, 1)
ens.dist_bt[:, k] = fd.read_ui16(4) * 0.01
Expand All @@ -1021,7 +1021,7 @@ def read_bottom(self):
if ens.longitude_gps[k] > 180:
ens.longitude_gps[k] = ens.longitude_gps[k] - 360
if ens.longitude_gps[k] == 0:
ens.longitude_gps[k] = np.NaN
ens.longitude_gps[k] = np.nan
fd.seek(16, 1)
qual = fd.read_ui8(1)
if qual == 0:
Expand All @@ -1030,8 +1030,8 @@ def read_bottom(self):
" qual==%d,%f %f"
% (qual, ens.latitude_gps[k], ens.longitude_gps[k])
)
ens.latitude_gps[k] = np.NaN
ens.longitude_gps[k] = np.NaN
ens.latitude_gps[k] = np.nan
ens.longitude_gps[k] = np.nan
fd.seek(71 - 45 - 16 - 17, 1)
self._nbyte = 2 + 68
else:
Expand Down
4 changes: 2 additions & 2 deletions mhkit/dolfyn/io/rdi_defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ def _idata(dat, nm, sz):
standard_name = data_defs[nm][5]
arr = np.empty(sz, dtype=dtype)
if dtype.startswith("float"):
arr[:] = np.NaN
arr[:] = np.nan
dat[group][nm] = arr
dat["units"][nm] = units
dat["long_name"][nm] = long_name
Expand Down Expand Up @@ -408,4 +408,4 @@ def __init__(self, navg, n_cells):
)

def clean_data(self):
self["vel"][self["vel"] == -32.768] = np.NaN
self["vel"][self["vel"] == -32.768] = np.nan
2 changes: 1 addition & 1 deletion mhkit/dolfyn/tools/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ def medfiltnan(a, kernel, thresh=0):
if thresh > 0:
out[
convolve2d(np.isnan(a), np.ones(kernel) / np.prod(kernel), "same") > thresh
] = np.NaN
] = np.nan
if flag_1D:
return out[0]
return out
2 changes: 1 addition & 1 deletion mhkit/loads/extreme/peaks.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ def _cdf(self, data_points, *args, **kwds) -> NDArray[np.float64]:

# Use the instance's threshold attribute instead of passing as a parameter
below_threshold = data_points < self.threshold
out[below_threshold] = np.NaN
out[below_threshold] = np.nan

above_threshold_indices = ~below_threshold
if np.any(above_threshold_indices):
Expand Down
2 changes: 1 addition & 1 deletion mhkit/tests/dolfyn/test_rotate_adp.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def test_rotate_inst2beam(self):

# # The reverse RDI rotation doesn't work b/c of NaN's in one beam
# # that propagate to others, so we impose that here.
cd_td["vel"].values[:, np.isnan(cd_td["vel"].values).any(0)] = np.NaN
cd_td["vel"].values[:, np.isnan(cd_td["vel"].values).any(0)] = np.nan

assert_allclose(td, cd_td, atol=1e-5)
assert_allclose(td_awac, cd_awac, atol=1e-5)
Expand Down
2 changes: 1 addition & 1 deletion mhkit/tests/dolfyn/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class tools_testcase(unittest.TestCase):
@classmethod
def setUpClass(self):
self.array = np.arange(10, dtype=float)
self.nan = np.zeros(3) * np.NaN
self.nan = np.zeros(3) * np.nan

@classmethod
def tearDownClass(self):
Expand Down

0 comments on commit 9dc3694

Please sign in to comment.