-
-
Notifications
You must be signed in to change notification settings - Fork 427
Gaia astroquery 1.1 #2376
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
Gaia astroquery 1.1 #2376
Changes from all commits
f45190a
46b11d2
f7dd7d2
79eceb9
62fc989
5d25430
9397b78
3990021
fc8d45b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,6 +33,7 @@ | |
| from astropy import units as u | ||
| import warnings | ||
| from astroquery.exceptions import InputWarning | ||
| from collections.abc import Iterable | ||
|
|
||
|
|
||
| class GaiaClass(TapPlus): | ||
|
|
@@ -44,14 +45,15 @@ class GaiaClass(TapPlus): | |
| MAIN_GAIA_TABLE_DEC = conf.MAIN_GAIA_TABLE_DEC | ||
| ROW_LIMIT = conf.ROW_LIMIT | ||
| VALID_DATALINK_RETRIEVAL_TYPES = conf.VALID_DATALINK_RETRIEVAL_TYPES | ||
| GAIA_MESSAGES = "notification?action=GetNotifications" | ||
|
|
||
| def __init__(self, tap_plus_conn_handler=None, | ||
| datalink_handler=None, | ||
| gaia_tap_server='https://gea.esac.esa.int/', | ||
| gaia_data_server='https://gea.esac.esa.int/', | ||
| tap_server_context="tap-server", | ||
| data_server_context="data-server", | ||
| verbose=False): | ||
| verbose=False, show_server_messages=True): | ||
| super(GaiaClass, self).__init__(url=gaia_tap_server, | ||
| server_context=tap_server_context, | ||
| tap_context="tap", | ||
|
|
@@ -74,6 +76,10 @@ def __init__(self, tap_plus_conn_handler=None, | |
| else: | ||
| self.__gaiadata = datalink_handler | ||
|
|
||
| # Enable notifications | ||
| if show_server_messages: | ||
| self.get_status_messages() | ||
|
|
||
| def login(self, user=None, password=None, credentials_file=None, | ||
| verbose=False): | ||
| """Performs a login. | ||
|
|
@@ -158,7 +164,7 @@ def logout(self, verbose=False): | |
| except HTTPError as err: | ||
| log.error("Error logging out data server") | ||
|
|
||
| def load_data(self, ids, data_release=None, data_structure='INDIVIDUAL', retrieval_type="ALL", valid_data=True, | ||
| def load_data(self, ids, data_release=None, data_structure='INDIVIDUAL', retrieval_type="ALL", valid_data=False, | ||
| band=None, avoid_datatype_check=False, format="votable", output_file=None, | ||
| overwrite_output_file=False, verbose=False): | ||
| """Loads the specified table | ||
|
|
@@ -185,12 +191,12 @@ def load_data(self, ids, data_release=None, data_structure='INDIVIDUAL', retriev | |
| retrieval type identifier. For GAIA DR2 possible values are ['EPOCH_PHOTOMETRY'] | ||
| For future GAIA DR3 (Once published), possible values will be ['EPOC_PHOTOMETRY', 'RVS', 'XP_CONTINUOUS', | ||
| 'XP_SAMPLED', 'MCMC_GSPPHOT' or 'MCMC_MSC'] | ||
| valid_data : bool, optional, default True | ||
| By default, the epoch photometry service returns only valid data, | ||
| that is, all data rows where flux is not null and | ||
| rejected_by_photometry flag is not true. In order to retrieve | ||
| all data associated to a given source without this filter, | ||
| this request parameter should be included (valid_data=False) | ||
| valid_data : bool, optional, default False | ||
| By default, the epoch photometry service returns all available data, including | ||
| data rows where flux is null and/or the rejected_by_photometry flag is set to True. | ||
| In order to retrieve only valid data (data rows where flux is not null and/or the | ||
| rejected_by_photometry flag is set to False) this request parameter should be included | ||
| with valid_data=True. | ||
| band : str, optional, default None, valid values: G, BP, RP | ||
| By default, the epoch photometry service returns all the | ||
| available photometry bands for the requested source. | ||
|
|
@@ -911,5 +917,27 @@ def launch_job_async(self, query, name=None, output_file=None, | |
| upload_table_name=upload_table_name, | ||
| autorun=autorun) | ||
|
|
||
| def get_status_messages(self): | ||
| """Retrieve the messages to inform users about | ||
| the status of Gaia TAP | ||
| """ | ||
| try: | ||
| subContext = self.GAIA_MESSAGES | ||
| connHandler = self._TapPlus__getconnhandler() | ||
| response = connHandler.execute_tapget(subContext, False) | ||
| if response.status == 200: | ||
| if isinstance(response, Iterable): | ||
| for line in response: | ||
|
|
||
| try: | ||
| print(line.decode("utf-8").split('=', 1)[1]) | ||
| except ValueError as e: | ||
| print(e) | ||
| except IndexError: | ||
| print("Archive down for maintenance") | ||
|
|
||
| except OSError: | ||
| print("Status messages could not be retrieved") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why the try/except, why not raise this as an exception instead? Is it expected to be unstable? Also, no need for catching the exception (
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated. Thank you! |
||
|
|
||
|
|
||
| Gaia = GaiaClass() | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is best to use the most specific error type possible. In this case it looks like
ConnectionErroror perhaps even one of its subclasses would be more appropriate.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have opened a internal ticket to review your proposal