Skip to content

Commit 2eab004

Browse files
committed
fix np20, wao url, pandas delta deprecation
1 parent e5f3634 commit 2eab004

File tree

7 files changed

+32
-31
lines changed

7 files changed

+32
-31
lines changed

oceans/RPSstuff.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def h2hms(hours):
1313
Examples
1414
--------
1515
>>> h2hms(12.51)
16-
(12.0, 30.0, 36.0)
16+
(np.float64(12.0), np.float64(30.0), np.float64(36.0))
1717
1818
"""
1919
hour = np.floor(hours)
@@ -33,7 +33,7 @@ def hms2h(h, m=None, s=None):
3333
12.51
3434
>>> # Or,
3535
>>> hms2h(123036)
36-
12.51
36+
np.float64(12.51)
3737
3838
"""
3939
if not m and not s:
@@ -55,7 +55,7 @@ def ms2hms(millisecs):
5555
Examples
5656
--------
5757
>>> ms2hms(1e3 * 60)
58-
(0.0, 1.0, 0.0)
58+
(np.float64(0.0), np.float64(1.0), np.float64(0.0))
5959
6060
"""
6161
sec = np.round(millisecs / 1000)
@@ -233,7 +233,7 @@ def s2hms(secs):
233233
Examples
234234
--------
235235
>>> s2hms(3600 + 60 + 1)
236-
(1.0, 1.0, 1)
236+
(np.float64(1.0), np.float64(1.0), np.int64(1))
237237
238238
"""
239239
hr = np.floor(secs / 3600)
@@ -509,7 +509,7 @@ def fixcoast(coast):
509509
"""
510510

511511
ind = coast == -99999.0
512-
coast[ind] = np.NaN
512+
coast[ind] = np.nan
513513

514514
ind = np.where(np.isnan(coast[:, 0]))[0]
515515
dind = np.diff(ind)
@@ -518,9 +518,9 @@ def fixcoast(coast):
518518
coast = np.delete(coast, ind[idup], axis=0)
519519

520520
if not np.isnan(coast[0, 0]):
521-
coast = np.insert(coast, 0, np.NaN, axis=0)
521+
coast = np.insert(coast, 0, np.nan, axis=0)
522522

523523
if not np.isnan(coast[-1, -1]):
524-
coast = np.append(coast, np.c_[np.NaN, np.NaN], axis=0)
524+
coast = np.append(coast, np.c_[np.nan, np.nan], axis=0)
525525

526526
return coast

oceans/datasets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def _woa_variable(variable):
2828

2929

3030
def _woa_url(variable, time_period, resolution):
31-
base = "https://data.nodc.noaa.gov/thredds/dodsC"
31+
base = "https://www.ncei.noaa.gov/thredds-ocean/dodsC"
3232

3333
v = _woa_variable(variable)
3434

oceans/filters.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ def smoo2(A, hei, wid, kind="hann", badflag=-9999, beta=14):
205205
A = np.asanyarray(A)
206206
Fnan = np.isnan(A)
207207
imax, jmax = A.shape
208-
As = np.NaN * np.ones((imax, jmax))
208+
As = np.nan * np.ones((imax, jmax))
209209

210210
for i in range(imax):
211211
for j in range(jmax):
@@ -257,7 +257,7 @@ def smoo2(A, hei, wid, kind="hann", badflag=-9999, beta=14):
257257
a = Ac * wdwc
258258
As[i, j] = a.sum() / wdwc.sum()
259259
# Assigning NaN to the positions holding NaNs in the original array.
260-
As[Fnan] = np.NaN
260+
As[Fnan] = np.nan
261261

262262
return As
263263

@@ -329,7 +329,7 @@ def weim(x, N, kind="hann", badflag=-9999, beta=14):
329329
ln = (N - 1) / 2
330330
lx = x.size
331331
lf = lx - ln
332-
xs = np.NaN * np.ones(lx)
332+
xs = np.nan * np.ones(lx)
333333

334334
# Eliminating bad data from mean computation.
335335
fbad = x == badflag
@@ -459,7 +459,7 @@ def medfilt1(x, L=3):
459459
msg = "Input sequence has to be 1d: ndim = {}".format
460460
raise ValueError(msg(xin.ndim))
461461

462-
xout = np.zeros_like(xin) + np.NaN
462+
xout = np.zeros_like(xin) + np.nan
463463

464464
Lwing = (L - 1) // 2
465465

@@ -538,7 +538,7 @@ def md_trenberth(x):
538538
>>> filtered = md_trenberth(x)
539539
>>> fig, ax = plt.subplots()
540540
>>> (l1,) = ax.plot(t, x, label="original")
541-
>>> pad = [np.NaN] * 5
541+
>>> pad = [np.nan] * 5
542542
>>> (l2,) = ax.plot(t, np.r_[pad, filtered, pad], label="filtered")
543543
>>> legend = ax.legend()
544544
@@ -598,9 +598,9 @@ def pl33tn(x, dt=1.0, T=33.0, mode="valid", t=None):
598598
>>> filtered_33d3 = pl33tn(x, dt=4.0, T=72.0) # 3 day filter
599599
>>> fig, ax = plt.subplots()
600600
>>> (l1,) = ax.plot(t, x, label="original")
601-
>>> pad = [np.NaN] * 8
601+
>>> pad = [np.nan] * 8
602602
>>> (l2,) = ax.plot(t, np.r_[pad, filtered_33, pad], label="33 hours")
603-
>>> pad = [np.NaN] * 17
603+
>>> pad = [np.nan] * 17
604604
>>> (l3,) = ax.plot(t, np.r_[pad, filtered_33d3, pad], label="3 days")
605605
>>> legend = ax.legend()
606606

oceans/ocfis.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import gsw
55
import numpy as np
66
import numpy.ma as ma
7+
import pandas as pd
78

89

910
def spdir2uv(spd, ang, deg=False):
@@ -583,7 +584,7 @@ def bin_dates(self, freq, tz=None):
583584
>>> from pandas import Series, date_range
584585
>>> n = 24 * 30
585586
>>> sig = np.random.rand(n) + 2 * np.cos(2 * np.pi * np.arange(n))
586-
>>> dates = date_range(start="1/1/2000", periods=n, freq="H")
587+
>>> dates = date_range(start="1/1/2000", periods=n, freq="h")
587588
>>> series = Series(data=sig, index=dates)
588589
>>> new_series = bin_dates(series, freq="D", tz=None)
589590
@@ -593,7 +594,7 @@ def bin_dates(self, freq, tz=None):
593594
new_index = date_range(start=self.index[0], end=self.index[-1], freq=freq, tz=tz)
594595
new_series = self.groupby(new_index.asof).mean()
595596
# Averages at the center.
596-
secs = new_index.freq.delta.total_seconds()
597+
secs = pd.Timedelta(new_index.freq).total_seconds()
597598
new_series.index = new_series.index.values + int(secs // 2)
598599
return new_series
599600

@@ -625,7 +626,7 @@ def series_spline(self):
625626

626627
def despike(self, n=3, recursive=False):
627628
"""
628-
Replace spikes with np.NaN.
629+
Replace spikes with np.nan.
629630
Removing spikes that are >= n * std.
630631
default n = 3.
631632
@@ -638,12 +639,12 @@ def despike(self, n=3, recursive=False):
638639
)
639640

