Differences between revisions 1 and 6 (spanning 5 versions)
Revision 1 as of 2013-03-07 18:48:52
Size: 3140
Editor: JesusTorrado
Comment:
Revision 6 as of 2013-03-12 12:32:40
Size: 3595
Editor: JesusTorrado
Comment:
Deletions are marked like this. Additions are marked like this.
Line 6: Line 6:
 * 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.  * 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.
Line 16: Line 16:
 * numpy >= 1.6 (1.5 as of Sage 5.7)
 * pyfits
 * 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
Line 21: Line 22:
 1. Download the ''source'' from [[http://www.stsci.edu/institute/software_hardware/pyfits/Download|here]].  1. Download the '''source''' tarball from [[http://www.stsci.edu/institute/software_hardware/pyfits/Download|here]].
Line 26: Line 27:
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. 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.
Line 28: Line 29:
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. 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.
Line 30: Line 31:
=== Actuallly installing healpy === === Actually installing healpy ===
Line 34: Line 35:
 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; 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.  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.
Line 42: Line 43:
Let's first make some general imports: Let us first make some general imports:
Line 55: Line 56:
If the import is clean, we can start testing the examples in the [[http://healpy.readthedocs.org/en/latest/tutorial.html|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('')}}}. 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]].

Installing and using ''healpy'' in Sage

healpy is a 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 #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 pyfits:

  1. Download the source tarball 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.

Actually 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; 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:

   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, 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 here.