Plotting Class

The plotting module of ForMoSA:

class ForMoSA.plotting.plotting_class.ComplexRadar(fig, variables, ranges, n_ordinate_levels=6)[source]

Class to create Radar plots with asymmetric error bars.

Author: Paulina Palma-Bifani, Matthieu Ravet, Allan Denis

Adapted from Damian Cummins: https://github.com/DamianCummins/statsbomb-football-event-visualisations/blob/master/Statsbomb%20Womens%20World%20Cup%202019%20visualisation.ipynb

Initialize class.

Parameters:
  • fig (object) – matplotlib figure object

  • variables (list) – list of parameters to plot

  • ranges (list(tuple)) – upper and lower limits for each parameters

  • n_ordinate_levels (int) – (default = 6) number of gridlines in the plot

Returns:

None

fill(data, *args, **kw)[source]

Add symmetric error bars to the plot.

Parameters:
  • data (list) – best value for each parameter

  • *args – Variable length argument list.

  • **kw – Arbitrary keyword arguments.

Returns:

None

fill_between(list_down, list_up, *args, **kw)[source]

Add asymmetric error bars to the plot.

Parameters:
  • list_down (list) – list of lower error bars

  • list_up (list) – list of upper error bars

  • *args – Variable length argument list.

  • **kw – Arbitrary keyword arguments.

Returns:

None

plot(data, *args, **kw)[source]

Function to display the plot.

Parameters:
  • data (list) – best value for each parameter

  • *args – Variable length argument list.

  • **kw – Arbitrary keyword arguments.

Returns:

None

scale_data(data, ranges)[source]

Function to check that lower and upper limits are correctly ordered. It scales data[1:] to ranges[0]

Parameters:
  • data (list) – best value for each parameter

  • ranges (list(tuple)) – upper and lower limits for each parameters

  • *args – Variable length argument list.

  • **kw – Arbitrary keyword arguments.

Returns:

None

class ForMoSA.plotting.plotting_class.PlottingForMoSA(config_file_path=None, color_out='blue', global_params=None)[source]

Class containing all the plotting functionalities of ForMoSA.

Author: Paulina Palma-Bifani, Simon Petrus, Matthieu Ravet and Allan Denis

Initialize class by inheriting the global parameter class of ForMoSA.

Parameters:
  • config_file_path (str) – path to the config.ini file currently used

  • color_out (str) – color to use for the model

  • global_params (GlobFile, optional) – already-initialized GlobFile object

Returns:

None

compute_ccf_single_rv(rv, wav_mod, flx_mod, flx_mod_no_rv, res_mod_obs, wav_obs, flx_obs, res_obs, transm_obs, Sf, indobs)[source]

Compute a cross-correlation coefficient for a single rv. This function is used for the parallelised ccf computation

Parameters:
  • rv (float) – rv value to apply to the model

  • wav_mod (ndarray) – wavelength grid of the model

  • flx_mod (ndarray) – flux of the model

  • flx_mod_no_rv (ndarray) – flx of the model at 0 rv (used for autocorrelation)

  • res_mod_obs (ndarray) – resolution of the model interpolated onto obs_wav

  • wav_obs (ndarray) – wavelength grid of the observation

  • flx_obs (ndarray) – flux of the observation

  • res_obs (ndarray) – resolution of the observation

  • transm_obs (ndarray) – atmospheric and instrumental transmission

  • Sf (float) – L2 norm of the observation

  • indobs (int) – Index of the current observation loop

Returns:

cross-correlation coefficient - acf (float) : autocorrelation coefficient - logL (float) : logL value

Return type:

  • ccf (float)

plot_HiRes_comp_model(figsize=(10, 5), indobs=0)[source]

Specific function to plot the best fit comparing with the data for high-resolution spectroscopy.

Parameters:
  • figsize (tuple) – (default = (10, 5)) Size of the plot

  • indobs (int) – Index of the current observation loop

Returns:

matplotlib figure object - fig, ax (object): matplotlib axes objects - flx_obs_broadened (array): Flux of the observation with all fitted contributions removed + broadened at vsini

Return type:

  • fig1, ax1 (object)

plot_PT_chem(PT_chem, photosphere={}, par_to_plot=['temperature'], figsize=(10, 5))[source]

Function to plot the Pressure-Temperature profiles and associated vmr/molecular profiles.

Parameters:
  • PT_chem (dict) – Dictionary containing the pressure, temperature and chemical arrays

  • photosphere (dict) – Dictionary containing the P/T profile of the photosphere

  • par_to_plot (list(str)) – Key list of the parameters from the PT_chem you want to plot

Returns:

matplotlib figure object - ax (object): matplotlib axes objects - ax_twin (object): matplotlib axes objects

Return type:

  • fig (object)

plot_ccf(rv_grid=[-300, 300], rv_step=0.5, figsize=(10, 5), window_normalisation=100, continuum_res=500, vsini=[], wav_mod_nativ=[], flx_mod_nativ=[], res_mod_nativ=[], indobs=0, plot=True, map_rv_vsini=False, flx_obs=[], wav_obs=[], res_obs=[], transm_obs=[])[source]

Plot the cross-correlation function. It is used for high resolution spectroscopy.

