species.plot package

Submodules

species.plot.plot_color module

Module with functions for creating color-magnitude and color-color plot.

species.plot.plot_color.plot_color_color(boxes: list, objects: Union[List[Tuple[str, Tuple[str, str], Tuple[str, str]]], List[Tuple[str, Tuple[str, str], Tuple[str, str], Optional[dict], Optional[dict]]], None] = None, mass_labels: Union[List[float], List[Tuple[float, str]], None] = None, teff_labels: Union[List[float], List[Tuple[float, str]], None] = None, companion_labels: bool = False, reddening: Optional[List[Tuple[Tuple[str, str], Tuple[str, str], Tuple[str, float], str, float, Tuple[float, float]]]] = None, field_range: Optional[Tuple[str, str]] = None, label_x: str = 'Color', label_y: str = 'Color', xlim: Optional[Tuple[float, float]] = None, ylim: Optional[Tuple[float, float]] = None, offset: Optional[Tuple[float, float]] = None, legend: Union[str, dict, Tuple[float, float], None] = 'upper left', figsize: Optional[Tuple[float, float]] = (4.0, 4.3), output: str = 'color-color.pdf') → None[source]

Function for creating a color-color diagram.

Parameters:
  • boxes (list(species.core.box.ColorColorBox, species.core.box.IsochroneBox, )) – Boxes with the color-color and isochrone data from photometric libraries, spectral libraries, and/or atmospheric models. The synthetic data have to be created with get_color_color(). These boxes contain synthetic colors for a given age and a range of masses.
  • objects (tuple(tuple(str, tuple(str, str), tuple(str, str)), ),) – tuple(tuple(str, tuple(str, str), tuple(str, str), dict, dict), ), None Tuple with individual objects. The objects require a tuple with their database tag, the two filter names for the first color, and the two filter names for the second color. Optionally, a dictionary with keyword arguments can be provided for the object’s marker and label, respectively. For example, {'marker': 'o', 'ms': 10} for the marker and {'ha': 'left', 'va': 'bottom', 'xytext': (5, 5)}) for the label. Not used if set to None.
  • mass_labels (list(float, ), list(tuple(float, str), ), None) – Plot labels with masses next to the isochrone data of models. The list with masses has to be provided in Jupiter mass. Alternatively, a list of tuples can be provided with the planet mass and position of the label (‘left’ or ‘right), for example [(10., 'left'), (20., 'right')]. No labels are shown if set to None.
  • teff_labels (list(float, ), list(tuple(float, str), ), None) – Plot labels with temperatures (K) next to the synthetic Planck photometry. Alternatively, a list of tuples can be provided with the planet mass and position of the label (‘left’ or ‘right), for example [(1000., 'left'), (1200., 'right')]. No labels are shown if set to None.
  • companion_labels (bool) – Plot labels with the names of the directly imaged companions.
  • reddening (list(tuple(tuple(str, str), tuple(str, str), tuple(str, float), str, float,) – tuple(float, float)), None Include reddening arrows by providing a list with tuples. Each tuple contains the filter names for the color, the filter name for the magnitude, the particle radius (um), and the start position (color, mag) of the arrow in the plot, so (filter_color_1, filter_color_2, filter_mag, composition, radius, (x_pos, y_pos)). The composition can be either ‘Fe’ or ‘MgSiO3’ (both with crystalline structure). The parameter is not used if set to None.
  • field_range (tuple(str, str), None) – Range of the discrete colorbar for the field dwarfs. The tuple should contain the lower and upper value (‘early M’, ‘late M’, ‘early L’, ‘late L’, ‘early T’, ‘late T’, ‘early Y). The full range is used if set to None.
  • label_x (str) – Label for the x-axis.
  • label_y (str) – Label for the y-axis.
  • xlim (tuple(float, float)) – Limits for the x-axis.
  • ylim (tuple(float, float)) – Limits for the y-axis.
  • offset (tuple(float, float), None) – Offset of the x- and y-axis label.
  • legend (str, tuple(float, float), dict, None) – Legend position or keyword arguments. No legend is shown if set to None.
  • figsize (tuple(float, float)) – Figure size.
  • output (str) – Output filename.
Returns:

None

Return type:

NoneType

species.plot.plot_color.plot_color_magnitude(boxes: list, objects: Union[List[Tuple[str, str, str, str]], List[Tuple[str, str, str, str, Optional[dict], Optional[dict]]], None] = None, mass_labels: Union[List[float], List[Tuple[float, str]], None] = None, teff_labels: Union[List[float], List[Tuple[float, str]], None] = None, companion_labels: bool = False, accretion: bool = False, reddening: Optional[List[Tuple[Tuple[str, str], Tuple[str, float], str, float, Tuple[float, float]]]] = None, field_range: Optional[Tuple[str, str]] = None, label_x: str = 'Color', label_y: str = 'Absolute magnitude', xlim: Optional[Tuple[float, float]] = None, ylim: Optional[Tuple[float, float]] = None, offset: Optional[Tuple[float, float]] = None, legend: Union[str, dict, Tuple[float, float], None] = 'upper left', output: str = 'color-magnitude.pdf') → None[source]

Function for creating a color-magnitude diagram.

Parameters:
  • boxes (list(species.core.box.ColorMagBox, species.core.box.IsochroneBox, )) – Boxes with the color-magnitude and isochrone data from photometric libraries, spectral libraries, and/or atmospheric models. The synthetic data have to be created with get_color_magnitude(). These boxes contain synthetic colors and magnitudes for a given age and a range of masses.
  • objects (list(tuple(str, str, str, str), ),) – list(tuple(str, str, str, str, dict, dict), ), None Tuple with individual objects. The objects require a tuple with their database tag, the two filter names for the color, and the filter name for the absolute magnitude. Optionally, a dictionary with keyword arguments can be provided for the object’s marker and label, respectively. For example, {'marker': 'o', 'ms': 10} for the marker and {'ha': 'left', 'va': 'bottom', 'xytext': (5, 5)}) for the label. Not used if set to None.
  • mass_labels (list(float, ), list(tuple(float, str), ), None) – Plot labels with masses next to the isochrone data of models. The list with masses has to be provided in Jupiter mass. Alternatively, a list of tuples can be provided with the planet mass and position of the label (‘left’ or ‘right), for example [(10., 'left'), (20., 'right')]. No labels are shown if set to None.
  • teff_labels (list(float, ), list(tuple(float, str), ), None) – Plot labels with temperatures (K) next to the synthetic Planck photometry. Alternatively, a list of tuples can be provided with the planet mass and position of the label (‘left’ or ‘right), for example [(1000., 'left'), (1200., 'right')]. No labels are shown if set to None.
  • companion_labels (bool) – Plot labels with the names of the directly imaged companions.
  • accretion (bool) – Plot accreting, directly imaged objects with a different symbol than the regular, directly imaged objects. The object names from objects will be compared with the data from get_data() to check if a companion is accreting or not.
  • reddening (list(tuple(tuple(str, str), tuple(str, float), str, float,) – tuple(float, float)), None Include reddening arrows by providing a list with tuples. Each tuple contains the filter names for the color, the filter name and value of the magnitude, the particle radius (um), and the start position (color, mag) of the arrow in the plot, so ((filter_color_1, filter_color_2), (filter_mag, mag_value), composition, radius, (x_pos, y_pos)). The composition can be either 'Fe' or 'MgSiO3' (both with crystalline structure). Both xlim and ylim need to be set for the correct rotation of the reddening label. The parameter is not used if set to None.
  • field_range (tuple(str, str), None) – Range of the discrete colorbar for the field dwarfs. The tuple should contain the lower and upper value (‘early M’, ‘late M’, ‘early L’, ‘late L’, ‘early T’, ‘late T’, ‘early Y). The full range is used if set to None.
  • label_x (str) – Label for the x-axis.
  • label_y (str) – Label for the y-axis.
  • xlim (tuple(float, float), None) – Limits for the x-axis. Not used if set to None.
  • ylim (tuple(float, float), None) – Limits for the y-axis. Not used if set to None.
  • offset (tuple(float, float), None) – Offset of the x- and y-axis label.
  • legend (str, tuple(float, float), dict, None) – Legend position or keyword arguments. No legend is shown if set to None.
  • output (str) – Output filename.
Returns:

None

Return type:

NoneType

species.plot.plot_comparison module

Module with a function for plotting results from the empirical spectral analysis.

species.plot.plot_comparison.plot_empirical_spectra(tag: str, n_spectra: int, xlim: Optional[Tuple[float, float]] = None, ylim: Optional[Tuple[float, float]] = None, title: Optional[str] = None, offset: Optional[Tuple[float, float]] = None, figsize: Optional[Tuple[float, float]] = (4.0, 2.5), output: str = 'empirical.pdf')[source]

Function for plotting the results from the empirical spectrum comparison.

Parameters:
  • tag (str) – Database tag where the results from the empirical comparison with spectral_type are stored.
  • n_spectra (int) – The number of spectra with the lowest goodness-of-fit statistic that will be plotted in comparison with the data.
  • xlim (tuple(float, float)) – Limits of the spectral type axis.
  • ylim (tuple(float, float)) – Limits of the goodness-of-fit axis.
  • title (str) – Plot title.
  • offset (tuple(float, float)) – Offset for the label of the x- and y-axis.
  • figsize (tuple(float, float)) – Figure size.
  • output (str) – Output filename.
Returns:

None

Return type:

NoneType

species.plot.plot_comparison.plot_grid_statistic(tag: str, xlim: Optional[Tuple[float, float]] = None, ylim: Optional[Tuple[float, float]] = None, title: Optional[str] = None, offset: Optional[Tuple[float, float]] = None, figsize: Optional[Tuple[float, float]] = (4.0, 2.5), output: str = 'grid_statistic.pdf')[source]

Function for plotting the results from the empirical spectrum comparison.

Parameters:
  • tag (str) – Database tag where the results from the empirical comparison with spectral_type are stored.
  • xlim (tuple(float, float)) – Limits of the spectral type axis.
  • ylim (tuple(float, float)) – Limits of the goodness-of-fit axis.
  • title (str) – Plot title.
  • offset (tuple(float, float)) – Offset for the label of the x- and y-axis.
  • figsize (tuple(float, float)) – Figure size.
  • output (str) – Output filename.
Returns:

None

Return type:

NoneType

species.plot.plot_comparison.plot_statistic(tag: str, xlim: Optional[Tuple[float, float]] = None, ylim: Optional[Tuple[float, float]] = None, title: Optional[str] = None, offset: Optional[Tuple[float, float]] = None, figsize: Optional[Tuple[float, float]] = (4.0, 2.5), output: str = 'statistic.pdf')[source]

Function for plotting the goodness-of-fit statistic of the empirical spectral comparison.

Parameters:
  • tag (str) – Database tag where the results from the empirical comparison with spectral_type are stored.
  • xlim (tuple(float, float)) – Limits of the spectral type axis in numbers (i.e. 0=M0, 5=M5, 10=L0, etc.).
  • ylim (tuple(float, float)) – Limits of the goodness-of-fit axis.
  • title (str) – Plot title.
  • offset (tuple(float, float)) – Offset for the label of the x- and y-axis.
  • figsize (tuple(float, float)) – Figure size.
  • output (str) – Output filename.
Returns:

None

Return type:

NoneType

species.plot.plot_mcmc module

Module for plotting MCMC results.

species.plot.plot_mcmc.plot_extinction(tag: str, burnin: Optional[int] = None, random: Optional[int] = None, wavel_range: Optional[Tuple[float, float]] = None, xlim: Optional[Tuple[float, float]] = None, ylim: Optional[Tuple[float, float]] = None, offset: Optional[Tuple[float, float]] = None, output: str = 'extinction.pdf') → None[source]

Function to plot random samples of the extinction, either from fitting a size distribution of enstatite grains (dust_radius, dust_sigma, and dust_ext), or from fitting ISM extinction (ism_ext and optionally ism_red).

Parameters:
  • tag (str) – Database tag with the samples.
  • burnin (int, None) – Number of burnin steps to exclude. All samples are used if set to None. Only required after running MCMC with run_mcmc().
  • random (int, None) – Number of randomly selected samples. All samples are used if set to None.
  • wavel_range (tuple(float, float), None) – Wavelength range (um) for the extinction. The default wavelength range (0.4, 10.) is used if set to None.
  • xlim (tuple(float, float), None) – Limits of the wavelength axis. The range is set automatically if set to None.
  • ylim (tuple(float, float)) – Limits of the extinction axis. The range is set automatically if set to None.
  • offset (tuple(float, float), None) – Offset of the x- and y-axis label. Default values are used if set to None.
  • output (str) – Output filename.
Returns:

None

Return type:

NoneType

species.plot.plot_mcmc.plot_mag_posterior(tag: str, filter_name: str, burnin: int = None, xlim: Tuple[float, float] = None, output: str = 'mag_posterior.pdf') → None[source]

Function to plot the posterior distribution of the synthetic magnitudes.

Parameters:
  • tag (str) – Database tag with the posterior samples.
  • filter_name (str) – Filter name.
  • burnin (int, None) – Number of burnin steps to exclude. All samples are used if set to None.
  • xlim (tuple(float, float), None) – Axis limits. Automatically set if set to None.
  • output (str) – Output filename.
Returns:

None

Return type:

NoneType

species.plot.plot_mcmc.plot_posterior(tag: str, burnin: Optional[int] = None, title: Optional[str] = None, offset: Optional[Tuple[float, float]] = None, title_fmt: Union[str, List[str]] = '.2f', limits: Optional[List[Tuple[float, float]]] = None, max_posterior: bool = False, inc_luminosity: bool = False, inc_mass: bool = False, output: str = 'posterior.pdf') → None[source]

Function to plot the posterior distribution.

Parameters:
  • tag (str) – Database tag with the samples.
  • burnin (int, None) – Number of burnin steps to exclude. All samples are used if set to None.
  • title (str, None) – Plot title. No title is shown if set to None.
  • offset (tuple(float, float), None) – Offset of the x- and y-axis label. Default values are used if set to None.
  • title_fmt (str, list(str)) – Format of the titles above the 1D distributions. Either a single string, which will be used for all parameters, or a list with the title format for each parameter separately (in the order as shown in the corner plot).
  • limits (list(tuple(float, float), ), None) – Axis limits of all parameters. Automatically set if set to None.
  • max_posterior (bool) – Plot the position of the sample with the maximum posterior probability.
  • inc_luminosity (bool) – Include the log10 of the luminosity in the posterior plot as calculated from the effective temperature and radius.
  • inc_mass (bool) – Include the mass in the posterior plot as calculated from the surface gravity and radius.
  • output (str) – Output filename.
Returns:

None

Return type:

NoneType

species.plot.plot_mcmc.plot_size_distributions(tag: str, burnin: Optional[int] = None, random: Optional[int] = None, offset: Optional[Tuple[float, float]] = None, output: str = 'size_distributions.pdf') → None[source]

Function to plot random samples of the log-normal or power-law size distributions.

Parameters:
  • tag (str) – Database tag with the samples.
  • burnin (int, None) – Number of burnin steps to exclude. All samples are used if set to None. Only required after running MCMC with run_mcmc().
  • random (int, None) – Number of randomly selected samples. All samples are used if set to None.
  • offset (tuple(float, float), None) – Offset of the x- and y-axis label. Default values are used if set to None.
  • output (str) – Output filename.
Returns:

None

Return type:

NoneType

species.plot.plot_mcmc.plot_walkers(tag: str, nsteps: Optional[int] = None, offset: Optional[Tuple[float, float]] = None, output: str = 'walkers.pdf') → None[source]

Function to plot the step history of the walkers.

Parameters:
  • tag (str) – Database tag with the samples.
  • nsteps (int, None) – Number of steps that are plotted. All steps are plotted if set to None.
  • offset (tuple(float, float), None) – Offset of the x- and y-axis label. Default values are used if set to None.
  • output (str) – Output filename.
Returns:

None

Return type:

NoneType

species.plot.plot_spectrum module

Module with a function for plotting spectra.

species.plot.plot_spectrum.plot_spectrum(boxes: list, filters: Optional[List[str]] = None, residuals: Optional[species.core.box.ResidualsBox] = None, plot_kwargs: Optional[List[Optional[dict]]] = None, xlim: Optional[Tuple[float, float]] = None, ylim: Optional[Tuple[float, float]] = None, ylim_res: Optional[Tuple[float, float]] = None, scale: Optional[Tuple[str, str]] = None, title: Optional[str] = None, offset: Optional[Tuple[float, float]] = None, legend: Union[str, dict, Tuple[float, float], List[Union[str, dict, Tuple[float, float], None]], None] = None, figsize: Optional[Tuple[float, float]] = (10.0, 5.0), object_type: str = 'planet', quantity: str = 'flux density', output: str = 'spectrum.pdf')[source]
Parameters:
  • boxes (list(species.core.box, )) – Boxes with data.
  • filters (list(str, ), None) – Filter IDs for which the transmission profile is plotted. Not plotted if set to None.
  • residuals (species.core.box.ResidualsBox, None) – Box with residuals of a fit. Not plotted if set to None.
  • plot_kwargs (list(dict, ), None) –

    List with dictionaries of keyword arguments for each box. For example, if the boxes are a ModelBox and ObjectBox:

    plot_kwargs=[{'ls': '-', 'lw': 1., 'color': 'black'},
                 {'spectrum_1': {'marker': 'o', 'ms': 3., 'color': 'tab:brown', 'ls': 'none'},
                  'spectrum_2': {'marker': 'o', 'ms': 3., 'color': 'tab:blue', 'ls': 'none'},
                  'Paranal/SPHERE.IRDIS_D_H23_3': {'marker': 's', 'ms': 4., 'color': 'tab:cyan', 'ls': 'none'},
                  'Paranal/SPHERE.IRDIS_D_K12_1': [{'marker': 's', 'ms': 4., 'color': 'tab:orange', 'ls': 'none'},
                                                   {'marker': 's', 'ms': 4., 'color': 'tab:red', 'ls': 'none'}],
                  'Paranal/NACO.Lp': {'marker': 's', 'ms': 4., 'color': 'tab:green', 'ls': 'none'},
                  'Paranal/NACO.Mp': {'marker': 's', 'ms': 4., 'color': 'tab:green', 'ls': 'none'}}]
    

    For an ObjectBox, the dictionary contains items for the different spectrum and filter names stored with add_object(). In case both and ObjectBox and a SynphotBox are provided, then the latter can be set to None in order to use the same (but open) symbols as the data from the ObjectBox. Note that if a filter name is duplicated in an ObjectBox (Paranal/SPHERE.IRDIS_D_K12_1 in the example) then a list with two dictionaries should be provided. Colors are automatically chosen if plot_kwargs is set to None.

  • xlim (tuple(float, float)) – Limits of the wavelength axis.
  • ylim (tuple(float, float)) – Limits of the flux axis.
  • ylim_res (tuple(float, float), None) – Limits of the residuals axis. Automatically chosen (based on the minimum and maximum residual value) if set to None.
  • scale (tuple(str, str), None) – Scale of the x and y axes (‘linear’ or ‘log’). The scale is set to ('linear', 'linear') if set to None.
  • title (str) – Title.
  • offset (tuple(float, float)) – Offset for the label of the x- and y-axis.
  • legend (str, tuple, dict, list(dict, dict), None) – Location of the legend (str or tuple(float, float)) or a dictionary with the **kwargs of matplotlib.pyplot.legend, for example {'loc': 'upper left', 'fontsize: 12.}. Alternatively, a list with two values can be provided to separate the model and data handles in two legends. Each of these two elements can be set to None. For example, [None, {'loc': 'upper left', 'fontsize: 12.}], if only the data points should be included in a legend.
  • figsize (tuple(float, float)) – Figure size.
  • object_type (str) – Object type (‘planet’ or ‘star’). With ‘planet’, the radius and mass are expressed in Jupiter units. With ‘star’, the radius and mass are expressed in solar units.
  • quantity (str) – The quantity of the y-axis (‘flux density’, ‘flux’, or ‘magnitude’).
  • output (str) – Output filename.
Returns:

None

Return type:

NoneType

Module contents