jplsbdb.SBDBQuery

jplsbdb.SBDBQuery(
    info=None,
    fields='pdes',
    sort=None,
    limit=None,
    limit_from=None,
    full_prec=False,
    sb_ns=None,
    sb_kind=None,
    sb_group=None,
    sb_class=None,
    sb_sat=None,
    sb_xfrag=None,
    sb_defs=None,
    sb_cdata=None,
)

Class to handle SBDB queries.

Notes

It is based on SBDB Query API Version 1.0 (Aug 2021), which is the most recent version as of 2024 Sept.

This will get matured/generated in the future similar to astroquery.jplsbdb. This is at a primitive stage to query all information specifically for “all objects”.

Parameters

info : {"count", "field", "all"}, default = None

When "count" is selected, return the number of objects available in the SBDB. When "field" is selected, return all available output fields. If "all" is selected, output count and field results. See mode I section in the link below for details. https://ssd-api.jpl.nasa.gov/doc/sbdb_query.html If provided, mode I will be used, and all other parameters except sp_defs will completely be ignored. Default is None.

fields : str (comma-separated) or list of str, default = 'pdes'

List of fields to be output. If no fields are specified, only the count (number of records matching found) is output. Field names are case-sensitive.

Some convenient options from SBDB_FIELDS are available:

  • "*": Literally all fields
  • "all": "*" without the ignore columns.
  • "ignore": Columns that are extremely unlikely to be used in practice.
  • "simple": Columns that are most likely to be used in practice.
  • "lite": num(columns) between “all” and “simple”…
  • "simple_ast": "simple" without the comet-related columns.
  • "simple_com": "simple" without the asteroid-related columns.
  • "lite_ast": "lite" without the comet-related columns.
  • "lite_com": "lite" without the asteroid-related columns.
  • "all_ast": "all" without the comet-related columns.
  • "all_com": "all" without the asteroid-related columns.

Default is "pdes".

sort : str, default = None

Sort results by the specified field(s). Up to three fields can be specified, separated by commas (,) and descending direction can be specified by prefixing the field name with minus (-) (ascending is the default).

limit : int, default = None

Limit data to the first limit results (where limit is the specified number and must be an integer value greater than zero). Default is None, which returns all matching results.

limit_from : int, default = None

Limit data starting from the specified record (where zero is the first record). Useful for “paging” through large datasets. Requires limit. CAUTION: it is possible for the underlying database to change between API calls.

full_prec : bool, int optional, default = False

Output data in full precision (normally, data are returned in reduced precision for display purposes). Default is False.

sb_ns : str, default = None

Numbered status: restrict query results to either numbered ("n") or unnumbered ("u") small-bodies.

sb_kind : str, default = None

Limit results to either asteroids-only ("a") or comets-only ("c").

sb_group : str, default = None

Limit results to NEOs-only ("neo") or PHAs-only ("pha").

sb_class : str (comma-separated) or list of str, default = None

Limit results to small-bodies with orbits of the specified class (or classes). Allowable values are valid 3-character orbit-class codes (see section below on orbit classes). If specifying more than one class, separate entities with a comma (e.g., "TJN,CEN") or provide a list of str (e.g., ["TJN", "CEN"]). Codes are case-sensitive. See “Available SBDB Orbit Classes” section at the link for details: https://ssd-api.jpl.nasa.gov/doc/sbdb_filter.html

sb_sat : bool, default = None

Limit results to small-bodies with at least one known satellite.

sb_xfrag : bool, default = None

Exclude all comet fragments (if any) from results.

sb_defs : {"class", "field", "all"}, default = None

Return SBDB definitions and data related to available filter constraints. These data are typically only useful in supporting webpage apps. See “mode I” section in the link for details. https://ssd-api.jpl.nasa.gov/doc/sbdb_filter.html If provided, mode I will be used, and all other parameters except info will completely be ignored.

sb_cdata : str, default = None

Custom field constraints ("sb-cdata" field). Maximum length is 2048 characters when converted to the URI encoded string. See this link for details: https://ssd-api.jpl.nasa.gov/doc/sbdb_filter.html#constraints

Methods

Name Description
query Query SBDB.

query

jplsbdb.SBDBQuery.query(
    kind2bools=True,
    neo2bool=True,
    pha2bool=True,
    twobody2bool=True,
    drop_unreliable=False,
    drop_impacted=False,
    cols2kete=False,
)

Query SBDB.

Parameters

kind2bools : bool, default = True

If True, convert "kind" column to two boolean columns:

  • "is_comet": True if "kind" starts with “c”, not “a”
  • "has_number": True if "kind" ends with “n”, not “u”.

Default is True.

neo2bool : bool, default = True

If True, convert "neo" and "pha" columns to boolean columns. They are True if the original value is “Y”, False otherwise. Default is True.

pha2bool : bool, default = True

If True, convert "neo" and "pha" columns to boolean columns. They are True if the original value is “Y”, False otherwise. Default is True.

twobody2bool : bool, default = True

If True, convert "two_body" column to boolean column. It is True if the original value is “T”, False otherwise. Default is True.

drop_unreliable : bool, default = False

If True, drop unreliable objects based on the following criteria:

  • no magnitude-related information (H, G, M1, M2, K1, K2, PC)
  • prefix is “D” or “X” (disappeared or lost comets)
  • solution date is NaN/“None” or no date available (no reliable orbit)
  • two body is “T”/True (two body assumed orbit - unreliable)

Default is False (because some users may want all data).

drop_impacted : bool, default = False

If True, drop impacted objects based on IMPACTED list. Default is False (because some users may want all data).

cols2kete : bool, default = False

If True, convert column names to KETE style (e.g., "e" to "ecc"). see KETE_SBDB2KETECOLS in skyloc.configs.

Returns

: pandas.DataFrame or dict

Processed orbit table for normal queries. Information queries using info or sb_defs return a copy of the API response dictionary, without orbit-table processing.

Notes

XXX2bools are for columns, drop_XXX are for rows.