API Reference¶
Utilities¶
Auto-Download Module
This function downloads Sunsmart PV Power Plant data from the OSF database.
- dddt_gfm.util.io.OSF_download(file_number, output_file, output_dir)[source]¶
Helper function that downloads CSV files from OSF Database. The urls are already in the function so whichever one can be downloaded
- Parameters:
file_number (int) – an integer (0-89) that specifies which csv file to download -> 0,1,2 for 2001; 3,4,5 for 2002; etc…
output_file (string) – name for CSV file
output_dir (string) – directory for which the file should be saved in
Models¶
- class dddt_gfm.models.stGAE.STConvDecoder(num_nodes, in_channels, hidden_channels, out_channels, kernel_size, kernel_size_de, stride, padding, K, normalization='sym', bias=True)[source]¶
Bases:
Module- forward(X, edge_index, edge_weight=None)[source]¶
Forward pass. If edge weights are not present the forward pass defaults to an unweighted graph.
- Return type:
FloatTensor
- Arg types:
X (PyTorch FloatTensor) - Sequence of node features of shape (Batch size X Input time steps X Num nodes X In channels).
edge_index (PyTorch LongTensor) - Graph edge indices.
edge_weight (PyTorch LongTensor, optional)- Edge weight vector.
- Return types:
T (PyTorch FloatTensor) - Sequence of node features.
- class dddt_gfm.models.stGAE.STConvEncoder(num_nodes, in_channels, hidden_channels, out_channels, kernel_size, stride, padding, K, normalization='sym', bias=True)[source]¶
Bases:
Module- forward(X, edge_index, edge_weight=None)[source]¶
Forward pass. If edge weights are not present the forward pass defaults to an unweighted graph.
- Return type:
FloatTensor
- Arg types:
X (PyTorch FloatTensor) - Sequence of node features of shape (Batch size X Input time steps X Num nodes X In channels).
edge_index (PyTorch LongTensor) - Graph edge indices.
edge_weight (PyTorch LongTensor, optional)- Edge weight vector.
- Return types:
T (PyTorch FloatTensor) - Sequence of node features.
- class dddt_gfm.models.stGAE.TemporalConv(in_channels, out_channels, kernel_size, stride, padding)[source]¶
Bases:
Module- Parameters:
- forward(X)[source]¶
Forward pass through temporal convolution block.
- Return type:
FloatTensor
- Arg types:
- X (torch.FloatTensor) - Input data of shape
(batch_size, input_time_steps, num_nodes, in_channels).
- Return types:
- H (torch.FloatTensor) - Output data of shape
(batch_size, in_channels, num_nodes, input_time_steps).
- class dddt_gfm.models.stGAE.TemporalDeConv1(in_channels, out_channels, kernel_size, stride, padding)[source]¶
Bases:
Module- Parameters:
- forward(X)[source]¶
Forward pass through temporal convolution block.
- Return type:
FloatTensor
- Arg types:
- X (torch.FloatTensor) - Input data of shape
(batch_size, input_time_steps, num_nodes, in_channels).
- Return types:
- H (torch.FloatTensor) - Output data of shape
(batch_size, in_channels, num_nodes, input_time_steps).
- class dddt_gfm.models.stGAE.TemporalDeConv2(in_channels, out_channels, kernel_size, stride)[source]¶
Bases:
Module- Parameters:
- forward(X)[source]¶
Forward pass through temporal convolution block.
- Return type:
FloatTensor
- Arg types:
- X (torch.FloatTensor) - Input data of shape
(batch_size, input_time_steps, num_nodes, in_channels).
- Return types:
- H (torch.FloatTensor) - Output data of shape
(batch_size, in_channels, num_nodes, input_time_steps).
Dataloaders¶
- class dddt_gfm.dataloaders.dataloader_DIW.DIWDataset(target_path, connectivity=None, eval_mask=None, index=None, mask=None, covariates=None, input_map=None, target_map=None, auxiliary_map=None, scalers=None, trend=None, transform=None, window=12, stride=1, window_lag=1, precision=32, name=None)[source]¶
Bases:
ImputationDataset
- class dddt_gfm.dataloaders.dataloader_sunsmart.stDataloader(*args: Any, **kwargs: Any)[source]¶
Bases:
Dataset- apply_conditions(conditions_list, write=False)[source]¶
Apply a list of conditions to the specified DataFrame in a list using conditions based on other DataFrames.
- Parameters:
conditions_list (list of tuples) – Each tuple contains (target_index, conditions, fill_df_index, fallback_index). - conditions: A list of tuples, each containing (channel_x, operator, channel_y, scalar). - conditions_op: Operator to act on conditional statments. - channel_if_true: Name of DataFrame from self.channel_names to get the value_if_true from. If None, use scalar_values. - channel_if_false: Name of DataFrame self.channel_names to return values from if conditions are not met. - scalar_if_true: Value used for filling if fill_df_index = None. - scalar_if_true: Value used for returning if df_df_index = None. - condition_name: Name corresponding to this condition.
- Returns:
The modified DataFrame list after applying all conditions.
- Return type:
pd.DataFrame
- generate_datasetgrade_adjacency_matrix(grade_col='', min_grade_threshold=[0.7], max_diff_thresholds=[0.75], weighted=True, nodeID_col='nodeID', write=False)[source]¶
- generate_distance_adjacency_matrix(latitude='latd', longitude='longd', epsilons=[0.75], weighted=True, nodeID_col='nodeID', write=False)[source]¶
- get_longest_timespan(list_dfs=None, freq='15min', time_var='tmst', tz='EST', set_params=True)[source]¶
- haversine(lon1, lat1, lon2, lat2)[source]¶
Calculate the great circle distance between two points on the earth (specified in decimal degrees)
- read_files_with_nodeID()[source]¶
Reads a list of CSV files and adds a ‘nodeID’ column to each DataFrame with the name of the file (without .csv).
Parameters: filepaths (list): A list of file paths to the CSV files.
Returns: list: A list of DataFrames with the ‘nodeID’ column added.
- subset(data, dim)[source]¶
Splits the array along a specified dimension using predefined column indices.
- ts_reindex_with_interpolation(df_to_reindex, start_freq='1h', chunk_size=None, method='linear', order=3)[source]¶
Reindex a DataFrame to a new index range and perform spline interpolation.
- Parameters:
df_to_reindex (pd.DataFrame) – Input DataFrame.
- Returns:
DataFrame with reindexed index and interpolated values.
- Return type:
pd.DataFrame
- class dddt_gfm.dataloaders.rwb_dataloader_sunsmart.stDataloader(*args: Any, **kwargs: Any)[source]¶
Bases:
Dataset- apply_conditions(conditions_list, write=False)[source]¶
Apply a list of conditions to the specified DataFrame in a list using conditions based on other DataFrames.
- Parameters:
conditions_list (list of tuples) – Each tuple contains (target_index, conditions, fill_df_index, fallback_index). - conditions: A list of tuples, each containing (channel_x, operator, channel_y, scalar). - conditions_op: Operator to act on conditional statments. - channel_if_true: Name of DataFrame from self.channel_names to get the value_if_true from. If None, use scalar_values. - channel_if_false: Name of DataFrame self.channel_names to return values from if conditions are not met. - scalar_if_true: Value used for filling if fill_df_index = None. - scalar_if_true: Value used for returning if df_df_index = None. - condition_name: Name corresponding to this condition.
- Returns:
The modified DataFrame list after applying all conditions.
- Return type:
pd.DataFrame
- batch_plot(x, mask, y, y_pred, plot_nodes=5, num_plots_per_node=3, plot_range=200, plot_type='sunangle')[source]¶
- generate_datasetgrade_adjacency_matrix(grade_col='', min_grade_threshold=[0.7], max_diff_thresholds=[0.75], weighted=True, nodeID_col='nodeID', write=False)[source]¶
- generate_distance_adjacency_matrix(latitude='latd', longitude='longd', epsilons=[0.75], weighted=True, nodeID_col='nodeID', write=False)[source]¶
- get_longest_timespan(list_dfs=None, freq='15min', time_var='tmst', tz='EST', set_params=True)[source]¶
- haversine(lon1, lat1, lon2, lat2)[source]¶
Calculate the great circle distance between two points on the earth (specified in decimal degrees)
- read_files_with_nodeID()[source]¶
Reads a list of CSV files and adds a ‘nodeID’ column to each DataFrame with the name of the file (without .csv).
Parameters: filepaths (list): A list of file paths to the CSV files.
Returns: list: A list of DataFrames with the ‘nodeID’ column added.
- subset(data, dim)[source]¶
Splits the array along a specified dimension using predefined column indices.
- ts_reindex_with_interpolation(df_to_reindex, start_freq='1h', chunk_size=None, method='linear', order=3)[source]¶
Reindex a DataFrame to a new index range and perform spline interpolation.
- Parameters:
df_to_reindex (pd.DataFrame) – Input DataFrame.
- Returns:
DataFrame with reindexed index and interpolated values.
- Return type:
pd.DataFrame