@@ -790,7 +790,7 @@ def __getQuantityInput(self, value, msg):
790
790
if value is None :
791
791
raise ValueError (f"Missing required argument: { msg } " )
792
792
if not (isinstance (value , str ) or isinstance (value , units .Quantity )):
793
- raise ValueError (f"{ msg } must be either a string or astropy.coordinates" )
793
+ raise ValueError (f"{ msg } must be either a string or astropy.coordinates: { type ( value ) } " )
794
794
795
795
if isinstance (value , str ):
796
796
return Quantity (value )
@@ -883,8 +883,9 @@ def cross_match_basic(self, *, table_a_full_qualified_name, table_a_column_ra, t
883
883
the ‘dec’ column in the table table_b_full_qualified_name
884
884
results_name : str, optional, default None
885
885
custom name defined by the user for the job that is going to be created
886
- radius : float (arc. seconds), optional, default 1.0
887
- radius (valid range: 0.1-10.0)
886
+ radius : float (arc. seconds), str or astropy.coordinate, optional, default 1.0
887
+ radius (valid range: 0.1-10.0). For an astropy.coordinate any angular unit is valid, but its value in arc
888
+ sec must be contained within the valid range.
888
889
background : bool, optional, default 'False'
889
890
when the job is executed in asynchronous mode, this flag specifies
890
891
whether the execution will wait until results are available
@@ -896,8 +897,12 @@ def cross_match_basic(self, *, table_a_full_qualified_name, table_a_column_ra, t
896
897
A Job object
897
898
"""
898
899
899
- if radius < 0.1 or radius > 10.0 :
900
- raise ValueError (f"Invalid radius value. Found { radius } , valid range is: 0.1 to 10.0" )
900
+ radius_quantity = self .__get_radius_as_quantity_arcsec (radius )
901
+
902
+ radius_arc_sec = radius_quantity .value
903
+
904
+ if radius_arc_sec < 0.1 or radius_arc_sec > 10.0 :
905
+ raise ValueError (f"Invalid radius value. Found { radius_quantity } , valid range is: 0.1 to 10.0" )
901
906
902
907
schema_a = self .__get_schema_name (table_a_full_qualified_name )
903
908
if not schema_a :
@@ -928,7 +933,7 @@ def cross_match_basic(self, *, table_a_full_qualified_name, table_a_column_ra, t
928
933
f"b.{ table_b_column_dec } ) AS separation, b.* "
929
934
f"FROM { table_a_full_qualified_name } AS a JOIN { table_b_full_qualified_name } AS b "
930
935
f"ON DISTANCE(a.{ table_a_column_ra } , a.{ table_a_column_dec } , b.{ table_b_column_ra } , b.{ table_b_column_dec } )"
931
- f" < { radius } / 3600. " )
936
+ f" < { radius_quantity . to ( u . deg ). value } " )
932
937
933
938
return self .launch_job_async (query = query ,
934
939
name = results_name ,
@@ -940,6 +945,16 @@ def cross_match_basic(self, *, table_a_full_qualified_name, table_a_column_ra, t
940
945
upload_resource = None ,
941
946
upload_table_name = None )
942
947
948
+ def __get_radius_as_quantity_arcsec (self , radius ):
949
+ """
950
+ transform the input radius into an astropy.Quantity in arc seconds
951
+ """
952
+ if not isinstance (radius , units .Quantity ):
953
+ radius_quantity = Quantity (value = radius , unit = u .arcsec )
954
+ else :
955
+ radius_quantity = radius .to (u .arcsec )
956
+ return radius_quantity
957
+
943
958
def __update_ra_dec_columns (self , full_qualified_table_name , column_ra , column_dec , table_metadata , verbose ):
944
959
"""
945
960
Update table metadata for the ‘ra’ and the ‘dec’ columns in the input table
@@ -1007,8 +1022,9 @@ def cross_match(self, *, full_qualified_table_name_a,
1007
1022
a full qualified table name (i.e. schema name and table name)
1008
1023
results_table_name : str, mandatory
1009
1024
a table name without schema. The schema is set to the user one
1010
- radius : float (arc. seconds), optional, default 1.0
1011
- radius (valid range: 0.1-10.0)
1025
+ radius : float (arc. seconds), str or astropy.coordinate, optional, default 1.0
1026
+ radius (valid range: 0.1-10.0). For an astropy.coordinate any angular unit is valid, but its value in arc
1027
+ sec must be contained within the valid range.
1012
1028
background : bool, optional, default 'False'
1013
1029
when the job is executed in asynchronous mode, this flag specifies
1014
1030
whether the execution will wait until results are available
@@ -1019,8 +1035,13 @@ def cross_match(self, *, full_qualified_table_name_a,
1019
1035
-------
1020
1036
A Job object
1021
1037
"""
1022
- if radius < 0.1 or radius > 10.0 :
1023
- raise ValueError (f"Invalid radius value. Found { radius } , valid range is: 0.1 to 10.0" )
1038
+
1039
+ radius_quantity = self .__get_radius_as_quantity_arcsec (radius )
1040
+
1041
+ radius_arc_sec = radius_quantity .value
1042
+
1043
+ if radius_arc_sec < 0.1 or radius_arc_sec > 10.0 :
1044
+ raise ValueError (f"Invalid radius value. Found { radius_quantity } , valid range is: 0.1 to 10.0" )
1024
1045
1025
1046
schema_a = self .__get_schema_name (full_qualified_table_name_a )
1026
1047
@@ -1033,7 +1054,7 @@ def cross_match(self, *, full_qualified_table_name_a,
1033
1054
if taputils .get_schema_name (results_table_name ) is not None :
1034
1055
raise ValueError ("Please, do not specify schema for 'results_table_name'" )
1035
1056
1036
- query = f"SELECT crossmatch_positional('{ schema_a } ','{ table_a } ','{ schema_b } ','{ table_b } ',{ radius } , " \
1057
+ query = f"SELECT crossmatch_positional('{ schema_a } ','{ table_a } ','{ schema_b } ','{ table_b } ',{ radius_arc_sec } , " \
1037
1058
f"'{ results_table_name } ') FROM dual;"
1038
1059
1039
1060
name = str (results_table_name )
0 commit comments