PTO.database package

Submodules

PTO.database.NASA_exo module

PTO.database.NASA_exoplanet_archive module

class PTO.database.NASA_exoplanet_archive.NASA_Exoplanet_Archive_CompositeDefault(table: DataFrame | None = None, filename: str = 'CatalogComposite.pkl', drop_mode: str = 'drop', legacy_table: DataFrame | None = None)[source]

Bases: CatalogComposite

NASA_Exoplanet_Archive_CompositeDefault is a class that extends the CatalogComposite class to handle the loading and processing of the NASA Exoplanet Archive Composite table using the TAP protocol.

:meth:`.NASA_Exoplanet_Archive_CompositeDefault.load_API_table`

Loads the Table using the API system, in particular the TAP protocol. This method is rerun every week, but the output is saved and by default loaded instead of rerunning the TAP protocol.

:meth:`.NASA_Exoplanet_Archive_CompositeDefault._rename_columns`

Renames the columns in the pandas dataframe according to a predefined mapping.

:meth:`.NASA_Exoplanet_Archive_CompositeDefault._drop_columns`

Drops all columns that are irrelevant from the pandas dataframe.

:meth:`.NASA_Exoplanet_Archive_CompositeDefault._absolute_errors`

Reverses the sign of the lower error to an absolute value to ensure further functionality.

load_API_table(force_load=False) None[source]

Loads the Table using the API system, in particular the TAP protocol.

This is rerun every week, but the output is saved and by default loaded instead of rerunning the TAP protocol.

Parameters:

force_load (bool) –

Flag to trigger reloading of the TAP protocol.

If False, the self.filename is going to be loaded, and only if a week or more passed the TAP protocol is rerun. If True or if last run happened week or more ago, the TAP protocal is relaunched. (default: False)

class PTO.database.NASA_exoplanet_archive.NASA_Exoplanet_Archive_CompositeMostPrecise[source]

Bases: NASA_Exoplanet_Archive_FullTable

aggregate_most_precise_values()[source]
get_most_precise_value(group, column)[source]
class PTO.database.NASA_exoplanet_archive.NASA_Exoplanet_Archive_FullTable[source]

Bases: CatalogFull

NASA_Exoplanet_Archive_FullTable is a class that handles the loading and processing of the NASA Exoplanet Archive Composite table using the TAP protocol. It extends the CatalogFull class from the Catalog module.

load_API_table(force_load=False) None[source]

Loads the Table using the API system, in particular the TAP protocol. This method is rerun every week, but the output is saved and by default loaded instead of rerunning the TAP protocol.

_rename_columns() None[source]

Renames the columns in the pandas dataframe according to a predefined mapping.

_drop_columns() None[source]

Drops all columns that are irrelevant from the pandas dataframe.

get_most_precise_value(group, column)

Returns the most precise value for a given column within a group, based on the smallest error range.

aggregate_most_precise_values() None

Aggregates the most precise values for each planet by considering the error ranges for relevant columns.

load_API_table(force_load=False) None[source]

Loads the Table using the API system, in particular the TAP protocol.

This is rerun every week, but the output is saved and by default loaded instead of rerunning the TAP protocol

Parameters:

force_load (bool, optional) – Flag to trigger reloading of the TAP protocol, by default False. If False, the self.filename is going to loaded, and only if a week or more passed the TAP protocol is rerun. If True or if last run happened week or more ago, the TAP protocal is relaunched.

PTO.database.NASA_exoplanet_archive.transform_time_format(input_string)[source]

PTO.database.calculation module

class PTO.database.calculation.CalculationUtilities[source]

Bases: object

constraint_values(values: list, error_values: list, missing_variable: str) [<class 'pandas.Series'>, <class 'pandas.Series'>][source]

Apply constraints to values and their errors

Parameters:
  • values (list) – List of pandas Series containing values

  • error_values (list) – List of pandas Series containing error values

  • missing_variable (str) – Variable name to check constraints against

Returns:

Modified values and error values lists

Return type:

list, list

PTO.database.catalog module

class PTO.database.catalog.CatalogComposite(table: DataFrame | None = None, filename: str = 'CatalogComposite.pkl', drop_mode: str = 'drop', legacy_table: DataFrame | None = None)[source]

Bases: _Utilities, PlotUtilitiesComposite, CalculationUtilities

CatalogComposite class is a class that combines various utility classes and provides methods to handle and process exoplanet composite catalog data.

table

The main data table containing the catalog data.

Type:

pd.DataFrame | None

filename

The filename to save or load the catalog data. Default is ‘CatalogComposite.pkl’.

Type:

str

drop_mode

The mode to handle missing error bars. Can be ‘drop’ to drop rows without error bars or ‘replace’ to replace NaN error bars with 0. Default is ‘drop’.

Type:

str

legacy_table

An optional legacy data table for backward compatibility.

Type:

pd.DataFrame | None

_get_all() None[source]

Calculates the missing values that can be calculated in the catalog. - Logs a warning if drop_mode is ‘drop’ and drops all values without error bars. - Logs an info message if drop_mode is ‘replace’ and replaces NaN error bars with 0. - Fills in Earth and Jupiter Radius units in the catalog if empty. - Fills in semimajor axis over stellar radius ratio in the catalog if empty. - Checks for inclination and impact parameters values. - Calculates T_14 and related values.

__init__(table: DataFrame | None = None, filename: str = 'CatalogComposite.pkl', drop_mode: str = 'drop', legacy_table: DataFrame | None = None) None
drop_mode: str = 'drop'
filename: str = 'CatalogComposite.pkl'
legacy_table: DataFrame | None = None
table: DataFrame | None = None
class PTO.database.catalog.CatalogFull[source]

