plot_params.py

load_training_points(dims, file_name_path='', file_name='')

Load the table of model parameters and total weighted distances of the model iterations compared to the Kepler data, that was used for training the Gaussian process emulator.

Parameters:
  • dims (int) – The number of (free) model parameters.

  • file_name_path (str, default='') – The path to the file containing the results of the model iterations.

  • file_name (str, default='') – The name of the file containing the results of the model iterations (e.g., ‘Active_params_recomputed_distances_table_best100000_every10.txt’).

Returns:

data_train – A dictionary of the model training points.

Return type:

dict

The dictionary contains the following fields:

  • active_params_names: The names of the (free) model parameters.

  • xtrain: The (free) model parameter values for each iteration (2-d array).

  • ytrain: The total weighted distance of the model compared to the Kepler data for each iteration (1-d array).

load_GP_table_prior_draws(file_name, file_name_path='')

Load a table of model parameter draws from the prior.

transform_sum_diff_params(xpoints, i, j)

Transform two parameters into their sum and difference.

Parameters:
  • xpoints (array[float]) – An array of parameters for each iteration (2-d array).

  • i (int) – The index of a parameter to transform.

  • j (int) – The index of a parameter to transform.

Returns:

xpoints_transformed – The array of parameters with the x_i and x_j parameters replaced by their sum (x_i+x_j) and difference (x_j-x_i). 2-d array with the same shape as xpoints.

Return type:

array[float]

See also

transform_sum_diff_params_inverse

Perform the inverse transformation (return the original parameters from their sum and difference).

transform_sum_diff_params_inverse(xpoints, i, j)

Transform the sum and difference of two parameters back into the original parameters.

Parameters:
  • xpoints (array[float]) – An array of parameters for each iteration (2-d array), where the x_i and x_j parameters are the sum and difference of two original parameters.

  • i (int) – The index of a transformed parameter.

  • j (int) – The index of a transformed parameter.

Returns:

xpoints_transformed – The array of original parameters (2-d array). Equivalent to the transformation of x_i and x_j to (x_i-x_j)/2 and (x_i+x_j)/2.

Return type:

array[float]

See also

transform_sum_diff_params

Perform the sum and difference of two parameters (the inverse of this transformation).

make_cuts_GP_mean_std_post(x_names, xprior_table, max_mean=numpy.inf, max_std=numpy.inf, max_post=numpy.inf)

Return a restricted sample of parameters given cuts on the Gaussian process (GP) emulator predictions at those parameters.

Parameters:
  • x_names (array[str]) – The names of the parameters.

  • xprior_table (structured array) – The table of parameter values and GP predictions at each iteration, with parameter/column names corresponding to x_names.

  • max_mean (float, default=inf) – The maximum mean prediction to include.

  • max_std (float, default=inf) – The maximum standard deviation to include.

  • max_post (float, default=inf) – The maximum posterior draw value to include.

Returns:

xpoints_cut – The table of parameter values at the iterations surviving all of the cuts.

Return type:

structured array

plot_fig_hists_GP_draws(fig_size, xprior_table, bins=100, save_name='no_name_fig.pdf', save_fig=False)

Plot figure for visualizing the Gaussian process emulator statistics.

Contains four panels for the histograms of the Gaussian process mean predictions, prediction draws, and standard deviations, along with a scatter plot of mean prediction vs. standard deviation.

Parameters:
  • fig_size (tuple) – The figure size, e.g. (16,8).

  • xprior_table (structured array) – The table of parameter values and GP predictions at each iteration.

  • bins (int, default=100) – The number of bins to use for the histograms.

  • save_name (str, default='no_name_fig.pdf') – The file name for saving the figure.

  • save_fig (bool, default=False) – Whether to save the figure. If True, will save the figure in the working directory with the file name given by save_name.

