make_figures.py
- swxg.make_figures.compare_synth_to_obs(dp: str, ext: str, synth_df: DataFrame, obs_df: DataFrame) None
Comparing the synthesized WX data with the observed WX data through a variety of statistical and visual tests
Parameters
- dp: str
Filepath for saving the validation figure
- ext: str
Filepath extension for saving the validation figure
- synth_df: pd.DataFrame
Synthesized precipitation and temperature data at defined resolution
- obs_df: pd.DataFrame
Observed precipitation and temperature data at defined resolution
- swxg.make_figures.squarest_subplots(n: int) tuple[int]
For some input value, return the most rectangular (or square) 2D arrangement of that input value
Parameters
- n: int
Number of elements to rectangularize
Returns
- rows: int
Number of rows in the 2D arrangement
- cols: int
Number of cols in the 2D arrangement
- swxg.make_figures.validate_copulae_statistics(dp: str, ext: str, data: DataFrame, t_dict: dict) None
Validation figures for the copulae, confirming: * best-fitting copulae via AIC comparison * copulae plots vs. empirical copula
Parameters
- dp: str
Filepath for saving the validation figure
- ext: str
Filepath extension for saving the validation figure
- data: pd.DataFrame
Temporally-formated precipitation and temperature data, as a dataframe
- t_dict: dict
The fitted precip/copulae/temperature data, as a dict
- swxg.make_figures.validate_explore_pt_dependence(dp: str, ext: str, pt_data: DataFrame, good_years: list[int]) None
Validation figure for exploring the Kendall and Spearman correlation coefficients between precipitation and temperature. Significant positive or negative correlations implies a need for a copula to represent the conditional relationship between them.
Parameters
- dp: str
Filepath for saving the validation figure
- ext: str
Filepath extension for saving the validation figure
- pt_data: pd.DataFrame
The precipitation and temperature data, as a DataFrame
- good_years: list[int]
The list of years fit by the GMMHMM
- swxg.make_figures.validate_gmhmm_states(dp: str, ext: str, min_states: int, max_states: int, lls: list[float], aics: list[float], bics: list[float]) None
Validation figure for confirming the best-fitting number of states for the Gaussian mixture hidden Markov model that represents precipitation
Parameters
- dp: str
Filepath for saving the validation figure
- ext: str
Filepath extension for saving the validation figure
- min_states: int
The minimum number of attempted hidden states in fit
- max_states: int
The maximum number of attempted hidden states in fit
- lls: list[float]
Log-likelihood calculation for each fit GMMHMM by number of states
- aics: list[float]
AIC calculation for each fit GMHMM by number of states
- bics: list[float]
BIC calculation for each fit GMHMM by number of states
- swxg.make_figures.validate_gmhmm_statistics(dp: str, ext: str, data: DataFrame, p_dict: dict) None
Validation figures for the precipitation GMHMM, confirming:
that the transition between hidden states is Markovian (if more than one state is found)
the solved hidden state as a function of date (year)
the transition probabilities between states are sensible
that the transformed precipitation data is Gaussian
Parameters
- dp: str
Filepath for saving the validation figure
- ext: str
Filepath extension for saving the validation figure
- data: pd.DataFrame
Temporally-formated precipitation and temperature data, as a dataframe
- p_dict: dict
The fitted precipitation data, as a dict
- swxg.make_figures.validate_obs_spatial_temporal_correlations(dp: str, ext: str, data: DataFrame, p_dict: dict, t_dict: dict, val_wvar: list[str]) None
Validation figures for all the observed precipitation and temperature spatial correlations, using the Pearson method (since there’s no comparison between parameters); precipitation temporal (Markovian) structure at annual and monthly levels. CURRENTLY NOT PRODUCED since
compare_synth_to_obs()replicates these.Parameters
- dp: str
Filepath for saving the validation figure
- ext: str
Filepath extension for saving the validation figure
- data: pd.DataFrame
Temporally-formated precipitation and temperature data, as a dataframe
- p_dict: dict
The fitted precipitation data, as a dict
- t_dict: dict
The fitted temperature and copulae data, as a dict
- val_wvar: list[str]
Produce just precipitation, temperature, or both
- swxg.make_figures.validate_pt_acf(dp: str, ext: str, pt_dict: dict, lag: int) None
Validation figure for ACF fits on precipitation and temperature, as small multiples by month
Parameters
- dp: str
Filepath for saving the validation figure
- ext: str
Filepath extension for saving the validation figure
- pt_dict: pd.DataFrame
The precipitation and temperature data organized by month, as a dict
- lag: int
The lag considered in the autocorrelation function
- swxg.make_figures.validate_pt_dependence_structure(dp: str, ext: str, pt_dict: dict) None
Validation figure for checking the dependence structure of copula families for the precipitation and temperature residuals through K-plots (Genest & Boies, 2003: https://www.jstor.org/stable/30037296)
Parameters
- dp: str
Filepath for saving the validation figure
- ext: str
Filepath extension for saving the validation figure
- pt_dict: dict
The precipitation and temperature data organized by month, as a dict
- swxg.make_figures.validate_pt_fits(dp: str, ext: str, data_df: DataFrame, precip_dict: dict, temp_dict: dict, val_figs: list[str]) None
Validation manager for all of the figures that can be generated after fitting precipitation and temperature
Parameters
- dp: str
Filepath for saving the validation figure
- ext: str
Filepath extension for saving the validation figure
- data_df: pd.DataFrame
Temporally-formated precipitation and temperature data, as a dataframe
- precip_dict: dict
The fitted precipitation data, as a dict
- temp_dict: dict
The fitted temperature and copulae data, as a dict
- val_figs: list[str]
Which of the validation figure methods to use/plot, can be ‘precip’ or ‘copula’
- swxg.make_figures.validate_pt_stationarity(dp: str, ext: str, pt_dict: dict) None
Validation figure for checking the stationarity of the precipitation and temperature residuals through the Augmented Dickey-Fuller unit root test and the Kwiatkowski-Phillips-Schmidt-Shin stationarity test. Note the null hypothesis for the ADF test is that the data is non-stationary so rejecting the null hypothesis is desired and therefore this figure shows 1 - ADF.pvalue
Parameters
- dp: str
Filepath for saving the validation figure
- ext: str
Filepath extension for saving the validation figure
- pt_dict: pd.DataFrame
The precipitation and temperature data organized by month, as a dict