From 80a3f2702f586c883fbaa70d1f319cf57436b8b8 Mon Sep 17 00:00:00 2001
From: mmpe <mmpe@dtu.dk>
Date: Thu, 18 Feb 2021 12:53:04 +0100
Subject: [PATCH] np.int>int, np.float>float

---
 py_wake/deficit_models/fuga.py                |  2 +-
 py_wake/deficit_models/gcl.py                 |  2 +-
 py_wake/examples/data/iea37/iea37_reader.py   |  2 +-
 py_wake/site/distance.py                      |  2 +-
 py_wake/site/wasp_grid_site.py                |  2 +-
 .../tests/test_sites/test_wasp_grid_site.py   |  2 +-
 .../test_enginering_wind_farm_model.py        |  2 +-
 py_wake/utils/fuga_utils.py                   |  2 +-
 py_wake/utils/gradients.py                    |  4 ++--
 py_wake/utils/grid_interpolator.py            |  4 ++--
 py_wake/validation/validation_lib.py          |  6 +++---
 .../wind_farm_models/engineering_models.py    |  4 ++--
 py_wake/wind_turbines.py                      | 20 +++++++++----------
 13 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/py_wake/deficit_models/fuga.py b/py_wake/deficit_models/fuga.py
index 3e82984a3..97985bbf6 100644
--- a/py_wake/deficit_models/fuga.py
+++ b/py_wake/deficit_models/fuga.py
@@ -159,7 +159,7 @@ class LUTInterpolator(object):
         # zp = np.maximum(np.minimum(zp, self.z[-1]), self.z[0])
 
         def i0f(_i):
-            _i0 = np.asarray(_i).astype(np.int)
+            _i0 = np.asarray(_i).astype(int)
             _if = _i - _i0
             return _i0, _if
 
diff --git a/py_wake/deficit_models/gcl.py b/py_wake/deficit_models/gcl.py
index 172790761..792d4b7b3 100644
--- a/py_wake/deficit_models/gcl.py
+++ b/py_wake/deficit_models/gcl.py
@@ -123,7 +123,7 @@ def get_dU(x, r, R, CT, TI):
         Wake velocity deficit at a location
     """
 
-    CT = np.maximum(CT, np.finfo(np.float).eps)
+    CT = np.maximum(CT, np.finfo(float).eps)
     Area = np.pi * R * R
     Rw, xx0, c1 = get_Rw(x, R, TI, CT)
     c1s = c1 * c1
diff --git a/py_wake/examples/data/iea37/iea37_reader.py b/py_wake/examples/data/iea37/iea37_reader.py
index ee4704968..5b0c5d99a 100644
--- a/py_wake/examples/data/iea37/iea37_reader.py
+++ b/py_wake/examples/data/iea37/iea37_reader.py
@@ -31,7 +31,7 @@ def read_iea37_windturbine(filename):
 
     def ct(wsp):
         wsp = np.asarray(wsp)
-        ct = np.zeros_like(wsp, dtype=np.float)
+        ct = np.zeros_like(wsp, dtype=float)
         ct[(wsp >= wsp_cut_in) & (wsp <= wsp_cut_out)] = constant_ct
         return ct
 
diff --git a/py_wake/site/distance.py b/py_wake/site/distance.py
index 7d902ff86..5e79bfe83 100644
--- a/py_wake/site/distance.py
+++ b/py_wake/site/distance.py
@@ -337,7 +337,7 @@ class TerrainFollowingDistance2():
         x_rotated_il = x_i[:, na] * cos_wd_il + y_i[:, na] * sin_wd_il
         y_rotated_il = y_i[:, na] * cos_wd_il - x_i[:, na] * sin_wd_il
 
-        downwind_order_il = np.argsort(x_rotated_il, 0).astype(np.int)
+        downwind_order_il = np.argsort(x_rotated_il, 0).astype(int)
 
         dist_down_iil = dx_ii[:, :, na] * cos_wd_il[:, na, :] + dy_ii[:, :, na] * sin_wd_il[:, na, :]
         dy_rotated_iil = dy_ii[:, :, na] * cos_wd_il[:, na, :] - dx_ii[:, :, na] * sin_wd_il[:, na, :]
diff --git a/py_wake/site/wasp_grid_site.py b/py_wake/site/wasp_grid_site.py
index 793d47240..f180c0863 100644
--- a/py_wake/site/wasp_grid_site.py
+++ b/py_wake/site/wasp_grid_site.py
@@ -135,7 +135,7 @@ def load_wasp_grd(path, globstr='*.grd', speedup_using_pickle=True):
             yl, yu = _parse_line_floats(f)
             zl, zu = _parse_line_floats(f)
             values = np.array([l.split() for l in f.readlines() if l.strip() != b""],
-                              dtype=np.float)  # around 8 times faster
+                              dtype=float)  # around 8 times faster
 
         xarr = np.linspace(xl, xu, nx)
         yarr = np.linspace(yl, yu, ny)
diff --git a/py_wake/tests/test_sites/test_wasp_grid_site.py b/py_wake/tests/test_sites/test_wasp_grid_site.py
index d76dfe5ed..2c85c0ecf 100644
--- a/py_wake/tests/test_sites/test_wasp_grid_site.py
+++ b/py_wake/tests/test_sites/test_wasp_grid_site.py
@@ -90,7 +90,7 @@ def test_wasp_resources_grid_point(site):
     # 0.7221162    4.606324    17.96417    11.45838
     # 0.8088576    8.196074    16.16308    9.277925
     # 0.8800673    3.932325    14.82337    5.380589
-    # 0.8726974    -3.199536    19.99724    -1.433086""".split("\n")], dtype=np.float)
+    # 0.8726974    -3.199536    19.99724    -1.433086""".split("\n")], dtype=float)
     #     for x_ in x.T:
     #         print(list(x_))
     x = [262978]