plot_cornerpy_wrapper(x_symbols, xpoints, xpoints_extra=None, c_extra='r', s_extra=1, quantiles=[0.16, 0.5, 0.84], verbose=False, fig=None, show_titles=True, label_kwargs={'fontsize': 20}, title_kwargs={'fontsize': 20}, save_name='no_name_fig.pdf', save_fig=False)

Plot a parameter space as a corner plot.

Wrapper for the corner.corner function from the corner.py package, with the option of over-plotting an additional set of points for comparison.

Parameters:
  • x_symbols (list or array[str]) – The list of the parameter names/symbols.

  • xpoints (array[float]) – The sample of parameter values (2-d array).

  • xpoints_extra (array[float], optional) – An additional sample of parameter values to plot (2-d array).

  • c_extra (str, default='r') – The color for plotting the additional sample of parameters.

  • s_extra (float, default=1) – The marker size for plotting the additional sample of parameters.

  • quantiles (list, default=[0.16, 0.5, 0.84]) – The quantiles to show on the histograms of the parameters as vertical lines.

  • verbose (bool, default=False) – Whether to print the quantiles for the distribution of each parameter.

  • fig (matplotlib.figure.Figure, optional) – An existing figure object to plot on.

  • show_titles (bool, default=True) – Whether to show the quantiles for the distribution of each parameter above each histogram.

  • label_kwargs (dict, default={'fontsize': 20}) – Extra parameters for setting the labels.

  • title_kwargs (dict, default={'fontsize': 20}) – Extra parameters for setting the title.

  • save_name (str, default='no_name_fig.pdf') – The file name for saving the figure.

  • save_fig (bool, default=False) – Whether to save the figure. If True, will save the figure in the working directory with the file name given by save_name.

Returns:

fig – The figure, if save_fig=False.

Return type:

matplotlib.figure.Figure

plot_contours_and_points_corner(x_symbols, xlower, xupper, contour_2d_grids, xpoints=None, points_size=1.0, points_alpha=1.0, afs=10, tfs=12, lfs=10, fig_size=(16, 16), fig_lbrtwh=[0.05, 0.05, 0.98, 0.98, 0.05, 0.05], save_name='no_name_fig.pdf', save_fig=False)

Plot contours for the evaluations of a function over 2-d grids of an n-d parameter space.

Parameters:
  • x_symbols (list or array[str]) – The list of the parameter names/symbols.

  • xlower (list or array[float]) – The lower bounds for each parameter.

  • xupper (list or array[float]) – The upper bounds for each parameter.

  • contour_2d_grids (array[float]) – The array of 2-d grids for the evaluations of a function (3-d array of dimensions ‘(N,gdim,gdim)’ where ‘N’ is the number of unique pairs of parameters, and ‘gdim’ is the number of grid points along each grid dimension).

  • xpoints (array[float], optional) – An additional sample of parameter values to plot (2-d array).

  • points_size (float, default=1.) – The point size for plotting the additional sample of parameters.

  • points_alpha (float, default=1.) – The transparency of the points for plotting the additional sample of parameters.

  • afs (int, default=10) – The axes fontsize.

  • tfs (int, default=12) – The text fontsize.

  • lfs (int, default=10) – The legend fontsize.

  • fig_size (tuple, default=(16,16)) – The figure size.

  • fig_lbrtwh (list, default=[0.05, 0.05, 0.98, 0.98, 0.05, 0.05]) – The positions of the (left, bottom, right, and top) margins of all the plotting panels (between 0 and 1), followed by the width and height space between the panels.

  • save_name (str, default='no_name_fig.pdf') – The file name for saving the figure.

  • save_fig (bool, default=False) – Whether to save the figure. If True, will save the figure in the working directory with the file name given by save_name.

plot_2d_points_and_contours_with_histograms(x, y, x_min=None, x_max=None, y_min=None, y_max=None, log_x=False, log_y=False, bins_hist=50, bins_cont=50, points_sizes=1.0, points_colors='k', points_only=False, xlabel_text='x', ylabel_text='y', extra_text=None, plot_qtls=True, log_x_qtls=False, log_y_qtls=False, x_str_format='{:0.2f}', y_str_format='{:0.2f}', x_symbol='$x$', y_symbol='$y$', afs=20, tfs=20, lfs=16, fig_size=(8, 8), fig_lbrtwh=[0.15, 0.15, 0.95, 0.95, 0.0, 0.0], save_name='no_name_fig.pdf', save_fig=False)

