Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for TESS/TICA FFIs when getting products for observations #3083

Merged
merged 2 commits into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 47 additions & 4 deletions astroquery/mast/observations.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,48 @@ def query_criteria_count(self, *, pagesize=None, page=None, **criteria):

return self._portal_api_connection.service_request(service, params)[0][0].astype(int)

def _filter_ffi_observations(self, observations):
"""
Given a `~astropy.table.Row` or `~astropy.table.Table` of observations, filter out full-frame images (FFIs)
from TESS and TICA. If any observations are filtered, warn the user.

Parameters
----------
observations : `~astropy.table.Row` or `~astropy.table.Table`
Row/Table of MAST query results (e.g. output from `query_object`)

Returns
-------
filtered_obs_table : filtered observations Table
"""
obs_table = Table(observations)
tess_ffis = obs_table[obs_table['target_name'] == 'TESS FFI']['obs_id']
tica_ffis = obs_table[obs_table['target_name'] == 'TICA FFI']['obs_id']

if tess_ffis.size:
# Warn user if TESS FFIs exist
log.warning("Because of their large size, Astroquery should not be used to "
"download TESS FFI products.\n"
"If you are looking for TESS image data for a specific target, "
"please use TESScut at https://mast.stsci.edu/tesscut/.\n"
"If you need a TESS image for an entire field, please see our "
"dedicated page for downloading larger quantities of TESS data at \n"
"https://archive.stsci.edu/tess/. Data products will not be fetched "
"for the following observations IDs: \n" + "\n".join(tess_ffis))

if tica_ffis.size:
# Warn user if TICA FFIs exist
log.warning("Because of their large size, Astroquery should not be used to "
"download TICA FFI products.\n"
"Please see our dedicated page for downloading larger quantities of "
"TICA data: https://archive.stsci.edu/hlsp/tica.\n"
"Data products will not be fetched for the following "
"observation IDs: \n" + "\n".join(tica_ffis))

# Filter out FFIs with a mask
mask = (obs_table['target_name'] != 'TESS FFI') & (obs_table['target_name'] != 'TICA FFI')
return obs_table[mask]

@class_or_instance
def get_product_list_async(self, observations):
"""
Expand All @@ -423,15 +465,16 @@ def get_product_list_async(self, observations):

Returns
-------
response : list of `~requests.Response`
response : list of `~requests.Response`
"""

# getting the obsid list
if isinstance(observations, Row):
observations = observations["obsid"]
if np.isscalar(observations):
observations = np.array([observations])
if isinstance(observations, Table):
if isinstance(observations, Table) or isinstance(observations, Row):
# Filter out TESS FFIs and TICA FFIs
# Can only perform filtering on Row or Table because of access to `target_name` field
observations = self._filter_ffi_observations(observations)
observations = observations['obsid']
if isinstance(observations, list):
observations = np.array(observations)
Expand Down
14 changes: 14 additions & 0 deletions astroquery/mast/tests/test_mast_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,20 @@ def test_observations_get_product_list(self):
assert len(obs_collection) == 1
assert obs_collection[0] == 'IUE'

def test_observations_get_product_list_tess_tica(self, caplog):
# Get observations and products with both TESS and TICA FFIs
obs = Observations.query_criteria(target_name=['TESS FFI', 'TICA FFI', '429031146'])
prods = Observations.get_product_list(obs)

# Check that WARNING messages about FFIs were logged
with caplog.at_level("WARNING", logger="astroquery"):
assert "TESS FFI products" in caplog.text
assert "TICA FFI products" in caplog.text

# Should only return products corresponding to target 429031146
assert len(prods) > 0
assert (np.char.find(prods['obs_id'], '429031146') != -1).all()

def test_observations_filter_products(self):
observations = Observations.query_object("M8", radius=".04 deg")
obsLoc = np.where(observations["obs_id"] == 'ktwo200071160-c92_lc')
Expand Down
Loading