    def __nowcast_main(self):
        """
        Main nowcast loop that iterates through the ensemble members and time steps
        to generate forecasts.
        """
        # Isolate the last time slice of observed precipitation
        precip = self.__precip[
            -1, :, :
        ]  # Extract the last available precipitation field

        # Prepare state and params dictionaries, these need to be formatted a specific way for the nowcast_main_loop
        state = self.__return_state_dict()
        params = self.__return_params_dict(precip)

        print("Starting nowcast computation.")

        # Run the nowcast main loop
        self.__state.precip_forecast = nowcast_main_loop(
            precip,
            self.__velocity,
            state,
            self.__time_steps,
            self.__config.extrapolation_method,
            self.__update_state,  # Reference to the update function
            extrap_kwargs=self.__state.extrapolation_kwargs,
            velocity_pert_gen=self.__state.velocity_perturbations,
            params=params,
            ensemble=True,
            num_ensemble_members=self.__config.n_ens_members,
            callback=self.__config.callback,
            return_output=self.__config.return_output,
            num_workers=self.__params.num_ensemble_workers,
            measure_time=self.__config.measure_time,
        )
Main nowcast loop that iterates through the ensemble members and time steps
to generate forecasts.
pysteps/nowcasts/steps.py