API#

class lksearch.Conf[source]#

Configuration parameters for search.

Refer to astropy.config.ConfigNamespace for API details.

Refer to Astropy documentation for usage.

The attributes listed below are the available configuration parameters.

Parameters:
  • search_result_display_extra_columns – List of extra columns to be included when displaying a SearchResult object.

  • cache_dir – Default cache directory for data files downloaded, etc. Defaults to ~/.lksearch/cache if not specified.

  • PREFER_CLOUD – Use Cloud-based data product retrieval where available (primarily Amazon S3 buckets for MAST holdings)

  • DOWNLOAD_CLOUD – Download cloud based data. If False, download() will return a pointer to the cloud based data instead of downloading it - intended usage for cloud-based science platforms (e.g. TIKE)

CLOUD_ONLY#

Only Download cloud based data.If False, will download all dataIf True, will only download data located on a cloud (Amazon S3) bucket

DOWNLOAD_CLOUD#

Download cloud based data.If False, download() will return a pointer to the cloud based datainstead of downloading it - intended usage for cloud-based science platforms (e.g. TIKE)

PREFER_CLOUD#

Prefer Cloud-based data product retrieval where available

cache_dir#

Default cache directory for data files downloaded, etc.

search_result_display_extra_columns#

List of extra columns to be included when displaying a SearchResult object.

class lksearch.MASTSearch(target: str | tuple[float] | SkyCoord | None = None, obs_table: DataFrame | None = None, prod_table: DataFrame | None = None, table: DataFrame | None = None, search_radius: float | Quantity | None = None, exptime: str | int | tuple | None = (0, 9999), mission: str | list[str] | None = ['Kepler', 'K2', 'TESS'], pipeline: str | list[str] | None = ['Kepler', 'K2', 'SPOC'], sequence: int | list[int] | None = None)[source]#

Generic Search Class for data exploration that queries mast for observations performed by the: Kepler, K2, TESS Missions, and returns the results in a convenient table with options to download. By default only mission products are returned.

Parameters:
  • target (Optional[Union[str, tuple[float], SkyCoord]] = None) – The target to search for observations of. Can be provided as a name (string), coordinates in decimal degrees (tuple), or astropy SkyCoord Object.

  • obs_table (Optional[pd.DataFrame] = None) – Optionally, can provice a Astropy Table Object from AstroQuery query_criteria which will be used to construct the observations table

  • prod_table (Optional[pd.DataFrame] = None) – Optionally, if you provide an obs_table, you may also provide a products table of assosciated products. These two tables will be concatenated to become the primary joint table of data products.

  • table (Optional[pd.DataFrame] = None) – Optionally, may provide an stropy Table Object that is the already merged joint table of obs_table and prod_table.

  • search_radius (Optional[Union[float,u.Quantity]] = None) – The radius around the target name/location to search for observations. Can be provided in arcsonds (float) or as an AstroPy Quantity Object

  • exptime (Optional[Union[str, int, tuple]] = (0,9999)) – Exposure time to filter observation results on. Can be provided as a mission-specific string, an int which forces an exact match to the time in seconds, or a tuple, which provides a range to filter on.

  • mission (Optional[Union[str, list[str]]] = ["Kepler", "K2", "TESS"]) – Mission(s) for which to search for data on

  • pipeline (Optional[Union[str, list[str]]] = ["Kepler", "K2", "SPOC"]) – Pipeline(s) which have produced the observed data

  • sequence (Optional[Union[int, list[int]]] = None,) – Mission Specific Survey value that corresponds to Sector (TESS) AND Campaign (K2). Not valid for Kepler. Setting sequence is not recommented for MASTSearch.

property cloud_uris#

Returns the cloud uris for products in self.table. :returns: an array where each element is the cloud-URI of a product in self.table :rtype: ~numpy.array of URI’s from ~astroquery.mast

property cubedata#

return a MASTSearch object with self.table only containing products that are image cubes

property dec#

Declination coordinate for each data product found.

download(cloud: bool = True, cache: bool = True, cloud_only: bool = False, download_dir: str = '/home/runner/.lksearch/cache', remove_incomplete: str = True) DataFrame[source]#

downloads products in self.table to the local hard-drive

