Skip to content

Commit 20be1ef

Browse files
authored
Merge pull request #2668 from jaymedina/cutouts-tica
Expanding `astroquery.mast.Tesscut` to support TICA
2 parents e388ceb + 3ae952f commit 20be1ef

File tree

4 files changed

+242
-63
lines changed

4 files changed

+242
-63
lines changed

CHANGES.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ mast
142142
- Expanding ``Cutouts`` functionality to support making Hubble Advanced Product (HAP)
143143
cutouts via HAPCut. [#2613]
144144

145+
- Expanding ``Cutouts`` functionality to support TICA HLSPs now available through
146+
``TesscutClass``. [##2668]
147+
145148
oac
146149
^^^
147150

astroquery/mast/cutouts.py

Lines changed: 63 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ def __init__(self):
106106
}
107107
self._service_api_connection.set_service_params(services, "tesscut")
108108

109-
def get_sectors(self, *, coordinates=None, radius=0*u.deg, objectname=None, moving_target=False, mt_type=None):
109+
def get_sectors(self, *, coordinates=None, radius=0*u.deg, product='SPOC', objectname=None,
110+
moving_target=False, mt_type=None):
110111
"""
111112
Get a list of the TESS data sectors whose footprints intersect
112113
with the given search area.
@@ -126,6 +127,14 @@ def get_sectors(self, *, coordinates=None, radius=0*u.deg, objectname=None, movi
126127
`astropy.units` may also be used.
127128
128129
NOTE: If moving_target is supplied, this argument is ignored.
130+
product : str
131+
Default is 'SPOC'.
132+
The product whose sectors will be returned. Options are: 'SPOC' or 'TICA', for the Science Processing
133+
Operations Center (SPOC) products, and the TESS Image CAlibration (TICA) high-level science products,
134+
respectively. TICA products will usually be available for the latest sectors sooner than their SPOC
135+
counterparts, but are not available for sectors 1-26.
136+
137+
NOTE: TICA is currently not available for moving targets.
129138
objectname : str, optional
130139
The target around which to search, by name (objectname="M104")
131140
or TIC ID (objectname="TIC 141914082"). If moving_target is True, input must be the name or ID
@@ -152,6 +161,10 @@ def get_sectors(self, *, coordinates=None, radius=0*u.deg, objectname=None, movi
152161

153162
if moving_target:
154163

164+
# The Moving Targets service is currently only available for SPOC
165+
if product.upper() != "SPOC":
166+
raise InvalidQueryError("Only SPOC is available for moving targets queries.")
167+
155168
# Check that objectname has been passed in and coordinates
156169
# is not
157170
if coordinates:
@@ -163,7 +176,7 @@ def get_sectors(self, *, coordinates=None, radius=0*u.deg, objectname=None, movi
163176
"`JPL ephemerides service <https://ssd.jpl.nasa.gov/horizons.cgi>`__) "
164177
"of a moving target such as an asteroid or comet.")
165178

166-
params = {"obj_id": objectname}
179+
params = {"product": product.upper(), "obj_id": objectname}
167180

168181
# Add optional parameter is present
169182
if mt_type:
@@ -179,9 +192,14 @@ def get_sectors(self, *, coordinates=None, radius=0*u.deg, objectname=None, movi
179192
# If radius is just a number we assume degrees
180193
radius = Angle(radius, u.deg)
181194

195+
# Making sure input product is either SPOC or TICA
196+
if product.upper() not in ['TICA', 'SPOC']:
197+
raise InvalidQueryError("Input product must either be SPOC or TICA.")
198+
182199
params = {"ra": coordinates.ra.deg,
183200
"dec": coordinates.dec.deg,
184-
"radius": radius.deg}
201+
"radius": radius.deg,
202+
"product": product.upper()}
185203

186204
response = self._service_api_connection.service_request_async("sector", params)
187205

@@ -204,8 +222,8 @@ def get_sectors(self, *, coordinates=None, radius=0*u.deg, objectname=None, movi
204222
warnings.warn("Coordinates are not in any TESS sector.", NoResultsWarning)
205223
return Table(sector_dict)
206224

207-
def download_cutouts(self, *, coordinates=None, size=5, sector=None, path=".", inflate=True,
208-
objectname=None, moving_target=False, mt_type=None, verbose=False):
225+
def download_cutouts(self, *, coordinates=None, size=5, sector=None, product='SPOC', path=".",
226+
inflate=True, objectname=None, moving_target=False, mt_type=None, verbose=False):
209227
"""
210228
Download cutout target pixel file(s) around the given coordinates with indicated size.
211229
@@ -228,6 +246,14 @@ def download_cutouts(self, *, coordinates=None, size=5, sector=None, path=".", i
228246
Optional.
229247
The TESS sector to return the cutout from. If not supplied, cutouts
230248
from all available sectors on which the coordinate appears will be returned.
249+
product : str
250+
Default is 'SPOC'.
251+
The product that the cutouts will be made out of. Options are: 'SPOC' or 'TICA', for the Science Processing
252+
Operations Center (SPOC) products, and the TESS Image CAlibration (TICA) high-level science products,
253+
respectively. TICA products will usually be available for the latest sectors sooner than their SPOC
254+
counterparts, but are not available for sectors 1-26.
255+
256+
NOTE: TICA is currently not available for moving targets.
231257
path : str
232258
Optional.
233259
The directory in which the cutouts will be saved.
@@ -262,6 +288,10 @@ def download_cutouts(self, *, coordinates=None, size=5, sector=None, path=".", i
262288

263289
if moving_target:
264290

291+
# The Moving Targets service is currently only available for SPOC
292+
if product.upper() != "SPOC":
293+
raise InvalidQueryError("Only SPOC is available for moving targets queries.")
294+
265295
# Check that objectname has been passed in and coordinates
266296
# is not
267297
if coordinates:
@@ -273,7 +303,7 @@ def download_cutouts(self, *, coordinates=None, size=5, sector=None, path=".", i
273303
"`JPL ephemerides service <https://ssd.jpl.nasa.gov/horizons.cgi>`__) "
274304
"of a moving target such as an asteroid or comet.")
275305

276-
astrocut_request = f"moving_target/astrocut?obj_id={objectname}"
306+
astrocut_request = f"moving_target/astrocut?obj_id={objectname}&product={product.upper()}"
277307
if mt_type:
278308
astrocut_request += f"&obj_type={mt_type}"
279309

@@ -288,6 +318,12 @@ def download_cutouts(self, *, coordinates=None, size=5, sector=None, path=".", i
288318
size_dict = _parse_cutout_size(size)
289319
astrocut_request += f"&y={size_dict['y']}&x={size_dict['x']}&units={size_dict['units']}"
290320

321+
# Making sure input product is either SPOC or TICA,
322+
# and adding the argument to the request URL
323+
if product.upper() not in ['TICA', 'SPOC']:
324+
raise InvalidQueryError("Input product must either be SPOC or TICA.")
325+
astrocut_request += f"&product={product.upper()}"
326+
291327
if sector:
292328
astrocut_request += "&sector={}".format(sector)
293329

@@ -322,7 +358,7 @@ def download_cutouts(self, *, coordinates=None, size=5, sector=None, path=".", i
322358
localpath_table['Local Path'] = [path+x for x in cutout_files]
323359
return localpath_table
324360

325-
def get_cutouts(self, *, coordinates=None, size=5, sector=None,
361+
def get_cutouts(self, *, coordinates=None, size=5, product='SPOC', sector=None,
326362
objectname=None, moving_target=False, mt_type=None):
327363
"""
328364
Get cutout target pixel file(s) around the given coordinates with indicated size,
@@ -343,6 +379,14 @@ def get_cutouts(self, *, coordinates=None, size=5, sector=None,
343379
``(ny, nx)`` order. Scalar numbers in ``size`` are assumed to be in
344380
units of pixels. `~astropy.units.Quantity` objects must be in pixel or
345381
angular units.
382+
product : str
383+
Default is 'SPOC'.
384+
The product that the cutouts will be made out of. Options are: 'SPOC' or 'TICA', for the Science Processing
385+
Operations Center (SPOC) products, and the TESS Image CAlibration (TICA) high-level science products,
386+
respectively. TICA products will usually be available for the latest sectors sooner than their SPOC
387+
counterparts, but are not available for sectors 1-26.
388+
389+
NOTE: TICA is currently not available for moving targets.
346390
sector : int
347391
Optional.
348392
The TESS sector to return the cutout from. If not supplied, cutouts
@@ -379,6 +423,12 @@ def get_cutouts(self, *, coordinates=None, size=5, sector=None,
379423

380424
if moving_target:
381425

426+
# The Moving Targets service is currently only available for SPOC
427+
if product.upper() != "SPOC":
428+
raise InvalidQueryError("Only SPOC is available for moving targets queries.")
429+
430+
param_dict['product'] = product.upper()
431+
382432
# Check that objectname has been passed in and coordinates
383433
# is not
384434
if coordinates:
@@ -400,6 +450,12 @@ def get_cutouts(self, *, coordinates=None, size=5, sector=None,
400450

401451
else:
402452

453+
# Making sure input product is either SPOC or TICA, then add the `product` param
454+
if product.upper() not in ['TICA', 'SPOC']:
455+
raise InvalidQueryError("Input product must either be SPOC or TICA.")
456+
457+
param_dict['product'] = product.upper()
458+
403459
# Get Skycoord object for coordinates/object
404460
coordinates = parse_input_location(coordinates, objectname)
405461

0 commit comments

Comments
 (0)