Package resokit.query

The ResoKit.query package includes tools to make online queries.

resokit.query.build_query(source: str, select: str = '*', alias: str = '', conditions: str = '', order_by: str = '') str[source]

Construct a very simple query for the specified dataset source.

For more information on how to write the conditions, visit: - EU information: http://voparis-tap-planeto.obspm.fr/__system__/dc_tables/show/tableinfo/exoplanet.epn_core - NASA information: https://exoplanetarchive.ipac.caltech.edu/docs/TAP/usingTAP.html#sync-query

Parameters:
  • source (str) – Data source identifier (‘eu’ or ‘nasa’).

  • select (str, optional. Default: '*'.) – Columns to select in the query (default is ‘*’).

  • alias (str, optional. Default: ''.) – Optional alias for the table or columns.

  • conditions (list of str, optional. Default: ''.) – Multiple (list) conditions are grouped with ‘AND’ clause. If ‘OR’ is needed, it must be written explicitly. List of conditions for WHERE clause.

  • order_by (str, optional. Default: ''.) – Column name for ORDER BY clause.

Returns:

Constructed query string.

Return type:

str

resokit.query.execute_query(source: str, query: str, cache: bool = True, to_bytes: bool = False, verbose: bool = True, soft: bool = False) bytes | DataFrame[source]

Execute a query on the specified dataset source.

This function attempts to follow all TAPs. For more information on how to write the conditions, visit: - EU information: http://voparis-tap-planeto.obspm.fr/__system__/dc_tables/show/tableinfo/exoplanet.epn_core - NASA information: https://exoplanetarchive.ipac.caltech.edu/docs/TAP/usingTAP.html#sync-query

Parameters:
  • source (str) – Data source identifier (‘eu’ or ‘nasa’).

  • query (str) – Query string to execute.

  • cache (bool, optional. Default: True.) – Cache the query and result (dataframe) in case of repetition during this session.

  • to_bytes (bool, optional. Default: False) – Return bytes instead of pandas dataframe.

  • verbose (bool, optional. Default: True.) – Print messages

  • soft (bool, optional. Default = False.) – Whether to perform a query that do not includes a WHERE statement. This is not recommended, as it would download the full databases. Use resokit.datasets.download(…) for this.

Returns:

Resulting dataset as a pandas DataFrame, or bytes if requested.

Return type:

Union[bytes, pd.DataFrame]

resokit.query.query_system(source: str, star_name: str = '', planet_name: str = '', default_flag: int = 1, controversial_flag: int = 0, cache: bool = True, verbose: bool = True, as_frame: bool = False, raw: bool = False) DataFrame | ResokitDataFrame | StaticSystem[source]

Query the online dataset based on specified filters.

Parameters:
  • source (str) – Data source identifier (‘eu’ or ‘nasa’).

  • star_name (str, optional. Default: ''.) – Host star or system name.

  • planet_name (str, optional. Default: ''.) – Planet name.

  • default_flag (int, optional. Default: 1.) – Restrict to default values in NASA dataset. If equal to 0, only returns non default parameter set for each planet. If equal to 1, only returns default parameter set for each planet. If None, all planet sets (default and not) are returned.

  • controversial_flag (int, optional. Default: 0.) – Restrict to controversial planets in NASA dataset. If equal to 0, only returns confirmed planets. If equal to 1, only returns controversial planets. If None, all planets (confirmed and not) are returned.

  • cache (bool, optional. Default: True.) – Cache the query and result in case of repetition during this session.

  • verbose (bool, optional. Default: True.) – Print query information.

  • as_frame (bool, optional. Default: False.) – Whether to return the dataset in a ResokitDataFrame format (True), or a StaticSystem format (False).

  • raw (bool, optional. Default = False.) – Whether to return a pandas DataFrame of the query result. Overrides as_frame parameter.

Returns:

data – Results of the query in a ResokitDataFrame (if as_resokit=True), or StaticSystem, or pandas.DataFrame (if raw=True).

Return type:

DataFrame, ResokitDataFrame or StaticSystem