Parameters:
  • cloud (bool, optional) – enable cloud (as opposed to MAST) downloading, by default True

  • cloud_only (bool, optional) – download only products availaible in the cloud, by default False

  • download_dir (str, optional) – directory where the products should be downloaded to, by default default_download_dir cache : bool, optional

  • download_products (passed to) – if False, will overwrite the file to be downloaded (for example to replace a corrrupted file)

  • True (by default) – if False, will overwrite the file to be downloaded (for example to replace a corrrupted file)

  • remove_incomplete (str, optional) – remove files with a status not “COMPLETE” in the manifest, by default True

Returns:

table where each row is an ~astroquery.mast.Observations.download_products() manifest

Return type:

DataFrame

property dvreports#

return a MASTSearch object with self.table only containing products that are data validation pdf files

property exptime#

Exposure times for all returned products

filter_table(target_name: str | list[str] = None, pipeline: str | list[str] = None, mission: str | list[str] = None, exptime: int | float | tuple[float] = None, distance: float | tuple[float] = None, year: int | list[int] | tuple[int] = None, description: str | list[str] = None, filetype: str | list[str] = None, sequence: str | list[str] = None, limit: int = None, inplace=False)[source]#

Filter the search by keywords

Parameters:
  • target_name (str, optional) – Name of targets. A list will look for multiple target names.

  • pipeline (str or list[str]], optional) – Data pipeline. A list will look for multiple pipelines.

  • mission (str or list[str]], optional) – Mission. A list will look for muliple missions.

  • exptime (int or float, tuple[float]], optional) – Exposure Time. A tuple will look for a range of times.

  • distance (float or tuple[float]], optional) – Distance. A float searches for products with a distance less than the value given, a tuple will search between the given values.

  • year (int or list[int], tuple[int]], optional) – Year. A list will look for multiple years, a tuple will look in the range of years.

  • description (str or list[str]], optional) – Description of product. A list will look for descriptions containing any keywords given, a tuple will look for descriptions containing all the keywords.

  • filetype (str or list[str]], optional) – Type of product. A list will look for multiple filetypes.

  • sequence (int or list[int]], optional) – Sequence number refers to “quarter” for Kepler, “campaign” for K2, and “sector” for TESS.

  • limit (int, optional) – _description_, by default None

  • inplace (bool, optional) – _description_, by default False

Returns:

Returns a filtered MASTSearch object or None if inplace=True

Return type:

MASTSearch or None

property mission#

Kepler quarter or TESS sector names for each data product found.

property pipeline#

Pipeline name for each data product found.

query_table(criteria: str, inplace: bool = False)[source]#

Filter the Search Result table using pandas query https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.query.html

Parameters:
  • criteria (str) – string containing criteria to filter table. Can handle multiple criteria, e.g. “exptime>=100 and exptime<=500”.

  • inplace (bool) – if True, modify table in MASTSearch object directly. If False, returns a new MASTSearch object with the resulting table

Returns:

MASTSearch – Only returned if inplace = False

Return type:

MASTSearch object

property ra#

Right Ascension coordinate for each data product found.

property target_name#

Target name for each data product found.

property timeseries#

return a MASTSearch object with self.table only containing products that are a time-series measurement

property uris#

Location Information of the products in the table

property year#

Year the observation was made.

class lksearch.KeplerSearch(target: [Union[str, tuple[float], astropy.coordinates.sky_coordinate.SkyCoord]], obs_table: DataFrame | None = None, prod_table: DataFrame | None = None, table: DataFrame | None = None, search_radius: float | Quantity | None = None, exptime: str | int | tuple | None = (0, 9999), pipeline: str | list[str] | None = None, quarter: int | list[int] | None = None, month: int | None = None, hlsp: bool = True)[source]#

Search Class that queries mast for observations performed by the Kepler Mission, and returns the results in a convenient table with options to download. By default both mission products and HLSPs are returned.

