SWXGModel
- class swxg.SWXGModel(raw_data: DataFrame)
- __init__(raw_data: DataFrame) None
The base class to create, debias, fit, synthesize, and validate the stochastic weather generation model.
Parameters
- raw_data: pd.DataFrame
Input dataframe to use as for stochastic weather generation
Attributes
- raw_data: pd.DataFrame
Mirrors in the input
raw_dataparameter- data: pd.DataFrame
Temporal reformatting of
raw_dataso that each year, month, day have their own column in the DataFrame- resolution: str
Determined resolution of the observed data. Can be “monthly” or “daily”
- precip_fit_dict: dict
Dictionary containing statistical information related to fitting of precipitation data
- copulaetemp_fit_dict: dict
Dictionary containing statistical information related to fitting of copulae and temperature data
- is_fit: bool:
Flag to confirm that this instance of the generator has been fit
- fit(verbose: bool = True, validate: bool = True, dirpath: str = '', kwargs: dict = {}) None
Local method that calls the
fit_datafunction, which aptly fits the input weather data by returning extracted statistical parameters and reformatted dataParameters
- verbose: bool, optional
Flag for displaying precipitation and temperature fit statistics. Default: True
- validate: bool, optional
Flag for producing figures to validate each step of the generator. Default: True
- dirpath: str, optional
Path for where to save the validation figures. Default: “”
- kwargs: dict, optional
Keyword arguments related to the fit. Leaving this empty sets the keyword arguments to their default values. Keywords are:
gmhmm_min_states: int, default = 1gmhmm_max_states: int, default = 4gmhmm_states: int, default = 0max_convergence_attempts: int, default = 50ar_lag: int, default = 1copula_families: list[str], default = [“Independence”, “Frank”, “Gaussian”]figure_extension: str, default=”svg”validation_figures: list[str], default = [“precip”, “copula”]
- format_time_resolution(data: DataFrame) None
Function that separates the raw data’s datetime stamps to individual dataframe columns based on the input resolution
Parameters
- data: pd.DataFrame
Input raw data to be used for the fitting
- synthesize(n: int = 0, resolution: str = '', validate: bool = True, dirpath: str = '', kwargs: dict = {}) DataFrame
Local method that calls the
synthesize_datafunction, which aptly synthesizes weather through either observed fit or given statistical parametersParameters
- n: int, optional
Number of years to synthesize. Default takes the same size as the number of years in the observed dataset
- resolution: str, optional
The resolution to synthesize the data at. Leaving this empty sets the same resolution as the raw data
- validate: bool, optional
Flag for producing figures to validate each step of the generator. Default: True
- dirpath: str, optional
Path for where to save the validation figures. Default: “”
- kwargs: dict, optional
Keyword arguments related to the fit. Leaving this empty sets the keyword arguments to their default values. Keywords are:
validation_samplesize_mult: int, default = 10figure_extension: str, default=”svg”
Returns
- synthesized_data: pd.DataFrame
The synthesized weather data at the desired time resolution