Differences between revisions 6 and 7
Revision 6 as of 2013-03-12 12:32:40
Size: 3595
Editor: JesusTorrado
Comment:
Revision 7 as of 2022-04-06 01:37:44
Size: 0
Editor: mkoeppe
Comment: outdated
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
= Installing and using ''healpy'' in Sage =

[[https://github.com/healpy/healpy|healpy]] is a [[http://healpix.jpl.nasa.gov/|healpix]] python wrapper, including all its capabilities.

===== Notes: =====
 * Using the latest snapshot of healpy is recommended, since the management of the ''cfitsio'' library is simplified w.r.t. the latest release: 1.5.0.
 * Right now, the latest snapshot is '''broken for 32 bits systems!'''
 * Unfortunately, until [[http://trac.sagemath.org/sage_trac/ticket/11334|#11334]] gets merged, the numpy version shipped with Sage is too old, so it is necessary to apply that patch manually, preferably in a branch in which we will work.

== Install ==

=== Requirements ===

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

 * system tools: ''pkg-config'', ''autoconf'', ''libtool'', ''gcc'', ''g++'', ''python-dev'' (use e.g. your system's package manager)
 * ''numpy'' >= 1.6 (1.5 as of Sage 5.7)
 * ''pyfits'' >= 3.0

In the first place, let us install [[http://www.stsci.edu/institute/software_hardware/pyfits|pyfits]]:

 1. Download the '''source''' tarball from [[http://www.stsci.edu/institute/software_hardware/pyfits/Download|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 [[http://trac.sagemath.org/sage_trac/ticket/11334|#11334]], following the general instructions at the [[http://www.sagemath.org/doc/developer/|Sage Developer’s Guide]]. After it, one should be able to import ''numpy'' cleanly inside Sage.

=== Actually installing healpy ===

 1. Download the latest snapshot (see notes at the beginning) from [[https://github.com/healpy/healpy|here]].
 2. Extract it in some dummy directory and change to it.
 3. Download the latest snapshot of ''cfitsio'' and ''healpix'' from [[https://github.com/healpy/cfitsio|here]] and [[https://github.com/healpy/healpixmirror|here]], respectively, and extract the contents in the corresponding subfolders of the dummy folder; i.e. the files of ''cfitsio'' should appear under the ''cfitsio'' subfolder, without any intermediate folder and the same for ''healpix''. 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 us first make some general imports:

{{{#!python
    sage: import numpy as np
    sage: import matplotlib.pyplot as plt
}}}

And, of course:

{{{#!python
    sage: import healpy as hp
}}}

If the import is clean, we can start testing the examples in the [[http://healpy.readthedocs.org/en/latest/tutorial.html|healpy tutorial]], noticing the following:

=== Plotting ===

All the (static) plotting functions work: {{{mollview()}}}, {{{gnomview()}}} and {{{cartview()}}}. But in order for Sage to show the figure, one must save it with {{{plt.savefig('')}}}, where {{{plt}}} is the name with which {{{matplotlib.pyplot}}} was imported.

Making the dynamic {{{mollzoom()}}} work is still work to do, '''possibly''' related with using an interactive matplotlib backend, as explained [[http://wiki.sagemath.org/sage_matlab|here]].