Parameters:
  • target (Optional[Union[str, tuple[float], SkyCoord]] = None) – The target to search for observations of. Can be provided as a name (string), coordinates in decimal degrees (tuple), or Astropy SkyCoord Object.

  • obs_table (Optional[pd.DataFrame] = None) – Optionally, can provice a Astropy Table Object from AstroQuery astroquery.mast.Observations.query_criteria which will be used to construct the observations table

  • prod_table (Optional[pd.DataFrame] = None) – Optionally, if you provide an obs_table, you may also provide a products table of assosciated products. These two tables will be concatenated to become the primary joint table of data products.

  • table (Optional[pd.DataFrame] = None) – Optionally, may provide an stropy Table Object that is the already merged joint table of obs_table and prod_table.

  • search_radius (Optional[Union[float,u.Quantity]] = None) – The radius around the target name/location to search for observations. Can be provided in arcseconds (float) or as an AstroPy Quantity Object

  • exptime (Optional[Union[str, int, tuple]] = (0,9999)) – Exposure time to filter observation results on. Can be provided as a mission-specific string, an int which forces an exact match to the time in seconds, or a tuple, which provides a range to filter on.

  • mission (Optional[Union[str, list[str]]] = ["Kepler", "K2", "TESS"]) – Mission(s) for which to search for data on

  • pipeline (Optional[Union[str, list[str]]] = ["Kepler", "K2", "SPOC"]) – Pipeline(s) which have produced the observed data

  • quarter (Optional[Union[int, list[int]]] = None,) – Kepler Observing Quarter(s) for which to search for data.

  • month (Optional[int] = None,) – Observation month for Kepler

property HLSPs#

return a MASTSearch object with self.table only containing High Level Science Products

filter_table(target_name: str | list[str] = None, pipeline: str | list[str] = None, mission: str | list[str] = None, exptime: int | float | tuple[float] = None, distance: float | tuple[float] = None, year: int | list[int] | tuple[int] = None, description: str | list[str] = None, filetype: str | list[str] = None, limit: int = None, inplace=False, quarter: int | None = None, month: int | None = None)[source]#

Filters the search result table by specified parameters

Parameters:
  • target_name (str, optional) – Name of targets. A list will look for multiple target names.

  • pipeline (str or list[str]], optional) – Data pipeline. A list will look for multiple pipelines.

  • mission (str or list[str]], optional) – Mission. A list will look for muliple missions.

  • exptime (int or float, tuple[float]], optional) – Exposure Time. A tuple will look for a range of times.

  • distance (float or tuple[float]], optional) – Distance. A float searches for products with a distance less than the value given, a tuple will search between the given values.

  • year (int or list[int], tuple[int]], optional) – Year. A list will look for multiple years, a tuple will look in the range of years.

  • description (str or list[str]], optional) – Description of product. A list will look for descriptions containing any keywords given, a tuple will look for descriptions containing all the keywords.

  • filetype (str or list[str]], optional) – Type of product. A list will look for multiple filetypes.

  • quarter (Optional[int], optional) – Kepler observing quarter, by default None

  • month (Optional[int], optional) – Kepler observing month, by default None

  • limit (int, optional) – how many rows to return, by default None

  • inplace (bool, optional) – whether to modify the KeplerSearch inplace, by default False

Return type:

KeplerSearch object with updated table or None if inplace==True

property mission_products#

return a MASTSearch object with self.table only containing Mission Products

class lksearch.K2Search(target: [Union[str, tuple[float], astropy.coordinates.sky_coordinate.SkyCoord]], obs_table: DataFrame | None = None, prod_table: DataFrame | None = None, table: DataFrame | None = None, search_radius: float | Quantity | None = None, exptime: str | int | tuple | None = (0, 9999), pipeline: str | list[str] | None = None, campaign: int | list[int] | None = None, hlsp: bool = True)[source]#

Search Class that queries mast for observations performed by the K2 Mission, and returns the results in a convenient table with options to download. By default both mission products and HLSPs are returned.

Parameters:
  • target (Optional[Union[str, tuple[float], SkyCoord]] = None) – The target to search for observations of. Can be provided as a name (string), coordinates in decimal degrees (tuple), or Astropy SkyCoord Object.

  • obs_table (Optional[pd.DataFrame] = None) – Optionally, can provice a Astropy Table Object from AstroQuery query_criteria which will be used to construct the observations table

  • prod_table (Optional[pd.DataFrame] = None) – Optionally, if you provide an obs_table, you may also provide a products table of assosciated products. These two tables will be concatenated to become the primary joint table of data products.

  • table (Optional[pd.DataFrame] = None) – Optionally, may provide an astropy Table Object that is the already merged joint table of obs_table and prod_table.

  • search_radius (Optional[Union[float,u.Quantity]] = None) – The radius around the target name/location to search for observations. Can be provided in arcseconds (float) or as an AstroPy Quantity Object

  • exptime (Optional[Union[str, int, tuple]] = (0,9999)) – Exposure time to filter observation results on. Can be provided as a mission-specific string, an int which forces an exact match to the time in seconds, or a tuple, which provides a range to filter on.

  • mission (Optional[Union[str, list[str]]] = ["Kepler", "K2", "TESS"]) – Mission(s) for which to search for data on

  • pipeline (Optional[Union[str, list[str]]] = ["Kepler", "K2", "SPOC"]) – Pipeline(s) which have produced the observed data

  • campaign (Optional[Union[int, list[int]]] = None,) – K2 Observing Campaign(s) for which to search for data.

