2010年7月15日木曜日

getImageFItsKey1.pl

a perl script to output some keywords from a image fits header.
This is for suzaku/XIS image fits.
I hope this to help your job.

#!/usr/local/bin/perl -w

$image="$ARGV[0]+0";
# print $image;
#$dbg=1;
$dbg=0;

sub getKey {
    my $fits = $_[0];
    my $key = $_[1];
    system("fkeypar $fits $key ") && return -1;
    my $value = `pget fkeypar value`;
    chomp($value);
    return $value;
}

my $object = &getKey($image, "OBJECT");
printf("#1 object = %12s¥n", $object) if ($dbg);
my $exposure = &getKey($image, "EXPOSURE");
my $cts = &getKey($image, "TOTCTS");

my $rate=0;
if ($exposure >= 0){
    $rate = $cts/$exposure;
}

printf("%12s |%-28s |%6.1f (ks) |%6.1f (kcts) |%6.1f (c/s) ¥n",
    $image, $object, $exposure/1000, $cts/1000, $rate);

exit;