Skip to content

Commit 4b7c262

Browse files
committed
Filter out TESS/TICA FFIs when getting products
1 parent 2a27dff commit 4b7c262

File tree

2 files changed

+62
-4
lines changed

2 files changed

+62
-4
lines changed

astroquery/mast/observations.py

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

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

410+
def _filter_ffi_observations(self, observations):
411+
"""
412+
Given a `~astropy.table.Row` or `~astropy.table.Table` of observations, filter out full-frame images (FFIs)
413+
from TESS and TICA. If any observations are filtered, warn the user.
414+
415+
Parameters
416+
----------
417+
observations : `~astropy.table.Row` or `~astropy.table.Table`
418+
Row/Table of MAST query results (e.g. output from `query_object`)
419+
420+
Returns
421+
-------
422+
filtered_obs_table : filtered observations Table
423+
"""
424+
obs_table = Table(observations)
425+
tess_ffis = obs_table[obs_table['target_name'] == 'TESS FFI']['obs_id']
426+
tica_ffis = obs_table[obs_table['target_name'] == 'TICA FFI']['obs_id']
427+
428+
if tess_ffis.size:
429+
# Warn user if TESS FFIs exist
430+
log.warning("Because of their large size, Astroquery should not be used to "
431+
"download TESS FFI products.\n"
432+
"If you are looking for TESS image data for a specific target, "
433+
"please use TESScut at https://mast.stsci.edu/tesscut/.\n"
434+
"If you need a TESS image for an entire field, please see our "
435+
"dedicated page for downloading larger quantities of TESS data at \n"
436+
"https://archive.stsci.edu/tess/. Data products will not be fetched "
437+
"for the following observations IDs: \n"
438+
+ "\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 observation IDs: \n"
447+
+ "\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+
410453
@class_or_instance
411454
def get_product_list_async(self, observations):
412455
"""
@@ -423,15 +466,16 @@ def get_product_list_async(self, observations):
423466
424467
Returns
425468
-------
426-
response : list of `~requests.Response`
469+
response : list of `~requests.Response`
427470
"""
428471

429472
# getting the obsid list
430-
if isinstance(observations, Row):
431-
observations = observations["obsid"]
432473
if np.isscalar(observations):
433474
observations = np.array([observations])
434-
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)
435479
observations = observations['obsid']
436480
if isinstance(observations, list):
437481
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
@@ -369,6 +369,20 @@ def test_observations_get_product_list(self):
369369
assert len(obs_collection) == 1
370370
assert obs_collection[0] == 'IUE'
371371

372+
def test_observations_get_product_list_tess_tica(self, caplog):
373+
# Get observations and products with both TESS and TICA FFIs
374+
obs = Observations.query_criteria(target_name=['TESS FFI', 'TICA FFI', '429031146'])
375+
prods = Observations.get_product_list(obs)
376+
377+
# Check that WARNING messages about FFIs were logged
378+
with caplog.at_level("WARNING", logger="astroquery"):
379+
assert "TESS FFI products" in caplog.text
380+
assert "TICA FFI products" in caplog.text
381+
382+
# Should only return products corresponding to target 429031146
383+
assert len(prods) > 0
384+
assert (np.char.find(prods['obs_id'], '429031146') != -1).all()
385+
372386
def test_observations_filter_products(self):
373387
observations = Observations.query_object("M8", radius=".04 deg")
374388
obsLoc = np.where(observations["obs_id"] == 'ktwo200071160-c92_lc')

0 commit comments

Comments
 (0)