Skip to content

Commit

Permalink
Fixes following numpy 2 (#365)
Browse files Browse the repository at this point in the history
  • Loading branch information
dnerini committed Jun 19, 2024
1 parent 2bc6b38 commit 5c6d08c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
6 changes: 3 additions & 3 deletions pysteps/blending/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,7 @@ def worker(j):
neginf=zerovalue,
)
# Put back the mask
R_f_ip_recomp[domain_mask] = np.NaN
R_f_ip_recomp[domain_mask] = np.nan
extrap_kwargs["displacement_prev"] = D[j]
R_f_ep_recomp_, D[j] = extrapolator(
R_f_ip_recomp,
Expand Down Expand Up @@ -1131,7 +1131,7 @@ def worker(j):
neginf=np.nanmin(R_f_ip),
)
for i in range(n_cascade_levels):
R_f_ep[i][temp_mask] = np.NaN
R_f_ep[i][temp_mask] = np.nan
# B. Noise
Yn_ip_recomp = blending.utils.recompose_cascade(
combined_cascade=Yn_ip,
Expand Down Expand Up @@ -1182,7 +1182,7 @@ def worker(j):
extrap_kwargs_pb["displacement_prev"] = D_pb[j]
# Apply the domain mask to the extrapolation component
R_ = precip.copy()
R_[domain_mask] = np.NaN
R_[domain_mask] = np.nan
R_pm_ep_, D_pb[j] = extrapolator(
R_,
velocity_blended,
Expand Down
2 changes: 1 addition & 1 deletion pysteps/feature/shitomasi.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def detection(

# convert to 8-bit
input_image = np.ndarray.astype(input_image, "uint8")
mask = (-1 * mask + 1).astype("uint8")
mask = ~mask & 1

params = dict(
maxCorners=max_num_features if max_num_features is not None else max_corners,
Expand Down
10 changes: 5 additions & 5 deletions pysteps/io/importers.py
Original file line number Diff line number Diff line change
Expand Up @@ -810,15 +810,15 @@ def import_knmi_hdf5(filename, qty="ACRR", accutime=5.0, pixelsize=1000.0, **kwa
# the no data value. The precision of the data is two decimals (0.01 mm).
if qty == "ACRR":
precip = np.where(
precip_intermediate == 65535, np.NaN, precip_intermediate / 100.0
precip_intermediate == 65535, np.nan, precip_intermediate / 100.0
)

# In case reflectivities are imported, the no data value is 255. Values are
# saved as integers. The reflectivities are not directly saved in dBZ, but
# as: dBZ = 0.5 * pixel_value - 32.0 (this used to be 31.5).
if qty == "DBZH":
precip = np.where(
precip_intermediate == 255, np.NaN, precip_intermediate * 0.5 - 32.0
precip_intermediate == 255, np.nan, precip_intermediate * 0.5 - 32.0
)

if precip is None:
Expand Down Expand Up @@ -1366,9 +1366,9 @@ def import_odim_hdf5(filename, qty="RATE", **kwargs):
mask = np.logical_and(~mask_u, ~mask_n)
quality = np.empty(arr.shape) # , dtype=float)
quality[mask] = arr[mask] * gain + offset
quality[~mask] = (
np.nan
) # a qui -----------------------------
quality[
~mask
] = np.nan # a qui -----------------------------

if precip is None:
raise IOError("requested quantity %s not found" % qty)
Expand Down
3 changes: 3 additions & 0 deletions pysteps/tests/test_io_nowcast_importers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
[(precip, metadata), (np.zeros_like(precip), metadata)],
)
def test_import_netcdf(precip, metadata, tmp_path):

pytest.importorskip("pyproj")

field_shape = (precip.shape[1], precip.shape[2])
startdate = metadata["timestamps"][-1]
timestep = metadata["accutime"]
Expand Down
3 changes: 3 additions & 0 deletions pysteps/tests/test_nowcasts_linda.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ def test_linda_wrong_inputs():

def test_linda_callback(tmp_path):
"""Test LINDA callback functionality to export the output as a netcdf."""

pytest.importorskip("skimage")

n_ens_members = 2
n_timesteps = 3

Expand Down

0 comments on commit 5c6d08c

Please sign in to comment.