1
- # -*- coding: utf-8 -*-
1
+ # Licensed under a 3-clause BSD style license - see LICENSE.rst
2
2
"""
3
3
Main module from ESA NEOCC library. This module contains the two main
4
4
methods of the library: *query_list* and *query_object*. The information
5
5
is obtained from ESA Near-Earth Object Coordination Centre's (NEOCC) web
6
6
portal: https://neo.ssa.esa.int/.
7
-
8
- * Project: NEOCC portal Python interface
9
- * Property: European Space Agency (ESA)
10
- * Developed by: Elecnor Deimos
11
- * Author: C. Álvaro Arroyo Parejo
12
- * Issue: 2.1.0
13
- * Date: 01-03-2021
14
- * Purpose: Main module which gets NEAs data from https://neo.ssa.esa.int/
15
- * Module: core.py
16
- * History:
17
-
18
- ======== =========== ============================================
19
- Version Date Change History
20
- ======== =========== ============================================
21
- 1.0 26-02-2021 Initial version
22
- 1.1 26-03-2021 Adding new docstrings
23
- 1.2 17-05-2021 Adding new docstrings for *help*
24
- property in dataframes and *<tab>*
25
- specification for obtaining attributes.\n
26
- For orbit properties *orbit_elements*
27
- changes to *orbital_elements*.\n
28
- Adding impacted objects lists.\n
29
- Minor typos changes.
30
- 1.3 16-06-2021 Renamed module from *neocc* to *core*.\n
31
- Adding class type as for astroquery
32
- implementation.\n
33
- Define methods as static.\n
34
- 1.3.1 29-06-2021 No changes
35
- 1.4.0 29-10-2021 Adding new docstrings.\n
36
- Change method for obtaining physical
37
- properties
38
- 2.0.0 21-01-2022 Prepare module for Astroquery integration
39
- 2.1.0 01-03-2022 Remove *parse* dependency
40
-
41
- © Copyright [European Space Agency][2022]
42
- All rights reserved
43
7
"""
44
8
45
9
import time
51
15
52
16
__all__ = ['neocc' , 'ESAneoccClass' ]
53
17
18
+
54
19
@async_to_sync
55
20
class ESAneoccClass (BaseQuery ):
56
21
"""
@@ -89,13 +54,13 @@ def query_list(list_name):
89
54
90
55
Returns
91
56
-------
92
- neocc_lst : *pandas.Series* or *pandas.DataFrame*
93
- Data Frame which contains the information of the requested list
57
+ neocc_lst : `~astropy.table.Table`
58
+ Astropy Table which contains the data of the requested list.
94
59
95
60
Examples
96
61
--------
97
62
**NEA list, Updated NEA list, Monthly computation date:** The output
98
- of this list is a *pandas.Series* which contains the list of all NEAs
63
+ of this list is a `~astropy.table.Table` which contains the list of all NEAs
99
64
currently considered in the NEOCC system.
100
65
101
66
>>> from astroquery.esa.neocc import neocc
@@ -120,7 +85,7 @@ def query_list(list_name):
120
85
>>> list_data[4]
121
86
'1221 Amor'
122
87
123
- **Other lists:** The output of this list is a *pandas.DataFrame* which
88
+ **Other lists:** The output of this list is a `~astropy.table.Table` which
124
89
contains the information of the requested list.
125
90
126
91
>>> from astroquery.esa.neocc import neocc
@@ -192,7 +157,7 @@ def query_list(list_name):
192
157
193
158
return neocc_list
194
159
195
- except ConnectionError : # pragma: no cover
160
+ except ConnectionError : # pragma: no cover
196
161
print ('Initial attempt to obtain list failed. Reattempting...' )
197
162
# Wait 5 seconds
198
163
time .sleep (5 )
@@ -439,12 +404,13 @@ def query_object(name, tab, **kwargs):
439
404
tab_list = ['impacts' , 'close_approaches' , 'observations' ,
440
405
'physical_properties' , 'orbit_properties' ,
441
406
'ephemerides' , 'summary' ]
407
+
442
408
# Check the input of the method if tab is not in the list
443
409
# print and error and show the valid names
444
410
if tab not in tab_list :
445
411
raise KeyError ('Please introduce a valid tab name. '
446
- 'valid tabs names are: ' + \
447
- ', ' .join ([str (elem ) for elem in tab_list ]))
412
+ 'valid tabs names are: '
413
+ ', ' .join ([str (elem ) for elem in tab_list ]))
448
414
# Depending on the tab selected the information will be requested
449
415
# following different methods. Create "switch" for each case:
450
416
@@ -458,32 +424,27 @@ def query_object(name, tab, **kwargs):
458
424
try :
459
425
# Get object data
460
426
data_obj = tabs .get_object_data (url )
461
- except ConnectionError : # pragma: no cover
427
+ except ConnectionError : # pragma: no cover
462
428
print ('Initial attempt to obtain object data failed. '
463
429
'Reattempting...' )
464
430
# Wait 5 seconds
465
431
time .sleep (5 )
466
432
# Get object data
467
433
data_obj = tabs .get_object_data (url )
468
434
435
+ resp_str = data_obj .decode ('utf-8' )
436
+
437
+ # TODO: check data here
438
+
469
439
if tab == 'impacts' :
470
- # Create empty object with class Impacts
471
- neocc_obj = tabs .Impacts ()
472
- # Parse the requested data using Impacts parser
473
- neocc_obj ._impacts_parser (data_obj )
440
+ neocc_obj = tabs .parse_impacts (resp_str )
474
441
elif tab == 'close_approaches' :
475
- # Parse the requested data using Close Approaches parser
476
- neocc_obj = tabs .CloseApproaches .clo_appr_parser (data_obj )
442
+ neocc_obj = tabs .parse_close_aproach (resp_str )
477
443
elif tab == 'observations' :
478
- # Create empty object
479
- neocc_obj = tabs .AsteroidObservations ()
480
- # Get object with attributes from data
481
- neocc_obj ._ast_obs_parser (data_obj )
444
+ neocc_obj = tabs .parse_observations (resp_str )
482
445
elif tab == 'physical_properties' :
483
- # Create empty object with class Physical properties
484
- neocc_obj = tabs .PhysicalProperties ()
485
- # Parse the requested data using Physical properties parser
486
- neocc_obj ._phys_prop_parser (data_obj )
446
+ neocc_obj = tabs .parse_physical_properties (resp_str )
447
+
487
448
# Orbit properties
488
449
elif tab == 'orbit_properties' :
489
450
# Raise error if no elements are provided
@@ -505,25 +466,16 @@ def query_object(name, tab, **kwargs):
505
466
try :
506
467
# Get object data
507
468
data_obj = tabs .get_object_data (url )
508
- except ConnectionError : # pragma: no cover
469
+ except ConnectionError : # pragma: no cover
509
470
print ('Initial attempt to obtain object data failed. '
510
471
'Reattempting...' )
511
472
# Wait 5 seconds
512
473
time .sleep (5 )
513
474
# Get object data
514
475
data_obj = tabs .get_object_data (url )
515
476
516
- # Assign orbit properties depending on the elements requested
517
- if kwargs ['orbital_elements' ] == "keplerian" :
518
- # Create empty object with class Orbit properties
519
- neocc_obj = tabs .KeplerianOrbitProperties ()
520
- # Parse the requested data using Orbit properties parser
521
- neocc_obj ._orb_kep_prop_parser (data_obj )
522
- elif kwargs ['orbital_elements' ] == "equinoctial" :
523
- # Create empty object with class Orbit properties
524
- neocc_obj = tabs .EquinoctialOrbitProperties ()
525
- # Parse the requested data using Orbit properties parser
526
- neocc_obj ._orb_equi_prop_parser (data_obj )
477
+ resp_str = data_obj .decode ('utf-8' )
478
+ neocc_obj = tabs .parse_orbital_properties (resp_str )
527
479
528
480
# Ephemerides
529
481
elif tab == 'ephemerides' :
@@ -536,21 +488,22 @@ def query_object(name, tab, **kwargs):
536
488
# Check if any kwargs is missing
537
489
for element in args_dict :
538
490
if element not in kwargs :
539
- raise KeyError ('Please specify ' + args_dict [element ]
540
- + ' for ephemerides' )
491
+ raise KeyError (f'Please specify { args_dict [element ]} for ephemerides.' )
541
492
542
- # Create empty object with class Ephemerides
543
- neocc_obj = tabs .Ephemerides ()
544
- # Parse the requested data using Ephemerides parser
545
- neocc_obj ._ephem_parser (name , observatory = kwargs ['observatory' ],
493
+ resp_str = tabs .get_ephemerides_data (name , observatory = kwargs ['observatory' ],
546
494
start = kwargs ['start' ], stop = kwargs ['stop' ],
547
495
step = kwargs ['step' ],
548
496
step_unit = kwargs ['step_unit' ])
497
+ neocc_obj = tabs .parse_ephemerides (resp_str )
498
+
549
499
elif tab == 'summary' :
500
+ resp_str = tabs .get_summary_data (name )
501
+
502
+ neocc_obj = tabs .parse_summary (resp_str )
550
503
# Create empty object with class Summary
551
- neocc_obj = tabs .Summary ()
504
+ # neocc_obj = tabs.Summary()
552
505
# Parse the requested data using Summary parser
553
- neocc_obj ._summary_parser (name )
506
+ # neocc_obj._summary_parser(name)
554
507
555
508
return neocc_obj
556
509
0 commit comments