-
-
Notifications
You must be signed in to change notification settings - Fork 435
Expand file tree
/
Copy pathcore.py
More file actions
1487 lines (1303 loc) · 73.2 KB
/
core.py
File metadata and controls
1487 lines (1303 loc) · 73.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Licensed under a 3-clause BSD style license - see LICENSE.rst
# 1. standard library imports
from collections import OrderedDict
from typing import Mapping
import warnings
# 2. third party imports
from requests.exceptions import HTTPError
from numpy import nan
from numpy import isnan
from numpy import ndarray
from astropy.table import Table, Column
from astropy.io import ascii
from astropy.time import Time
from astropy import units as u
from astropy.utils.exceptions import AstropyDeprecationWarning
from astropy.utils.decorators import deprecated_renamed_argument, deprecated_attribute
# 3. local imports - use relative imports
# commonly required local imports shown below as example
# all Query classes should inherit from BaseQuery.
from ..query import BaseQuery
# async_to_sync generates the relevant query tools from _async methods
from ..utils import async_to_sync
# import configurable items declared in __init__.py
from . import conf
__all__ = ['Horizons', 'HorizonsClass']
@async_to_sync
class HorizonsClass(BaseQuery):
"""
Query the `JPL Horizons <https://ssd.jpl.nasa.gov/horizons/>`_ service.
"""
TIMEOUT = conf.timeout
raw_response = deprecated_attribute(
'raw_response', '0.4.7',
alternative=("an ``_async`` method (e.g., ``ephemerides_async``) to "
"return a response object, and access the content with "
"``response.text``"))
def __init__(self, id=None, *, location=None, epochs=None,
id_type=None):
"""
Initialize JPL query.
Parameters
----------
id : str or dict, required
Name, number, or designation of target object. Uses the same codes
as JPL Horizons. Arbitrary topocentric coordinates can be added in a
dict. The dict has to be of the form {``'lon'``: longitude in deg
(East positive, West negative), ``'lat'``: latitude in deg (North
positive, South negative), ``'elevation'``: elevation in km above
the reference ellipsoid, [``'body'``: Horizons body ID of the
central body; optional; if this value is not provided it is assumed
that this location is on Earth]}. Float values are assumed to have
units of degrees and kilometers.
location : str or dict, optional
Observer's location for ephemerides queries or center body name for
orbital element or vector queries. Uses the same codes as JPL
Horizons. If no location is provided, Earth's center is used for
ephemerides queries and the Sun's center for elements and vectors
queries. Arbitrary topocentric coordinates for ephemerides queries
can be provided in the format of a dictionary. The dictionary has to
be of the form {``'lon'``: longitude (East positive, West negative),
``'lat'``: latitude (North positive, South negative),
``'elevation'``: elevation above the reference ellipsoid,
[``'body'``: Horizons body ID of the central body; optional; if this
value is not provided it is assumed that this location is on
Earth]}. Float values are assumed to have units of degrees and
kilometers.
epochs : scalar, list-like, or dictionary, optional
Either a list of epochs in JD or MJD format or a dictionary defining
a range of times and dates; the range dictionary has to be of the
form {``'start'``: 'YYYY-MM-DD [HH:MM:SS]', ``'stop'``: 'YYYY-MM-DD
[HH:MM:SS]', ``'step'``: 'n[y|d|m|s]'}. Epoch timescales depend on
the type of query performed: UTC for ephemerides queries, TDB for
element and vector queries. If no epochs are provided, the current
time is used.
id_type : str, optional
Controls Horizons's object selection for ``id``
[HORIZONSDOC_SELECTION]_ . Options: ``'designation'`` (small body
designation), ``'name'`` (asteroid or comet name),
``'asteroid_name'``, ``'comet_name'``, ``'smallbody'`` (asteroid and
comet search), or ``None`` (first search search planets, natural
satellites, spacecraft, and special cases, and if no matches, then
search small bodies).
References
----------
.. [HORIZONSDOC_SELECTION] https://ssd.jpl.nasa.gov/horizons/manual.html#select
(retrieved 2021 Sep 23).
Examples
--------
>>> from astroquery.jplhorizons import Horizons
>>> eros = Horizons(id='433', location='568',
... epochs={'start': '2017-01-01',
... 'stop': '2017-02-01',
... 'step': '1d'})
>>> print(eros)
JPLHorizons instance "433"; location=568,
epochs={'start': '2017-01-01', 'stop': '2017-02-01', 'step': '1d'}, id_type=None
"""
super().__init__()
self.id = id
self.location = location
# check for epochs to be dict or list-like; else: make it a list
if epochs is not None:
if isinstance(epochs, (list, tuple, ndarray)):
pass
elif isinstance(epochs, dict):
if not ('start' in epochs and 'stop' in epochs and 'step' in epochs):
raise ValueError('time range ({:s}) requires start, stop, '
'and step'.format(str(epochs)))
else:
# turn scalars into list
epochs = [epochs]
self.epochs = epochs
# check for id_type
if id_type in ['majorbody', 'id']:
warnings.warn("``id_type``s 'majorbody' and 'id' are deprecated "
"and replaced with ``None``, which has the same "
"functionality.", AstropyDeprecationWarning)
id_type = None
if id_type not in [None, 'smallbody', 'designation', 'name',
'asteroid_name', 'comet_name']:
raise ValueError('id_type ({:s}) not allowed'.format(id_type))
self.id_type = id_type
# return raw response?
self.return_raw = False
self.query_type = None # ['ephemerides', 'elements', 'vectors']
self.uri = None # will contain query URL
self._raw_response = None # will contain raw response from server
def __str__(self):
"""
String representation of this instance.
Examples
--------
>>> from astroquery.jplhorizons import Horizons
>>> eros = Horizons(id='433', location='568',
... epochs={'start':'2017-01-01',
... 'stop':'2017-02-01',
... 'step':'1d'})
>>> print(eros)
JPLHorizons instance "433"; location=568,
epochs={'start': '2017-01-01', 'stop': '2017-02-01', 'step': '1d'}, id_type=None
"""
return ('JPLHorizons instance \"{:s}\"; location={:s}, '
'epochs={:s}, id_type={:s}').format(
str(self.id),
str(self.location),
str(self.epochs),
str(self.id_type))
@property
def id(self):
return self._id
@id.setter
def id(self, _id):
# check & format coordinate dictionaries for id; simply treat other
# values as given
if isinstance(_id, Mapping):
self._id = self._prep_loc_dict(dict(_id), "id")
else:
self._id = _id
@property
def location(self):
return self._location
@location.setter
def location(self, _location):
# check & format coordinate dictionaries for location; simply treat
# other values as given
if isinstance(_location, Mapping):
self._location = self._prep_loc_dict(dict(_location), "location")
else:
self._location = _location
# ---------------------------------- query functions
@deprecated_renamed_argument("get_raw_response", None, since="0.4.7",
alternative="async methods")
def ephemerides_async(self, *, airmass_lessthan=99,
solar_elongation=(0, 180), max_hour_angle=0,
rate_cutoff=None,
skip_daylight=False,
refraction=False,
refsystem='ICRF',
closest_apparition=False, no_fragments=False,
quantities=conf.eph_quantities,
optional_settings=None,
get_query_payload=False,
get_raw_response=False, cache=True,
extra_precision=False):
"""
Query JPL Horizons for ephemerides.
.. deprecated:: 0.4.7
The ``get_raw_response`` keyword argument is deprecated. The
`~HorizonsClass.ephemerides_async` method will return a raw response.
The ``location`` parameter in ``HorizonsClass`` refers in this case to
the location of the observer.
The following tables list the values queried, their definitions, data
types, units, and original Horizons designations (where available). For
more information on the definitions of these quantities, please refer to
the `Horizons User Manual <https://ssd.jpl.nasa.gov/horizons/manual.html>`_.
+------------------+-----------------------------------------------+
| Column Name | Definition |
+==================+===============================================+
| targetname | official number, name, designation (string) |
+------------------+-----------------------------------------------+
| H | absolute magnitude in V band (float, mag) |
+------------------+-----------------------------------------------+
| G | photometric slope parameter (float) |
+------------------+-----------------------------------------------+
| M1 | comet total abs mag (float, mag, ``M1``) |
+------------------+-----------------------------------------------+
| M2 | comet nuclear abs mag (float, mag, ``M2``) |
+------------------+-----------------------------------------------+
| k1 | total mag scaling factor (float, ``k1``) |
+------------------+-----------------------------------------------+
| k2 | nuclear mag scaling factor (float, ``k2``) |
+------------------+-----------------------------------------------+
| phasecoeff | comet phase coeff (float, mag/deg, ``PHCOFF``)|
+------------------+-----------------------------------------------+
| datetime_str | epoch (str, ``Date__(UT)__HR:MN:SC.fff``) |
+------------------+-----------------------------------------------+
| datetime_jd | epoch Julian Date (float, |
| | ``Date_________JDUT``) |
+------------------+-----------------------------------------------+
| solar_presence | information on Sun's presence (str) |
+------------------+-----------------------------------------------+
| flags | information on Moon, target status (str) |
+------------------+-----------------------------------------------+
| RA | target RA (float, deg, ``DEC_(XXX)``) |
+------------------+-----------------------------------------------+
| DEC | target DEC (float, deg, ``DEC_(XXX)``) |
+------------------+-----------------------------------------------+
| RA_app | target apparent RA (float, deg, |
| | ``R.A._(a-app)``) |
+------------------+-----------------------------------------------+
| DEC_app | target apparent DEC (float, deg, |
| | ``DEC_(a-app)``) |
+------------------+-----------------------------------------------+
| RA_rate | target rate RA (float, arcsec/hr, ``RA*cosD``)|
+------------------+-----------------------------------------------+
| DEC_rate | target RA (float, arcsec/hr, ``d(DEC)/dt``) |
+------------------+-----------------------------------------------+
| AZ | Azimuth (float, deg, EoN, ``Azi_(a-app)``) |
+------------------+-----------------------------------------------+
| EL | Elevation (float, deg, ``Elev_(a-app)``) |
+------------------+-----------------------------------------------+
| AZ_rate | Azimuth rate (float, arcsec/minute, |
| | ``dAZ*cosE``) |
+------------------+-----------------------------------------------+
| EL_rate | Elevation rate (float, arcsec/minute, |
| | ``d(ELV)/dt``) |
+------------------+-----------------------------------------------+
| sat_X | satellite X position (arcsec, |
| | ``X_(sat-prim)``) |
+------------------+-----------------------------------------------+
| sat_Y | satellite Y position (arcsec, |
| | ``Y_(sat-prim)``) |
+------------------+-----------------------------------------------+
| sat_PANG | satellite position angle (deg, |
| | ``SatPANG``) |
+------------------+-----------------------------------------------+
| siderealtime | local apparent sidereal time (str, |
| | ``L_Ap_Sid_Time``) |
+------------------+-----------------------------------------------+
| airmass | target optical airmass (float, ``a-mass``) |
+------------------+-----------------------------------------------+
| magextinct | V-mag extinction (float, mag, ``mag_ex``) |
+------------------+-----------------------------------------------+
| V | V magnitude (float, mag, ``APmag``) |
+------------------+-----------------------------------------------+
| Tmag | comet Total magnitude (float, mag, ``T-mag``) |
+------------------+-----------------------------------------------+
| Nmag | comet Nucleaus magnitude (float, mag, |
| | ``N-mag``) |
+------------------+-----------------------------------------------+
| surfbright | surf brightness (float, mag/arcsec^2, |
| | ``S-brt``) |
+------------------+-----------------------------------------------+
| illumination | frac of illumination (float, percent, |
| | ``Illu%``) |
+------------------+-----------------------------------------------+
| illum_defect | Defect of illumination (float, arcsec, |
| | ``Dec_illu``) |
+------------------+-----------------------------------------------+
| sat_sep | Target-primary angular separation (float, |
| | arcsec, ``ang-sep``) |
+------------------+-----------------------------------------------+
| sat_vis | Target-primary visibility (str, ``v``) |
+------------------+-----------------------------------------------+
| ang_width | Angular width of target (float, arcsec, |
| | ``Ang-diam``) |
+------------------+-----------------------------------------------+
| PDObsLon | Apparent planetodetic longitude (float, deg, |
| | ``ObsSub-LON``) |
+------------------+-----------------------------------------------+
| PDObsLat | Apparent planetodetic latitude (float, deg, |
| | ``ObsSub-LAT``) |
+------------------+-----------------------------------------------+
| PDSunLon | Subsolar planetodetic longitude (float, deg, |
| | ``SunSub-LON``) |
+------------------+-----------------------------------------------+
| PDSunLat | Subsolar planetodetic latitude (float, deg, |
| | ``SunSub-LAT``) |
+------------------+-----------------------------------------------+
| SubSol_ang | Target sub-solar point position angle |
| | (float, deg, ``SN.ang``) |
+------------------+-----------------------------------------------+
| SubSol_dist | Target sub-solar point position angle distance|
| | (float, arcsec, ``SN.dist``) |
+------------------+-----------------------------------------------+
| NPole_ang | Target's North Pole position angle |
| | (float, deg, ``NP.ang``) |
+------------------+-----------------------------------------------+
| NPole_dist | Target's North Pole position angle distance |
| | (float, arcsec, ``NP.dist``) |
+------------------+-----------------------------------------------+
| EclLon | heliocentr ecl long (float, deg, ``hEcl-Lon``)|
+------------------+-----------------------------------------------+
| EclLat | heliocentr ecl lat (float, deg, ``hEcl-Lat``) |
+------------------+-----------------------------------------------+
| ObsEclLon | obscentr ecl long (float, deg, ``ObsEcLon``) |
+------------------+-----------------------------------------------+
| ObsEclLat | obscentr ecl lat (float, deg, ``ObsEcLat``) |
+------------------+-----------------------------------------------+
| r | heliocentric distance (float, au, ``r``) |
+------------------+-----------------------------------------------+
| r_rate | heliocentric radial rate (float, km/s, |
| | ``rdot``) |
+------------------+-----------------------------------------------+
| delta | distance from observer (float, au, ``delta``) |
+------------------+-----------------------------------------------+
| delta_rate | obs-centric rad rate (float, km/s, ``deldot``)|
+------------------+-----------------------------------------------+
| lighttime | one-way light time (float, min, ``1-way_LT``) |
+------------------+-----------------------------------------------+
| vel_sun | Target center velocity wrt Sun |
| | (float, km/s, ``VmagSn``) |
+------------------+-----------------------------------------------+
| vel_obs | Target center velocity wrt Observer |
| | (float, km/s, ``VmagOb``) |
+------------------+-----------------------------------------------+
| elong | solar elongation (float, deg, ``S-O-T``) |
+------------------+-----------------------------------------------+
| elongFlag | app. position relative to Sun (str, ``/r``) |
+------------------+-----------------------------------------------+
| alpha | solar phase angle (float, deg, ``S-T-O``) |
+------------------+-----------------------------------------------+
| lunar_elong | Apparent lunar elongation angle wrt target |
| | (float, deg, ``T-O-M``) |
+------------------+-----------------------------------------------+
| lunar_illum | Lunar illumination percentage |
| | (float, percent, ``MN_Illu%``) |
+------------------+-----------------------------------------------+
| IB_elong | Apparent interfering body elongation angle |
| | wrt target (float, deg, ``T-O-I``) |
+------------------+-----------------------------------------------+
| IB_illum | Interfering body illumination percentage |
| | (float, percent, ``IB_Illu%``) |
+------------------+-----------------------------------------------+
| sat_alpha | Observer-Primary-Target angle |
| | (float, deg, ``O-P-T``) |
+------------------+-----------------------------------------------+
| OrbPlaneAng | orbital plane angle (float, deg, ``PlAng``) |
+------------------+-----------------------------------------------+
| sunTargetPA | -Sun vector PA (float, deg, EoN, ``PsAng``) |
+------------------+-----------------------------------------------+
| velocityPA | -velocity vector PA (float, deg, EoN, |
| | ``PsAMV``) |
+------------------+-----------------------------------------------+
| constellation | constellation ID containing target (str, |
| | ``Cnst``) |
+------------------+-----------------------------------------------+
| TDB-UT | difference between TDB and UT (float, |
| | seconds, ``TDB-UT``) |
+------------------+-----------------------------------------------+
| NPole_RA | Target's North Pole RA (float, deg, |
| | ``N.Pole-RA``) |
+------------------+-----------------------------------------------+
| NPole_DEC | Target's North Pole DEC (float, deg, |
| | ``N.Pole-DC``) |
+------------------+-----------------------------------------------+
| GlxLon | galactic longitude (float, deg, ``GlxLon``) |
+------------------+-----------------------------------------------+
| GlxLat | galactic latitude (float, deg, ``GlxLat``) |
+------------------+-----------------------------------------------+
| solartime | local apparent solar time (string, |
| | ``L_Ap_SOL_Time``) |
+------------------+-----------------------------------------------+
| earth_lighttime | observer lighttime from center of Earth |
| | (float, minutes, ``399_ins_LT`` |
+------------------+-----------------------------------------------+
| RA_3sigma | 3 sigma positional uncertainty in RA (float, |
| | arcsec, ``RA_3sigma``) |
+------------------+-----------------------------------------------+
| DEC_3sigma | 3 sigma positional uncertainty in DEC (float,|
| | arcsec, ``DEC_3sigma``) |
+------------------+-----------------------------------------------+
| SMAA_3sigma | 3sig pos unc error ellipse semi-major axis |
| | (float, arcsec, ``SMAA_3sig``) |
+------------------+-----------------------------------------------+
| SMIA_3sigma | 3sig pos unc error ellipse semi-minor axis |
| | (float, arcsec, ``SMIA_3sig``) |
+------------------+-----------------------------------------------+
| Theta_3sigma | pos unc error ellipse position angle |
| | (float, deg, ``Theta``) |
+------------------+-----------------------------------------------+
| Area_3sigma | 3sig pos unc error ellipse are |
| | (float, arcsec^2, ``Area_3sig``) |
+------------------+-----------------------------------------------+
| RSS_3sigma | 3sig pos unc error ellipse root-sum-square |
| | (float, arcsec, ``POS_3sigma``) |
+------------------+-----------------------------------------------+
| r_3sigma | 3sig range uncertainty |
| | (float, km, ``RNG_3sigma``) |
+------------------+-----------------------------------------------+
| r_rate_3sigma | 3sig range rate uncertainty |
| | (float, km/second, ``RNGRT_3sigma``) |
+------------------+-----------------------------------------------+
| SBand_3sigma | 3sig Doppler radar uncertainties at S-band |
| | (float, Hertz, ``DOP_S_3sig``) |
+------------------+-----------------------------------------------+
| XBand_3sigma | 3sig Doppler radar uncertainties at X-band |
| | (float, Hertz, ``DOP_X_3sig``) |
+------------------+-----------------------------------------------+
| DoppDelay_3sigma | 3sig Doppler radar round-trip delay |
| | unc (float, second, ``RT_delay_3sig``) |
+------------------+-----------------------------------------------+
| true_anom | True Anomaly (float, deg, ``Tru_Anom``) |
+------------------+-----------------------------------------------+
| hour_angle | local apparent hour angle (float, |
| | hour, ``L_Ap_Hour_Ang``) |
+------------------+-----------------------------------------------+
| alpha_true | true phase angle (float, deg, ``phi``) |
+------------------+-----------------------------------------------+
| PABLon | phase angle bisector longitude |
| | (float, deg, ``PAB-LON``) |
+------------------+-----------------------------------------------+
| PABLat | phase angle bisector latitude |
| | (float, deg, ``PAB-LAT``) |
+------------------+-----------------------------------------------+
| App_Lon_Sun | apparent target-centered longitude of the Sun |
| | (float, hour, ``App_Lon_Sun``) |
+------------------+-----------------------------------------------+
| RA_ICRF_app | airless apparent right ascension of the target|
| | in the ICRF |
| | (float, hour, ``RA_(ICRF-a-app)``) |
+------------------+-----------------------------------------------+
| DEC_ICRF_app | airless apparent declination of the target |
| | in the ICRF |
| | (float, deg, ``DEC_(ICRF-a-app)``) |
+------------------+-----------------------------------------------+
| RA_ICRF_rate_app | RA rate of change in the targets' ICRF |
| | multiplied by the cosine of declination |
| | (float, arcsec/hour, ``I_dRA*cosD``) |
+------------------+-----------------------------------------------+
| DEC_ICRF_rate_app| DEC rate of change in the targets' ICRF |
| | (float, arcsec/hour, ``I_d(DEC)/dt``) |
+------------------+-----------------------------------------------+
| Sky_motion | Total apparent angular rate in the plane-of- |
| | sky |
| | (float, arcsec/minute, ``Sky_motion``) |
+------------------+-----------------------------------------------+
| Sky_mot_PA | position angle direction of motion in the |
| | plane-of-sky |
| | (float, deg, ``Sky_mot_PA``) |
+------------------+-----------------------------------------------+
| RelVel-ANG | flight path angle of the target's relative |
| | motion with respect to the observer's |
| | line-of-sight |
| | (float, deg, ``RelVel-ANG``) |
+------------------+-----------------------------------------------+
| Lun_Sky_Brt | Sky brightness due to moonlight |
| | (float, mag, ``Lun_Sky_Brt``) |
+------------------+-----------------------------------------------+
| sky_SNR | approximate visual signal-to-noise ratio of |
| | the target's brightness divided by lunar sky |
| | brightness |
| | (float, unitless, ``sky_SNR``) |
+------------------+-----------------------------------------------+
Parameters
----------
airmass_lessthan : float, optional
Defines a maximum airmass for the query, default: 99
solar_elongation : tuple, optional
Permissible solar elongation range: (minimum, maximum); default:
(0,180)
max_hour_angle : float, optional
Defines a maximum hour angle for the query, default: 0
rate_cutoff : float, optional
Angular range rate upper limit cutoff in arcsec/h; default: disabled
skip_daylight : boolean, optional
Crop daylight epochs in query, default: False
refraction : boolean
If ``True``, coordinates account for a standard atmosphere
refraction model; if ``False``, coordinates do not account for
refraction (airless model); default: ``False``
refsystem : string
Coordinate reference system: ``'ICRF'`` or ``'B1950'``; default:
``'ICRF'``
closest_apparition : boolean, optional
Only applies to comets. This option will choose the closest
apparition available in time to the selected epoch; default: False.
Do not use this option for non-cometary objects.
no_fragments : boolean, optional
Only applies to comets. Reject all comet fragments from selection;
default: False. Do not use this option for non-cometary objects.
quantities : integer or string, optional
Single integer or comma-separated list in the form of a string
corresponding to all the quantities to be queried from JPL Horizons
using the coding according to the `JPL Horizons User Manual
Definition of Observer Table Quantities
<https://ssd.jpl.nasa.gov/horizons/manual.html#obsquan>`_;
default: all quantities
optional_settings: dict, optional
key-value based dictionary to inject some additional optional settings
See `Optional observer-table settings" <https://ssd.jpl.nasa.gov/horizons/app.html>`_;
default: empty optional setting
get_query_payload : boolean, optional
When set to `True` the method returns the HTTP request parameters as
a dict, default: False
get_raw_response : boolean, optional
Return raw data as obtained by JPL Horizons without parsing the data
into a table, default: False
extra_precision : boolean, optional
Enables extra precision in RA and DEC values; default: False
cache : bool
Defaults to True. If set overrides global caching behavior.
See :ref:`caching documentation <astroquery_cache>`.
Returns
-------
response : `requests.Response`
The response of the HTTP request.
Examples
--------
>>> from astroquery.jplhorizons import Horizons
>>> obj = Horizons(id='Ceres', location='568',
... epochs={'start':'2010-01-01',
... 'stop':'2010-03-01',
... 'step':'10d'})
>>> eph = obj.ephemerides() # doctest: +REMOTE_DATA
>>> print(eph) # doctest: +SKIP
targetname datetime_str datetime_jd ... PABLon PABLat
--- --- d ... deg deg
----------------- ----------------- ----------- ... -------- ------
1 Ceres (A801 AA) 2010-Jan-01 00:00 2455197.5 ... 238.2494 4.5532
1 Ceres (A801 AA) 2010-Jan-11 00:00 2455207.5 ... 241.3339 4.2832
1 Ceres (A801 AA) 2010-Jan-21 00:00 2455217.5 ... 244.3394 4.0089
1 Ceres (A801 AA) 2010-Jan-31 00:00 2455227.5 ... 247.2518 3.7289
1 Ceres (A801 AA) 2010-Feb-10 00:00 2455237.5 ... 250.0576 3.4415
1 Ceres (A801 AA) 2010-Feb-20 00:00 2455247.5 ... 252.7383 3.1451
"""
URL = conf.horizons_server
# check for required information and assemble commanddline stub
if self.id is None:
raise ValueError("'id' parameter not set. Query aborted.")
elif isinstance(self.id, dict):
commandline = self._format_id_coords(self.id)
else:
commandline = str(self.id)
if self.location is None:
self.location = '500@399'
if self.epochs is None:
self.epochs = Time.now().jd
# expand commandline based on self.id_type
if self.id_type in ['designation', 'name',
'asteroid_name', 'comet_name']:
commandline = ({'designation': 'DES=',
'name': 'NAME=',
'asteroid_name': 'ASTNAM=',
'comet_name': 'COMNAM='}[self.id_type] + commandline)
if self.id_type in ['smallbody', 'asteroid_name',
'comet_name', 'designation']:
commandline += ';'
if isinstance(closest_apparition, bool):
if closest_apparition:
commandline += ' CAP;'
else:
commandline += ' CAP{:s};'.format(closest_apparition)
if no_fragments:
commandline += ' NOFRAG;'
request_payload = OrderedDict([
('format', 'text'),
('EPHEM_TYPE', 'OBSERVER'),
('QUANTITIES', "'" + str(quantities) + "'"),
('COMMAND', '"' + commandline + '"'),
('SOLAR_ELONG', ('"' + str(solar_elongation[0]) + ","
+ str(solar_elongation[1]) + '"')),
('LHA_CUTOFF', (str(max_hour_angle))),
('CSV_FORMAT', ('YES')),
('CAL_FORMAT', ('BOTH')),
('ANG_FORMAT', ('DEG')),
('APPARENT', ({False: 'AIRLESS',
True: 'REFRACTED'}[refraction])),
('REF_SYSTEM', refsystem),
('EXTRA_PREC', {True: 'YES', False: 'NO'}[extra_precision])])
if isinstance(self.location, dict):
request_payload = dict(**request_payload, **self._location_to_params(self.location))
else:
request_payload['CENTER'] = "'" + str(self.location) + "'"
if rate_cutoff is not None:
request_payload['ANG_RATE_CUTOFF'] = (str(rate_cutoff))
# parse self.epochs
if isinstance(self.epochs, (list, tuple, ndarray)):
request_payload['TLIST'] = "\n".join([str(epoch) for epoch in
self.epochs])
elif isinstance(self.epochs, dict):
if ('start' not in self.epochs or 'stop' not in self.epochs or 'step' not in self.epochs):
raise ValueError("'epochs' must contain start, stop, step")
request_payload['START_TIME'] = (
'"' + self.epochs['start'].replace("'", '') + '"')
request_payload['STOP_TIME'] = (
'"' + self.epochs['stop'].replace("'", '') + '"')
request_payload['STEP_SIZE'] = (
'"' + self.epochs['step'].replace("'", '') + '"')
else:
# treat epochs as scalar
request_payload['TLIST'] = str(self.epochs)
if airmass_lessthan < 99:
request_payload['AIRMASS'] = str(airmass_lessthan)
if skip_daylight:
request_payload['SKIP_DAYLT'] = 'YES'
else:
request_payload['SKIP_DAYLT'] = 'NO'
# inject optional settings if provided
if optional_settings:
for key, value in optional_settings.items():
request_payload[key] = value
self.query_type = 'ephemerides'
# return request_payload if desired
if get_query_payload:
return request_payload
# set return_raw flag, if raw response desired
if get_raw_response:
self.return_raw = True
# query and parse
response = self._request('GET', URL, params=request_payload,
timeout=self.TIMEOUT, cache=cache)
self.uri = response.url
# check length of uri
if len(self.uri) >= 2000:
warnings.warn(('The uri used in this query is very long '
'and might have been truncated. The results of '
'the query might be compromised. If you queried '
'a list of epochs, consider querying a range.'))
return response
@deprecated_renamed_argument("get_raw_response", None, since="0.4.7",
alternative="async methods")
def elements_async(self, *, get_query_payload=False,
refsystem='ICRF',
refplane='ecliptic',
tp_type='absolute',
closest_apparition=False, no_fragments=False,
get_raw_response=False, cache=True):
"""
Query JPL Horizons for osculating orbital elements.
.. deprecated:: 0.4.7
The ``get_raw_response`` keyword argument is deprecated. The
`~HorizonsClass.elements_async` method will return a raw response.
The ``location`` parameter in ``HorizonsClass`` refers in this case to
the center body relative to which the elements are provided.
The following table lists the values queried, their definitions, data
types, units, and original Horizons designations (where available). For
more information on the definitions of these quantities, please refer to
the `Horizons User Manual <https://ssd.jpl.nasa.gov/horizons/manual.html>`_.
+------------------+-----------------------------------------------+
| Column Name | Definition |
+==================+===============================================+
| targetname | official number, name, designation (string) |
+------------------+-----------------------------------------------+
| H | absolute magnitude in V band (float, mag) |
+------------------+-----------------------------------------------+
| G | photometric slope parameter (float) |
+------------------+-----------------------------------------------+
| M1 | comet total abs mag (float, mag, ``M1``) |
+------------------+-----------------------------------------------+
| M2 | comet nuclear abs mag (float, mag, ``M2``) |
+------------------+-----------------------------------------------+
| k1 | total mag scaling factor (float, ``k1``) |
+------------------+-----------------------------------------------+
| k2 | nuclear mag scaling factor (float, ``k2``) |
+------------------+-----------------------------------------------+
| phasecoeff | comet phase coeff (float, mag/deg, ``PHCOFF``)|
+------------------+-----------------------------------------------+
| datetime_str | epoch Date (str, ``Calendar Date (TDB)``) |
+------------------+-----------------------------------------------+
| datetime_jd | epoch Julian Date (float, ``JDTDB``) |
+------------------+-----------------------------------------------+
| e | eccentricity (float, ``EC``) |
+------------------+-----------------------------------------------+
| q | periapsis distance (float, au, ``QR``) |
+------------------+-----------------------------------------------+
| a | semi-major axis (float, au, ``A``) |
+------------------+-----------------------------------------------+
| incl | inclination (float, deg, ``IN``) |
+------------------+-----------------------------------------------+
| Omega | longitude of Asc. Node (float, deg, ``OM``) |
+------------------+-----------------------------------------------+
| w | argument of the perifocus (float, deg, ``W``) |
+------------------+-----------------------------------------------+
| Tp_jd | time of periapsis (float, Julian Date, ``Tp``)|
+------------------+-----------------------------------------------+
| n | mean motion (float, deg/d, ``N``) |
+------------------+-----------------------------------------------+
| M | mean anomaly (float, deg, ``MA``) |
+------------------+-----------------------------------------------+
| nu | true anomaly (float, deg, ``TA``) |
+------------------+-----------------------------------------------+
| period | orbital period (float, (Earth) d, ``PR``) |
+------------------+-----------------------------------------------+
| Q | apoapsis distance (float, au, ``AD``) |
+------------------+-----------------------------------------------+
Parameters
----------
refsystem : string
Element reference system for geometric and astrometric quantities:
``'ICRF'`` or ``'B1950'``; default: ``'ICRF'``
refplane : string
Reference plane for all output quantities: ``'ecliptic'`` (ecliptic
and mean equinox of reference epoch), ``'earth'`` (Earth mean
equator and equinox of reference epoch), or ``'body'`` (body mean
equator and node of date); default: ``'ecliptic'``
tp_type : string
Representation for time-of-perihelion passage: ``'absolute'`` or
``'relative'`` (to epoch); default: ``'absolute'``
closest_apparition : boolean, optional
Only applies to comets. This option will choose the closest
apparition available in time to the selected epoch; default: False.
Do not use this option for non-cometary objects.
no_fragments : boolean, optional
Only applies to comets. Reject all comet fragments from selection;
default: False. Do not use this option for non-cometary objects.
get_query_payload : boolean, optional
When set to ``True`` the method returns the HTTP request parameters
as a dict, default: False
get_raw_response: boolean, optional
Return raw data as obtained by JPL Horizons without parsing the data
into a table, default: False
cache : bool
Defaults to True. If set overrides global caching behavior.
See :ref:`caching documentation <astroquery_cache>`.
Returns
-------
response : `requests.Response`
The response of the HTTP request.
Examples
--------
>>> from astroquery.jplhorizons import Horizons
>>> obj = Horizons(id='433', location='500@10',
... epochs=2458133.33546)
>>> el = obj.elements() # doctest: +REMOTE_DATA
>>> print(el) # doctest: +SKIP
targetname datetime_jd ... Q P
--- d ... AU d
------------------ ------------- ... ------------- ------------
433 Eros (1898 DQ) 2458133.33546 ... 1.78244263804 642.93873484
"""
URL = conf.horizons_server
# check for required information and assemble commandline stub
if self.id is None:
raise ValueError("'id' parameter not set. Query aborted.")
elif isinstance(self.id, dict):
commandline = self._format_id_coords(self.id)
else:
commandline = str(self.id)
if self.location is None:
self.location = '500@10'
if self.epochs is None:
self.epochs = Time.now().jd
# expand commandline based on self.id_type
if self.id_type in ['designation', 'name',
'asteroid_name', 'comet_name']:
commandline = ({'designation': 'DES=',
'name': 'NAME=',
'asteroid_name': 'ASTNAM=',
'comet_name': 'COMNAM='}[self.id_type] + commandline)
if self.id_type in ['smallbody', 'asteroid_name',
'comet_name', 'designation']:
commandline += ';'
if isinstance(closest_apparition, bool):
if closest_apparition:
commandline += ' CAP;'
else:
commandline += ' CAP{:s};'.format(closest_apparition)
if no_fragments:
commandline += ' NOFRAG;'
if isinstance(self.location, dict):
raise ValueError(('cannot use topographic position in orbital '
'elements query'))
# configure request_payload for ephemerides query
request_payload = OrderedDict([
('format', 'text'),
('EPHEM_TYPE', 'ELEMENTS'),
('MAKE_EPHEM', 'YES'),
('OUT_UNITS', 'AU-D'),
('COMMAND', '"' + commandline + '"'),
('CENTER', ("'" + str(self.location) + "'")),
('CSV_FORMAT', 'YES'),
('ELEM_LABELS', 'YES'),
('OBJ_DATA', 'YES'),
('REF_SYSTEM', refsystem),
('REF_PLANE', {'ecliptic': 'ECLIPTIC', 'earth': 'FRAME',
'body': 'BODY'}[refplane]),
('TP_TYPE', {'absolute': 'ABSOLUTE',
'relative': 'RELATIVE'}[tp_type])])
# parse self.epochs
if isinstance(self.epochs, (list, tuple, ndarray)):
request_payload['TLIST'] = "\n".join([str(epoch) for
epoch in
self.epochs])
elif isinstance(self.epochs, dict):
if ('start' not in self.epochs or 'stop' not in self.epochs
or 'step' not in self.epochs):
raise ValueError("'epochs' must contain start, "
"stop, step")
request_payload['START_TIME'] = (
'"'+self.epochs['start'].replace("'", '')+'"')
request_payload['STOP_TIME'] = (
'"'+self.epochs['stop'].replace("'", '')+'"')
request_payload['STEP_SIZE'] = (
'"'+self.epochs['step'].replace("'", '')+'"')
else:
request_payload['TLIST'] = str(self.epochs)
self.query_type = 'elements'
# return request_payload if desired
if get_query_payload:
return request_payload
# set return_raw flag, if raw response desired
if get_raw_response:
self.return_raw = True
# query and parse
response = self._request('GET', URL, params=request_payload,
timeout=self.TIMEOUT, cache=cache)
self.uri = response.url
# check length of uri
if len(self.uri) >= 2000:
warnings.warn(('The uri used in this query is very long '
'and might have been truncated. The results of '
'the query might be compromised. If you queried '
'a list of epochs, consider querying a range.'))
return response
@deprecated_renamed_argument("get_raw_response", None, since="0.4.7",
alternative="async methods")
def vectors_async(self, *, get_query_payload=False,
closest_apparition=False, no_fragments=False,
get_raw_response=False, cache=True,
refplane='ecliptic', aberrations='geometric',
delta_T=False,):
"""
Query JPL Horizons for state vectors.
.. deprecated:: 0.4.7
The ``get_raw_response`` keyword argument is deprecated. The
`~HorizonsClass.vectors_async` method will return a raw response.
The ``location`` parameter in ``HorizonsClass`` refers in this case to
the center body relative to which the vectors are provided.
The following table lists the values queried, their definitions, data
types, units, and original Horizons designations (where available). For
more information on the definitions of these quantities, please refer to
the `Horizons User Manual <https://ssd.jpl.nasa.gov/horizons/manual.html>`_.
+------------------+-----------------------------------------------+
| Column Name | Definition |
+==================+===============================================+
| targetname | official number, name, designation (string) |
+------------------+-----------------------------------------------+
| H | absolute magnitude in V band (float, mag) |
+------------------+-----------------------------------------------+
| G | photometric slope parameter (float) |
+------------------+-----------------------------------------------+
| M1 | comet total abs mag (float, mag, ``M1``) |
+------------------+-----------------------------------------------+
| M2 | comet nuclear abs mag (float, mag, ``M2``) |
+------------------+-----------------------------------------------+
| k1 | total mag scaling factor (float, ``k1``) |
+------------------+-----------------------------------------------+
| k2 | nuclear mag scaling factor (float, ``k2``) |
+------------------+-----------------------------------------------+
| phasecoeff | comet phase coeff (float, mag/deg, ``PHCOFF``)|
+------------------+-----------------------------------------------+
| datetime_str | epoch Date (str, ``Calendar Date (TDB)``) |
+------------------+-----------------------------------------------+
| datetime_jd | epoch Julian Date (float, ``JDTDB``) |