3
3
obtain it from the ESA NEOCC portal and parse it to show it properly.
4
4
"""
5
5
6
- import io
7
6
import re
8
7
import requests
9
8
10
9
import numpy as np
11
10
12
11
from astropy .table import Table , Column
13
- from astropy .time import Time , TimeDelta
12
+ from astropy .time import Time
14
13
15
14
from astroquery .esa .neocc import conf
16
15
from astroquery .esa .neocc .utils import convert_time
@@ -59,7 +58,7 @@ def get_list_url(list_name):
59
58
"impacted_objects" : 'past_impactors_list' ,
60
59
"neo_catalogue_current" : 'neo_kc.cat' ,
61
60
"neo_catalogue_middle" : 'neo_km.cat'
62
- }
61
+ }
63
62
64
63
# Raise error is input is not in dictionary
65
64
if list_name not in lists_dict :
@@ -185,30 +184,30 @@ def parse_risk(resp_str):
185
184
186
185
neocc_lst = Table .read (resp_str , header_start = 2 , data_start = 4 , format = "ascii.fixed_width" )
187
186
188
- neocc_lst .rename_columns (("Num/des. Name" , "m" , "Vel km/s" ),
187
+ neocc_lst .rename_columns (("Num/des. Name" , "m" , "Vel km/s" ),
189
188
('Object Name' , 'Diameter in m' , 'Vel in km/s' ))
190
189
191
190
neocc_lst ['Date/Time' ] = Time (neocc_lst ['Date/Time' ], scale = "utc" )
192
191
neocc_lst ['*=Y' ] = neocc_lst ['*=Y' ].astype ("<U1" )
193
192
194
193
if "Years" in neocc_lst .colnames :
195
- first_year , last_year = np .array ([x .split ("-" ) for x in neocc_lst ["Years" ]]).swapaxes (0 ,1 ).astype (int )
196
- yr_index = neocc_lst .index_column ("Years" )
194
+ first_year , last_year = np .array ([x .split ("-" ) for x in neocc_lst ["Years" ]]).swapaxes (0 , 1 ).astype (int )
195
+ yr_index = neocc_lst .index_column ("Years" )
197
196
neocc_lst .remove_column ("Years" )
198
197
neocc_lst .add_column (Column (name = "Last Year" , data = last_year ), index = yr_index )
199
198
neocc_lst .add_column (Column (name = "First Year" , data = first_year ), index = yr_index )
200
199
201
- neocc_lst .meta = {'Object Name' : 'name of the NEA' ,
202
- 'Diamater in m' : 'approximate diameter in meters' ,
203
- '*=Y' : 'recording an asterisk if the value has been estimated from the absolute magnitude' ,
204
- 'Date/Time' : 'predicted impact date in datetime format' ,
205
- 'IP max' : 'Maximum Impact Probability' ,
206
- 'PS max' : 'Palermo scale rating' ,
207
- 'Vel in km/s' : 'Impact velocity at atmospheric entry in km/s' ,
208
- 'First year' : 'first year of possible impacts' ,
209
- 'Last year' : 'last year of possible impacts' ,
210
- 'IP cum' : 'Cumulative Impact Probability' ,
211
- 'PS cum' : 'Cumulative Palermo Scale' }
200
+ neocc_lst .meta = {'Object Name' : 'name of the NEA' ,
201
+ 'Diamater in m' : 'approximate diameter in meters' ,
202
+ '*=Y' : 'recording an asterisk if the value has been estimated from the absolute magnitude' ,
203
+ 'Date/Time' : 'predicted impact date in datetime format' ,
204
+ 'IP max' : 'Maximum Impact Probability' ,
205
+ 'PS max' : 'Palermo scale rating' ,
206
+ 'Vel in km/s' : 'Impact velocity at atmospheric entry in km/s' ,
207
+ 'First year' : 'first year of possible impacts' ,
208
+ 'Last year' : 'last year of possible impacts' ,
209
+ 'IP cum' : 'Cumulative Impact Probability' ,
210
+ 'PS cum' : 'Cumulative Palermo Scale' }
212
211
213
212
return neocc_lst
214
213
@@ -226,13 +225,10 @@ def parse_clo(resp_str):
226
225
Astropy Table with close approaches list data parsed.
227
226
"""
228
227
229
- neocc_lst = Table .read (resp_str , header_start = 2 , data_start = 4 , format = "ascii.fixed_width" ,
230
- names = ('Object Name' , 'Date' , 'Miss Distance in km' , 'Miss Distance in au' ,
231
- 'Miss Distance in LD' , 'Diameter in m' , '*=Yes' , 'H' , 'Max Bright' ,
232
- 'Rel. vel in km/s' , "drop" ))
233
-
234
- # Remove last column
235
- neocc_lst .remove_column ("drop" )
228
+ neocc_lst = Table .read (resp_str , header_start = 2 , data_start = 4 , format = "ascii.fixed_width" ,
229
+ names = ('Object Name' , 'Date' , 'Miss Distance in km' , 'Miss Distance in au' ,
230
+ 'Miss Distance in LD' , 'Diameter in m' , '*=Yes' , 'H' , 'Max Bright' ,
231
+ 'Rel. vel in km/s' , "CAI index" ))
236
232
237
233
neocc_lst ['Date' ] = Time (neocc_lst ['Date' ], scale = "utc" )
238
234
neocc_lst ["Diameter in m" ] = neocc_lst ["Diameter in m" ].astype (float )
@@ -264,10 +260,11 @@ def parse_pri(resp_str):
264
260
Astropy Table with priority list data parsed.
265
261
"""
266
262
267
- neocc_lst = Table .read (resp_str , data_start = 1 , format = "ascii.no_header" ,
268
- names = ['Priority' , 'Object' , 'R.A. in arcsec' , 'Decl. in deg' ,
269
- 'Elong. in deg' , 'V in mag' , 'Sky uncert.' , 'End of Visibility' ])
263
+ neocc_lst = Table .read (resp_str , data_start = 1 , format = "ascii.no_header" ,
264
+ names = ['Priority' , 'Object' , 'R.A. in arcsec' , 'Decl. in deg' ,
265
+ 'Elong. in deg' , 'V in mag' , 'Sky uncert.' , 'End of Visibility' ])
270
266
267
+ neocc_lst ["Object" ] = [x .replace (' ' , '' ) for x in neocc_lst ["Object" ]]
271
268
neocc_lst ['End of Visibility' ] = Time .strptime (neocc_lst ['End of Visibility' ], '%Y/%m/%d' )
272
269
273
270
neocc_lst .meta = {'Priority' : '0=UR: Urgent, 1=NE: Necessary, 2=US: Useful, 3=LP: Low Priority' ,
@@ -324,14 +321,14 @@ def parse_impacted(resp_str):
324
321
----------
325
322
data_byte_d : object
326
323
Decoded StringIO object.
327
-
324
+
328
325
Returns
329
326
-------
330
327
neocc_table : *astropy.table.table.Table*
331
328
Astropy table with impacted objects list data parsed.
332
329
"""
333
330
334
- neocc_table = Table .read (resp_str , header_start = 1 , format = "ascii.fixed_width" , fill_values = ['n/a' , np .nan ])
331
+ neocc_table = Table .read (resp_str , header_start = 1 , format = "ascii.fixed_width" , fill_values = ['n/a' , np .nan ])
335
332
neocc_table ['Impact date/time in UTC' ] = Time (neocc_table ['Impact date/time in UTC' ], scale = 'utc' )
336
333
337
334
return neocc_table
@@ -350,8 +347,8 @@ def parse_neo_catalogue(resp_str):
350
347
Astropy Table with catalogues of NEAs list data parsed.
351
348
"""
352
349
353
- neocc_lst = Table .read (resp_str , data_start = 6 , format = "ascii.no_header" ,
354
- names = ['Name' , 'Epoch (MJD)' , 'a' , 'e' , 'i' , 'long. node' , 'arg. peric.' ,
350
+ neocc_lst = Table .read (resp_str , data_start = 6 , format = "ascii.no_header" ,
351
+ names = ['Name' , 'Epoch (MJD)' , 'a' , 'e' , 'i' , 'long. node' , 'arg. peric.' ,
355
352
'mean anomaly' , 'absolute magnitude' , 'slope param.' , 'non-grav param.' ])
356
353
357
354
neocc_lst .meta = {'Name' : 'designator of the NEA' ,
@@ -362,9 +359,10 @@ def parse_neo_catalogue(resp_str):
362
359
'slope param' : 'Slope parameter' ,
363
360
'non-grav param.' : 'Number of non-gravitational parameters' }
364
361
365
- regex = re .search ("(format) += '(.+)'.+\n (rectype) += '(.+)'.+\n (elem) += '(.+)'.+\n (refsys) += (\w+ \w+)" , resp_str )
362
+ regex = re .search (r"(format) += '(.+)'.+\n(rectype) += '(.+)'.+\n(elem) "
363
+ r"+= '(.+)'.+\n(refsys) += (\w+ \w+)" , resp_str )
366
364
keyvals = zip (regex .groups ()[::2 ], regex .groups ()[1 ::2 ])
367
- for k ,v in keyvals :
365
+ for k , v in keyvals :
368
366
neocc_lst .meta [k ] = v
369
367
370
368
return neocc_lst
0 commit comments