Debian Codegraph @

docs/getting_started.rst

raw
1 .. include:: references.txt
2
3 .. _using:
4
5 Getting started
6 ===============
7
8 .. _using-intro:
9
10 The cleanest way to use the functionality in **healpix** is to make use of the
11 high-level :class:`~astropy_healpix.HEALPix` class. The
12 :class:`~astropy_healpix.HEALPix` class should be initialized with the ``nside``
13 parameter which controls the resolution of the pixellization - it is the number
14 of pixels on the side of each of the 12 top-level HEALPix pixels::
15
16 >>> from astropy_healpix import HEALPix
17 >>> hp = HEALPix(nside=16)
18
19 As described in the references above, HEALPix pixel indices can follow two
20 different ordering conventions - the *nested* convention and the *ring*
21 convention. By default, the :class:`~astropy_healpix.HEALPix` class assumes the ring
22 ordering convention, but it is possible to explicitly specify the convention to
23 use using the ``order`` argument, for example::
24
25 >>> hp = HEALPix(nside=16, order='ring')
26
27 or::
28
29 >>> hp = HEALPix(nside=16, order='nested')
30
31 Once this class has been set up, you can access various properties and methods
32 related to the HEALPix pixellization. For example, you can calculate the
33 number of pixels as well as the pixel area or resolution::
34
35 >>> hp.npix
36 3072
37 >>> hp.pixel_area # doctest: +FLOAT_CMP
38 <Quantity 0.0040906154343617095 sr>
39 >>> hp.pixel_resolution # doctest: +FLOAT_CMP
40 <Quantity 219.87113035631398 arcmin>
41
42 As you can see, when appropriate the properties and the methods on the
43 :class:`~astropy_healpix.HEALPix` class return Astropy high-level classes such as
44 :class:`~astropy.units.Quantity`, :class:`~astropy.coordinates.Longitude`, and
45 so on.
46
47 For example, the :meth:`~astropy_healpix.HEALPix.healpix_to_lonlat` method can be used
48 to convert HEALPix indices to :class:`~astropy.coordinates.Longitude` and
49 :class:`~astropy.coordinates.Latitude` objects::
50
51 >>> lon, lat = hp.healpix_to_lonlat([1, 442, 2200])
52 >>> lon # doctest: +FLOAT_CMP
53 <Longitude [ 0.83448555, 1.63624617, 0.4712389 ] rad>
54 >>> lat # doctest: +FLOAT_CMP
55 <Latitude [ 0.08343009, 0.94842784,-0.78529135] rad>
56
57 The :class:`~astropy_healpix.HEALPix` class includes methods that take or return
58 :class:`~astropy.coordinates.SkyCoord` objects (we will take a look at this in
59 the :ref:`celestial` section).
60
61 In the subsequent sections of the documentation, we will take a closer look at
62 converting between coordinate systems, as well as more advanced features such as
63 interpolation and cone searches.