Skip to content

Commit 1cfe16a

Browse files
committed
INTEGRALSWRQ-158: get_timeline with skycoords
1 parent a91ffca commit 1cfe16a

File tree

4 files changed

+14
-51
lines changed

4 files changed

+14
-51
lines changed

astroquery/esa/integral/core.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from astropy.table import Table
1212
from astroquery.query import BaseQuery, BaseVOQuery
1313
from astroquery import log
14+
from astroquery.utils import commons
1415
import pyvo
1516
from requests import HTTPError
1617

@@ -289,7 +290,7 @@ def get_observations(self, *, target_name=None, coordinates=None, radius=14.0, s
289290
dec = coord['dec'][0]
290291
conditions.append(conf.ISLA_COORDINATE_CONDITION.format(ra, dec, radius))
291292
elif coordinates:
292-
coord = esautils.get_coord_input(value=coordinates, msg=coordinates)
293+
coord = commons.parse_coordinates(coordinates=coordinates)
293294
ra = coord.ra.degree
294295
dec = coord.dec.degree
295296
conditions.append(conf.ISLA_COORDINATE_CONDITION.format(ra, dec, radius))
@@ -354,15 +355,13 @@ def download_science_windows(self, *, science_windows=None, observation_id=None,
354355
except Exception as e:
355356
log.error('No science windows have been found with these inputs. {}'.format(e))
356357

357-
def get_timeline(self, ra, dec, *, radius=14):
358+
def get_timeline(self, coordinates, *, radius=14):
358359
"""Retrieve the INTEGRAL timeline associated to coordinates and radius
359360
360361
Parameters
361362
----------
362-
ra: float, mandatory
363-
Right ascension
364-
dec: float, mandatory
365-
Declination
363+
coordinates: str or SkyCoord, mandatory
364+
RA and Dec of the source
366365
radius: float or quantity, optional, default value 14 degrees
367366
radius in degrees (int, float) or quantity of the cone_search
368367
@@ -378,10 +377,12 @@ def get_timeline(self, ra, dec, *, radius=14):
378377
if radius:
379378
radius = esautils.get_degree_radius(radius)
380379

380+
c = commons.parse_coordinates(coordinates=coordinates)
381+
381382
query_params = {
382383
'REQUEST': 'timelines',
383-
"ra": ra,
384-
"dec": dec,
384+
"ra": c.ra.degree,
385+
"dec": c.dec.degree,
385386
"radius": radius
386387
}
387388

astroquery/esa/integral/tests/test_isla_tap.py

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import os
1212

1313
from astropy.coordinates import SkyCoord
14-
1514
from astroquery.esa.integral import IntegralClass
1615
from astroquery.esa.integral import conf
1716
from unittest.mock import PropertyMock, patch, Mock
@@ -345,25 +344,12 @@ def test_download_science_windows(self, instrument_band_mock, download_mock):
345344
@patch('astroquery.esa.integral.core.pyvo.dal.TAPService.capabilities', [])
346345
@patch('astroquery.esa.utils.utils.execute_servlet_request')
347346
@patch('astroquery.esa.integral.core.IntegralClass.get_instrument_band_map')
348-
def test_get_timeline_no_distance(self, instrument_band_mock, servlet_mock):
349-
instrument_band_mock.return_value = mocks.get_instrument_bands()
350-
servlet_mock.return_value = mocks.get_mock_timeline()
351-
352-
isla = IntegralClass()
353-
isla.get_timeline(ra=83.63320922851562, dec=22.01447105407715)
354-
355-
args, kwargs = servlet_mock.call_args
356-
assert kwargs['query_params']['REQUEST'] == 'timelines'
357-
358-
@patch('astroquery.esa.integral.core.pyvo.dal.TAPService.capabilities', [])
359-
@patch('astroquery.esa.utils.utils.execute_servlet_request')
360-
@patch('astroquery.esa.integral.core.IntegralClass.get_instrument_band_map')
361-
def test_get_timeline_distance(self, instrument_band_mock, servlet_mock):
347+
def test_get_timeline(self, instrument_band_mock, servlet_mock):
362348
instrument_band_mock.return_value = mocks.get_instrument_bands()
363349
servlet_mock.return_value = mocks.get_mock_timeline()
364350

365351
isla = IntegralClass()
366-
timeline = isla.get_timeline(ra=83.63320922851562, dec=22.01447105407715)
352+
timeline = isla.get_timeline(coordinates='83.63320922851562 22.01447105407715')
367353

368354
assert len(timeline['timeline']['scwRevs']) > 0
369355

astroquery/esa/utils/utils.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
from astropy.units import Quantity
2222
from astropy.io import fits
2323
from pyvo.auth.authsession import AuthSession
24-
from astroquery.utils import commons
2524

2625
import requests
2726
from requests import Response
@@ -151,31 +150,6 @@ def _request(self, method, url, *args, **kwargs):
151150
return super()._request(method, url, **kwargs)
152151

153152

154-
def get_coord_input(value, msg):
155-
"""
156-
Auxiliary method to parse the coordinates
157-
158-
Parameters
159-
----------
160-
value: str or SkyCoord, mandatory
161-
coordinates to be parsed
162-
msg: str, mandatory
163-
Value to be shown in the error message
164-
165-
Returns
166-
-------
167-
The coordinates parsed
168-
"""
169-
if not (isinstance(value, str) or isinstance(value,
170-
commons.CoordClasses)):
171-
raise ValueError(f"{msg} must be either a string or astropy.coordinates")
172-
if isinstance(value, str):
173-
c = commons.parse_coordinates(value)
174-
return c
175-
else:
176-
return value
177-
178-
179153
def get_degree_radius(radius):
180154
"""
181155
Method to parse the radius and retrieve it in degrees

docs/esa/integral/integral.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,10 @@ to refine their search.
124124
.. doctest-remote-data::
125125

126126
>>> from astroquery.esa.integral import IntegralClass
127+
>>> from astropy.coordinates import SkyCoord
127128
>>> isla = IntegralClass()
128-
>>> timeline = isla.get_timeline(ra=83.63320922851562, dec=22.01447105407715)
129+
>>> coordinates = SkyCoord(83.63320922851562, 22.01447105407715, unit="deg")
130+
>>> timeline = isla.get_timeline(coordinates=coordinates)
129131
>>> timeline # doctest: +IGNORE_OUTPUT
130132
{'total_items': 8714, 'fraFC': 0.8510442965343126, 'totEffExpo': 16416293.994214607, 'timeline': <Table length=8714>
131133
scwExpo scwRevs scwTimes scwOffAxis

0 commit comments

Comments
 (0)