Data package
Submodules
Data.data_losses module
This module contains all losses used for training.
- class Data.data_losses.Full_MSELoss(**model_kwargs)
Bases:
Module
- forward(input, target)
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class Data.data_losses.GradientSmoothnessLoss(model, grad_regularization=0.001)
Bases:
Module
- forward(x)
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class Data.data_losses.Mean_MSELoss(**model_kwargs)
Bases:
Module
- forward(input, target)
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class Data.data_losses.NMLLLoss(model, regularization_weight, **model_kwargs)
Bases:
Module
Marginal Negative Log Likelihood for Gaussian Processes.
- forward(input, target, isTraining=True)
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class Data.data_losses.VariationalELBOLoss(model, regularization_weight, grad_regularization)
Bases:
Module
- forward(input, target, isTraining=True)
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
Data.forecast_dataset module
This module contains all dataset wrappers used for training.
- class Data.forecast_dataset.GridStationDataset(grid_ds: Dataset, station_df: DataFrame, sta_df: DataFrame, output_weather_vars: list, training_window: int)
Bases:
WeatherDataset
- era5_name_to_kis_name(name)
- get_domain_shape()
Returns the shape of the input grid.
- Returns:
torch.tensor: shape of the input grid
- get_in_channels()
Returns the number of input channels.
- Returns:
torch.tensor: number of input channels
- get_kis_obs(idx)
- get_num_train_data()
- get_test_idx(idx)
- get_test_loader(batch_size, shuffle=True)
- get_timestamp(idx)
- get_train_idx(idx)
- get_train_loader(batch_size)
- interpolate_era5(X: Tensor) Tensor
Interpolates ERA5 data to target coordinates for each batch and weather variable.
- Parameters:
X (Tensor): Input ERA5 data of shape [B, W, V, H]
- Returns:
Tensor: Interpolated values of shape [B, W_out, M]
- precompute_kis_obs()
- precompute_outputs()
Precompute interpolated outputs at station locations for all timesteps.
- shuffle_train_indices()
- to(device)
- class Data.forecast_dataset.PastNDaysForecastDataset(observations: array, training_window: int, train_ratio: float, test_ratio: float, covariances: array = None)
Bases:
WeatherDataset
- get_domain_shape()
Returns the shape of the input grid.
- Returns:
torch.tensor: shape of the input grid
- get_in_channels()
Returns the number of input channels.
- Returns:
torch.tensor: number of input channels
- get_test_loader(batch_size)
- get_test_xy()
- to(device)
- class Data.forecast_dataset.WeatherDataset(train_ratio: float, test_ratio: float)
Bases:
Dataset
Base class for other datasets containing weather data.
- data_split()
- abstract get_domain_shape() tensor
Returns the shape of the input grid.
- Returns:
torch.tensor: shape of the input grid
- abstract get_in_channels() int
Returns the number of input channels.
- Returns:
torch.tensor: number of input channels
- get_test_loader(batch_size)
- get_test_xy()
- get_train_loader(batch_size)
- get_train_xy()
- Data.forecast_dataset.create_GridStationDataset(training_window: int)
Data.Synthetic
This module contains the functionality for creating the synthetic dataset.
- Data.Synthetic.generate_synthetic_data.compute_and_sample_values()
Computes parameters mu and Sigma for the synthetic model at three settings. Saves these parameters and samples from the probabilistic distribution.
- Data.Synthetic.synthetic_data_util.compute_covariance(W, V, H, T, zeta, eps, h, c, ncycles=10)
Computes the full covariance matrix at various timesteps for the synthetic data.
- Data.Synthetic.synthetic_data_util.compute_mean(alpha, beta, gamma, delta, RH, X, Z)
Computes the mean at various timesteps for the synthetic data.
- Data.Synthetic.synthetic_data_util.compute_output(mu, S_full)
Computes samples at various timesteps for the synthetic data based on the means and covariance matrices.
- Data.Synthetic.synthetic_data_util.get_vmins_and_vmaxs(data, p)
- Data.Synthetic.synthetic_data_util.integrand(tau, t, alpha, x_vec)
Defines the integrand of the temperature solution.
- Data.Synthetic.synthetic_data_util.plot_contours(data, num_time_slices=3, ncycles=10, vmins=None, vmaxs=None, savedir=None, setting=None, save_name=None, time_offset=0, model=None, closeOnSave=True, is_rel=False, saveFull=False)
General-purpose plotting function to plot synthetic data samples at various timesteps with several configurable settings.
- Data.Synthetic.synthetic_data_util.sigma_t(t)
The time contribution to the covariance matrix.
- Data.Synthetic.synthetic_data_util.sigma_w(d1, d2, c)
The weather type contribution to the covariance matrix.
- Data.Synthetic.synthetic_data_util.sigma_x(x1, x2, eps, h)
The spatial contribution to the covariance matrix.
- Data.Synthetic.synthetic_data_util.temp(z, alpha, beta, gamma, delta)
Computes the solution to the inhomogeneous forced heat equation with Gaussian IC.
- Data.Synthetic.synthetic_data_util.temp_h(x_vec, t, alpha, gamma, delta)
Computes the solution to the homogeneous heat equation given the Gaussian initial temperature profile.
- Data.Synthetic.synthetic_data_util.temp_i(x_vec, gamma, delta)
Provides the initial temperature profile.
- Data.Synthetic.synthetic_data_util.temp_p(x_vec, t, alpha, beta)
Computes the particular temperature solution that is caused by the forcing term beta * sin(t) * delta(x).