Hello Derek,

sorry for not giving a working example, my code would not have made things clearer :) But your example is a good example ! I do not think the problem is in the extension reading. If you look at the header of your test.fits, you can see that the keyword NAXIS is equal to 0 and there is no KW NAXIS1 and NAXIS2, whereas if you only write the first extension, with wfits($bsub,'test.fits');, then you have
NAXIS   =  2
NAXIS1  =  3
NAXIS2  =  4
 which is what is expected.
The fact is, test.fits with the two extensions does contain the 3×4 image, it can be seen with ds9, but the header is wrong.

In my case, I read an existing fits file, process it, and save the results in another file, and I want to propagate the huge input primary header. The resulting header is the same as your test.fits, and I lose all the input KW. The problem is the writing of the primary header by wfits in the case of several extensions. Is there any solution ?

        Thank you in advance,
           Best regards.

Le 15/07/2014 20:42, Derek Lamb a écrit :
Hello Frédéric,

Without a minimal working example, I made my own, but if you have a better 
example it would be good to see it!

pdl> $bsub = sequence(3,4);
pdl> $FST = xvals(20);
pdl> $bsub->fhdr; #initialize an empty Astro::FITS::Header, let wfits correct it
pdl> $FST->fhdr;
pdl> wfits([$bsub,$FST],'test.fits');
pdl> ^Z
[2]+  Stopped                 pdl
$ more test.fits
#I see the primary header and then two extension headers which are correct
$ fg
pdl> $bsub_read = rfits('test.fits[1]'); #try to read them in one at a time
Unexpected end of FITS file at …PDL/IO/FITS.pm line 412.
##########
So it seems like there is a problem with the extension READING in PDL::IO::FITS.

Forcing a read of the primary extension seems to be OK:

pdl> $primary = rfits('test.fits[0]')
pdl> p keys %$primary
SIMPLE BITPIX NAXIS EXTEND COMMENT HDUNAME END

cheers,
Derek


On Jul 15, 2014, at 6:51 AM, Frédéric Royer <[email protected]> wrote:

Hello,

   I am trying to write Fits files with 2 extensions.
When using:
        wfits([$bsub,$FST],$skysubfits);
the header of the primary extension $bsub is not propagated and the output file 
has a simplistic primary header,
whereas if I only write the first extension using
        wfits($bsub,$skysubfits);
the output file has the correct header.

Is there a way to propagate the header when writing multi extension FITS files 
with wfits ?

        Thank you in advance
          Best regards.

--
   _
|// \|_  _ _ ._   _._|_ _ o._ _  |
| \_/|_)_>(/_| \/(_| |_(_)|| (/_ |--- G E P I
                  de  Paris      |
ROYER Frederic
GEPI / CNRS UMR 8111
Observatoire de Paris   Tel: +33 1 45 07 78 44
92195 MEUDON cedex      Fax: +33 1 45 07 78 78

_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl



--
   _
|// \|_  _ _ ._   _._|_ _ o._ _  |
| \_/|_)_>(/_| \/(_| |_(_)|| (/_ |--- G E P I
                  de  Paris      |
ROYER Frederic
GEPI / CNRS UMR 8111
Observatoire de Paris   Tel: +33 1 45 07 78 44
92190 MEUDON            Fax: +33 1 45 07 78 78

_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to