Skip to content

Commit ab47cba

Browse files
authored
Merge pull request #1 from D-arioSpace/release_astroquery
Release astroquery
2 parents 730c6ec + 01ee385 commit ab47cba

File tree

8 files changed

+166
-139
lines changed

8 files changed

+166
-139
lines changed

astroquery/esa/neocc/__init__.py

100755100644
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
European Space Agency (ESA)
77
88
Created on 16 Jun. 2021
9-
Last update 01 Mar. 2022
9+
Last update 22 Aug. 2022
1010
1111
"""
1212
import os

astroquery/esa/neocc/core.py

100755100644
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
* Property: European Space Agency (ESA)
1010
* Developed by: Elecnor Deimos
1111
* Author: C. Álvaro Arroyo Parejo
12-
* Issue: 2.1.0
13-
* Date: 01-03-2021
12+
* Issue: 2.2.0
13+
* Date: 19-08-2022
1414
* Purpose: Main module which gets NEAs data from https://neo.ssa.esa.int/
1515
* Module: core.py
1616
* History:
@@ -37,6 +37,7 @@
3737
properties
3838
2.0.0 21-01-2022 Prepare module for Astroquery integration
3939
2.1.0 01-03-2022 Remove *parse* dependency
40+
2.2.0 19-08-2022 Impacted objects list format change
4041
======== =========== ============================================
4142
4243

astroquery/esa/neocc/lists.py

100755100644
Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
* Property: European Space Agency (ESA)
88
* Developed by: Elecnor Deimos
99
* 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
1212
* Purpose: Module which request and parse list data from ESA NEOCC
1313
* Module: lists.py
1414
* History:
@@ -31,6 +31,7 @@
3131
Update docstrings.
3232
2.0.0 21-01-2022 Prepare module for Astroquery integration
3333
2.1.0 01-03-2022 Remove *parse* dependency
34+
2.2.0 19-08-2022 Impacted objects list format change
3435
======== =========== ==========================================
3536
3637
© Copyright [European Space Agency][2022]
@@ -39,6 +40,8 @@
3940

4041
import io
4142
from datetime import timedelta
43+
from astropy.table import Table
44+
from astropy.time import Time
4245
import pandas as pd
4346
import requests
4447
from astroquery.esa.neocc import conf
@@ -83,7 +86,7 @@ def get_list_url(list_name):
8386
"priority_list": 'esa_priority_neo_list',
8487
"priority_list_faint": 'esa_faint_neo_list',
8588
"close_encounter" : 'close_encounter2.txt',
86-
"impacted_objects" : 'impactedObjectsList.txt',
89+
"impacted_objects" : 'past_impactors_list',
8790
"neo_catalogue_current" : 'neo_kc.cat',
8891
"neo_catalogue_middle" : 'neo_km.cat'
8992
}
@@ -231,10 +234,11 @@ def parse_risk(data_byte_d):
231234
neocc_lst = neocc_lst.drop(neocc_lst.columns[-1], axis=1)
232235

233236
# 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')
235239
# 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:
238242
neocc_lst[['First year', 'Last year']] = neocc_lst['Years']\
239243
.str.split("-",
240244
expand=True)\
@@ -468,17 +472,25 @@ def parse_impacted(data_byte_d):
468472
Decoded StringIO object.
469473
Returns
470474
-------
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.
473477
"""
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
482494

483495

484496
def parse_neo_catalogue(data_byte_d):

astroquery/esa/neocc/tabs.py

100755100644
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
* Property: European Space Agency (ESA)
1111
* Developed by: Elecnor Deimos
1212
* Author: C. Álvaro Arroyo Parejo
13-
* Issue: 2.1.0
14-
* Date: 01-03-2021
13+
* Issue: 2.2.0
14+
* Date: 19-08-2022
1515
* Purpose: Module which request and parse list data from ESA NEOCC
1616
* Module: tabs.py
1717
* History:
@@ -50,6 +50,7 @@
5050
Adding redundancy for tab *summary* parsing.
5151
2.0.0 21-01-2022 Prepare module for Astroquery integration
5252
2.1.0 01-03-2022 Remove *parse* dependency
53+
2.2.0 19-08-2022 Minor corrections
5354
======== =========== =====================================================
5455
5556
© Copyright [European Space Agency][2022]
@@ -300,6 +301,7 @@ def _get_footer(data_obj):
300301

301302
# Drop NaN values if necessary
302303
df_txt = df_txt.dropna(how='all')
304+
303305
# Template for observations data:
304306
# Based on {total} optical observations (of which {rejected}
305307
# are rejected as outliers)
@@ -620,7 +622,6 @@ def _phys_prop_parser(self, data_obj):
620622
# Initialize index
621623
index = 0
622624
if len(df_check.columns) > 4:
623-
# rest = len(df_check.columns) - 4
624625
# Iterate over each element in last col to find
625626
# rows with additional elements separated by commas
626627
for element in df_check.iloc[:, -1]:
@@ -753,7 +754,6 @@ def _get_head_obs(df_d):
753754
else:
754755
mag = float(df_head.iloc[3][0].split('=')[1].strip())
755756

756-
757757
return ver, err, ast, mag
758758

759759
@staticmethod
@@ -1829,7 +1829,6 @@ def _get_head_ephem(data_obj):
18291829
# Template for initial date: Time step: {step}
18301830
tstep = head_ephe.iloc[4][0].split(':')[1].strip()
18311831

1832-
18331832
return obs, idate, fdate, tstep
18341833

18351834
def _ephem_parser(self, name, observatory, start, stop, step, step_unit):
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
Last Update: 2021-10-04 05:49 UTC
1+
Last Update: 2022-08-19 08:03 UTC
22
Object | Diameter | VI Max |
33
Num/des. Name | m | *=Y | Date/Time | IP max | PS max |TS | Vel km/s |
44
AAAAAAAAA AAAAAAAAAAAAAAAA | NNNN | A | YYYY-MM-DD HH:MM | EEEEEEEE | NNN.NN | NN | NNN.NN |
5+
101955 Bennu | 484 | | 2182-09-24 20:24 | 3.70E-4 | -1.59 | | 12.68 |
6+
29075 1950DA | 1300 | | 2880-03-16 23:48 | 1.96E-5 | -2.13 | | 17.99 |
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Last Update: 2022-04-04 10:00 UTC
2+
Object designator | Diameter in m | Impact date/time in UTC | Impact Velocity in km/s | Estimated energy in Mt | Measured energy in Mt |
3+
2022EB5 | 1.9* | 2022-03-11 21:22:00 | 18.53 | 2.96E-4 | 4.00E-3 |
4+
2019MO | 5* | 2019-06-22 21:30:00 | 16.34 | 3.82E-3 | 6.00E-3 |
5+
2018LA | 2.8* | 2018-06-02 16:44:00 | 16.98 | 8.90E-4 | 9.80E-4 |
6+
2014AA | 2.3* | 2014-01-02 02:30:00 | 11.97 | 2.44E-4 | n/a |
7+
2008TC3 | 3* | 2008-10-07 02:45:00 | 11.77 | 6.77E-4 | 1.00E-3 |

0 commit comments

Comments
 (0)