[AstroPy] astropy.io.fits documentation, suggested rewording
embray at stsci.edu
Mon May 14 11:46:06 EDT 2012
Agreed. I actually have a bit in the recently added PyFITS FAQ that
mentions that C/Python, and hence PyFITS use row-major order:
It should certainly read that way in the actual docs too.
On 05/12/2012 11:47 PM, Brian Kloppenborg wrote:
> I was reading over the astropy.io.fits documentation
> today and found the following phrase in the "Working with image data"
> section to be confusing:
>> "Note that, like C (and unlike FORTRAN), Python is 0-indexed and the
>> indices have the slowest axis first and fast axis last, i.e. for a 2-D
>> image, the fast axis (X-axis) which corresponds to the FITS NAXIS1
>> keyword, is the second index. Similarly, the 1-indexed sub-section of
>> x=11 to 20 (inclusive) and y=31 to 40 (inclusive) would be given in
>> Python as:"
> Perhaps we could rewrite this to refer to the indexing by it's name,
> "row-major order," instead? This would give interested parties a name by
> which to look it up.
> A drop-in replacement for the text and code sections could be:
> "Note that Python, like C, is zero-indexed. The indicies follow
> row-major order (unlike FORTRAN and IDL which use column-major
> indexing). To access the ith row (FITS NAXIS0) and jth column (FITS
> NAXIS1) one specifies
> >>> scidata[i,j]
> When accessing a subarray of pixel data, rows =31 to 40 (inclusive) and
> columns = 11 to 10 (inclusive) it would be done by decrementing the
> starting index by one (to account for the zero-indexed nature of Python)
> and accessing the subarray using a range of rows and columns thusly:
> >>> scidata[30:40, 10:20]
> We could also include a link to documentation for interested parties:
> I don't think the following bit is required, but if someone wanted to,
> we could write this too:
> The index of the [i,j] entry of a 2D array of width 'w' is computed by:
> index = i * w + j
> or something similar.
> Brian Kloppenborg
> AstroPy mailing list
> AstroPy at scipy.org
More information about the AstroPy