640641
removed = np.count_nonzero(outliers)
641-
result[outliers] = np.NaN
642+
result[outliers] = np.nan
642643

643644
counter = 0
644645
if recursive:
645646
while outliers.any():
646-
result[outliers] = np.NaN
647+
result[outliers] = np.nan
647648
base = np.abs(result - np.nanmean(result))
648649
outliers = base >= n * np.nanstd(result)
649650
counter += 1
@@ -658,7 +659,7 @@ def pol2cart(theta, radius, units="deg"):
658659
Examples
659660
--------
660661
>>> pol2cart(0, 1, units="deg")
661-
(1.0, 0.0)
662+
(np.float64(1.0), np.float64(0.0))
662663
663664
"""
664665
if units in ["deg", "degs"]:
@@ -781,7 +782,7 @@ def get_profile(x, y, f, xi, yi, mode="nearest", order=3):
781782
return map_coordinates(f, coords, mode=mode, order=order)
782783

783784

784-
def strip_mask(arr, fill_value=np.NaN):
785+
def strip_mask(arr, fill_value=np.nan):
785786
"""
786787
Take a masked array and return its data(filled) + mask.
787788

oceans/sw_extras/gamma_GP_from_SP_pt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ def gamma_GP_from_SP_pt(SP, pt, p, lon, lat):
445445
gamma_Pac = gamma_G_pacific(SP, pt)
446446
gamma_Ind = gamma_G_indian(SP, pt)
447447
gamma_SOce = gamma_G_southern_ocean(SP, pt, p)
448-
# gamma_Arc = np.zeros_like(SP) * np.NaN
448+
# gamma_Arc = np.zeros_like(SP) * np.nan
449449

