Plotting Functions

Various plotting functions to allow the user to interpret data from the mcmc

src.magpy_rv.plotting.GP_plot(time, rv, hparam, kernel_name, rv_err=None, model_list=None, model_param=None, flags=None, xpred=None, residuals=False, xlabel='Time [BJD]', ylabel='RV [m/s]', legend=True, save_folder=None, savefilename=None)[source]

Function to plot the rv data against the times with any offsets subtracted and the gp and models plotted on top

Parameters
  • time (array of floats) – x-axis array of the observation times

  • rv (array of floats) – y-axis array of the RVs

  • hparam (dictionary) – dictionary of the hyperparameters

  • kernel_name (string) – name of the kernel

  • rv_err (array of floats, optional) – array of rv errors, defaults to None

  • model_list (list of strings, optional) – list of the models in use, defaults to None

  • model_param (dictionary, optional) – dictionary of model parameters, defaults to None

  • flags (array of floats, optional) – array of flags representing offsets generated by the combine_data function, defaults to None

  • xpred (array of floats, optional) – array of prediced times to be used for the smooth model, defaults to intervals of 0.1 between the max and min times

  • residuals (bool, optional) – enable the plotting of residuals, defaults to false

  • xlabel (string, optional) – label of x-axis, defaults to “time [BJD]”

  • ylabel (string, optional) – label of y-axis, defaults to “RV [m/s]”

  • legend (bool, optional) – enable the plotting of a legend, defaults to True

  • save_folder (string, optional) – folder to save the plot, defaults to None

  • savefilename (string, optional) – name of the save file, defaults to None

Return type

rv plot with the predicted GP and any offsets subtracted from the data along with any models and residuals

src.magpy_rv.plotting.corner_plot(hparam_chain, kernel_name, model_param_chain, model_name, masses=None, save_folder=None, savefilename='corner', errors=False)[source]

Function to plot the posteriors of each parameter from the mcmc as corner plots. If there is no dynamic range in any of the parameters the plots will automatically show up as empty.

Parameters
  • hparam_chain (array) – Array of all the sets of hyperparameters of the MCMC

  • kernel_name (string) – Name of the kernel

  • model_param_chain (array) – Array of all the sets of model parameters of the MCMC.

  • model_name (string) – Name of the model

  • masses (array, optional) – Array of all the masses for all planets produced by the MCMC, defaults to None

  • save_folder (str, optional) – Folder to save the plot, by default None. If None, the plot is not saved.

  • savefilename (str, optional) – Name of the file to save the plot, by default Corner.

Return type

Corner plots of the posteriors of each parameter

src.magpy_rv.plotting.data_plot(time, rv, xlabel='time [BJD]', ylabel='RV [m/s]', legend=True, y_err=None, flags=None, offsets=None, save_folder=None, savefilename=None)[source]

Function to plot the rv data against the times with any given offsets subtracted from the data. It accepts a maximum of 6 offsets.

Parameters
  • time (array of floats) – x-axis array of the observation times

  • rv (array of floats) – y-axis array of the RVs

  • xlabel (string, optional) – label of x-axis, defaults to “time [BJD]”

  • ylabel (string, optional) – label of y-axis, defaults to “RV [m/s]”

  • legend (bool, optional) – enable the plotting of a legend, defaults to True

  • y_err (array of floats, optional) – array of rv errors, defaults to None

  • flags (array of floats, optional) – array of flags representing offsets generated by the combine_data function, defaults to None

  • offsets (list or tuple of floats, optional) – list or tuple of offsets ordered accordingly to the inputs in the combine_data function, defaults to None

  • save_folder (string, optional) – folder to save the plot, defaults to None

  • savefilename (string, optional) – name of the save file, defaults to None

Return type

rv plot with any offsets subtracted from the data

src.magpy_rv.plotting.keplerian_only_plot(time, rv, hparam, kernel_name, model_list, model_param, rv_err=None, keplerian_number=0, flags=None, xpred=None, residuals=False, xlabel='Time [BJD]', ylabel='RV [m/s]', legend=True, save_folder=None, savefilename=None, plot=True)[source]

Function to return a plot of the data with the GP and all models except from the chosen keplerian subtracted from it, with the chosen keplerian model plotted on top

