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
|
.. _astropy-coordinates-remote:
Usage Tips/Suggestions for Methods That Access Remote Resources
***************************************************************
There are currently two methods that rely on getting remote data to work.
The first is the :class:`~astropy.coordinates.SkyCoord` :meth:`~astropy.coordinates.SkyCoord.from_name` method, which uses
`Sesame <https://cds.unistra.fr/cgi-bin/Sesame>`_ to retrieve coordinates
for a particular named object::
>>> from astropy.coordinates import SkyCoord
>>> SkyCoord.from_name("PSR J1012+5307") # doctest: +REMOTE_DATA +FLOAT_CMP
<SkyCoord (ICRS): (ra, dec) in deg
( 153.1393271, 53.117343)>
.. testsetup::
>>> from astropy.coordinates import EarthLocation
>>> apo = EarthLocation(-1463969.3018517173, -5166673.342234327, 3434985.7120456537, unit='m')
The second is the :class:`~astropy.coordinates.EarthLocation` :meth:`~astropy.coordinates.EarthLocation.of_site` method, which
provides a similar quick way to get an
:class:`~astropy.coordinates.EarthLocation` from an observatory name::
>>> from astropy.coordinates import EarthLocation
>>> apo = EarthLocation.of_site('Apache Point Observatory') # doctest: +SKIP
>>> apo # doctest: +FLOAT_CMP
<EarthLocation (-1463969.3018517173, -5166673.342234327, 3434985.7120456537) m>
The full list of available observatory names can be obtained with
:meth:`astropy.coordinates.EarthLocation.get_site_names`.
.. testsetup::
>>> loc = EarthLocation(-1994502.60430614, -5037538.54232911, 3358104.99690298, unit='m')
While these methods are convenient, there are several considerations to take
into account:
* Since these methods access online data, the data may evolve over time (for
example, the accuracy of coordinates might improve, and new observatories
may be added). Therefore, this means that a script using these and currently
running may give a different answer in five years. Therefore, users concerned
with reproducibility should not use these methods in their final scripts,
but can instead use them to get the values required, and then hard-code them
into the scripts. For example, we can check the coordinates of the Kitt
Peak Observatories using::
>>> loc = EarthLocation.of_site('Kitt Peak') # doctest: +SKIP
Note that this command requires an internet connection.
We can then view the actual Cartesian coordinates for the observatory:
>>> loc # doctest: +FLOAT_CMP
<EarthLocation (-1994502.6043061386, -5037538.54232911, 3358104.9969029757) m>
This can then be converted into code::
>>> loc = EarthLocation(-1994502.6043061386, -5037538.54232911, 3358104.9969029757, unit='m')
This latter line can then be included in a script and will ensure that the
results stay the same over time.
* The online data may not be accurate enough for your purposes. If maximum
accuracy is paramount, we recommend that you determine the celestial or
Earth coordinates yourself and hard-code these, rather than using the
convenience methods.
* These methods will not function if an internet connection is not available.
Therefore, if you need to work on a script while offline, follow the
instructions in the first bullet point above to hard-code the coordinates
before going offline.
|