def for_batch(self, num_groups: int, num_timesteps: int, start_datetimes: Optional[np.ndarray] = None): for_batch = super().for_batch(num_groups=num_groups, num_timesteps=num_timesteps) # determine the delta (integer time accounting for different groups having different start datetimes) if start_datetimes is None: start_datetimes = np.zeros(num_groups) delta = self._dt_helper.make_delta_grid(start_datetimes, num_timesteps) # determine season: season = delta % self.seasonal_period # generate the fourier tensor: fourier_tens = fourier_tensor(time=Tensor(season), seasonal_period=self.seasonal_period, K=self.K) for state_element in self.state_elements: if state_element == 'position': continue r, c = (int(x) for x in state_element.split(sep=",")) for_batch._adjust_transition(from_element=state_element, to_element='position', adjustment=split_flat( fourier_tens[:, :, r, c], dim=1)) return for_batch
def for_batch( self, num_groups: int, num_timesteps: int, start_datetimes: Optional[np.ndarray] = None) -> ProcessForBatch: for_batch = super().for_batch(num_groups=num_groups, num_timesteps=num_timesteps) # determine the delta (integer time accounting for different groups having different start datetimes) delta = self.dt_tracker.get_delta(for_batch.num_groups, for_batch.num_timesteps, start_datetimes=start_datetimes) # determine season: season = delta % self.seasonal_period # generate the fourier tensor: fourier_tens = fourier_tensor(time=Tensor(season), seasonal_period=self.seasonal_period, K=self.K) for state_element in self.state_elements: if state_element == 'position': continue r, c = (int(x) for x in state_element.split(sep=",")) for_batch.adjust_transition(from_element=state_element, to_element='position', adjustment=fourier_tens[:, :, r, c]) return for_batch
def for_batch(self, num_groups: int, num_timesteps: int, start_datetimes: Optional[np.ndarray] = None): for_batch = super().for_batch(num_groups=num_groups, num_timesteps=num_timesteps) # determine the delta (integer time accounting for different groups having different start datetimes) if start_datetimes is None: if self._dt_helper.start_datetime: raise TypeError("Missing argument `start_datetimes`.") start_datetimes = np.zeros(num_groups) delta = self._dt_helper.make_delta_grid(start_datetimes, num_timesteps) # determine season: season = delta % self.seasonal_period # generate the fourier tensor: fourier_tens = fourier_tensor(time=Tensor(season), seasonal_period=self.seasonal_period, K=self.K) for measure in self.measures: for state_element in self.state_elements: r, c = (int(x) for x in state_element.split(sep=",")) for_batch._adjust_measure(measure=measure, state_element=state_element, adjustment=split_flat( fourier_tens[:, :, r, c], dim=1)) return for_batch
def for_batch(self, num_groups: int, num_timesteps: int, start_datetimes: Optional[np.ndarray] = None): for_batch = super().for_batch(num_groups=num_groups, num_timesteps=num_timesteps) # determine the delta (integer time accounting for different groups having different start datetimes) delta = self._get_delta(for_batch.num_groups, for_batch.num_timesteps, start_datetimes=start_datetimes) # determine season: season = delta % self.seasonal_period # generate the fourier tensor: fourier_tens = fourier_tensor(time=Tensor(season), seasonal_period=self.seasonal_period, K=self.K) for measure in self.measures: for state_element in self.state_elements: r, c = (int(x) for x in state_element.split(sep=",")) for_batch._adjust_measure( measure=measure, state_element=state_element, adjustment=split_flat(fourier_tens[:, :, r, c], dim=1) ) return for_batch