Skip to content

Commit ade4c4c

Browse files
mhsarmientojespinosaar
authored andcommitted
small corrections after rebase of the branch
1 parent 380fc6b commit ade4c4c

File tree

8 files changed

+53
-73
lines changed

8 files changed

+53
-73
lines changed

astroquery/gaia/core.py

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
European Space Agency (ESA)
1212
1313
Created on 30 jun. 2016
14-
Modified on 1 jun. 2021 by mhsarmiento
15-
Version: gaia-astroquery-1.0
14+
1615
1716
"""
1817
from requests import HTTPError
@@ -173,9 +172,12 @@ def load_data(self, ids, data_release=None, data_structure='INDIVIDUAL', retriev
173172
By default, it takes the current default one.
174173
data_structure: str, optional, default 'INDIVIDUAL'
175174
it can be 'INDIVIDUAL', 'COMBINED', 'RAW':
176-
'INDIVIDUAL' means...
177-
'COMBINED' means...
178-
'RAW' means...
175+
'INDIVIDUAL' products are provided in separate files for each sourceId. All files are zipped in a single
176+
bundle, even if only one source/file is considered
177+
'COMBINED' products are provided in a single file concatenating the data of all sourceIds together.
178+
How this is organised depends on the chosen format
179+
'RAW' products are provided following a Data Model similar to that used in the MDB, meaning in
180+
particular that parameters stored as arrays will remain as such. Like in the COMBINED structure, a single file is provided for the data of all sourceIds together, but in this case there will be always be one row per sourceId
179181
retrieval_type : str, optional, default 'ALL'
180182
retrieval type identifier. It can be either 'epoch_photometry'
181183
for compatibility reasons or 'ALL' to retrieve all data from
@@ -194,7 +196,7 @@ def load_data(self, ids, data_release=None, data_structure='INDIVIDUAL', retriev
194196
By default, this value will be set to False. If it is set to 'true'
195197
the Datalink items tags will not be checked.
196198
format : str, optional, default 'votable'
197-
loading format
199+
loading format. Other available formats are 'csv' and 'fits'
198200
output_file : string, optional, default None
199201
file where the results are saved.
200202
If it is not provided, the http response contents are returned.
@@ -903,23 +905,20 @@ def launch_job_async(self, query, name=None, output_file=None,
903905

904906
def rename_table(self, table_name=None, new_table_name=None, new_column_names_dict={},
905907
verbose=False):
906-
""" This new method allows you to update the column names of a user table.
907-
908-
Parameters
909-
----------
910-
table_name: str, required
911-
old name of the user's table
912-
new_table_name: str, required
913-
new name of the user's table
914-
new_column_names_dict: dict str:str, required
915-
dict with pairs "old_column1_name:new_column1_name"
916-
verbose : bool, optional, default 'False'
917-
flag to display information about the process
918-
919-
Example
920-
-------
921-
TapPlus.rename_table.rename_table(table_name=old_table_name, new_table_name=new_table_name,
922-
new_column_names_dict=[old_column1:new_column1, old_column2:new_column2, ...])
908+
"""
909+
This new method allows to update the column names of a user table.
910+
header example: rename_table(table_name=old_table_name, new_table_name=new_table_name -optional-
911+
, new_column_names_dict=[old_column1:new_column1, old_column2:new_colum2...])
912+
Parameters
913+
----------
914+
table_name: str, required
915+
old name of the user's table
916+
new_table_name: str, required
917+
new name of the user's table
918+
new_column_names_dict: dict str:str, required
919+
dict with pairs "old_column1_name:new_column1_name"
920+
verbose : bool, optional, default 'False'
921+
flag to display information about the process
923922
"""
924923
return TapPlus.rename_table(self, table_name=table_name, new_table_name=new_table_name,
925924
new_column_names_dict=new_column_names_dict, verbose=verbose)

