Skip to content

Commit 1c1588e

Browse files
authored
Merge pull request #3083 from snbianco/ASB-28093-tess-tica-check
Check for TESS/TICA FFIs when getting products for observations
2 parents 25fc665 + 4f267b8 commit 1c1588e

File tree

2 files changed

+61
-4
lines changed

2 files changed

+61
-4
lines changed

astroquery/mast/observations.py

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,48 @@ def query_criteria_count(self, *, pagesize=None, page=None, **criteria):
408408

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

411+
def _filter_ffi_observations(self, observations):
412+
"""
413+
Given a `~astropy.table.Row` or `~astropy.table.Table` of observations, filter out full-frame images (FFIs)
414+
from TESS and TICA. If any observations are filtered, warn the user.
415+
416+
Parameters
417+
----------
418+
observations : `~astropy.table.Row` or `~astropy.table.Table`
419+
Row/Table of MAST query results (e.g. output from `query_object`)
420+
421+
Returns
422+
-------
423+
filtered_obs_table : filtered observations Table
424+
"""
425+
obs_table = Table(observations)
426+
tess_ffis = obs_table[obs_table['target_name'] == 'TESS FFI']['obs_id']
427+
tica_ffis = obs_table[obs_table['target_name'] == 'TICA FFI']['obs_id']
428+
429+
if tess_ffis.size:
430+
# Warn user if TESS FFIs exist
431+
log.warning("Because of their large size, Astroquery should not be used to "
432+
"download TESS FFI products.\n"
433+
"If you are looking for TESS image data for a specific target, "
434+
"please use TESScut at https://mast.stsci.edu/tesscut/.\n"
435+
"If you need a TESS image for an entire field, please see our "
436+
"dedicated page for downloading larger quantities of TESS data at \n"
437+
"https://archive.stsci.edu/tess/. Data products will not be fetched "
438+
"for the following observations IDs: \n" + "\n".join(tess_ffis))
439+
440+
if tica_ffis.size:
441+
# Warn user if TICA FFIs exist
442+
log.warning("Because of their large size, Astroquery should not be used to "
443+
"download TICA FFI products.\n"
444+
"Please see our dedicated page for downloading larger quantities of "
445+
"TICA data: https://archive.stsci.edu/hlsp/tica.\n"
446+
"Data products will not be fetched for the following "
447+
"observation IDs: \n" + "\n".join(tica_ffis))
448+
449+
# Filter out FFIs with a mask
450+
mask = (obs_table['target_name'] != 'TESS FFI') & (obs_table['target_name'] != 'TICA FFI')
451+
return obs_table[mask]
452+
411453
@class_or_instance
412454
def get_product_list_async(self, observations):
413455
"""
@@ -424,15 +466,16 @@ def get_product_list_async(self, observations):
424466
425467
Returns
426468
-------
427-
response : list of `~requests.Response`
469+
response : list of `~requests.Response`
428470
"""
429471

430472
# getting the obsid list
431-
if isinstance(observations, Row):
432-
observations = observations["obsid"]
433473
if np.isscalar(observations):
434474
observations = np.array([observations])
435-
if isinstance(observations, Table):
475+
if isinstance(observations, Table) or isinstance(observations, Row):
476+
# Filter out TESS FFIs and TICA FFIs
477+
# Can only perform filtering on Row or Table because of access to `target_name` field
478+
observations = self._filter_ffi_observations(observations)
436479
observations = observations['obsid']
437480
if isinstance(observations, list):
438481
observations = np.array(observations)

astroquery/mast/tests/test_mast_remote.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,20 @@ def test_observations_get_product_list(self):
348348
assert len(obs_collection) == 1
349349
assert obs_collection[0] == 'IUE'
350350

351+
def test_observations_get_product_list_tess_tica(self, caplog):
352+
# Get observations and products with both TESS and TICA FFIs
353+
obs = Observations.query_criteria(target_name=['TESS FFI', 'TICA FFI', '429031146'])
354+
prods = Observations.get_product_list(obs)
355+
356+
# Check that WARNING messages about FFIs were logged
357+
with caplog.at_level("WARNING", logger="astroquery"):
358+
assert "TESS FFI products" in caplog.text
359+
assert "TICA FFI products" in caplog.text
360+
361+
# Should only return products corresponding to target 429031146
362+
assert len(prods) > 0
363+
assert (np.char.find(prods['obs_id'], '429031146') != -1).all()
364+
351365
def test_observations_filter_products(self):
352366
observations = Observations.query_object("M8", radius=".04 deg")
353367
obsLoc = np.where(observations["obs_id"] == 'ktwo200071160-c92_lc')

0 commit comments

Comments
 (0)