Skip to content

Commit

Permalink
Possible solution for errors solved
Browse files Browse the repository at this point in the history
  • Loading branch information
sidekock committed Oct 9, 2024
1 parent 46bc44a commit eb33c06
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions pysteps/nowcasts/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,18 +146,16 @@ def _nowcast_main(self):
"""
# Prepare state and params dictionaries
state = self._initialize_state()
params = self._initialize_params(self.precip)
params = self._initialize_params()

# Isolate the last time slice of precipitation
self.precip = self.precip[
-1, :, :
] # Extract the last available precipitation field
precip = self.precip[-1, :, :] # Extract the last available precipitation field

print("Starting nowcast computation.")

# Run the nowcast main loop
self.precip_forecast = nowcast_main_loop(
self.precip,
precip,
self.velocity,
state,
self.timesteps,
Expand Down Expand Up @@ -408,12 +406,12 @@ def _apply_noise_and_ar_model(self):
and adds noise perturbations if necessary.
"""
# Make a copy of the precipitation data and replace non-finite values
self.precip = self.precip.copy()
precip = self.precip.copy()
for i in range(self.precip.shape[0]):
# Replace non-finite values with the minimum finite value of the precipitation field
self.precip[i, ~np.isfinite(self.precip[i, :])] = np.nanmin(
self.precip[i, :]
)
precip[i, ~np.isfinite(precip[i, :])] = np.nanmin(precip[i, :])
# Store the precipitation data back in the object
self.precip = precip

# Initialize the noise generator if the noise_method is provided
if self.noise_method is not None:
Expand Down Expand Up @@ -664,7 +662,7 @@ def _initialize_state(self):
"randgen_prec": self.randgen_prec,
}

def _initialize_params(self, precip):
def _initialize_params(self):
"""
Initialize the params dictionary used during the nowcast iteration.
"""
Expand All @@ -686,7 +684,7 @@ def _initialize_params(self, precip):
"phi": self.phi,
"pert_gen": self.pert_gen,
"probmatching_method": self.probmatching_method,
"precip": precip,
"precip": self.precip,
"precip_thr": self.precip_thr,
"recomp_method": self.recomp_method,
"struct": self.struct,
Expand Down

0 comments on commit eb33c06

Please sign in to comment.