Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Data conversion of FITS images in PDL

by Xilman (Hermit)
on Aug 23, 2020 at 19:26 UTC ( [id://11121012]=perlquestion: print w/replies, xml ) Need Help??

Xilman has asked for the wisdom of the Perl Monks concerning the following question:

I am being stupid. Either that, or less likely, the documentation in PDL::IO::FITS is wrong.

I have a FITS image in which each pixel is a 32-bit float. That is, BITPIX == -32. I wish to convert it to 32-bit fixed-point format, where BITPIX == 16.

This is my script.

#! /usr/bin/perl

use strict;
use warnings;
use PDL;
use PDL::IO::FITS;
 
my $x = rfits('foo.fits');
$x->wfits('bar.fits', 16);

And here is what happens:

pcl@nut:~/Astro/Code$ imhead foo.fits | grep BITPIX
BITPIX  =                  -32 /
pcl@nut:~/Astro/Code$ perl to_int.pl
pcl@nut:~/Astro/Code$ imhead bar.fits | grep BITPIX
BITPIX  =                  -32

The output file is not converted to 16-bit unsigned format, despite what the documentation appears to say.

What am I not understanding and how do I get data conversion?

Replies are listed 'Best First'.
Re: Data conversion of FITS images in PDL
by swl (Parson) on Aug 23, 2020 at 22:24 UTC

      Many thanks. Your suggestion works a treat.

      I will submit a bug report.

        Thanks for this report! The bug was fixed by Derek Lamb, and released as PDL 2.022 in Sep 2020.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11121012]
Approved by Corion
Front-paged by haukex
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (3)
As of 2024-04-25 23:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found