Commit 80a3f270 authored by Mads M. Pedersen's avatar Mads M. Pedersen Committed by Mads M. Pedersen

np.int>int, np.float>float

parent 230aff5f
Pipeline #20334 passed with stages
in 9 minutes and 6 seconds
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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, :]
......
......@@ -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)
......
......@@ -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]
......
......@@ -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]}
......
......@@ -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))
......@@ -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
......
......@@ -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
......
......@@ -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():
......
......@@ -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)
......
......@@ -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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment