Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes following numpy 2 #365

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
# 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 @@
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[

Check warning on line 1369 in pysteps/io/importers.py

View check run for this annotation

Codecov / codecov/patch

pysteps/io/importers.py#L1369

Added line #L1369 was not covered by tests
~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
Loading