Skip to content

Commit 34b324d

Browse files
Jorge Fernandez HernandezJorge Fernandez Hernandez
Jorge Fernandez Hernandez
authored and
Jorge Fernandez Hernandez
committed
GAIASWRQ-25 Rename method to cross_match_basic
1 parent a8b1654 commit 34b324d

File tree

4 files changed

+43
-41
lines changed

4 files changed

+43
-41
lines changed

CHANGES.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ alma
2727
gaia
2828
^^^^
2929

30-
- New method cross_match_stream that simplifies the positional x-match method [#3320]
30+
- New method cross_match_basic that simplifies the positional x-match method [#3320]
3131

3232
linelists.cdms
3333
^^^^^^^^^^^^^^

astroquery/gaia/core.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -848,10 +848,10 @@ def load_user(self, user_id, *, verbose=False):
848848

849849
return self.is_valid_user(user_id=user_id, verbose=verbose)
850850

851-
def cross_match_stream(self, *, table_a_full_qualified_name, table_a_column_ra, table_a_column_dec,
852-
table_b_full_qualified_name=MAIN_GAIA_TABLE, table_b_column_ra=MAIN_GAIA_TABLE_RA,
853-
table_b_column_dec=MAIN_GAIA_TABLE_DEC, results_name=None,
854-
radius=1.0, background=False, verbose=False):
851+
def cross_match_basic(self, *, table_a_full_qualified_name, table_a_column_ra, table_a_column_dec,
852+
table_b_full_qualified_name=MAIN_GAIA_TABLE, table_b_column_ra=MAIN_GAIA_TABLE_RA,
853+
table_b_column_dec=MAIN_GAIA_TABLE_DEC, results_name=None,
854+
radius=1.0, background=False, verbose=False):
855855
"""Performs a positional cross-match between the specified tables.
856856
857857
This methods simples the execution of the method `cross_match` since it carries out the following steps in one
@@ -861,8 +861,10 @@ def cross_match_stream(self, *, table_a_full_qualified_name, table_a_column_ra,
861861
#. launches a positional cross-match as an asynchronous query;
862862
#. returns all the columns from both tables plus the angular distance (deg) for the cross-matched sources.
863863
864-
The result is a join table with the identifies of both tables and the distance. To speed up the cross-match,
865-
pass the biggest table to the ``table_b_full_qualified_name`` parameter.
864+
The result is a join table with the identifies of both tables and the distance (degrees), that is returned
865+
without metadata units. If desired, units can be added using the Units package of Astropy as follows:
866+
results[‘separation’].unit = u.degree. To speed up the cross-match, pass the biggest table to the
867+
``table_b_full_qualified_name`` parameter.
866868
TAP+ only
867869
868870
Parameters

astroquery/gaia/tests/test_gaiatap.py

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ def cross_match_kwargs():
441441

442442

443443
@pytest.fixture
444-
def cross_match_stream_kwargs():
444+
def cross_match_basic_kwargs():
445445
return {"table_a_full_qualified_name": "schemaA.tableA",
446446
"table_a_column_ra": "ra",
447447
"table_a_column_dec": "dec",
@@ -451,7 +451,7 @@ def cross_match_stream_kwargs():
451451

452452

453453
@pytest.fixture
454-
def cross_match_stream_2_kwargs():
454+
def cross_match_basic_2_kwargs():
455455
return {"table_a_full_qualified_name": "user_hola.tableA",
456456
"table_a_column_ra": "ra",
457457
"table_a_column_dec": "dec",
@@ -1384,7 +1384,7 @@ def make_table_metadata(table_name):
13841384

13851385

13861386
@pytest.mark.parametrize("background", [False, True])
1387-
def test_cross_match_stream(monkeypatch, background, cross_match_stream_kwargs, mock_querier_async):
1387+
def test_cross_match_basic(monkeypatch, background, cross_match_basic_kwargs, mock_querier_async):
13881388
def load_table_monkeypatched(self, table, verbose):
13891389
tap_table_a = make_table_metadata("schemaA.tableA")
13901390
tap_table_b = make_table_metadata("schemaB.tableB")
@@ -1394,14 +1394,14 @@ def load_table_monkeypatched(self, table, verbose):
13941394

13951395
monkeypatch.setattr(Tap, "load_table", load_table_monkeypatched)
13961396

1397-
job = mock_querier_async.cross_match_stream(**cross_match_stream_kwargs, background=background)
1397+
job = mock_querier_async.cross_match_basic(**cross_match_basic_kwargs, background=background)
13981398
assert job.async_ is True
13991399
assert job.get_phase() == "EXECUTING" if background else "COMPLETED"
14001400
assert job.failed is False
14011401

14021402

14031403
@pytest.mark.parametrize("background", [False, True])
1404-
def test_cross_match_stream_2(monkeypatch, background, cross_match_stream_2_kwargs, mock_querier_async):
1404+
def test_cross_match_basic_2(monkeypatch, background, cross_match_basic_2_kwargs, mock_querier_async):
14051405
def load_table_monkeypatched(self, table, verbose):
14061406
tap_table_a = make_table_metadata("user_hola.tableA")
14071407
tap_table_b = make_table_metadata("user_hola.tableB")
@@ -1415,14 +1415,14 @@ def update_user_table(self, table_name, list_of_changes, verbose):
14151415
monkeypatch.setattr(Tap, "load_table", load_table_monkeypatched)
14161416
monkeypatch.setattr(TapPlus, "update_user_table", update_user_table)
14171417

1418-
job = mock_querier_async.cross_match_stream(**cross_match_stream_2_kwargs, background=background)
1418+
job = mock_querier_async.cross_match_basic(**cross_match_basic_2_kwargs, background=background)
14191419
assert job.async_ is True
14201420
assert job.get_phase() == "EXECUTING" if background else "COMPLETED"
14211421
assert job.failed is False
14221422

14231423

14241424
@pytest.mark.parametrize("background", [False, True])
1425-
def test_cross_match_stream_3(monkeypatch, background, mock_querier_async):
1425+
def test_cross_match_basic_3(monkeypatch, background, mock_querier_async):
14261426
mock_querier_async.MAIN_GAIA_TABLE = None
14271427

14281428
def load_table_monkeypatched_2(self, table, verbose):
@@ -1438,15 +1438,15 @@ def update_user_table(self, table_name, list_of_changes, verbose):
14381438
monkeypatch.setattr(Tap, "load_table", load_table_monkeypatched_2)
14391439
monkeypatch.setattr(TapPlus, "update_user_table", update_user_table)
14401440

1441-
job = mock_querier_async.cross_match_stream(table_a_full_qualified_name="user_hola.tableA", table_a_column_ra="ra",
1442-
table_a_column_dec="dec", background=background)
1441+
job = mock_querier_async.cross_match_basic(table_a_full_qualified_name="user_hola.tableA", table_a_column_ra="ra",
1442+
table_a_column_dec="dec", background=background)
14431443
assert job.async_ is True
14441444
assert job.get_phase() == "EXECUTING" if background else "COMPLETED"
14451445
assert job.failed is False
14461446

14471447

14481448
@pytest.mark.parametrize("background", [False, True])
1449-
def test_cross_match_stream_wrong_column(monkeypatch, background, mock_querier_async):
1449+
def test_cross_match_basic_wrong_column(monkeypatch, background, mock_querier_async):
14501450
mock_querier_async.MAIN_GAIA_TABLE = None
14511451

14521452
def load_table_monkeypatched(self, table, verbose):
@@ -1464,18 +1464,18 @@ def update_user_table(self, table_name, list_of_changes, verbose):
14641464

14651465
error_message = "Please check: columns Wrong_ra or dec not available in the table 'user_hola.tableA'"
14661466
with pytest.raises(ValueError, match=error_message):
1467-
mock_querier_async.cross_match_stream(table_a_full_qualified_name="user_hola.tableA",
1468-
table_a_column_ra="Wrong_ra", table_a_column_dec="dec",
1469-
background=background)
1467+
mock_querier_async.cross_match_basic(table_a_full_qualified_name="user_hola.tableA",
1468+
table_a_column_ra="Wrong_ra", table_a_column_dec="dec",
1469+
background=background)
14701470

14711471
error_message = "Please check: columns ra or Wrong_dec not available in the table 'user_hola.tableA'"
14721472
with pytest.raises(ValueError, match=error_message):
1473-
mock_querier_async.cross_match_stream(table_a_full_qualified_name="user_hola.tableA",
1474-
table_a_column_ra="ra", table_a_column_dec="Wrong_dec",
1475-
background=background)
1473+
mock_querier_async.cross_match_basic(table_a_full_qualified_name="user_hola.tableA",
1474+
table_a_column_ra="ra", table_a_column_dec="Wrong_dec",
1475+
background=background)
14761476

14771477

1478-
def test_cross_match_stream_exceptions(monkeypatch):
1478+
def test_cross_match_basic_exceptions(monkeypatch):
14791479
def load_table_monkeypatched(self, table, verbose):
14801480
raise ValueError(f"Not found schema name in full qualified table: '{table}'")
14811481

@@ -1487,41 +1487,41 @@ def update_user_table(self, table_name, list_of_changes, verbose):
14871487

14881488
error_message = "Not found table 'user_hola.tableA' in the archive"
14891489
with pytest.raises(ValueError, match=error_message):
1490-
GAIA_QUERIER.cross_match_stream(table_a_full_qualified_name="user_hola.tableA", table_a_column_ra="ra",
1491-
table_a_column_dec="dec", background=True)
1490+
GAIA_QUERIER.cross_match_basic(table_a_full_qualified_name="user_hola.tableA", table_a_column_ra="ra",
1491+
table_a_column_dec="dec", background=True)
14921492

14931493
# Check invalid input values
14941494
error_message = "Not found schema name in full qualified table: 'hola'"
14951495
with pytest.raises(ValueError, match=error_message):
1496-
GAIA_QUERIER.cross_match_stream(table_a_full_qualified_name="hola", table_a_column_ra="ra",
1497-
table_a_column_dec="dec")
1496+
GAIA_QUERIER.cross_match_basic(table_a_full_qualified_name="hola", table_a_column_ra="ra",
1497+
table_a_column_dec="dec")
14981498

14991499
error_message = "Schema name is empty in full qualified table: '.table_name'"
15001500
with pytest.raises(ValueError, match=error_message):
1501-
GAIA_QUERIER.cross_match_stream(table_a_full_qualified_name=".table_name", table_a_column_ra="ra",
1502-
table_a_column_dec="dec")
1501+
GAIA_QUERIER.cross_match_basic(table_a_full_qualified_name=".table_name", table_a_column_ra="ra",
1502+
table_a_column_dec="dec")
15031503

15041504
error_message = "Not found schema name in full qualified table: 'hola'"
15051505
with pytest.raises(ValueError, match=error_message):
1506-
GAIA_QUERIER.cross_match_stream(table_a_full_qualified_name="schema.table_name", table_a_column_ra="ra",
1507-
table_a_column_dec="dec", table_b_full_qualified_name="hola")
1506+
GAIA_QUERIER.cross_match_basic(table_a_full_qualified_name="schema.table_name", table_a_column_ra="ra",
1507+
table_a_column_dec="dec", table_b_full_qualified_name="hola")
15081508

15091509
error_message = "Schema name is empty in full qualified table: '.table_name'"
15101510
with pytest.raises(ValueError, match=error_message):
1511-
GAIA_QUERIER.cross_match_stream(table_a_full_qualified_name="schema.table_name", table_a_column_ra="ra",
1512-
table_a_column_dec="dec", table_b_full_qualified_name=".table_name")
1511+
GAIA_QUERIER.cross_match_basic(table_a_full_qualified_name="schema.table_name", table_a_column_ra="ra",
1512+
table_a_column_dec="dec", table_b_full_qualified_name=".table_name")
15131513

15141514
error_message = "Invalid radius value. Found 50.0, valid range is: 0.1 to 10.0"
15151515
with pytest.raises(ValueError, match=error_message):
1516-
GAIA_QUERIER.cross_match_stream(table_a_full_qualified_name="schema.table_name", table_a_column_ra="ra",
1517-
table_a_column_dec="dec", table_b_full_qualified_name="schema.table_name",
1518-
radius=50.0)
1516+
GAIA_QUERIER.cross_match_basic(table_a_full_qualified_name="schema.table_name", table_a_column_ra="ra",
1517+
table_a_column_dec="dec", table_b_full_qualified_name="schema.table_name",
1518+
radius=50.0)
15191519

15201520
error_message = "Invalid radius value. Found 0.01, valid range is: 0.1 to 10.0"
15211521
with pytest.raises(ValueError, match=error_message):
1522-
GAIA_QUERIER.cross_match_stream(table_a_full_qualified_name="schema.table_name", table_a_column_ra="ra",
1523-
table_a_column_dec="dec", table_b_full_qualified_name="schema.table_name",
1524-
radius=0.01)
1522+
GAIA_QUERIER.cross_match_basic(table_a_full_qualified_name="schema.table_name", table_a_column_ra="ra",
1523+
table_a_column_dec="dec", table_b_full_qualified_name="schema.table_name",
1524+
radius=0.01)
15251525

15261526

15271527
@patch.object(TapPlus, 'login')

docs/gaia/gaia.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ The previous 3-step cross-match can be executed in one step by the following met
787787

788788
>>> from astroquery.gaia import Gaia
789789
>>> Gaia.login()
790-
>>> job = Gaia.cross_match_stream(table_a_full_qualified_name=full_qualified_table_name, table_a_column_ra='raj2000',
790+
>>> job = Gaia.cross_match_basic(table_a_full_qualified_name=full_qualified_table_name, table_a_column_ra='raj2000',
791791
table_a_column_dec='dej2000', table_b_full_qualified_name='gaiadr3.gaia_source',
792792
table_b_column_ra='ra', table_b_column_dec='dec, radius=1.0, background=True):
793793
>>> print(job)

0 commit comments

Comments
 (0)