Parameters:
  • figsize (tuple) – (default = (10, 5)) Size of the plot

  • rv_grid (list) – (default = [-300,300]) Maximum and minumum values of the radial velocity shift (in km/s)

  • rv_step (float) – (default = 0.5) Radial velocity shift steps (in km/s)

  • figsize – (default = (10,5)) Size of the figure to plot

  • window_normalisation (int) – (default = 100) Window used to exclude around the peak of the CCF for noise estimation

  • vsini (float) – (default = []) v.sin(i) used to apply to the model (in the case the user wants to apply another v.sin(i) than the v.sin(i) estimated by the NS)

  • wav_mod_nativ (array) – (default = []) Wavelength of the model to cross-correlate with the data in the case the user wants to use the rv_vsini map function or a different model (individual molecule for example)

  • flx_mod_nativ (array) – (default = []) Flux of the model to cross-correlate with the data in the case the user wants to use the rv_vsini map function or a different model (individual molecule for example)

  • res_mod_nativ (array) – (default = []) Resolution of the model to cross-correlate with the data in the case the user wants to use the rv_vsini map function or a different model (individual molecule for example)

  • indobs (int) – (default = 0) Index of the current observation loop

  • plot (bool) – (default = True) Whether to plot the ccf

  • map_rv_vsini (bool) – (default = False) Whether the user wants to use the rv_vsini map function

  • flx_obs (array) – (default = []) Data in the case the user wants to use the rv_vsini map function. This avoids repeating the same operation for each v.sini defined by the v.sini grid and sames some time

  • wav_obs (array) – (default = []) Wavelength in the case the user wants to use the rv_vsini map function. This avoids repeating the same operation for each v.sini defined by the v.sini grid and sames some time

  • res_obs (array) – (default = []) Resolution in the case the user wants to use the rv_vsini map function. This avoids repeating the same operation for each v.sini defined by the v.sini grid and sames some time

  • transm_obs (array) – (default = []) Transmission in the case the user wants to use the rv_vsini map function. This avoids repeating the same operation for each v.sini defined by the v.sini grid and sames some time

Returns:

matplotlib figure object - ax1 (object): matplotlib axes objects - rv_grid (list): Radial velocity grid - ccf_norm (list): Cross-correlation function - acf_norm (list): Auto-correlation function

Return type:

  • fig1 (object)

plot_chains(figsize=(7, 15), show_weights=True)[source]

Plot to check the convergence of the posterior chains. Multiple (sub-)axis plot.

Parameters:
  • figsize (tuple) – (default = (7, 15)) size of the plot

  • show_weights (bool) – True or False if you want to show the weights on the chain

Returns:

matplotlib figure object - ax (object) : matplotlib axes objects

Return type:

  • fig (object)

plot_corner(levels_sig=[0.997, 0.95, 0.68], bins=100, quantiles=(0.16, 0.5, 0.84), figsize=(15, 15))[source]

Function to display the corner plot

Parameters:
  • levels_sig (list) – (default = [0.997, 0.95, 0.68]) 1, 2 and 3 sigma contour levels of the corner plot

  • bins (int) – (default = 100) number of bins for the posteriors

  • quantiles (list) – (default = (0.16, 0.5, 0.84)) mean +- sigma to report the posterior values

  • burn_in (int) – (default = 0) number of steps to remove from the plot

Returns:

matplotlib figure object

Return type:

  • fig (object)

plot_fit(figsize=(13, 7), uncert='no', trans='no', logx='no', logy='no', norm='no')[source]

Plot the best fit comparing with the data.

Parameters:
  • figsize (tuple) – (default = (10, 5)) Size of the plot

  • uncert (str) – (default = no) ‘yes’ or ‘no’ to plot spectra with associated error bars

  • trans (str) – (default = no) ‘yes’ or ‘no’ to plot transmision curves for photometry

  • logx (str) – (default = no) ‘yes’ or ‘no’ to plot the wavelength in log scale

  • logy (str) – (default = no) ‘yes’ or ‘no’ to plot the flux in log scale

  • norm (str) – (default = no) ‘yes’ or ‘no’ to plot the normalized spectra

Returns:

matplotlib figure object - ax (object): matplotlib axes objects, main spectra plot - axr (object): matplotlib axes objects, residuals - axr2 (object): matplotlib axes objects, right side density histogram

Return type:

  • fig (object)

plot_map_rv_vsini(rv_grid=[-100, 100], rv_step=1.0, vsini_grid=[1, 100], vsini_step=1.0, wav_mod_nativ=[], flx_mod_nativ=[], res_mod_nativ=[], indobs=0, continuum_res=500)[source]

Plot a RV v.sini map. It is used for high resolution spectroscopy

Parameters:
  • rv_grid (list) – (default = [-100,100]) Maximum and minumum values of the radial velocity shift (in km/s)

  • rv_step (float) – (default = 0.5) Radial velocity shift steps (in km/s)

  • vsini_grid (list) – (default = [1,100]) Maximum and minimum values of the v.sini broadening (in km/s)

  • vsini_step (float) – (default = 1.0) v.sini broadening steps (in km/s)

  • wav_mod_nativ (array) – (default = []) Wavelength of the model to cross-correlate with the data in the case the user wants to use a different model (individual molecule for example)

  • flx_mod_nativ (array) – (default = []) Flux of the model to cross-correlate with the data in the case the user wants to use a different model (individual molecule for example)

  • res_mod_nativ (array) – (default = []) Resolution of the model to cross-correlate with the data in the case the user wants to use a different model (individual molecule for example)

Returns:

2D cross correlation map of rv and v.sini - fig (object) : matplotlib figure object - ax (object) : matplotlib axes objects

Return type:

  • ccf_map (ndarray)

plot_radar(ranges, label='', quantiles=[0.16, 0.5, 0.84])[source]

Radar plot to check the distribution of the parameters. Useful to compare different models.

Parameters:
  • ranges (list(tuple)) – upper and lower limits for each parameters

  • label (str) – (default = ‘’) label of the plot

  • quantiles (list) – (default = (0.16, 0.5, 0.84)) mean +- sigma to report the posterior values

Returns:

matplotlib figure object - radar.ax (object) : matplotlib radar class axes object

Return type:

  • fig (object)