18
18
from ..utils import async_to_sync , class_or_instance
19
19
from ..exceptions import InvalidQueryError , EmptyResponseError
20
20
21
-
22
21
__all__ = ['MPCClass' ]
23
22
24
23
@@ -1052,7 +1051,6 @@ def _parse_result(self, result, **kwargs):
1052
1051
raise InvalidQueryError (content )
1053
1052
table_end = content .find ('</pre>' )
1054
1053
text_table = content [table_start + 5 :table_end ]
1055
-
1056
1054
SKY = 'raty=a' in result .request .body
1057
1055
HELIOCENTRIC = 'raty=s' in result .request .body
1058
1056
GEOCENTRIC = 'raty=G' in result .request .body
@@ -1061,12 +1059,20 @@ def _parse_result(self, result, **kwargs):
1061
1059
# find column headings
1062
1060
if SKY :
1063
1061
# slurp to newline after "h m s"
1064
- i = text_table .index ('\n ' , text_table .index ('h m s' )) + 1
1062
+ # raise EmptyResponseError if no ephemeris lines are found in the query response
1063
+ try :
1064
+ i = text_table .index ('\n ' , text_table .index ('h m s' )) + 1
1065
+ except ValueError :
1066
+ raise EmptyResponseError (content )
1065
1067
columns = text_table [:i ]
1066
1068
data_start = columns .count ('\n ' ) - 1
1067
1069
else :
1068
1070
# slurp to newline after "JD_TT"
1069
- i = text_table .index ('\n ' , text_table .index ('JD_TT' )) + 1
1071
+ # raise EmptyResponseError if no ephemeris lines are found in the query response
1072
+ try :
1073
+ i = text_table .index ('\n ' , text_table .index ('JD_TT' )) + 1
1074
+ except ValueError :
1075
+ raise EmptyResponseError (content )
1070
1076
columns = text_table [:i ]
1071
1077
data_start = columns .count ('\n ' ) - 1
1072
1078
@@ -1088,24 +1094,24 @@ def _parse_result(self, result, **kwargs):
1088
1094
elif 's=s' in result .request .body : # sky Motion
1089
1095
names += ('dRA cos(Dec)' , 'dDec' )
1090
1096
units += ('arcsec/h' , 'arcsec/h' )
1091
- col_starts += (73 , 81 )
1092
- col_ends += (80 , 89 )
1097
+ col_starts += (73 , 82 )
1098
+ col_ends += (81 , 91 )
1093
1099
1094
1100
if 'Moon' in columns :
1095
1101
# table includes Alt, Az, Sun and Moon geometry
1096
1102
names += ('Azimuth' , 'Altitude' , 'Sun altitude' , 'Moon phase' ,
1097
1103
'Moon distance' , 'Moon altitude' )
1098
1104
col_starts += tuple ((col_ends [- 1 ] + offset for offset in
1099
- ( 2 , 9 , 14 , 20 , 27 , 33 )))
1105
+ ( 1 , 8 , 13 , 19 , 26 , 32 )))
1100
1106
col_ends += tuple ((col_ends [- 1 ] + offset for offset in
1101
- ( 8 , 13 , 19 , 26 , 32 , 37 )))
1107
+ ( 7 , 12 , 18 , 25 , 31 , 36 )))
1102
1108
units += ('deg' , 'deg' , 'deg' , None , 'deg' , 'deg' )
1103
1109
if 'Uncertainty' in columns :
1104
1110
names += ('Uncertainty 3sig' , 'Unc. P.A.' )
1105
1111
col_starts += tuple ((col_ends [- 1 ] + offset for offset in
1106
- (2 , 11 )))
1112
+ (1 , 10 )))
1107
1113
col_ends += tuple ((col_ends [- 1 ] + offset for offset in
1108
- (10 , 16 )))
1114
+ (9 , 15 )))
1109
1115
units += ('arcsec' , 'deg' )
1110
1116
if ">Map</a>" in first_row and self ._unc_links :
1111
1117
names += ('Unc. map' , 'Unc. offsets' )
@@ -1171,7 +1177,6 @@ def _parse_result(self, result, **kwargs):
1171
1177
else :
1172
1178
# convert from MPES string to Time
1173
1179
tab ['JD' ] = Time (tab ['JD' ], format = 'jd' , scale = 'tt' )
1174
-
1175
1180
return tab
1176
1181
1177
1182
elif self .query_type == 'observations' :
0 commit comments