Installing and using ''healpy'' in Sage

healpy is a healpix python wrapper, including all its capabilities.

Notes:

Install

Requirements

The requirements of healpy which do not come bundled within Sage are:

In the first place, let us install pyfits:

  1. Download the source from here.

  2. Extract it in some dummy directory and change to it.
  3.  $ bash sage --python setup.py build

  4.  $ bash sage --python setup.py install --user

If everything went fine, you should be able to do  import pyfits from Sage cleanly. If that is the case, the dummy directory can be safely erased.

The next step is branching and applying #11334, following the general instructions at the Sage Developer’s Guide. After it, one should be able to import numpy cleanly inside Sage.

Actuallly installing healpy

  1. Download the latest snapshot (see notes at the beginning) from here.

  2. Extract it in some dummy directory and change to it.
  3. Download the latest snapshot of cfitsio and healpix from here and here, respectively, and extract the contents in the corresponding subfolders of the dummy folder; e.g. the files of cfitsio should appear under the cfitsio subfolder, without any intermediate folder. To see the expected directory structure, one can explore the file tree at the healpy github.

  4.  $ bash sage --python setup.py build

  5.  $ bash sage --python setup.py install --user

If the examples in the next section work, the dummy directory can be erased.

Testing and general usage

Let's first make some general imports:

   1     sage: import numpy as np
   2     sage: import matplotlib.pyplot as plt

And, of course:

   1     sage: import healpy as hp

If the import is clean, we can start testing the examples in the healpy tutorial, having into account that inside Sage, in order to use pyplot, right before plotting we have to clean the canvas with #!python plt.clf(), and in order to show the figure in the notebook we do not use #! plt.show() but #! plt.savefig('').