Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if isinstance(target, int):
if (0 < target) and (target < 13161030):
log.warning("Warning: {} may refer to a different Kepler or TESS target. "
"Please add the prefix 'KIC' or 'TIC' to disambiguate."
"".format(target))
elif (0 < 200000000) and (target < 251813739):
log.warning("Warning: {} may refer to a different K2 or TESS target. "
"Please add the prefix 'EPIC' or 'TIC' to disambiguate."
"".format(target))
observations = _query_mast(target, project=mission, radius=radius)
log.debug("MAST found {} observations. "
"Now querying MAST for the corresponding data products."
"".format(len(observations)))
if len(observations) == 0:
raise SearchError('No data found for target "{}".'.format(target))
# Light curves and target pixel files
if filetype.lower() != 'ffi':
from astroquery.mast import Observations
products = Observations.get_product_list(observations)
result = join(products, observations, keys="obs_id", join_type='left',
uniq_col_name='{col_name}{table_name}', table_names=['', '_2'])
result.sort(['distance', 'obs_id'])
masked_result = _filter_products(result, filetype=filetype,
campaign=campaign, quarter=quarter,
cadence=cadence, project=mission,
month=month, sector=sector, limit=limit)
log.debug("MAST found {} matching data products.".format(len(masked_result)))
return SearchResult(masked_result)
from astroquery.exceptions import ResolverError
try:
with warnings.catch_warnings():
# suppress misleading AstropyWarning
warnings.simplefilter('ignore', AstropyWarning)
from astroquery.mast import Observations
log.debug("Started querying MAST for observations within {} of objectname='{}'."
"".format(radius.to(u.arcsec), target))
obs = Observations.query_criteria(objectname=target,
radius=str(radius.to(u.deg)),
project=project,
obs_collection=project)
obs.sort('distance')
return obs
except ResolverError as exc:
raise SearchError(exc)
def _open_downloaded_file(path, **kwargs):
"""Wrapper around `open()` which yields a more clear error message when
the file was downloaded from MAST but corrupted, e.g. due to the
download having been interrupted."""
try:
return open(path, **kwargs)
except ValueError:
raise SearchError("Failed to open the downloaded file ({}). "
"The file was likely only partially downloaded. "
"Please remove it from your disk and try again.".format(path))
* The KIC or EPIC identifier as an integer, e.g. 11904151.
* A coordinate string in decimal format, e.g. "285.67942179 +50.24130576".
* A coordinate string in sexagesimal format, e.g. "19:02:43.1 +50:14:28.7".
* An `astropy.coordinates.SkyCoord` object.
sector : int or list
TESS Sector number. Default (None) will return all available sectors. A
list of desired sectors can also be provided.
Returns
-------
result : :class:`SearchResult` object
Object detailing the data products found.
"""
try:
return _search_products(target, filetype="ffi", mission='TESS', sector=sector)
except SearchError as exc:
log.error(exc)
return SearchResult(None)