Hi Matt,

I think the problem you have is that at Point Two you have a 2D piddle, 
but the header has 3 dimensions (NAXIS=3 and NAXIS3=100).  When rfits 
reads in the new file before Point Three, it sees NAXIS3 and allocates 
an appropriately sized piddle (ignoring NAXIS=2, which was probably 
corrected by wfits -- $PDL::Verbose = 1 will tell you about that I 
think).  If that is the case, then you should have a bunch of zeroes 
along that 3rd axis.

Ways to fix: 1) delete NAXIS3 before writing. 2) download the latest 
CVS.  I fixed it in there about a month ago when I encountered the same 
problem.

hope that helps,
Derek

Matthew Kenworthy wrote:
> Hi,
>
> I have a program that reads in a data cube, and writes out a sigma
> clipped image combined along the third dimension as output.
>
> I want to copy the FITS headers to the new image - but I'm missing
> something, as when I write out the new image, both IRAF and the file
> size indicate that I'm writing out the smaller stacked image.
>
> BUT when I reread the image back into PDL, it only sees the original
> data cube size. I've attached the program below, and the output from
> this program which shows the problem.
>
> Any suggestions as to what is the proper way to copy FITS image headers
> greatly appreciated :)
>
>
> Here's the output, then the program:
>
> # stack_cube starting...
> # cube input: uma01-0003.fits
> # stacked output: cuma01-0003.fits
> POINT ZERO: PDL: Double D [320,258,100]
> POINT ONE: PDL: Double D [320,258]
> POINT TWO: PDL: Double D [320,258]
> POINT THREE: PDL: Double D [320,258,100]
> # ...averaged cube image cuma01-0003.fits written. END
>
> ...and the program.
>
> #!/usr/bin/perl -w
> use strict;
> use PDL;
> use PDL::NiceSlice;
> use PDL::AutoLoader;
> $|=1;
>
> # stack_cube.pl
>
> # read in image
> my $file = $ARGV[0] || "uma01-0003.fits";
> my $file_out = $ARGV[1] || "cuma01-0003.fits";
>
> print "# stack_cube starting...\n# cube input: $file\n# stacked output:
> $file_out\n";
>
> my $fin = rfits $file;
> my $finhdr = $fin->hdr;
>
> print "POINT ZERO: ".$fin->info()."\n";
>
> my ($im_out,$prms,$median,$min,$max,$adev,$rms,$weights) =
> statsoverclip($fin->mv(-1,0), 2.0, 1);
>
> ## rejected pixels
> ### my $imbad = $weights->sumover; imag $imbad; wfits $imbad,
> "badpix.fits";
>
> print "POINT ONE: ".$im_out->info()."\n";
>
> $im_out->sethdr($finhdr);
>
> print "POINT TWO: ".$im_out->info()."\n";
>
> wfits $im_out, $file_out;
>
> my $im_out_reread = rfits $file_out;
>
> print "POINT THREE: ".$im_out_reread->info()."\n";
>
> print "# ...averaged cube image $file_out written. END\n";
>
>
>
>
>
>
>
>
>   


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

Reply via email to