IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 27, 2015, 1:55:47 PM (11 years ago)
Author:
bills
Message:

remove dependence on FTOOLS

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/bills/concatp2batch

    r38860 r38968  
    2121
    2222GetOptions(
    23     "vebose|v"          =>  \$verbose,
     23    "verbose|v"          =>  \$verbose,
    2424    "save-temps"        =>  \$save_temps,
    2525    "test"              =>  \$test,
     
    3131my $output = shift;
    3232
    33 # TODO: make this an option
    34 my $stiltsJar = '/home/panstarrs/bills/jars/stilts.jar';
     33my $jardir = $ENV{JARDIR};
     34if (!$jardir) {
     35    $jardir = '/home/panstarrs/bills/jars';
     36}
     37my $stiltsJar = "$jardir/stilts.jar";
    3538
    3639my $stilts="java -jar $stiltsJar";
     
    3841my $ofmt = 'fits';
    3942
    40 my $extensionList = `ftlist $input h | grep Detection | awk '{print \$2}'`;
     43my $listArg = getExtensionArg($input);
    4144
    42 my ($listFile, $listName) = tempfile ("/tmp/foo.XXXX", UNLINK => !$save_temps);
     45my $cmd = "$stilts tcat in='$listArg' out=$output ofmt=$ofmt";
     46print STDERR "running $cmd\n";
    4347
    44 # make a list of the detection extension names
    45 print "$listName\n" if $save_temps;
    46 foreach my $n (split "\n", $extensionList) {
    47     print "$n\n" if $verbose;
    48     # ftlist HDU number starts with 1, stilts expects zero based index
    49     $n -= 1;
    50     print $listFile "$input#$n\n";
    51 }
    52 close $listFile;
    53 
    54 # my $cmd = "$stilts tcat in=\@$listName out=$output ofmt=$ofmt ocmd='tablename $extname;'";
    55 my $cmd = "$stilts tcat in=\@$listName out=$output ofmt=$ofmt";
    5648my $rc = system $cmd;
    5749if ($rc) {
     
    6254exit 0;
    6355
     56sub getExtensionArg {
     57    # find the zero offset extension number of each of the detection extensions and build
     58    # an argument list for them
     59    my $input = shift;
     60
     61    my $ftableOutput = `ftable -list $input`;
     62    die "ftable didn't return any output for $input\n" unless $ftableOutput;
     63
     64    my @lines = split "\n", $ftableOutput;
     65
     66    my $listArg = "";
     67    my $n = -1;
     68    foreach my $line (@lines) {
     69        # skip first line which is a list header
     70        if ($n == -1) {
     71            $n = 0;
     72            next;
     73        }
     74        if ($line =~ /^Detection/) {
     75            $listArg .= "$input#$n ";
     76        }
     77        $n++;
     78    }
     79
     80    return $listArg;
     81}
Note: See TracChangeset for help on using the changeset viewer.