Skip to content

Commit 24aa587

Browse files
authored
Merge pull request astropy#2859 from esdc-esac-esa-int/ESA_gaia_GAIAPCR-1290_Include_the_new_DataLink_linking_parameter
Esa gaia gaiapcr 1290 include the new data link linking parameter
2 parents 239acd8 + 8e4142d commit 24aa587

File tree

4 files changed

+119
-37
lines changed

4 files changed

+119
-37
lines changed

CHANGES.rst

+6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ gaia
2323
for example planned or our unplanned downtimes of the archive, etc. The notification
2424
will be also visible when accessing the archive through Astroquery. [#2376]
2525

26+
- Datalink can be used with the new parameter linking_parameter. It provides an additional
27+
meaning to the source identifiers: source_id, transit_id and image_id.
28+
This parameter is optional, in order to be backward compatible, and
29+
therefore, if the parameter is not set, the source identifiers are
30+
considered as source_id. [#2859]
31+
2632
hsa
2733
^^^
2834

astroquery/gaia/core.py

+17-4
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,10 @@ def logout(self, *, verbose=False):
163163
except HTTPError:
164164
log.error("Error logging out data server")
165165

166-
def load_data(self, ids, *, data_release=None, data_structure='INDIVIDUAL',
167-
retrieval_type="ALL", valid_data=False, band=None,
168-
avoid_datatype_check=False, format="votable", output_file=None,
169-
overwrite_output_file=False, verbose=False):
166+
def load_data(self, ids, *, data_release=None, data_structure='INDIVIDUAL', retrieval_type="ALL",
167+
linking_parameter='SOURCE_ID', valid_data=False, band=None, avoid_datatype_check=False,
168+
format="votable",
169+
output_file=None, overwrite_output_file=False, verbose=False):
170170
"""Loads the specified table
171171
TAP+ only
172172
@@ -194,6 +194,11 @@ def load_data(self, ids, *, data_release=None, data_structure='INDIVIDUAL',
194194
For GAIA DR4, possible values will be ['EPOCH_PHOTOMETRY', 'RVS', 'XP_CONTINUOUS', 'XP_SAMPLED',
195195
'MCMC_GSPPHOT', 'MCMC_MSC', 'EPOCH_ASTROMETRY', 'RV_EPOCH_SINGLE', 'RV_EPOCH_DOUBLE', 'RVS_EPOCH' or
196196
'RVS_TRANSIT']
197+
linking_parameter : str, optional, default SOURCE_ID, valid values: SOURCE_ID, TRANSIT_ID, IMAGE_ID
198+
By default, all the identifiers are considered as source_id
199+
SOURCE_ID: the identifiers are considered as source_id
200+
TRANSIT_ID: the identifiers are considered as transit_id
201+
IMAGE_ID: the identifiers are considered as sif_observation_id
197202
valid_data : bool, optional, default False
198203
By default, the epoch photometry service returns all available data, including
199204
data rows where flux is null and/or the rejected_by_photometry flag is set to True.
@@ -272,6 +277,14 @@ def load_data(self, ids, *, data_release=None, data_structure='INDIVIDUAL',
272277
params_dict['RETRIEVAL_TYPE'] = str(retrieval_type)
273278
params_dict['USE_ZIP_ALWAYS'] = 'true'
274279

280+
valid_param = {'SOURCE_ID', 'TRANSIT_ID', 'IMAGE_ID'}
281+
if linking_parameter not in valid_param:
282+
raise ValueError(
283+
f"Invalid linking_parameter value '{linking_parameter}' (Valid values: {', '.join(valid_param)})")
284+
else:
285+
if linking_parameter != 'SOURCE_ID':
286+
params_dict['LINKING_PARAMETER'] = linking_parameter
287+
275288
if path != '':
276289
try:
277290
os.mkdir(path)

astroquery/gaia/tests/test_gaiatap.py

+25
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,31 @@ def load_data_monkeypatched(self, params_dict, output_file, verbose):
195195
output_file=tmp_path / "output_file")
196196

197197

198+
def test_load_data_linking_parameter(monkeypatch, tmp_path):
199+
200+
def load_data_monkeypatched(self, params_dict, output_file, verbose):
201+
assert params_dict == {
202+
"VALID_DATA": "true",
203+
"ID": "1,2,3,4",
204+
"FORMAT": "votable",
205+
"RETRIEVAL_TYPE": "epoch_photometry",
206+
"DATA_STRUCTURE": "INDIVIDUAL",
207+
"LINKING_PARAMETER": "TRANSIT_ID",
208+
"USE_ZIP_ALWAYS": "true"}
209+
assert output_file == str(tmp_path / "output_file")
210+
assert verbose is True
211+
212+
monkeypatch.setattr(TapPlus, "load_data", load_data_monkeypatched)
213+
214+
GAIA_QUERIER.load_data(
215+
ids="1,2,3,4",
216+
retrieval_type="epoch_photometry",
217+
linking_parameter="TRANSIT_ID",
218+
valid_data=True,
219+
verbose=True,
220+
output_file=tmp_path / "output_file")
221+
222+
198223
def test_get_datalinks(monkeypatch):
199224

200225
def get_datalinks_monkeypatched(self, ids, verbose):

0 commit comments

Comments
 (0)