Very interesting. It would be helpful to have a copy of the original and mangled data file, or at least of their FITS headers if you can strip them out with your favorite text editor.

Cheers,
Craig

On Oct 2, 2007, at 3:13 PM, Matthew Kenworthy wrote:

I've been trying to copy the FITS headers from one piddle to another,
but wfits seems to be mangling the header somehow.

In the code below, I know that rfits should give $im a hash with the
FITS header, but I wanted to be explicit in pulling out the header into $im_hdr - the input is a data cube and the output is a smaller data cube
with NAXIS=3, NAXIS3=5:

---code---

my $im = rfits $file;
my $im_hdr = rfitshdr $file;

print "### BEFORE...\n";
print_hdr(%$im_hdr);
$$im_hdr{NAXIS3} = "5";
print "### CHANGED NAXIS3...\n";
print_hdr(%$im_hdr);
$output_image->sethdr($im_hdr);
print "AFTER...\n";
print_hdr(%$im_hdr);

wfits $output_image,$output_file;

sub print_hdr { use strict; my (%hash) = @_; foreach my $k (sort keys %hash) { print "$k => $hash{$k}\n"; } }

---end code---

...but wfits then cautions with:

Use of uninitialized value in string eq at
/usr/lib/perl5/site_perl/5.8.8/Astro/FITS/Header.pm line 1426,
<AUTOLOAD_FILE> line 22.

...and in IRAF ds9 cannot display the resultant image, and reporting
back with:

imhead test.fits l+
test.fits[320,258,5][double]:
No bad pixels, min=0., max=0. (old)
Line storage mode, physdim [320,258,5], length of user area 243 s.u.
Created Tue 14:01:24 02-Oct-2007, Last modified Tue 14:01:24 02- Oct-2007
Pixel file "test.fits" [NO PIXEL FILE]
BUNIT   = 'Data Value'
BSCALE  =                    1 / default scaling factor
BZERO   =                32768 / offset data range to that of unsigned
short
EXTEND  =                    T / FITS dataset may contain extensions
COMMENT   FITS (Flexible Image Transport System) format is defined in
'Astronomy
COMMENT   and Astrophysics', volume 376, page 359; bibcode:
2001A&A...376..359H

Note the [NO PIXEL FILE] comment seems to be the diagnostic of FITS file
not being read by IRAF.

If I remove the $$im_hdr{NAXIS3} = "5"; line then wfits gives me:

Warning: wfits corrected dimensions of FITS header at ./ clean_dark_and_flats.pl line 199

...with the same imhead result as before.

Finally, removing all attempts to adjust the header in $output_file
results in a working output file that can be displayed in IRAF, without
any of the headers.

Thanks for your time,

Matt

--
Matthew Kenworthy / Instrument Scientist / CAAO / Steward Observatory
Room N414 / 933 N. Cherry Ave / Tucson AZ 85721 / vox 520 626 6720

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



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

Reply via email to