Closed montefra closed 6 years ago
@ericmandel : commit aa73eae28ccdeed20c8d2af150c7d17466194d7a should solve issue #59 .
However when creating a 3D array I came across the fact that python uses C ordering while fits uses Fortran ordering.
This means that:
numpy shape | NAXIS1 | NAXIS2 | NAXIS 3 |
---|---|---|---|
(10, 8) | 8 | 10 | |
(3, 10, 8) | 8 | 10 | 3 |
So I:
set_np2arr
function.get_arr2np
already does the correct thing.
If you want to double check the ordering open python/ipython and do:
In [1]: from astropy.io import fits
In [2]: hdus = fits.open('my/fits/file')
In [3]: hdus[0].data.shape
In [4]: hdus[0].header
Can you please check the changes?
I tested this on a real data cube and it looks like it does what you want:
However, I can't comment on whether this is what numpy users expect, since I don't use Python/numpy. I think you should merge the PR but just keep in the back of your mind that there might be questions.
Thank you for checking. As I wrote, I think that this is the expected behaviour. Anyway I'll keep in mind
I'm confident you have it right. My comment is rooted in the fact that several years ago, I had it coded one way and then was told it needed to be the other way. So clearly I don't know which end is up with numpy!
So clearly I don't know which end is up with numpy!
I also never remember which way is numpy indexed. I always end up in a ipython
session to do some test.
This PR addresses issue #59
I have added a
test_3d.fits
file replicating 3 times thetest.fits
in the z-direction. This should be enough to test the problem