|
7 | 7 | * Property: European Space Agency (ESA)
|
8 | 8 | * Developed by: Elecnor Deimos
|
9 | 9 | * Author: C. Álvaro Arroyo Parejo
|
10 |
| -* Issue: 2.1.0 |
11 |
| -* Date: 01-03-2021 |
| 10 | +* Issue: 2.2.0 |
| 11 | +* Date: 19-08-2022 |
12 | 12 | * Purpose: Module which request and parse list data from ESA NEOCC
|
13 | 13 | * Module: lists.py
|
14 | 14 | * History:
|
|
31 | 31 | Update docstrings.
|
32 | 32 | 2.0.0 21-01-2022 Prepare module for Astroquery integration
|
33 | 33 | 2.1.0 01-03-2022 Remove *parse* dependency
|
| 34 | +2.2.0 19-08-2022 Impacted objects list format change |
34 | 35 | ======== =========== ==========================================
|
35 | 36 |
|
36 | 37 | © Copyright [European Space Agency][2022]
|
|
39 | 40 |
|
40 | 41 | import io
|
41 | 42 | from datetime import timedelta
|
| 43 | +from astropy.table import Table |
| 44 | +from astropy.time import Time |
42 | 45 | import pandas as pd
|
43 | 46 | import requests
|
44 | 47 | from astroquery.esa.neocc import conf
|
@@ -83,7 +86,7 @@ def get_list_url(list_name):
|
83 | 86 | "priority_list": 'esa_priority_neo_list',
|
84 | 87 | "priority_list_faint": 'esa_faint_neo_list',
|
85 | 88 | "close_encounter" : 'close_encounter2.txt',
|
86 |
| - "impacted_objects" : 'impactedObjectsList.txt', |
| 89 | + "impacted_objects" : 'past_impactors_list', |
87 | 90 | "neo_catalogue_current" : 'neo_kc.cat',
|
88 | 91 | "neo_catalogue_middle" : 'neo_km.cat'
|
89 | 92 | }
|
@@ -231,10 +234,11 @@ def parse_risk(data_byte_d):
|
231 | 234 | neocc_lst = neocc_lst.drop(neocc_lst.columns[-1], axis=1)
|
232 | 235 |
|
233 | 236 | # Convert column with date to datetime variable
|
234 |
| - neocc_lst['Date/Time'] = pd.to_datetime(neocc_lst['Date/Time']) |
| 237 | + neocc_lst['Date/Time'] = pd.to_datetime(neocc_lst['Date/Time'], |
| 238 | + errors='ignore') |
235 | 239 | # Split Years into 2 columns to avoid dashed between integers
|
236 |
| - # Check dataframe is not empty (for special list) |
237 |
| - if len(neocc_lst.index.values) != 0: |
| 240 | + # Check dataframe column length is differnt from 8 (for special risk) |
| 241 | + if len(neocc_lst.columns) != 8: |
238 | 242 | neocc_lst[['First year', 'Last year']] = neocc_lst['Years']\
|
239 | 243 | .str.split("-",
|
240 | 244 | expand=True)\
|
@@ -468,17 +472,25 @@ def parse_impacted(data_byte_d):
|
468 | 472 | Decoded StringIO object.
|
469 | 473 | Returns
|
470 | 474 | -------
|
471 |
| - neocc_lst : *pandas.DataFrame* |
472 |
| - Data frame with impacted objects list data parsed. |
| 475 | + neocc_table : *astropy.table.table.Table* |
| 476 | + Astropy table with impacted objects list data parsed. |
473 | 477 | """
|
474 |
| - # Read data as csv |
475 |
| - neocc_lst = pd.read_csv(data_byte_d, header=None, |
476 |
| - delim_whitespace=True) |
477 |
| - |
478 |
| - # Convert column with date to datetime variable |
479 |
| - neocc_lst[1] = pd.to_datetime(neocc_lst[1]) |
480 |
| - |
481 |
| - return neocc_lst |
| 478 | + # Read data as csv using astropy.table |
| 479 | + neocc_table = Table.read(data_byte_d, format='pandas.csv', |
| 480 | + delimiter=r'\s+\|\s+|\s+\|', |
| 481 | + engine='python', header=1, |
| 482 | + dtype={'Object designator': str, |
| 483 | + 'Diameter in m': str, |
| 484 | + 'Impact date/time in UTC': str, |
| 485 | + 'Impact Velocity in km/s': float, |
| 486 | + 'Estimated energy in Mt': float, |
| 487 | + 'Measured energy in Mt': float}) |
| 488 | + neocc_table.remove_column('Unnamed: 6') |
| 489 | + # Convert column with date to astropy.time ISO format variable |
| 490 | + neocc_table['Impact date/time in UTC'] =\ |
| 491 | + Time(neocc_table['Impact date/time in UTC'], scale='utc') |
| 492 | + |
| 493 | + return neocc_table |
482 | 494 |
|
483 | 495 |
|
484 | 496 | def parse_neo_catalogue(data_byte_d):
|
@@ -540,4 +552,3 @@ def parse_neo_catalogue(data_byte_d):
|
540 | 552 |
|
541 | 553 |
|
542 | 554 | return neocc_lst
|
543 |
| - |
|
0 commit comments