Plot a pair of parameters as a 2-d scatter plot with attached histograms of each parameter.

Parameters:
  • x (array[float]) – The values of the parameters (1-d array).

  • y (array[float]) – The values of the parameters (1-d array).

  • x_min (float, optional) – The minimum value of x to include.

  • x_max (float, optional) – The maximum value of x to include.

  • y_min (float, optional) – The minimum value of y to include.

  • y_max (float, optional) – The maximum value of y to include.

  • log_x (bool, default=False) – Whether to plot the x-axis on a log-scale (and take the log of the values in x for the histograms and quantiles)*.

  • log_y (bool, default=False) – Whether to plot the y-axis on a log-scale (and take the log of the values in y for the histograms and quantiles)*.

  • bins_hist (int, default=50) – The number of bins to use for the histograms.

  • bins_cont (int, default=50) – The number of bins to use for the contour maps (along each parameter).

  • points_sizes (float or array[float], default=1.) – The point size(s) for plotting the scatter points.

  • points_colors (float or array[float], default='k') – The point color(s) for plotting the scatter points.

  • points_only (bool, default=False) – Whether to plot only the scatter points instead of their contour maps.

  • xlabel_text (str, default='x') – The x-axis label.

  • ylabel_text (str, default='y') – The y-axis label.

  • extra_text (str, optional) – Extra text to be displayed on the figure.

  • plot_qtls (bool, default=True) – Whether to compute, print, and plot the quantiles of each parameter on the histograms.

  • log_x_qtls (bool, default=False) – Whether to use the log of the x values for computing their quantiles. Only used if log_x=True.

  • log_y_qtls (bool, default=False) – Whether to use the log of the y values for computing their quantiles. Only used if log_y=True.

  • x_str_format (str, default='{:0.2f}') – The string formatter for the x quantiles (e.g. to control how many significant figures are shown).

  • y_str_format (str, default='{:0.2f}') – The string formatter for the y quantiles (e.g. to control how many significant figures are shown).

  • x_symbol (str, default=r'$x$') – The symbol for the x parameter for labeling the quantiles.

  • y_symbol (str, default=r'$y$') – The symbol for the y parameter for labeling the quantiles.

  • afs (int, default=20) – The axes fontsize.

  • tfs (int, default=20) – The text fontsize.

  • lfs (int, default=16) – The legend fontsize.

  • fig_size (tuple, default=(8,8)) – The figure size.

  • fig_lbrtwh (list, default=[0.15, 0.15, 0.95, 0.95, 0., 0.]) – The positions of the (left, bottom, right, and top) margins of all the plotting panels (between 0 and 1), followed by the width and height space between the panels (main plot and top/side histograms).

  • save_name (str, default='no_name_fig.pdf') – The file name for saving the figure.

  • save_fig (bool, default=False) – Whether to save the figure. If True, will save the figure in the working directory with the file name given by save_name.

Returns:

  • ax_main (matplotlib.axes._subplots.AxesSubplot) – The plotting axes for the main panel (scatter plot/contour map).

  • ax_top (matplotlib.axes._subplots.AxesSubplot) – The plotting axes for the top panel (histogram of x).

  • ax_side (matplotlib.axes._subplots.AxesSubplot) – The plotting axes for the side panel (histogram of y).

Note

*The log_x and log_y parameters are options to take the log of the x and y inputs, NOT to mean that the input values are already logged! The user should always pass unlogged values for x and y (and their limits).

