Skip to content

Commit 7151b9f

Browse files
Jorge Fernandez HernandezJorge Fernandez Hernandez
authored andcommitted
GAIASWRQ-25 Rename method to cross_match_basic
1 parent 66ebc71 commit 7151b9f

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
@@ -447,7 +447,7 @@ def cross_match_kwargs():
447447

448448

449449
@pytest.fixture
450-
def cross_match_stream_kwargs():
450+
def cross_match_basic_kwargs():
451451
return {"table_a_full_qualified_name": "schemaA.tableA",
452452
"table_a_column_ra": "ra",
453453
"table_a_column_dec": "dec",
@@ -457,7 +457,7 @@ def cross_match_stream_kwargs():
457457

458458

459459
@pytest.fixture
460-
def cross_match_stream_2_kwargs():
460+
def cross_match_basic_2_kwargs():
461461
return {"table_a_full_qualified_name": "user_hola.tableA",
462462
"table_a_column_ra": "ra",
463463
"table_a_column_dec": "dec",
@@ -1390,7 +1390,7 @@ def make_table_metadata(table_name):
13901390

13911391

13921392
@pytest.mark.parametrize("background", [False, True])
1393-
def test_cross_match_stream(monkeypatch, background, cross_match_stream_kwargs, mock_querier_async):
1393+
def test_cross_match_basic(monkeypatch, background, cross_match_basic_kwargs, mock_querier_async):
13941394
def load_table_monkeypatched(self, table, verbose):
13951395
tap_table_a = make_table_metadata("schemaA.tableA")
13961396
tap_table_b = make_table_metadata("schemaB.tableB")
@@ -1400,14 +1400,14 @@ def load_table_monkeypatched(self, table, verbose):
14001400

14011401
monkeypatch.setattr(Tap, "load_table", load_table_monkeypatched)
14021402

1403-
job = mock_querier_async.cross_match_stream(**cross_match_stream_kwargs, background=background)
1403+
job = mock_querier_async.cross_match_basic(**cross_match_basic_kwargs, background=background)
14041404
assert job.async_ is True
14051405
assert job.get_phase() == "EXECUTING" if background else "COMPLETED"
14061406
assert job.failed is False
14071407

14081408

14091409
@pytest.mark.parametrize("background", [False, True])
1410-
def test_cross_match_stream_2(monkeypatch, background, cross_match_stream_2_kwargs, mock_querier_async):
1410+
def test_cross_match_basic_2(monkeypatch, background, cross_match_basic_2_kwargs, mock_querier_async):
14111411
def load_table_monkeypatched(self, table, verbose):
14121412
tap_table_a = make_table_metadata("user_hola.tableA")
14131413
tap_table_b = make_table_metadata("user_hola.tableB")
@@ -1421,14 +1421,14 @@ def update_user_table(self, table_name, list_of_changes, verbose):
14211421
monkeypatch.setattr(Tap, "load_table", load_table_monkeypatched)
14221422
monkeypatch.setattr(TapPlus, "update_user_table", update_user_table)
14231423

1424-
job = mock_querier_async.cross_match_stream(**cross_match_stream_2_kwargs, background=background)
1424+
job = mock_querier_async.cross_match_basic(**cross_match_basic_2_kwargs, background=background)
14251425
assert job.async_ is True
14261426
assert job.get_phase() == "EXECUTING" if background else "COMPLETED"
14271427
assert job.failed is False
14281428

14291429

14301430
@pytest.mark.parametrize("background", [False, True])
1431-
def test_cross_match_stream_3(monkeypatch, background, mock_querier_async):
1431+
def test_cross_match_basic_3(monkeypatch, background, mock_querier_async):
14321432
mock_querier_async.MAIN_GAIA_TABLE = None
14331433

14341434
def load_table_monkeypatched_2(self, table, verbose):
@@ -1444,15 +1444,15 @@ def update_user_table(self, table_name, list_of_changes, verbose):
14441444
monkeypatch.setattr(Tap, "load_table", load_table_monkeypatched_2)
14451445
monkeypatch.setattr(TapPlus, "update_user_table", update_user_table)
14461446

1447-
job = mock_querier_async.cross_match_stream(table_a_full_qualified_name="user_hola.tableA", table_a_column_ra="ra",
1448-
table_a_column_dec="dec", background=background)
1447+
job = mock_querier_async.cross_match_basic(table_a_full_qualified_name="user_hola.tableA", table_a_column_ra="ra",
1448+
table_a_column_dec="dec", background=background)
14491449
assert job.async_ is True
14501450
assert job.get_phase() == "EXECUTING" if background else "COMPLETED"
14511451
assert job.failed is False
14521452

14531453

14541454
@pytest.mark.parametrize("background", [False, True])
1455-
def test_cross_match_stream_wrong_column(monkeypatch, background, mock_querier_async):
1455+
def test_cross_match_basic_wrong_column(monkeypatch, background, mock_querier_async):
14561456
mock_querier_async.MAIN_GAIA_TABLE = None
14571457

14581458
def load_table_monkeypatched(self, table, verbose):
@@ -1470,18 +1470,18 @@ def update_user_table(self, table_name, list_of_changes, verbose):
14701470

14711471
error_message = "Please check: columns Wrong_ra or 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="Wrong_ra", table_a_column_dec="dec",
1475-
background=background)
1473+
mock_querier_async.cross_match_basic(table_a_full_qualified_name="user_hola.tableA",
1474+
table_a_column_ra="Wrong_ra", table_a_column_dec="dec",
1475+
background=background)
14761476

14771477
error_message = "Please check: columns ra or Wrong_dec not available in the table 'user_hola.tableA'"
14781478
with pytest.raises(ValueError, match=error_message):
1479-
mock_querier_async.cross_match_stream(table_a_full_qualified_name="user_hola.tableA",
1480-
table_a_column_ra="ra", table_a_column_dec="Wrong_dec",
1481-
background=background)
1479+
mock_querier_async.cross_match_basic(table_a_full_qualified_name="user_hola.tableA",
1480+
table_a_column_ra="ra", table_a_column_dec="Wrong_dec",
1481+
background=background)
14821482

14831483

1484-
def test_cross_match_stream_exceptions(monkeypatch):
1484+
def test_cross_match_basic_exceptions(monkeypatch):
14851485
def load_table_monkeypatched(self, table, verbose):
14861486
raise ValueError(f"Not found schema name in full qualified table: '{table}'")
14871487

@@ -1493,41 +1493,41 @@ def update_user_table(self, table_name, list_of_changes, verbose):
14931493

14941494
error_message = "Not found table 'user_hola.tableA' in the archive"
14951495
with pytest.raises(ValueError, match=error_message):
1496-
GAIA_QUERIER.cross_match_stream(table_a_full_qualified_name="user_hola.tableA", table_a_column_ra="ra",
1497-
table_a_column_dec="dec", background=True)
1496+
GAIA_QUERIER.cross_match_basic(table_a_full_qualified_name="user_hola.tableA", table_a_column_ra="ra",
1497+
table_a_column_dec="dec", background=True)
14981498

14991499
# Check invalid input values
15001500
error_message = "Not found schema name in full qualified table: 'hola'"
15011501
with pytest.raises(ValueError, match=error_message):
1502-
GAIA_QUERIER.cross_match_stream(table_a_full_qualified_name="hola", table_a_column_ra="ra",
1503-
table_a_column_dec="dec")
1502+
GAIA_QUERIER.cross_match_basic(table_a_full_qualified_name="hola", table_a_column_ra="ra",
1503+
table_a_column_dec="dec")
15041504

15051505
error_message = "Schema name is empty in full qualified table: '.table_name'"
15061506
with pytest.raises(ValueError, match=error_message):
1507-
GAIA_QUERIER.cross_match_stream(table_a_full_qualified_name=".table_name", table_a_column_ra="ra",
1508-
table_a_column_dec="dec")
1507+
GAIA_QUERIER.cross_match_basic(table_a_full_qualified_name=".table_name", table_a_column_ra="ra",
1508+
table_a_column_dec="dec")
15091509

15101510
error_message = "Not found schema name in full qualified table: 'hola'"
15111511
with pytest.raises(ValueError, match=error_message):
1512-
GAIA_QUERIER.cross_match_stream(table_a_full_qualified_name="schema.table_name", table_a_column_ra="ra",
1513-
table_a_column_dec="dec", table_b_full_qualified_name="hola")
1512+
GAIA_QUERIER.cross_match_basic(table_a_full_qualified_name="schema.table_name", table_a_column_ra="ra",
1513+
table_a_column_dec="dec", table_b_full_qualified_name="hola")
15141514

15151515
error_message = "Schema name is empty in full qualified table: '.table_name'"
15161516
with pytest.raises(ValueError, match=error_message):
1517-
GAIA_QUERIER.cross_match_stream(table_a_full_qualified_name="schema.table_name", table_a_column_ra="ra",
1518-
table_a_column_dec="dec", table_b_full_qualified_name=".table_name")
1517+
GAIA_QUERIER.cross_match_basic(table_a_full_qualified_name="schema.table_name", table_a_column_ra="ra",
1518+
table_a_column_dec="dec", table_b_full_qualified_name=".table_name")
15191519

15201520
error_message = "Invalid radius value. Found 50.0, 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=50.0)
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=50.0)
15251525

15261526
error_message = "Invalid radius value. Found 0.01, valid range is: 0.1 to 10.0"
15271527
with pytest.raises(ValueError, match=error_message):
1528-
GAIA_QUERIER.cross_match_stream(table_a_full_qualified_name="schema.table_name", table_a_column_ra="ra",
1529-
table_a_column_dec="dec", table_b_full_qualified_name="schema.table_name",
1530-
radius=0.01)
1528+
GAIA_QUERIER.cross_match_basic(table_a_full_qualified_name="schema.table_name", table_a_column_ra="ra",
1529+
table_a_column_dec="dec", table_b_full_qualified_name="schema.table_name",
1530+
radius=0.01)
15311531

15321532

15331533
@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)