Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vectorize HEASARC object queries #3013

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ New Tools and Services
Service fixes and enhancements
------------------------------

heasarc
^^^

- Added vectoring for querying objects [#3013]

mpc
^^^

Expand Down
8 changes: 4 additions & 4 deletions astroquery/heasarc/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ def query_object_async(self, object_name, mission, *,
cache=True, get_query_payload=False,
**kwargs):
"""
Query around a specific object within a given mission catalog
Query around a specific objects within a given mission catalog

Parameters
----------
object_name : str
Object to query around. To set search radius use the 'radius'
object_name : str or iterable (list or tuple) of strings
Objects to query around. To set search radius use the 'radius'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you specify what the iterable is here? i.e., the iterable must be an iterable (list, tuple, ...) of strings

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can do. I tested with lists and tuples, but should work with any iterable

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the wording here to object_name : str or iterable (list or tuple) of strings

parameter.
mission : str
Mission table to search from
Expand All @@ -139,7 +139,7 @@ def query_object_async(self, object_name, mission, *,
"""
request_payload = self._args_to_payload(
mission=mission,
entry=object_name,
entry=object_name if isinstance(object_name, str) else "; ".join(object_name),
**kwargs
)

Expand Down
2,002 changes: 1,001 additions & 1,001 deletions astroquery/heasarc/tests/data/10f92917.dat

Large diffs are not rendered by default.

84 changes: 84 additions & 0 deletions astroquery/heasarc/tests/data/1136b3a7.dat

Large diffs are not rendered by default.

128 changes: 64 additions & 64 deletions astroquery/heasarc/tests/data/157a5015.dat

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions astroquery/heasarc/tests/data/2f018503.dat

Large diffs are not rendered by default.

1,096 changes: 552 additions & 544 deletions astroquery/heasarc/tests/data/404652d5.dat

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions astroquery/heasarc/tests/data/4511b20b.dat

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions astroquery/heasarc/tests/data/63035ed0.dat

Large diffs are not rendered by default.

1,096 changes: 552 additions & 544 deletions astroquery/heasarc/tests/data/6ad7a587.dat

Large diffs are not rendered by default.

2,720 changes: 1,719 additions & 1,001 deletions astroquery/heasarc/tests/data/6df5af53.dat

Large diffs are not rendered by default.

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions astroquery/heasarc/tests/data/8eb05834.dat

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions astroquery/heasarc/tests/data/b493ec2a.dat
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@ Available tables:
|INTEGRAL-REV3|integral_rev3_prop |Proposals |
|INTEGRAL-REV3|integral_rev3_prop_obs|Proposal Information and Observation Parameters|
|INTEGRAL-REV3|integral_rev3_scw |SCW - Science Window Data |
|INTEGRAL-REV4|integral_rev4_prop |Proposals |
|INTEGRAL-REV4|integral_rev4_prop_obs|Proposal Information and Observation Parameters|
|INTEGRAL-REV4|integral_rev4_scw |SCW - Science Window Data |
BatchEnd
38 changes: 27 additions & 11 deletions astroquery/heasarc/tests/data/bca1ec4b.dat

Large diffs are not rendered by default.

210 changes: 210 additions & 0 deletions astroquery/heasarc/tests/data/e69f6008.dat

Large diffs are not rendered by default.

2,002 changes: 1,001 additions & 1,001 deletions astroquery/heasarc/tests/data/eb62ea7d.dat

Large diffs are not rendered by default.

128 changes: 64 additions & 64 deletions astroquery/heasarc/tests/data/f3778475.dat

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions astroquery/heasarc/tests/data/f6d793e8.dat

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions astroquery/heasarc/tests/data/ff1f8d6a.dat

Large diffs are not rendered by default.

2,303 changes: 490 additions & 1,813 deletions astroquery/heasarc/tests/data/last-month-integral_rev3_scw.dat

Large diffs are not rendered by default.

806 changes: 178 additions & 628 deletions astroquery/heasarc/tests/data/last-month-intscw.dat

Large diffs are not rendered by default.

17 changes: 15 additions & 2 deletions astroquery/heasarc/tests/test_heasarc_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from astropy.coordinates import SkyCoord
from astropy import units as u
from astropy.table import unique


@parametrization_local_save_remote
Expand Down Expand Up @@ -83,13 +84,25 @@ def test_mission_cols(self):

def test_query_object_async(self):
mission = 'rosmaster'
object_name = '3c273'
object_names = ['3c273', 'PSR B0531+21']

heasarc = Heasarc()
response = heasarc.query_object_async(object_name, mission=mission)
response = heasarc.query_object_async(object_names, mission=mission)
assert response is not None
assert isinstance(response, (requests.models.Response, MockResponse))

def test_query_object(self):
mission = "nicermastr"
object_names = ("Swift_J1818.0-1607", "SAX_J1808.4-3658")

heasarc = Heasarc()
response = heasarc.query_object(object_name=object_names,
mission=mission)
uresponse = unique(response, keys="NAME")
returned_names = [str(i).replace(" ", "") for i in uresponse["NAME"]]
assert "Swift_J1818.0-1607" in returned_names
assert "SAX_J1808.4-3658" in returned_names

def test_query_region_async(self):
heasarc = Heasarc()
mission = 'rosmaster'
Expand Down
11 changes: 6 additions & 5 deletions astroquery/heasarc/tests/test_heasarc_remote_isdc.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,10 @@ def test_mission_list(self):
with self.isdc_context:
missions = heasarc.query_mission_list()

# Assert that there are indeed a large number of tables
# Number of tables could change, but should be > 900 (currently 956)
assert len(missions) == 5
# Assert that there are indeed numerous tables from ISDC
# Qunatity of tables could change due to breakdown of the descriptions
# Accessing via isdc returns only Integral related tables from HEASARC
assert len(missions) >= 5
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made this change to test_mission_list since it wasn't passing and the previous comment was inaccurate. In short, accessing heasarc from isdc will just return stuff related to the integral mission. The 5 tables that were expected before have now grown to 8 since some have been added with proposal and description info.

I just followed the lead of the heasarc remote tests and just asserted that as long as we are getting multiple tables (from what was previously seen), that should be ok.


def test_mission_cols(self):
heasarc = Heasarc()
Expand All @@ -184,10 +185,10 @@ def test_mission_cols(self):

def test_query_object_async(self):
mission = 'integral_rev3_scw'
object_name = '3c273'
object_names = ['3c273', "Crab"]

heasarc = Heasarc()
response = heasarc.query_object_async(object_name, mission=mission)
response = heasarc.query_object_async(object_names, mission=mission)
assert response is not None
assert isinstance(response, (requests.models.Response, MockResponse))

Expand Down
Loading