Skip to content

Commit dac6dad

Browse files
committed
Add astroquery.mast.Tesscut support for TICA
1 parent c293417 commit dac6dad

File tree

1 file changed

+66
-7
lines changed

1 file changed

+66
-7
lines changed

astroquery/mast/cutouts.py

Lines changed: 66 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,11 @@ 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+
product = "SPOC"
167+
warnings.warn("Only SPOC is available for moving targets queries. Defaulting to SPOC.", InputWarning)
168+
155169
# Check that objectname has been passed in and coordinates
156170
# is not
157171
if coordinates:
@@ -163,7 +177,7 @@ def get_sectors(self, *, coordinates=None, radius=0*u.deg, objectname=None, movi
163177
"`JPL ephemerides service <https://ssd.jpl.nasa.gov/horizons.cgi>`__) "
164178
"of a moving target such as an asteroid or comet.")
165179

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

168182
# Add optional parameter is present
169183
if mt_type:
@@ -179,9 +193,14 @@ def get_sectors(self, *, coordinates=None, radius=0*u.deg, objectname=None, movi
179193
# If radius is just a number we assume degrees
180194
radius = Angle(radius, u.deg)
181195

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

186205
response = self._service_api_connection.service_request_async("sector", params)
187206

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

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):
226+
def download_cutouts(self, *, coordinates=None, size=5, sector=None, product='SPOC', path=".",
227+
inflate=True, objectname=None, moving_target=False, mt_type=None, verbose=False):
209228
"""
210229
Download cutout target pixel file(s) around the given coordinates with indicated size.
211230
@@ -228,6 +247,14 @@ def download_cutouts(self, *, coordinates=None, size=5, sector=None, path=".", i
228247
Optional.
229248
The TESS sector to return the cutout from. If not supplied, cutouts
230249
from all available sectors on which the coordinate appears will be returned.
250+
product : str
251+
Default is 'SPOC'.
252+
The product that the cutouts will be made out of. Options are: 'SPOC' or 'TICA', for the Science Processing
253+
Operations Center (SPOC) products, and the TESS Image CAlibration (TICA) high-level science products,
254+
respectively. TICA products will usually be available for the latest sectors sooner than their SPOC
255+
counterparts, but are not available for sectors 1-26.
256+
257+
NOTE: TICA is currently not available for moving targets.
231258
path : str
232259
Optional.
233260
The directory in which the cutouts will be saved.
@@ -262,6 +289,11 @@ def download_cutouts(self, *, coordinates=None, size=5, sector=None, path=".", i
262289

263290
if moving_target:
264291

292+
# The Moving Targets service is currently only available for SPOC
293+
if product.upper() != "SPOC":
294+
product = "SPOC"
295+
warnings.warn("Only SPOC is available for moving targets queries. Defaulting to SPOC.", InputWarning)
296+
265297
# Check that objectname has been passed in and coordinates
266298
# is not
267299
if coordinates:
@@ -273,7 +305,7 @@ def download_cutouts(self, *, coordinates=None, size=5, sector=None, path=".", i
273305
"`JPL ephemerides service <https://ssd.jpl.nasa.gov/horizons.cgi>`__) "
274306
"of a moving target such as an asteroid or comet.")
275307

276-
astrocut_request = f"moving_target/astrocut?obj_id={objectname}"
308+
astrocut_request = f"moving_target/astrocut?obj_id={objectname}&product={product.upper()}"
277309
if mt_type:
278310
astrocut_request += f"&obj_type={mt_type}"
279311

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

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

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

325-
def get_cutouts(self, *, coordinates=None, size=5, sector=None,
363+
def get_cutouts(self, *, coordinates=None, size=5, product='SPOC', sector=None,
326364
objectname=None, moving_target=False, mt_type=None):
327365
"""
328366
Get cutout target pixel file(s) around the given coordinates with indicated size,
@@ -343,6 +381,14 @@ def get_cutouts(self, *, coordinates=None, size=5, sector=None,
343381
``(ny, nx)`` order. Scalar numbers in ``size`` are assumed to be in
344382
units of pixels. `~astropy.units.Quantity` objects must be in pixel or
345383
angular units.
384+
product : str
385+
Default is 'SPOC'.
386+
The product that the cutouts will be made out of. Options are: 'SPOC' or 'TICA', for the Science Processing
387+
Operations Center (SPOC) products, and the TESS Image CAlibration (TICA) high-level science products,
388+
respectively. TICA products will usually be available for the latest sectors sooner than their SPOC
389+
counterparts, but are not available for sectors 1-26.
390+
391+
NOTE: TICA is currently not available for moving targets.
346392
sector : int
347393
Optional.
348394
The TESS sector to return the cutout from. If not supplied, cutouts
@@ -379,6 +425,13 @@ def get_cutouts(self, *, coordinates=None, size=5, sector=None,
379425

380426
if moving_target:
381427

428+
# The Moving Targets service is currently only available for SPOC
429+
if product.upper() != "SPOC":
430+
product = "SPOC"
431+
warnings.warn("Only SPOC is available for moving targets queries. Defaulting to SPOC.", InputWarning)
432+
433+
param_dict['product'] = product.upper()
434+
382435
# Check that objectname has been passed in and coordinates
383436
# is not
384437
if coordinates:
@@ -400,6 +453,12 @@ def get_cutouts(self, *, coordinates=None, size=5, sector=None,
400453

401454
else:
402455

456+
# Making sure input product is either SPOC or TICA, then add the `product` param
457+
if product.upper() not in ['TICA', 'SPOC']:
458+
raise InvalidQueryError("Input product must either be SPOC or TICA.")
459+
460+
param_dict['product'] = product.upper()
461+
403462
# Get Skycoord object for coordinates/object
404463
coordinates = parse_input_location(coordinates, objectname)
405464

0 commit comments

Comments
 (0)