|
45 | 45 |
|
46 | 46 | import math
|
47 | 47 | import time
|
| 48 | +from copy import deepcopy |
48 | 49 |
|
49 | 50 | import numpy as np
|
50 | 51 | from scipy.linalg import inv
|
|
55 | 56 | from pysteps.postprocessing import probmatching
|
56 | 57 | from pysteps.timeseries import autoregression, correlation
|
57 | 58 |
|
58 |
| -from copy import deepcopy |
59 |
| - |
60 | 59 | try:
|
61 | 60 | import dask
|
62 | 61 |
|
@@ -2443,36 +2442,14 @@ def _fill_nans_infs_nwp_cascade(
|
2443 | 2442 | """Ensure that the NWP cascade and fields do no contain any nans or infinite number"""
|
2444 | 2443 | # Fill nans and infinite numbers with the minimum value present in precip
|
2445 | 2444 | # (corresponding to zero rainfall in the radar observations)
|
2446 |
| - precip_models_cascade = np.nan_to_num( |
2447 |
| - precip_models_cascade, |
2448 |
| - copy=True, |
2449 |
| - nan=np.nanmin(precip_cascade), |
2450 |
| - posinf=np.nanmin(precip_cascade), |
2451 |
| - neginf=np.nanmin(precip_cascade), |
2452 |
| - ) |
2453 |
| - precip_models_pm = np.nan_to_num( |
2454 |
| - precip_models_pm, |
2455 |
| - copy=True, |
2456 |
| - nan=np.nanmin(precip), |
2457 |
| - posinf=np.nanmin(precip), |
2458 |
| - neginf=np.nanmin(precip), |
2459 |
| - ) |
| 2445 | + min_cascade = np.nanmin(precip_cascade) |
| 2446 | + min_precip = np.nanmin(precip) |
| 2447 | + precip_models_cascade[~np.isfinite(precip_models_cascade)] = min_cascade |
| 2448 | + precip_models_pm[~np.isfinite(precip_models_pm)] = min_precip |
2460 | 2449 | # Also set any nans or infs in the mean and sigma of the cascade to
|
2461 | 2450 | # respectively 0.0 and 1.0
|
2462 |
| - mu_models = np.nan_to_num( |
2463 |
| - mu_models, |
2464 |
| - copy=True, |
2465 |
| - nan=0.0, |
2466 |
| - posinf=0.0, |
2467 |
| - neginf=0.0, |
2468 |
| - ) |
2469 |
| - sigma_models = np.nan_to_num( |
2470 |
| - sigma_models, |
2471 |
| - copy=True, |
2472 |
| - nan=0.0, |
2473 |
| - posinf=0.0, |
2474 |
| - neginf=0.0, |
2475 |
| - ) |
| 2451 | + mu_models[~np.isfinite(mu_models)] = 0.0 |
| 2452 | + sigma_models[~np.isfinite(sigma_models)] = 0.0 |
2476 | 2453 |
|
2477 | 2454 | return precip_models_cascade, precip_models_pm, mu_models, sigma_models
|
2478 | 2455 |
|
|
0 commit comments