diff --git a/py_wake/tests/test_wind_farm_models/test_enginering_wind_farm_model.py b/py_wake/tests/test_wind_farm_models/test_enginering_wind_farm_model.py
index b700a3186..564e22271 100644
--- a/py_wake/tests/test_wind_farm_models/test_enginering_wind_farm_model.py
+++ b/py_wake/tests/test_wind_farm_models/test_enginering_wind_farm_model.py
@@ -179,7 +179,7 @@ def test_dAEP_2wt():
     x, y = iea37_site.initial_position[np.array([0, 2, 5, 8, 14])].T
 
     # plot 2 wt case
-    x, y = np.array([[0, 130 * 4], [0, 0]], dtype=np.float)
+    x, y = np.array([[0, 130 * 4], [0, 0]], dtype=float)
     x_lst = np.array([0., 1.]) * np.arange(1, 600, 10)[:, na]
     kwargs = {'ws': [10], 'wd': [270]}
 
diff --git a/py_wake/utils/fuga_utils.py b/py_wake/utils/fuga_utils.py
index 4c617a5ff..2691fc2fe 100644
--- a/py_wake/utils/fuga_utils.py
+++ b/py_wake/utils/fuga_utils.py
@@ -91,5 +91,5 @@ class FugaUtils():
 
     def load_luts(self, UVLT=['UL', 'UT', 'VL', 'VT'], zlevels=None):
         luts = np.array([[np.fromfile(str(self.path / (self.prefix + '%04d%s.dat' % (j, uvlt))), np.dtype('<f'), -1)
-                          for j in (zlevels or self.zlevels)] for uvlt in UVLT]).astype(np.float)
+                          for j in (zlevels or self.zlevels)] for uvlt in UVLT]).astype(float)
         return luts.reshape((len(UVLT), len(zlevels or self.zlevels), self.ny // 2, self.nx))
diff --git a/py_wake/utils/gradients.py b/py_wake/utils/gradients.py
index b085796bb..14ef9e40d 100644
--- a/py_wake/utils/gradients.py
+++ b/py_wake/utils/gradients.py
@@ -21,7 +21,7 @@ anp.asarray = asarray
 
 
 # replace dsqrt to avoid divide by zero if x=0
-eps = 2 * np.finfo(np.float).eps ** 2
+eps = 2 * np.finfo(float).eps ** 2
 defvjp(anp.sqrt, lambda ans, x: lambda g: g * 0.5 * np.where(x == 0, eps, x)**-0.5)  # @UndefinedVariable
 
 
@@ -57,7 +57,7 @@ def use_autograd_in(modules=["py_wake."]):
 
 def _step_grad(f, argnum, step_func, step):
     def wrap(*args, **kwargs):
-        x = np.atleast_1d(args[argnum]).astype(np.float)
+        x = np.atleast_1d(args[argnum]).astype(float)
         ref = f(*args, **kwargs)
         return np.array([step_func(f(*(args[:argnum] + (x_,) + args[argnum + 1:]), **kwargs), ref, step)
                          for x_ in x + np.diag(np.ones_like(x) * step)]).T
diff --git a/py_wake/utils/grid_interpolator.py b/py_wake/utils/grid_interpolator.py
index 5574e152b..3f0c3fd8d 100644
--- a/py_wake/utils/grid_interpolator.py
+++ b/py_wake/utils/grid_interpolator.py
@@ -119,11 +119,11 @@ class EqDistRegGrid2DInterpolator():
         xp, yp = x, y
         xi = (xp - self.x0) / self.dx
         xif, xi0 = np.modf(xi)
-        xi0 = xi0.astype(np.int)
+        xi0 = xi0.astype(int)
 
         yi = (yp - self.y0) / self.dy
         yif, yi0 = np.modf(yi)
-        yi0 = yi0.astype(np.int)
+        yi0 = yi0.astype(int)
         if mode == 'extrapolate':
             xif[xi0 < self.xi_valid_min] = 0
             xif[xi0 > self.xi_valid_max - 2] = 1
diff --git a/py_wake/validation/validation_lib.py b/py_wake/validation/validation_lib.py
index 0094f0473..2fba67d78 100644
--- a/py_wake/validation/validation_lib.py
+++ b/py_wake/validation/validation_lib.py
@@ -10,7 +10,7 @@ from py_wake.deficit_models.noj import NOJDeficit
 from py_wake.deficit_models.gaussian import BastankhahGaussianDeficit
 from py_wake.superposition_models import SquaredSum
 from py_wake.rotor_avg_models import RotorCenter
-
+import xarray as xr
 
 # -----------------------------------------------------
 # Default values
@@ -339,7 +339,7 @@ def plot_single_wake(swc_out, lw=lw):
     '''
     for case in swc_out.keys():
         jj = len(swc_out[case]['xDown'])
-        color = cm.tab10(np.linspace(0, 1, len(swc_out[case]['deficit_models'])))
+        color = cm.tab10(np.linspace(0, 1, len(swc_out[case]['deficit_models'])))  # @UndefinedVariable
 
         fig, ax = plt.subplots(1, jj, sharey=False, figsize=(5 * jj, 5))
         fig.suptitle(case)
@@ -396,7 +396,7 @@ def plotbar_single_wake(swc_out, cLES=cLES, cRANS=cRANS):
     names = []
     subnames = []
     lines = []
-    color = cm.tab10(np.linspace(0, 1, len(swc_out[case]['deficit_models'])))
+    color = cm.tab10(np.linspace(0, 1, len(swc_out[case]['deficit_models'])))  # @UndefinedVariable
     i = 0
     ymax = 0
     for case in swc_out.keys():
diff --git a/py_wake/wind_farm_models/engineering_models.py b/py_wake/wind_farm_models/engineering_models.py
index f6ed4c18f..1e6458187 100644
--- a/py_wake/wind_farm_models/engineering_models.py
+++ b/py_wake/wind_farm_models/engineering_models.py
@@ -175,7 +175,7 @@ class EngineeringWindFarmModel(WindFarmModel):
 
         # add eps to avoid non-differentiable 0
         if 'autograd' in np.__name__:
-            eps = 2 * np.finfo(np.float).eps ** 2
+            eps = 2 * np.finfo(float).eps ** 2
         else:
             eps = 0
         cw_iil = np.sqrt(hcw_iil**2 + dh_iil**2 + eps)
@@ -374,7 +374,7 @@ class PropagateDownwind(EngineeringWindFarmModel):
         dh_nk = []
 
         def ilk2mk(x_ilk):
-            return np.broadcast_to(x_ilk.astype(np.float), (I, L, K)).reshape((I * L, K))
+            return np.broadcast_to(x_ilk.astype(float), (I, L, K)).reshape((I * L, K))
 
         indices = np.arange(I * I * L).reshape((I, I, L))
         TI_mk = ilk2mk(lw.TI_ilk)
diff --git a/py_wake/wind_turbines.py b/py_wake/wind_turbines.py
index 27573b314..32f44ad5a 100644
--- a/py_wake/wind_turbines.py
+++ b/py_wake/wind_turbines.py
@@ -366,22 +366,22 @@ class WindTurbines():
             root = tree.getroot()
             # Reading data from wtg_file
             name = root.attrib['Description']
-            diameter = np.float(root.attrib['RotorDiameter'])
-            hub_height = np.float(root.find('SuggestedHeights').find('Height').text)
+            diameter = float(root.attrib['RotorDiameter'])
+            hub_height = float(root.find('SuggestedHeights').find('Height').text)
 
             perftab = list(root.iter('PerformanceTable'))[m]
-            density = np.float(perftab.attrib['AirDensity'])
-            ws_cutin = np.float(perftab.find('StartStopStrategy').attrib['LowSpeedCutIn'])
-            ws_cutout = np.float(perftab.find('StartStopStrategy').attrib['HighSpeedCutOut'])
+            density = float(perftab.attrib['AirDensity'])
+            ws_cutin = float(perftab.find('StartStopStrategy').attrib['LowSpeedCutIn'])
+            ws_cutout = float(perftab.find('StartStopStrategy').attrib['HighSpeedCutOut'])
             cut_ins.append(ws_cutin)
             cut_outs.append(ws_cutout)
 
             i_point = 0
             for DataPoint in perftab.iter('DataPoint'):
                 i_point = i_point + 1
-                ws = np.float(DataPoint.attrib['WindSpeed'])
-                Ct = np.float(DataPoint.attrib['ThrustCoEfficient'])
-                power = np.float(DataPoint.attrib['PowerOutput'])
+                ws = float(DataPoint.attrib['WindSpeed'])
+                Ct = float(DataPoint.attrib['ThrustCoEfficient'])
+                power = float(DataPoint.attrib['PowerOutput'])
                 if i_point == 1:
                     dt = np.array([[ws, Ct, power]])
                 else:
@@ -498,7 +498,7 @@ class Interp(object):
 def cube_power(ws_cut_in=3, ws_cut_out=25, ws_rated=12, power_rated=5000):
     def power_func(ws):
         ws = np.asarray(ws)
-        power = np.zeros_like(ws, dtype=np.float)
+        power = np.zeros_like(ws, dtype=float)
         m = (ws >= ws_cut_in) & (ws < ws_rated)
         power[m] = power_rated * ((ws[m] - ws_cut_in) / (ws_rated - ws_cut_in))**3
         power[(ws >= ws_rated) & (ws <= ws_cut_out)] = power_rated
@@ -510,7 +510,7 @@ def dummy_thrust(ws_cut_in=3, ws_cut_out=25, ws_rated=12, ct_rated=8 / 9):
     # temporary thrust curve fix
     def ct_func(ws):
         ws = np.asarray(ws)
-        ct = np.zeros_like(ws, dtype=np.float)
+        ct = np.zeros_like(ws, dtype=float)
         if ct_rated > 0:
             # ct = np.ones_like(ct)*ct_rated
             m = (ws >= ws_cut_in) & (ws < ws_rated)
-- 
GitLab