Bases: _Utilities, CalculationUtilities

CatalogComposite class is a class that combines various utility classes and provides methods to handle and process exoplanet full catalog data.

table

The main data table containing the catalog data.

Type:

pd.DataFrame | None

filename

The filename to save or load the catalog data. Default is ‘CatalogComposite.pkl’.

Type:

str

drop_mode

The mode to handle missing error bars. Can be ‘drop’ to drop rows without error bars or ‘replace’ to replace NaN error bars with 0. Default is ‘drop’.

Type:

str

legacy_table

An optional legacy data table for backward compatibility.

Type:

pd.DataFrame | None

_get_all() None[source]

Calculates the missing values that can be calculated in the catalog. - Logs a warning if drop_mode is ‘drop’ and drops all values without error bars. - Logs an info message if drop_mode is ‘replace’ and replaces NaN error bars with 0. - Fills in Earth and Jupiter Radius units in the catalog if empty. - Fills in semimajor axis over stellar radius ratio in the catalog if empty. - Checks for inclination and impact parameters values. - Calculates T_14 and related values.

drop_mode: str = 'drop'
filename: str = 'CatalogFull.pkl'
legacy_table: DataFrame | None = None
table: DataFrame | None = None

PTO.database.mappers module

PTO.database.plot module

class PTO.database.plot.ColorPopulationDiagram(theme: str, cmap: str, scatter: dict, highlight_scatter: dict)[source]

Bases: object

A class to define a theme for a color population diagram.

theme

The name of the theme.

Type:

str

cmap

The colormap used for the diagram.

Type:

str

scatter

The scatter plot data kwargs.

Type:

dict

highlight_scatter

The highlighted scatter plot kwargs.

Type:

dict

__init__(theme: str, cmap: str, scatter: dict, highlight_scatter: dict) None
cmap: str
highlight_scatter: dict
scatter: dict
theme: str
class PTO.database.plot.PlotUtilitiesComposite[source]

Bases: object

A utility class for creating and customizing population diagrams and highlighting samples on plots. .. method:: _set_labels(ax: plt.Axes, x_key: str, y_key: str)

Sets the x and y labels for the given axes based on the provided keys.

_set_scales(ax: plt.Axes, x_key: str, y_key: str)[source]

Sets the x and y scales for the given axes based on the provided keys.

plot_population_diagram(x_key: str, y_key: str, ax: plt.Axes | None = None, fig: plt.Figure | None = None, theme: str | ColorPopulationDiagram = 'blue', \*\*kwargs) [plt.Figure, plt.Axes][source]

Plots a population diagram on the given axes or creates new ones if not provided. Allows customization through themes and additional keyword arguments.

highlight_sample(x_key: str, y_key: str, ax: plt.Axes | None = None, fig: plt.Figure | None = None, theme: str | ColorPopulationDiagram = 'blue', \*\*kwargs) [plt.Figure, plt.Axes][source]

Highlights a sample on the population diagram. If axes are not provided, it creates a new population diagram first.

available_themes()[source]

Prints and returns the available themes for the population diagram.

available_themes()[source]
highlight_sample(x_key: str, y_key: str, ax: Axes | None = None, fig: Figure | None = None, populate: bool = False, theme: str | ColorPopulationDiagram = 'blue', sns_context: str = 'talk', **kwargs) [<class 'matplotlib.figure.Figure'>, <class 'matplotlib.axes._axes.Axes'>][source]

Highlights a sample on the population diagram.

This method highlights specific data points on an existing population diagram or creates a new one if axes are not provided. It uses the specified x and y keys for the data and allows customization through themes and additional keyword arguments for the scatter plot.

Parameters:
  • x_key (str) – The key to retrieve the x-axis data from the table.

  • y_key (str) – The key to retrieve the y-axis data from the table.

  • ax (plt.Axes | None, optional) – The matplotlib Axes object to plot on. If None, a new population diagram is created.

  • fig (plt.Figure | None, optional) – The matplotlib Figure object to plot on. If None, a new figure is created.

  • populate (bool) – Whether to populate the exoplanet population, by default False.

  • theme (str | ColorPopulationDiagram, optional) – The theme for highlighting the sample. Can be a string representing the theme name or an instance of ColorPopulationDiagram. Default is ‘blue’.

  • **kwargs – Additional keyword arguments for the scatter plot.

Returns:

The matplotlib Figure and Axes objects with the highlighted sample.

Return type:

[plt.Figure, plt.Axes]

plot_population_diagram(x_key: str, y_key: str, ax: Axes | None = None, fig: Figure | None = None, theme: str | ColorPopulationDiagram = 'blue', **kwargs) [<class 'matplotlib.figure.Figure'>, <class 'matplotlib.axes._axes.Axes'>][source]

Plots a population diagram on the given axes or creates new ones if not provided.

This method generates a population diagram using the specified x and y keys for the data. It allows customization through themes and additional keyword arguments for the scatter plot.

Parameters:
  • x_key (str) – The key to retrieve the x-axis data from the legacy_table.

  • y_key (str) – The key to retrieve the y-axis data from the legacy_table.

  • ax (plt.Axes | None, optional) – The matplotlib Axes object to plot on. If None, a new figure and axes are created.

  • fig (plt.Figure | None, optional) – The matplotlib Figure object to plot on. If None, a new figure is created.

  • theme (str | ColorPopulationDiagram, optional) – The theme for the population diagram. Can be a string representing the theme name or an instance of ColorPopulationDiagram. Default is ‘blue’.

  • **kwargs – Additional keyword arguments for the scatter plot.

Returns:

The matplotlib Figure and Axes objects with the population diagram.

Return type:

[plt.Figure, plt.Axes]

Module contents