Parameters
  • time (array of floats) – x-axis array of the observation times

  • rv (array of floats) – y-axis array of the RVs

  • hparam (dictionary) – dictionary of the hyperparameters

  • kernel_name (string) – name of the kernel

  • model_list (list of strings) – list of the models in use

  • model_param (dictionary) – dictionary of model parameters

  • rv_err (array of floats, optional) – array of rv errors, defaults to None

  • keplerian_number (int, optional) – number representing the chosen keplerian to plot, 0 to plot first keplerian, 1 to plot second keplerian etc… defaults to None

  • flags (array of floats, optional) – array of flags representing offsets generated by the combine_data function, defaults to None

  • xpred (array of floats, optional) – array of prediced times to be used for the smooth model, defaults to intervals of 0.1 between the max and min times

  • residuals (bool, optional) – enable the plotting of residuals, defaults to false

  • xlabel (string, optional) – label of x-axis, defaults to “time [BJD]”

  • ylabel (string, optional) – label of y-axis, defaults to “RV [m/s]”

  • legend (bool, optional) – enable the plotting of a legend, defaults to True

  • save_folder (string, optional) – folder to save the plot, defaults to None

  • savefilename (string, optional) – name of the save file, defaults to None

  • plot (bool, optional) – true returns the plot, false returns parameter and rv data, defaults to True

Returns

  • plot of subtracted data and chosen keplerian model if plot is True

  • parameter and rv data with optional residuals if plot is False

src.magpy_rv.plotting.mixing_plot(hparam_chain, kernel_name, model_param_chain, model_name, LogL_chain, mass=None, save_folder=None, savefilename='mixing')[source]

Function to plot the mixing chains from the mcmc for each parameter

Parameters
  • hparam_chain (array) – Array of all the sets of hyperparameters of the MCMC, now in chains

  • kernel_name (string) – Name of the kernel

  • model_param_chain (array) – Array of all the sets of model parameters of the MCMC, now in chains

  • model_name (string) – Name of the model

  • LogL_chain (array) – Array containing all the Log Likelihood

  • mass (array, optional) – Array of all the masses for all planets produced by the MCMC, defaults to None

  • save_folder (str, optional) – Folder to save the plot, by default None. If None, the plot is not saved.

  • savefilename (str, optional) – Name of the file to save the plot, by default Mixing.

Return type

Mixing plots for each parameter

src.magpy_rv.plotting.offset_subtract(rv, flags, offsets)[source]

Function to return the RVs with offsets subtracted

Parameters
  • rv (array of floats) – y-axis array of the RVs

  • flags (array of floats) – array of flags representing offsets generated by the combine_data function

  • offsets (list or tuple of floats) – list or tuple of offsets ordered accordingly to the inputs in the combine_data function

Returns

y – array of RVs with offsets subtracted

Return type

array of floats

src.magpy_rv.plotting.phase_plot(time, rv, hparam, kernel_name, model_list, model_param, rv_err=None, keplerian_number=0, flags=None, xpred=None, residuals=False, xlabel='Time [BJD]', ylabel='RV [m/s]', legend=True, save_folder=None, savefilename=None)[source]

Function to plot the phase folded rv curve of the chosen keplerian model along with the data representing that model

Parameters
  • time (array of floats) – x-axis array of the observation times

  • rv (array of floats) – y-axis array of the RVs

  • hparam (dictionary) – dictionary of the hyperparameters

  • kernel_name (string) – name of the kernel

  • model_list (list of strings) – list of the models in use

  • model_param (dictionary) – dictionary of model parameters

  • rv_err (array of floats, optional) – array of rv errors, defaults to None

  • keplerian_number (int, optional) – number representing the chosen keplerian to plot, 0 to plot first keplerian, 1 to plot second keplerian etc… defaults to None

  • flags (array of floats, optional) – array of flags representing offsets generated by the combine_data function, defaults to None

  • xpred (array of floats, optional) – array of prediced times to be used for the smooth model, defaults to intervals of 0.1 between the max and min times

  • residuals (bool, optional) – enable the plotting of residuals, defaults to false

  • xlabel (string, optional) – label of x-axis, defaults to “time [BJD]”

  • ylabel (string, optional) – label of y-axis, defaults to “RV [m/s]”

  • legend (bool, optional) – enable the plotting of a legend, defaults to True

  • save_folder (string, optional) – folder to save the plot, defaults to None

  • savefilename (string, optional) – name of the save file, defaults to None

Return type

phase-folded plot of the chosen keplerian along with the subtracted data