@@ -18,7 +18,7 @@ class XMatchClass(BaseQuery):
1818 TIMEOUT = conf .timeout
1919
2020 def query (self , cat1 , cat2 , max_distance , colRA1 = None , colDec1 = None ,
21- colRA2 = None , colDec2 = None , cache = True ):
21+ colRA2 = None , colDec2 = None , cache = True , get_query_payload = False ):
2222 """
2323 Query the `CDS cross-match service
2424 <http://cdsxmatch.u-strasbg.fr/xmatch>`_ by finding matches between
@@ -58,12 +58,16 @@ def query(self, cat1, cat2, max_distance, colRA1=None, colDec1=None,
5858 Query results table
5959 """
6060 response = self .query_async (cat1 , cat2 , max_distance , colRA1 , colDec1 ,
61- colRA2 , colDec2 , cache = cache )
61+ colRA2 , colDec2 , cache = cache ,
62+ get_query_payload = get_query_payload )
63+ if get_query_payload :
64+ return response
6265 return ascii .read (response .text , format = 'csv' )
6366
6467 @prepend_docstr_noreturns ("\n " + query .__doc__ )
6568 def query_async (self , cat1 , cat2 , max_distance , colRA1 = None , colDec1 = None ,
66- colRA2 = None , colDec2 = None , cache = True ):
69+ colRA2 = None , colDec2 = None , cache = True ,
70+ get_query_payload = False ):
6771 """
6872 Returns
6973 -------
@@ -83,8 +87,13 @@ def query_async(self, cat1, cat2, max_distance, colRA1=None, colDec1=None,
8387 self ._prepare_sending_table (1 , payload , kwargs , cat1 , colRA1 , colDec1 )
8488 self ._prepare_sending_table (2 , payload , kwargs , cat2 , colRA2 , colDec2 )
8589
90+ if get_query_payload :
91+ return payload , kwargs
92+
8693 response = self ._request (method = 'POST' , url = self .URL , data = payload ,
8794 timeout = self .TIMEOUT , cache = cache , ** kwargs )
95+ response .raise_for_status ()
96+
8897 return response
8998
9099 def _prepare_sending_table (self , i , payload , kwargs , cat , colRA , colDec ):
@@ -101,10 +110,10 @@ def _prepare_sending_table(self, i, payload, kwargs, cat, colRA, colDec):
101110 fp = six .StringIO ()
102111 cat .write (fp , format = 'ascii.csv' )
103112 fp .seek (0 )
104- kwargs ['files' ] = {catstr : fp }
113+ kwargs ['files' ] = {catstr : ( 'cat1.csv' , fp . read ()) }
105114 else :
106115 # assume it's a file-like object, support duck-typing
107- kwargs ['files' ] = {catstr : cat }
116+ kwargs ['files' ] = {catstr : ( 'cat1.csv' , cat . read ()) }
108117 if not self .is_table_available (cat ):
109118 if ((colRA is None ) or (colDec is None )):
110119 raise ValueError ('Specify the name of the RA/Dec columns in' +
0 commit comments