plot_function_heatmap_contours_given_irregular_points_corner(x_symbols, xpoints, fpoints, xlower=None, xupper=None, show_points=True, points_size=1.0, points_alpha=1.0, afs=10, tfs=12, lfs=10, fig_size=(16, 16), fig_lbrtwh=[0.05, 0.05, 0.98, 0.98, 0.05, 0.05], save_name='no_name_fig.pdf', save_fig=False)

Plot 2-d heat-maps and contours of a function evaluated on a set of irregularly spaced points in the n-d parameter space.

Parameters:
  • x_symbols (list or array[str]) – The list of the parameter names/symbols.

  • xpoints (array[float]) – The sample of parameter values at which the function was evaluated (2-d array).

  • fpoints (array[float]) – The function evaluations at the points given by xpoints.

  • xlower (list or array[float]) – The lower bounds for each parameter.

  • xupper (list or array[float]) – The upper bounds for each parameter.

  • show_points (bool, default=True) – Whether to plot the individual parameter points.

  • points_size (float, default=1.) – The point size for plotting the sample of parameters.

  • points_alpha (float, default=1.) – The transparency of the points for plotting the sample of parameters.

  • afs (int, default=10) – The axes fontsize.

  • tfs (int, default=12) – The text fontsize.

  • lfs (int, default=10) – The legend fontsize.

  • fig_size (tuple, default=(16,16)) – The figure size.

  • fig_lbrtwh (list, default=[0.05, 0.05, 0.98, 0.98, 0.05, 0.05]) – The positions of the (left, bottom, right, and top) margins of all the plotting panels (between 0 and 1), followed by the width and height space between the panels.

  • save_name (str, default='no_name_fig.pdf') – The file name for saving the figure.

  • save_fig (bool, default=False) – Whether to save the figure. If True, will save the figure in the working directory with the file name given by save_name.

plot_function_heatmap_averaged_grid_given_irregular_points_corner(x_symbols, xpoints, fpoints, flabel='f', xlower=None, xupper=None, x_bins=20, show_cbar=True, show_points=True, points_size=1.0, points_alpha=1.0, afs=10, tfs=12, lfs=10, fig_size=(16, 16), fig_lbrtwh=[0.05, 0.05, 0.98, 0.98, 0.05, 0.05], save_name='no_name_fig.pdf', save_fig=False)

Plot 2-d heat-maps (using matplotlib.pyplot.imshow) on grids based on the evaluations of a function on a set of irregularly spaced points in the n-d parameter space.

The value of each grid bin is computed as the mean of the function evaluated at all of the points inside the bin.

Parameters:
  • x_symbols (list or array[str]) – The list of the parameter names/symbols.

  • xpoints (array[float]) – The sample of parameter values at which the function was evaluated (2-d array).

  • fpoints (array[float]) – The function evaluations at the points given by xpoints.

  • flabel (str, default='f') – The text label for the function.

  • xlower (list or array[float]) – The lower bounds for each parameter.

  • xupper (list or array[float]) – The upper bounds for each parameter.

  • x_bins (int, default=20) – The number of bins to use for each dimension of each grid.

  • show_cbar (bool, default=True) – Whether to show the colorbar for the function.

  • show_points (bool, default=True) – Whether to plot the individual parameter points.

  • points_size (float, default=1.) – The point size for plotting the sample of parameters.

  • points_alpha (float, default=1.) – The transparency of the points for plotting the sample of parameters.

  • afs (int, default=10) – The axes fontsize.

  • tfs (int, default=12) – The text fontsize.

  • lfs (int, default=10) – The legend fontsize.

  • fig_size (tuple, default=(16,16)) – The figure size.

  • fig_lbrtwh (list, default=[0.05, 0.05, 0.98, 0.98, 0.05, 0.05]) – The positions of the (left, bottom, right, and top) margins of all the plotting panels (between 0 and 1), followed by the width and height space between the panels.

  • save_name (str, default='no_name_fig.pdf') – The file name for saving the figure.

  • save_fig (bool, default=False) – Whether to save the figure. If True, will save the figure in the working directory with the file name given by save_name.