32
32
from astropy .io import fits
33
33
from astropy .table import Table
34
34
from astropy import units as u
35
+ import warnings
35
36
36
37
37
38
class GaiaClass (TapPlus ):
@@ -429,7 +430,8 @@ def __query_object(self, coordinate, radius=None, width=None, height=None,
429
430
dist ASC
430
431
""" .format (** {'row_limit' : "TOP {0}" .format (self .ROW_LIMIT ) if self .ROW_LIMIT > 0 else "" ,
431
432
'ra_column' : self .MAIN_GAIA_TABLE_RA , 'dec_column' : self .MAIN_GAIA_TABLE_DEC ,
432
- 'columns' : columns , 'table_name' : self .MAIN_GAIA_TABLE or conf .MAIN_GAIA_TABLE , 'ra' : ra , 'dec' : dec ,
433
+ 'columns' : columns , 'table_name' : self .MAIN_GAIA_TABLE or conf .MAIN_GAIA_TABLE ,
434
+ 'ra' : ra , 'dec' : dec ,
433
435
'width' : widthDeg .value , 'height' : heightDeg .value })
434
436
if async_job :
435
437
job = self .launch_job_async (query , verbose = verbose )
@@ -566,7 +568,8 @@ def __cone_search(self, coordinate, radius, table_name=None,
566
568
""" .format (** {'ra_column' : ra_column_name ,
567
569
'row_limit' : "TOP {0}" .format (self .ROW_LIMIT ) if self .ROW_LIMIT > 0 else "" ,
568
570
'dec_column' : dec_column_name , 'columns' : columns , 'ra' : ra , 'dec' : dec ,
569
- 'radius' : radiusDeg , 'table_name' : table_name or self .MAIN_GAIA_TABLE or conf .MAIN_GAIA_TABLE })
571
+ 'radius' : radiusDeg ,
572
+ 'table_name' : table_name or self .MAIN_GAIA_TABLE or conf .MAIN_GAIA_TABLE })
570
573
571
574
if async_job :
572
575
return self .launch_job_async (query = query ,
@@ -823,12 +826,14 @@ def launch_job(self, query, name=None, output_file=None,
823
826
----------
824
827
query : str, mandatory
825
828
query to be executed
829
+ name : str, optional, default None
830
+ custom name defined by the user for the job that is going to be created
826
831
output_file : str, optional, default None
827
832
file name where the results are saved if dumpToFile is True.
828
833
If this parameter is not provided, the jobid is used instead
829
834
output_format : str, optional, default 'votable'
830
835
results format. Available formats are: 'votable', 'votable_plain',
831
- 'fits', 'csv' and 'json', default is 'votable'.
836
+ 'fits', 'csv', 'ecsv' and 'json', default is 'votable'.
832
837
Returned results for 'votable' and 'fits' formats are compressed
833
838
gzip files.
834
839
verbose : bool, optional, default 'False'
@@ -845,8 +850,30 @@ def launch_job(self, query, name=None, output_file=None,
845
850
-------
846
851
A Job object
847
852
"""
853
+ compressed_extension = ".gz"
854
+ format_with_results_compressed = ['votable' , 'fits' ]
855
+ output_file_with_extension = output_file
856
+
857
+ if output_file is not None :
858
+ if output_format in format_with_results_compressed :
859
+ # In this case we will have to take also into account the .fits format
860
+ if not output_file .endswith (compressed_extension ):
861
+ warnings .warn ('WARNING!!! By default, results in "votable" and "fits" format are returned in '
862
+ f'compressed format therefore your file { output_file } '
863
+ f'will be renamed to { output_file } .gz' )
864
+ if output_format == 'votable' :
865
+ if output_file .endswith ('.vot' ):
866
+ output_file_with_extension = output_file + '.gz'
867
+ else :
868
+ output_file_with_extension = output_file + '.vot.gz'
869
+ elif output_format == 'fits' :
870
+ if output_file .endswith ('.fits' ):
871
+ output_file_with_extension = output_file + '.gz'
872
+ else :
873
+ output_file_with_extension = output_file + '.fits.gz'
874
+
848
875
return TapPlus .launch_job (self , query = query , name = name ,
849
- output_file = output_file ,
876
+ output_file = output_file_with_extension ,
850
877
output_format = output_format ,
851
878
verbose = verbose ,
852
879
dump_to_file = dump_to_file ,
@@ -864,6 +891,8 @@ def launch_job_async(self, query, name=None, output_file=None,
864
891
----------
865
892
query : str, mandatory
866
893
query to be executed
894
+ name : str, optional, default None
895
+ custom name defined by the user for the job that is going to be created
867
896
output_file : str, optional, default None
868
897
file name where the results are saved if dumpToFile is True.
869
898
If this parameter is not provided, the jobid is used instead
@@ -892,9 +921,31 @@ def launch_job_async(self, query, name=None, output_file=None,
892
921
-------
893
922
A Job object
894
923
"""
924
+ compressed_extension = ".gz"
925
+ format_with_results_compressed = ['votable' , 'fits' ]
926
+ output_file_with_extension = output_file
927
+
928
+ if output_file is not None :
929
+ if output_format in format_with_results_compressed :
930
+ # In this case we will have to take also into account the .fits format
931
+ if not output_file .endswith (compressed_extension ):
932
+ warnings .warn ('WARNING!!! By default, results in "votable" and "fits" format are returned in '
933
+ f'compressed format therefore your file { output_file } '
934
+ f'will be renamed to { output_file } .gz' )
935
+ if output_format == 'votable' :
936
+ if output_file .endswith ('.vot' ):
937
+ output_file_with_extension = output_file + '.gz'
938
+ else :
939
+ output_file_with_extension = output_file + '.vot.gz'
940
+ elif output_format == 'fits' :
941
+ if output_file .endswith ('.fits' ):
942
+ output_file_with_extension = output_file + '.gz'
943
+ else :
944
+ output_file_with_extension = output_file + '.fits.gz'
945
+
895
946
return TapPlus .launch_job_async (self , query = query ,
896
947
name = name ,
897
- output_file = output_file ,
948
+ output_file = output_file_with_extension ,
898
949
output_format = output_format ,
899
950
verbose = verbose ,
900
951
dump_to_file = dump_to_file ,
0 commit comments