#!/usr/bin/perl
CFITSIO::PerlyUnpacking(0);
my
(
$fptr
,
$file
,
$status
,
$ycol
,
$i
,
$nrows
,
$anynul
,
$pdl
);
$file
=
@ARGV
?
shift
:
'bintable.fits'
;
$fptr
= CFITSIO::open_file(
$file
,READONLY,
$status
);
check_status(
$status
);
$fptr
->movnam_hdu(ANY_HDU,
'EVENTS'
,0,
$status
);
check_status(
$status
);
$fptr
->get_num_rows(
$nrows
,
$status
);
check_status(
$status
);
$fptr
->get_colnum(0,
'Y'
,
$ycol
,
$status
);
(
$status
== COL_NOT_FOUND) and
"$0: could not find TTYPE 'Y' in binary table"
;
$pdl
= zeroes(
$nrows
)->long;
$fptr
->read_col_lng(
$ycol
,1,1,
$nrows
,0,${
$pdl
->get_dataref},
$anynul
,
$status
);
check_status(
$status
);
my
$hist
=
$pdl
->hist(
$pdl
->min,
$pdl
->max,1.0);
my
$y
=
$hist
->sequence +
$pdl
->min;
line
$y
,
$hist
;
sub
check_status {
my
$status
=
shift
;
my
$errtxt
;
if
(
$status
) {
CFITSIO::fits_get_errstatus(
$status
,
$errtxt
);
print
STDERR
<<EOP;
$0 - CFITSIO error detected (see below), aborting
$errtxt
EOP
exit
1;
}
}