astroquery/utils/tap/conn/tapconn.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def __init__(self, ishttps,
8787
self.__connPort = port
8888
self.__connPortSsl = sslport
8989
if server_context is not None:
90-
if (server_context.startswith("/")):
90+
if(server_context.startswith("/")):
9191
self.__serverContext = server_context
9292
else:
9393
self.__serverContext = f"/{server_context}"
@@ -107,7 +107,7 @@ def __init__(self, ishttps,
107107

108108
def __create_context(self, context):
109109
if (context is not None and context != ""):
110-
if (str(context).startswith("/")):
110+
if(str(context).startswith("/")):
111111
return f"{self.__serverContext}{context}"
112112
else:
113113
return f"{self.__serverContext}/{context}"
@@ -125,7 +125,7 @@ def __interna_init(self):
125125
self.__postHeaders = {
126126
"Content-type": CONTENT_TYPE_POST_DEFAULT,
127127
"Accept": "text/plain"
128-
}
128+
}
129129
self.__getHeaders = {}
130130
self.__cookie = None
131131
self.__currentStatus = 0
@@ -414,6 +414,9 @@ def execute_table_tool(self, data,
414414
context = self.__get_table_edit_context()
415415
return self.__execute_post(context, data, content_type, verbose)
416416

417+
418+
419+
417420
def __execute_post(self, context, data,
418421
content_type=CONTENT_TYPE_POST_DEFAULT,
419422
verbose=False):
@@ -599,7 +602,7 @@ def get_file_from_header(self, headers):
599602
if content_disposition is not None:
600603
p = content_disposition.find('filename="')
601604
if p >= 0:
602-
filename = content_disposition[p + 10:len(content_disposition) - 1]
605+
filename = content_disposition[p+10:len(content_disposition)-1]
603606
content_encoding = self.find_header(headers, 'Content-Encoding')
604607
if content_encoding is not None:
605608
if "gzip" == content_encoding.lower():
@@ -733,7 +736,7 @@ def encode_multipart(self, fields, files):
733736

734737
def __str__(self):
735738
return f"\tHost: {self.__connHost}\n\tUse HTTPS: {self.__isHttps}" \
736-
f"\n\tPort: {self.__connPort}\n\tSSL Port: {self.__connPortSsl}"
739+
f"\n\tPort: {self.__connPort}\n\tSSL Port: {self.__connPortSsl}"
737740

738741

739742
class ConnectionHandler:

astroquery/utils/tap/core.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,7 +1245,7 @@ def get_datalinks(self, ids, verbose=False):
12451245
print("Retrieving datalink.")
12461246
if ids is None:
12471247
raise ValueError("Missing mandatory argument 'ids'")
1248-
if isinstance(ids, str):
1248+
if isinstance(ids, str):
12491249
ids_arg = f"ID={ids}"
12501250
else:
12511251
if isinstance(ids, int):
@@ -1368,7 +1368,7 @@ def login(self, user=None, password=None, credentials_file=None,
13681368
user = ins.readline().strip()
13691369
password = ins.readline().strip()
13701370
if user is None:
1371-
user = input("User: ")
1371+
user = input("User: ")
13721372
if user is None:
13731373
print("Invalid user name")
13741374
return
@@ -2059,7 +2059,7 @@ def login(self, user=None, password=None, credentials_file=None,
20592059
user = ins.readline().strip()
20602060
password = ins.readline().strip()
20612061
if user is None:
2062-
user = input("User: ")
2062+
user = input("User: ")
20632063
if user is None:
20642064
log.info("Invalid user name")
20652065
return
@@ -2165,4 +2165,4 @@ def __changesContainFlag(changes=None, flag=None, verbose=False):
21652165
return c
21662166

21672167
def __getconnhandler(self):
2168-
return self._Tap__connHandler
2168+
return self._Tap__connHandler

astroquery/utils/tap/tests/data/job_1.vot

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<VOTABLE version="1.3" xmlns="http://www.ivoa.net/xml/VOTable/v1.3">
22
<RESOURCE type="results">
33
<INFO name="QUERY_STATUS" value="OK"/>
4-
<INFO name="ADQL_QUERY" value="select * from user_mhenar.table_test_update" />
4+
<INFO name="ADQL_QUERY" value="select * from user_test.table_test_update" />
55
<INFO name="CAPTION" value="If you use public Gaia DR1 data in your paper, please take note of our guide on how to acknowledge and cite Gaia DR1: http://gaia.esac.esa.int/documentation/GDR1/Miscellaneous/sec_credit_and_citation_instructions.html" />
66
<TABLE>
77
<FIELD datatype="double" name="ra">
@@ -14,7 +14,7 @@
1414
<DESCRIPTION>source_id</DESCRIPTION>
1515
</FIELD>
1616
<FIELD datatype="int" name="table1_oid">
17-
<DESCRIPTION>table_test_update_oid</DESCRIPTION>
17+
<DESCRIPTION>table1_oid</DESCRIPTION>
1818
</FIELD>
1919
<DATA>
2020
<BINARY2>

astroquery/utils/tap/tests/data/table_test_rename.vot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<VOTABLE version="1.3" xmlns="http://www.ivoa.net/xml/VOTable/v1.3">
22
<RESOURCE type="results">
33
<INFO name="QUERY_STATUS" value="OK"/>
4-
<INFO name="ADQL_QUERY" value="select * from user_mhenar.table_test_update" />
4+
<INFO name="ADQL_QUERY" value="select * from user_test.table_test_update" />
55
<INFO name="CAPTION" value="If you use public Gaia DR1 data in your paper, please take note of our guide on how to acknowledge and cite Gaia DR1: http://gaia.esac.esa.int/documentation/GDR1/Miscellaneous/sec_credit_and_citation_instructions.html" />
66
<TABLE>
77
<FIELD datatype="double" name="ra">

astroquery/utils/tap/tests/data/test_table_rename.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<name>user_mhenar</name>
88
<description/>
99
<table type="base_table" esatapplus:size="3" esatapplus:flags="0">
10-
<name>user_mhenar.table1</name>
10+
<name>user_test.table1</name>
1111
<description>
1212
<![CDATA[ Uploaded from disk ]]>
1313
</description>

astroquery/utils/tap/tests/test_tap.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -205,13 +205,13 @@ def test_launch_sync_job():
205205
results = job.get_results()
206206
assert len(results) == 3
207207
__check_results_column(results,
208-
'alpha',
209-
'alpha',
208+
'ra',
209+
'ra',
210210
None,
211211
np.float64)
212212
__check_results_column(results,
213-
'delta',
214-
'delta',
213+
'dec',
214+
'dec',
215215
None,
216216
np.float64)
217217
__check_results_column(results,
@@ -308,13 +308,13 @@ def test_launch_sync_job_redirect():
308308
results = job.get_results()
309309
assert len(results) == 3
310310
__check_results_column(results,
311-
'alpha',
312-
'alpha',
311+
'ra',
312+
'ra',
313313
None,
314314
np.float64)
315315
__check_results_column(results,
316-
'delta',
317-
'delta',
316+
'dec',
317+
'dec',
318318
None,
319319
np.float64)
320320
__check_results_column(results,
@@ -404,13 +404,13 @@ def test_launch_async_job():
404404
results = job.get_results()
405405
assert len(results) == 3
406406
__check_results_column(results,
407-
'alpha',
408-
'alpha',
407+
'ra',
408+
'ra',
409409
None,
410410
np.float64)
411411
__check_results_column(results,
412-
'delta',
413-
'delta',
412+
'dec',
413+
'dec',
414414
None,
415415
np.float64)
416416
__check_results_column(results,
@@ -954,8 +954,8 @@ def test_update_user_table():
954954

955955

956956
def test_rename_table():
957-
tableName = 'user_mhenar.table_test_rename'
958-
newTableName = 'user_mhenar.table_test_rename_new'
957+
tableName = 'user_test.table_test_rename'
958+
newTableName = 'user_test.table_test_rename_new'
959959
newColumnNames = {'ra': 'alpha', 'dec': 'delta'}
960960
connHandler = DummyConnHandler()
961961
tap = TapPlus("http://test:1111/tap", connhandler=connHandler)
@@ -997,8 +997,6 @@ def test_rename_table():
997997
tap.rename_table(table_name=tableName, new_table_name=newTableName, new_column_names_dict=newColumnNames)
998998

999999

1000-
# __end_of_Test
1001-
10021000
def __find_table(schemaName, tableName, tables):
10031001
qualifiedName = f"{schemaName}.{tableName}"
10041002
for table in (tables):

docs/gaia/gaia.rst

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ will be able to access to your shared table in a query.
849849
>>> from astroquery.gaia import Gaia
850850
>>> Gaia.login()
851851
>>> Gaia.share_table(group_name="my_group",
852-
... table_name="user_<user_loign_name>.my_table",
852+
... table_name="user_<user_login_name>.my_table",
853853
... description="description")
854854
855855
@@ -862,26 +862,6 @@ will be able to access to your shared table in a query.
862862
>>> Gaia.login()
863863
>>> Gaia.share_table_stop(table_name="user_<user_login_name>.my_table", group_name="my_group")
864864
865-
2.7.8. Rename Table
866-
~~~~~~~~~~~~~~~~~~~~
867-
868-
This query allows the user to rename a table and/or its columns names. For this method it is only mandatory
869-
to provide the old name of the table and at least one of the following parameters: new table name and/or
870-
new columns names. Here is an example:
871-
872-
873-
.. code-block:: python
874-
875-
>>>from astroquery.gaia import Gaia, GaiaClass
876-
>>>from astroquery.utils.tap.model.tapcolumn import TapColumn
877-
>>>from astroquery.utils.tap.core import TapPlus, TAP_CLIENT_ID
878-
>>>from astroquery.utils.tap import taputils
879-
>>>gaia = GaiaClass(gaia_tap_server='https://<env>.esac.esa.int/', gaia_data_server='https://<env>.esac.esa.int/')
880-
>>>gaia.login()
881-
>>>tableName = 'user_<user_login_name>.my_old_table_name'
882-
>>>newTableName = 'user_<user_login_name>.my_new_table_name'
883-
>>>newColumnNames = {'old_col_name1': 'new_col_name1', 'old_col_name2': 'new_col_name2'}
884-
>>>gaia.rename_table(table_name=tableName, new_table_name=newTableName, new_column_names_dict=newColumnNames,verbose=True)
885865
886866
Reference/API
887867
=============

0 commit comments

Comments
 (0)