450450
# Definition of the Indian part.
451451
io_lon = np.array(
@@ -590,7 +590,7 @@ def gamma_GP_from_SP_pt(SP, pt, p, lon, lat):
590590
gamma_GP = w_so * gamma_SOce + (1.0 - w_so) * gamma_middle
591591

592592
# Set NaN in the arctic region.
593-
gamma_GP[lat > 66.0] = np.NaN
593+
gamma_GP[lat > 66.0] = np.nan
594594

595595
# De-normalization.
596596
gamma_GP = 20.0 * gamma_GP - 20

oceans/sw_extras/sw_extras.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ def cor_beta(lat):
321321
--------
322322
>>> import oceans.sw_extras.sw_extras as swe
323323
>>> swe.cor_beta(0)
324-
2.2891225867210798e-11
324+
np.float64(2.2891225867210798e-11)
325325
326326
References
327327
----------
@@ -358,7 +358,7 @@ def inertial_period(lat):
358358
>>> import oceans.sw_extras.sw_extras as swe
359359
>>> lat = 30.0
360360
>>> swe.inertial_period(lat) / 3600
361-
23.93484986278565
361+
np.float64(23.93484986278565)
362362
363363
"""
364364
lat = np.asanyarray(lat)
@@ -427,7 +427,7 @@ def visc(s, t, p):
427427
--------
428428
>>> import oceans.sw_extras.sw_extras as swe
429429
>>> swe.visc(40.0, 40.0, 1000.0)
430-
8.200192496633804e-07
430+
np.float64(8.200192496633804e-07)
431431
432432
Modifications: Original 1998/01/19 - Ayal Anis 1998
433433
@@ -466,7 +466,7 @@ def tcond(s, t, p):
466466
--------
467467
>>> import oceans.sw_extras.sw_extras as swe
468468
>>> swe.tcond(35, 20, 0)
469-
0.5972445569999999
469+
np.float64(0.5972445569999999)
470470
471471
References
472472
----------

oceans/sw_extras/waves.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ def __init__(self, h, T=None, L=None, thetao=None, Ho=None, lat=None):
144144
self.Ks = np.sqrt(1 / (1 + self.G) / np.tanh(self.k * self.h))
145145

146146
if thetao is None:
147-
self.theta = np.NaN
148-
self.Kr = np.NaN
147+
self.theta = np.nan
148+
self.Kr = np.nan
149149
if thetao is not None:
150150
self.theta = np.rad2deg(
151151
np.asin(self.C / self.Co * np.sin(np.deg2rad(self.thetao))),
@@ -155,6 +155,6 @@ def __init__(self, h, T=None, L=None, thetao=None, Ho=None, lat=None):
155155
)
156156

157157
if Ho is None:
158-
self.H = np.NaN
158+
self.H = np.nan
159159
if Ho is not None:
160160
self.H = self.Ho * self.Ks * self.Kr

0 commit comments

Comments
 (0)