From 7f95f90cd25f64b747e24055aec951240f52b9f6 Mon Sep 17 00:00:00 2001 From: Tom Aldcroft Date: Fri, 6 Feb 2015 15:33:50 -0500 Subject: [PATCH] Clean up astropy.io.fits references --- source/astropy/fits.rst | 12 +++++++----- source/files/binaryfiles.rst | 10 ++++++---- source/fitting/low-level.rst | 3 ++- source/fitting/spectrum.rst | 2 ++ source/intro/quick-tour.rst | 2 +- source/references.rst | 2 +- 6 files changed, 19 insertions(+), 12 deletions(-) diff --git a/source/astropy/fits.rst b/source/astropy/fits.rst index 6f49819..601c592 100644 --- a/source/astropy/fits.rst +++ b/source/astropy/fits.rst @@ -1,9 +1,11 @@ +.. include:: ../references.rst + .. _handling-fits-files: Handling FITS files =================== -.. note:: If you are already familiar with PyFITS, `astropy.io.fits` is in +.. note:: If you are already familiar with PyFITS, `astropy.io.fits`_ is in fact the same code as the latest version of PyFITS, and you can adapt old scripts that use PyFITS to use Astropy by simply doing:: @@ -17,7 +19,7 @@ Documentation ------------- For more information about the features presented below, you can read the -`astropy.io.fits `_ docs. +`astropy.io.fits`_ docs. @@ -215,14 +217,14 @@ Accessing Tabular Data In Astropy 0.2, FITS tables cannot be read/written directly from the ``Table`` class. To create a ``Table`` object from a FITS table, you can use -``astropy.io.fits``:: +`astropy.io.fits`_:: >>> from astropy.io import fits >>> from astropy.table import Table >>> data = fits.getdata('catalog.fits', 1) >>> t = Table(data) -and to write out, you can use ``astropy.io.fits``, converting the table to a +and to write out, you can use `astropy.io.fits`_, converting the table to a Numpy array:: >>> fits.writeto('new_catalog.fits', np.array(t)) @@ -285,7 +287,7 @@ Practical Exercises Using Matplotlib, make an all-sky plot of the LAT Background Model in the Plate Carée projection showing the LAT Point Source Catalog overlaid with markers, and with the correct coordinates on the axes. You should do this - using only ``astropy.io.fits``, Numpy, and Matplotlib (no WCS or + using only `astropy.io.fits`_, Numpy, and Matplotlib (no WCS or coordinate conversion library). Hint: the -CAR projection is such that the x pixel position is proportional to longitude, and the y pixel position to latitude. Bonus points for a pretty colormap. diff --git a/source/files/binaryfiles.rst b/source/files/binaryfiles.rst index e460319..50e7c53 100644 --- a/source/files/binaryfiles.rst +++ b/source/files/binaryfiles.rst @@ -1,3 +1,5 @@ +.. include:: ../references.rst + :tocdepth: 2 Binary formats useful for astronomers @@ -6,12 +8,12 @@ Binary formats useful for astronomers astropy.io.fits - Reading and writing fits files ================================================ -`astropy.io.fits `_ is a Python module developed at STScI to read and write all types of fits files. The full html manual is available `here `_. +`astropy.io.fits`_ is a Python module developed at STScI to read and write all types of fits files. .. admonition:: External resource! - The astropy.io.fits tutorial itself is good for our purpose and since this - is the internet I will not reinvent the wheel. Read the manual `here `_ + The `astropy.io.fits`_ tutorial itself is good for our purpose and since this + is the internet I will not reinvent the wheel. Read the manual then come back to this page for an exercise. .. admonition:: Exercise @@ -47,7 +49,7 @@ Here is a possible solution:: plt.colorbar() You might recognize this piece of code. It was used before in -the :doc:`../core/numpy_scipy` part of the tutorial, but now you should understand the ``astropy.io.fits`` commands in more detail. +the :doc:`../core/numpy_scipy` part of the tutorial, but now you should understand the `astropy.io.fits`_ commands in more detail. .. raw:: html diff --git a/source/fitting/low-level.rst b/source/fitting/low-level.rst index 1147b56..517d000 100644 --- a/source/fitting/low-level.rst +++ b/source/fitting/low-level.rst @@ -1,3 +1,4 @@ +.. include:: ../references.rst The low-level Sherpa API ------------------------ @@ -32,7 +33,7 @@ Import a few Sherpa classes needed to characterize a fit:: from sherpa.optmethods import LevMar from sherpa.fit import Fit -Import the Python FITS reader ``astropy.io.fits`` and open the spectrum as a table:: +Import the Python FITS reader `astropy.io.fits`_ and open the spectrum as a table:: from astropy.io import fits dat = fits.open('3c273.fits')[1].data diff --git a/source/fitting/spectrum.rst b/source/fitting/spectrum.rst index 2921152..544bf98 100644 --- a/source/fitting/spectrum.rst +++ b/source/fitting/spectrum.rst @@ -1,3 +1,5 @@ +.. include:: ../references.rst + 1-D data with errors -------------------- diff --git a/source/intro/quick-tour.rst b/source/intro/quick-tour.rst index fe3edbe..cdf1ea4 100644 --- a/source/intro/quick-tour.rst +++ b/source/intro/quick-tour.rst @@ -147,7 +147,7 @@ This example demonstrates how to create a synthetic image of a cluster, including convolution with a Gaussian filter and the addition of noise. :: - import astropy.io.fits as fits + from astropy.io import fits from scipy.ndimage import gaussian_filter # Create empty image diff --git a/source/references.rst b/source/references.rst index d93b7fe..32bdcdc 100644 --- a/source/references.rst +++ b/source/references.rst @@ -4,7 +4,6 @@ .. _`IPython`: http://ipython.org .. _CIAO: http://cxc.harvard.edu/ciao/ .. _SAS: http://xmm.vilspa.esa.es/sas/ -.. _astropy_doc: http://astropy.readthedocs.org/en/stable .. _APLpy: http://aplpy.github.com .. _SAMPy: http://pypi.python.org/pypi/sampy .. _COATPy: https://github.com/python4vo/coatpy @@ -14,5 +13,6 @@ .. _TOPCAT: http://www.star.bris.ac.uk/~mbt/topcat .. _Directory: http://nvo.stsci.edu/vor10/index.aspx .. _astropy: http://astropy.org +.. _astropy_doc: http://astropy.readthedocs.org/en/stable .. _`astropy.io.ascii`: http://astropy.readthedocs.org/en/stable/io/ascii/ .. _`astropy.io.fits`: http://astropy.readthedocs.org/en/stable/io/fits/