property HLSPs#

return a MASTSearch object with self.table only containing High Level Science Products

filter_table(target_name: str | list[str] = None, pipeline: str | list[str] = None, mission: str | list[str] = None, exptime: int | float | tuple[float] = None, distance: float | tuple[float] = None, year: int | list[int] | tuple[int] = None, description: str | list[str] = None, filetype: str | list[str] = None, campaign: int | list = None, limit: int = None, inplace=False)[source]#

Filters the search result table by specified parameters

Parameters:
  • target_name (str, optional) – Name of targets. A list will look for multiple target names.

  • pipeline (str or list[str]], optional) – Data pipeline. A list will look for multiple pipelines.

  • mission (str or list[str]], optional) – Mission. A list will look for muliple missions.

  • exptime (int or float, tuple[float]], optional) – Exposure Time. A tuple will look for a range of times.

  • distance (float or tuple[float]], optional) – Distance. A float searches for products with a distance less than the value given, a tuple will search between the given values.

  • year (int or list[int], tuple[int]], optional) – Year. A list will look for multiple years, a tuple will look in the range of years.

  • description (str or list[str]], optional) – Description of product. A list will look for descriptions containing any keywords given, a tuple will look for descriptions containing all the keywords.

  • filetype (str or list[str]], optional) – Type of product. A list will look for multiple filetypes.

  • campaign (Optional[int], optional) – K2 observing campaign, by default None

  • limit (int, optional) – how many rows to return, by default None

  • inplace (bool, optional) – whether to modify the KeplerSearch inplace, by default False

Return type:

K2Search object with updated table or None if inplace==True

property mission_products#

return a MASTSearch object with self.table only containing Mission Products

class lksearch.TESSSearch(target: str | tuple[float] | SkyCoord | None = None, obs_table: DataFrame | None = None, prod_table: DataFrame | None = None, table: DataFrame | None = None, search_radius: float | Quantity | None = None, exptime: str | int | tuple | None = (0, 9999), pipeline: str | list[str] | None = None, sector: int | list[int] | None = None, hlsp: bool = True)[source]#

Search Class that queries mast for observations performed by the TESS Mission, and returns the results in a convenient table with options to download. By default mission products and HLSPs are returned.

Parameters:
  • target (Optional[Union[str, tuple[float], SkyCoord]] = None) – The target to search for observations of. Can be provided as a name (string), coordinates in decimal degrees (tuple), or Astropy SkyCoord Object.

  • obs_table (Optional[pd.DataFrame] = None) – Optionally, can provice a Astropy Table Object from AstroQuery astroquery.mast.Observations.query_criteria which will be used to construct the observations table

  • prod_table (Optional[pd.DataFrame] = None) – Optionally, if you provide an obs_table, you may also provide a products table of assosciated products. These two tables will be concatenated to become the primary joint table of data products.

  • table (Optional[pd.DataFrame] = None) – Optionally, may provide an astropy Table Object that is the already merged joint table of obs_table and prod_table.

  • search_radius (Optional[Union[float,u.Quantity]] = None) – The radius around the target name/location to search for observations. Can be provided in arcseconds (float) or as an astropy Quantity Object

  • exptime (Optional[Union[str, int, tuple]] = (0,9999)) – Exposure time to filter observation results on. Can be provided as a mission-specific string, an int which forces an exact match to the time in seconds, or a tuple, which provides a range to filter on.

  • mission (Optional[Union[str, list[str]]] = ["Kepler", "K2", "TESS"]) – Mission(s) for which to search for data on

  • pipeline (Optional[Union[str, list[str]]] = ["Kepler", "K2", "SPOC"]) – Pipeline(s) which have produced the observed data

  • sector (Optional[Union[int, list[int]]] = None,) – TESS Observing Sector(s) for which to search for data.

property HLSPs#

return a MASTSearch object with self.table only containing High Level Science Products

property cubedata#

return a MASTSearch object with self.table only containing products that are image cubes

download(cloud: bool = True, cache: bool = True, cloud_only: bool = False, download_dir: str = '/home/runner/.lksearch/cache', TESScut_size: int | tuple = 10)[source]#

