20
20
import os
21
21
import argparse
22
22
from warnings import warn
23
- from typing import Union
23
+ from typing import List , Union
24
24
25
25
import numpy as np
26
26
from numpy import ndarray , hstack , iterable
@@ -484,12 +484,12 @@ def from_mpc(cls, targetids, epochs=None, location='500', ra_format=None,
484
484
485
485
@classmethod
486
486
@requires ("astroquery" )
487
- @cite ({'data source' : 'http ://vo.imcce.fr/webservices/miriade/' ,
487
+ @cite ({'data source' : 'https ://vo.imcce.fr/webservices/miriade/' ,
488
488
'software: astroquery' : '2019AJ....157...98G' })
489
489
def from_miriade (cls , targetids , objtype = 'asteroid' ,
490
490
epochs = None , location = '500' , ** kwargs ):
491
491
"""Load target ephemerides from
492
- `IMCCE Miriade <http ://vo.imcce.fr/webservices/miriade/>`_ using
492
+ `IMCCE Miriade <https ://vo.imcce.fr/webservices/miriade/>`_ using
493
493
`astroquery.imcce.MiriadeClass.get_ephemerides`
494
494
495
495
Parameters
@@ -984,14 +984,8 @@ def main():
984
984
epochs = epochs ,
985
985
location = args .location ,
986
986
)
987
-
988
- # simplify output
989
- for k in ["Targetname" ]:
990
- del eph .table [k ]
991
987
elif args .service == "horizons" :
992
- epochs ["step" ] = (
993
- int (args .step ) if args .step .unit == u .dimensionless_unscaled else args .step
994
- )
988
+ epochs ["step" ] = args .step
995
989
996
990
# comet specific options: always avoid multiple fragment matches, always
997
991
# return closest apparition
@@ -1020,8 +1014,9 @@ def main():
1020
1014
eph ["epoch" ].format = "iso"
1021
1015
eph ["ra" ] = eph ["ra" ].unmasked
1022
1016
eph ["dec" ] = eph ["dec" ].unmasked
1023
- for k in ["M1" , "k1" , "solar_presence" , "lunar_presence" , "targetname" ]:
1024
- del eph .table [k ]
1017
+ for k in ["M1" , "k1" , "solar_presence" , "lunar_presence" ]:
1018
+ if k in eph .table .colnames :
1019
+ del eph .table [k ]
1025
1020
elif args .service == "miriade" :
1026
1021
if args .step .unit == u .dimensionless_unscaled :
1027
1022
epochs ["number" ] = int (args .step )
@@ -1038,8 +1033,7 @@ def main():
1038
1033
1039
1034
# simplify output
1040
1035
eph ["epoch" ].format = "iso"
1041
- for k in ["target" ]:
1042
- del eph .table [k ]
1036
+
1043
1037
for k in eph .field_names :
1044
1038
if hasattr (eph [k ], "unmasked" ):
1045
1039
eph [k ] = eph [k ].unmasked
@@ -1057,28 +1051,40 @@ def main():
1057
1051
eph ["ra" ].info .format = lambda x : x .to_string ()
1058
1052
eph ["dec" ].info .format = lambda x : x .to_string ()
1059
1053
1060
- # unified output order for most common columns
1061
- fields = eph .field_names
1062
- for k in eph ._translate_columns (
1063
- [
1064
- "RA*cos(Dec)_rate" ,
1065
- "DEC_rate" ,
1066
- "elong" ,
1067
- "phase" ,
1068
- "delta" ,
1069
- "rh" ,
1070
- "dec" ,
1071
- "ra" ,
1072
- "epoch" ,
1073
- ],
1074
- ignore_missing = True ,
1075
- ):
1054
+ # normalize output for most common columns
1055
+ first_fields : List [str ] = [
1056
+ "target" ,
1057
+ "date" ,
1058
+ "RA" ,
1059
+ "Dec" ,
1060
+ "rh" ,
1061
+ "delta" ,
1062
+ "phase" ,
1063
+ "solarelong" ,
1064
+ "DEC_rate" ,
1065
+ "RA*cos(Dec)_rate" ,
1066
+ ]
1067
+
1068
+ k : str
1069
+ translated : str
1070
+ for k in first_fields :
1071
+ if k not in eph :
1072
+ continue
1073
+ translated = eph ._translate_columns (k )[0 ]
1074
+ eph .table .rename_column (translated , k )
1075
+
1076
+ # re-order
1077
+ fields : List [str ] = eph .field_names
1078
+ for k in reversed (first_fields ):
1076
1079
if k not in fields :
1077
1080
continue
1078
1081
fields .insert (0 , fields .pop (fields .index (k )))
1079
1082
1080
- eph [fields ].table .pprint_all ()
1081
-
1083
+ eph = eph [fields ]
1084
+ target = eph ["target" ][0 ]
1085
+ del eph .table ["target" ]
1082
1086
1083
- if __name__ == "__main__" :
1084
- main ()
1087
+ print (f"# requested target: { args .target } " )
1088
+ print (f"# returned target: { target } " )
1089
+ print (f"# location: { args .location } " )
1090
+ eph .table .pprint_all ()
0 commit comments