downloads products in self.table to the local hard-drive

Parameters:
  • cloud (bool, optional) – enable cloud (as opposed to MAST) downloading, by default True

  • cloud_only (bool, optional) – download only products availaible in the cloud, by default False

  • download_dir (str, optional) – directory where the products should be downloaded to, by default default_download_dir cache : bool, optional

  • download_products (passed to) – if False, will overwrite the file to be downloaded (for example to replace a corrrupted file)

  • True (by default) – if False, will overwrite the file to be downloaded (for example to replace a corrrupted file)

  • remove_incomplete (str, optional) – remove files with a status not “COMPLETE” in the manifest, by default True

  • TESScut_size (Union[int, tuple], optional,) – The size of a TESScut FFI cutout in pixels

Returns:

table where each row is an ~astroquery.mast.Observations.download_products() manifest

Return type:

DataFrame

filter_table(target_name: str | list[str] = None, pipeline: str | list[str] = None, mission: str | list[str] = None, exptime: int | float | tuple[float] = None, distance: float | tuple[float] = None, year: int | list[int] | tuple[int] = None, description: str | list[str] = None, filetype: str | list[str] = None, limit: int = None, inplace=False, sector: int | list[str] = None)[source]#

Filters the search result table by specified parameters

Parameters:
  • target_name (str, optional) – Name of targets. A list will look for multiple target names.

  • pipeline (str or list[str]], optional) – Data pipeline. A list will look for multiple pipelines.

  • mission (str or list[str]], optional) – Mission. A list will look for muliple missions.

  • exptime (int or float, tuple[float]], optional) – Exposure Time. A tuple will look for a range of times.

  • distance (float or tuple[float]], optional) – Distance. A float searches for products with a distance less than the value given, a tuple will search between the given values.

  • year (int or list[int], tuple[int]], optional) – Year. A list will look for multiple years, a tuple will look in the range of years.

  • description (str or list[str]], optional) – Description of product. A list will look for descriptions containing any keywords given, a tuple will look for descriptions containing all the keywords.

  • filetype (str or list[str]], optional) – Type of product. A list will look for multiple filetypes.

  • sector (Optional[int], optional) – TESS observing sector, by default None

  • limit (int, optional) – how many rows to return, by default None

  • inplace (bool, optional) – whether to modify the KeplerSearch inplace, by default False

Return type:

TESSSearch object with updated table or None if inplace==True

property mission_products#

return a MASTSearch object with self.table only containing Mission Products

search_sector_ffis(sector: int | type[None], **extra_query_criteria)[source]#

Returns a list of the FFIs available in a particular sector

Parameters:

sector (Union[int, type[None]]) – sector(s) in which to search for FFI files, by default None

Returns:

TESSSearch object that contains a joint table of FFI info

Return type:

TESSSearch

property tesscut#

return the TESScut only data

class lksearch.config.ConfigItem(defaultvalue='', description=None, cfgtype=None, module=None, aliases=None)[source]#
rootname = 'lksearch'#

Rootname sets the base path for all config files.

class lksearch.config.ConfigNamespace[source]#
lksearch.config.clearcache(test=True)[source]#

Deletes all downloaded files in the lksearch download directory

Parameters:

test (bool, optional) – perform this in test mode, printing what folders will be deleted, by default True. Set test=False to delete cache

lksearch.config.create_config_file(overwrite: bool = False)[source]#

Creates a default configuration file in the config directory

lksearch.config.get_cache_dir()[source]#

Determines the default lksearch cache directory name and creates the directory if it doesn’t exist. If the directory cannot be access or created, then it returns the current directory (".").

This directory is typically $HOME/.lksearch/cache, but if the XDG_CACHE_HOME environment variable is set and the $XDG_CACHE_HOME/lksearch directory exists, it will be that directory. If neither exists, the former will be created and symlinked to the latter.

The value can be also configured via cache_dir configuration parameter.

Returns:

  • cachedir (str) – The absolute path to the cache directory.

  • See Conf for more information.

lksearch.config.get_config_dir()[source]#

Determines the package configuration directory name and creates the directory if it doesn’t exist.

This directory is typically $HOME/.lksearch/config, but if the XDG_CONFIG_HOME environment variable is set and the $XDG_CONFIG_HOME/lksearch directory exists, it will be that directory. If neither exists, the former will be created and symlinked to the latter.

Returns:

configdir – The absolute path to the configuration directory.

Return type:

str