IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 10, 2010, 7:44:33 PM (16 years ago)
Author:
eugene
Message:

updates from eam_branches/20091201

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippScripts/scripts/magic_process.pl

    r25934 r26901  
    3131my $magictool      = can_run('magictool') or (warn "Can't find magictool" and $missing_tools = 1);
    3232my $detectstreaks = can_run('DetectStreaks') or (warn "Can't find DetectStreaks" and $missing_tools = 1);
     33my $VerifyStreaks = can_run('VerifyStreaks') or (warn "Can't find VerifyStreaks, will not produce png images");
    3334if ($missing_tools) {
    3435    warn("Can't find required tools.");
     
    3738
    3839# Parse the command-line arguments
    39 my ($magic_id, $node, $camera, $dbname, $outroot, $save_temps, $verbose, $no_update, $no_op, $logfile);
     40my ($magic_id, $node, $camera, $dbname, $baseroot, $save_temps, $verbose, $no_update, $no_op, $logfile);
    4041
    4142GetOptions(
     
    4445           'camera=s'        => \$camera,     # Camera name
    4546           'dbname=s'        => \$dbname,     # Database name
    46            'outroot=s'       => \$outroot,    # Output root name
     47           'baseroot=s'      => \$baseroot,   # Output root name
    4748           'save-temps'      => \$save_temps, # Save temporary files?
    4849           'verbose'         => \$verbose,    # Print stuff?
     
    5354
    5455pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    55 pod2usage( -msg => "Required options: --magic_id --camera --node --outroot",
     56pod2usage( -msg => "Required options: --magic_id --camera --node --baseroot",
    5657           -exitval => 3) unless
    5758    defined $magic_id and
    5859    defined $node and
    5960    defined $camera and
    60     defined $outroot;
     61    defined $baseroot;
    6162
    6263my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $magic_id, $node, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
    6364$ipprc->redirect_output($logfile) or my_die( "Unable to redirect output", $magic_id, $node, $PS_EXIT_SYS_ERROR ) if $logfile;
    6465
    65 # DetectStreaks doesn't know about nebulous. It expects to be able to append strings to outroot
    66 # to form valid file names.
    67 # So forbid nebulous path in outroot. We could relax this by change DetectStreaks to take all
    68 # of the file names as arguments or by teaching it about Nebulous
    69 if ($outroot =~ 'neb:/') {
     66# DetectStreaks doesn't know about nebulous. It expects to be able to
     67# append strings to baseroot to form valid file names.  So forbid
     68# nebulous path in baseroot. We could relax this by change
     69# DetectStreaks to take all of the file names as arguments or by
     70# teaching it about Nebulous
     71if ($baseroot =~ 'neb:/') {
    7072    &my_die("DetectStreaks does not support nebulous paths in outroot", $magic_id, $node, $PS_EXIT_CONFIG_ERROR);
    7173}
    7274
     75# most filenames are of the form $baseroot.$node.*, but VerifyStreaks
     76# needs access to $baseroot.*, so we construct $outroot =
     77# $baseroot.$node in here
     78
    7379# resolve any path:// or file:// in outroot
    74 $outroot = $ipprc->file_resolve($outroot);
     80$baseroot = $ipprc->file_resolve($baseroot);
     81my $outroot = "$baseroot.$node";
    7582
    7683my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
     
    255262    }
    256263
     264    &run_verifystreaks($baseroot);
     265
    257266    my $command = "$magictool -addmask";
    258267    $command   .= " -magic_id $magic_id";
     
    275284}
    276285
    277 
    278 
    279286### Pau.
     287
     288sub run_verifystreaks {
     289
     290    my $baseroot = shift;
     291
     292    unless ($VerifyStreaks) {
     293        print STDERR "skipping VerifyStreaks\n";
     294        return 1;
     295    }
     296
     297    # VerifyStreaks --out $outdir --clusters $outdir/clusters.list $rootname.root.streakMap
     298
     299    my $outdir = "$baseroot.verify";
     300
     301    my($status) = system ("mkdir -p $outdir");
     302    if ($status) {
     303        print STDERR "failed to create output directory $outdir\n";
     304        return 1;
     305    }
     306
     307    my $FILE;
     308
     309    my @files = <$baseroot.*.clusters>;
     310
     311    unless (open ($FILE, ">$outdir/clusters.list")) {
     312        print "failed to create cluster file $outdir/clusters.list\n";
     313        return 1;
     314    }
     315    foreach my $file (@files) {
     316        $file =~ s|.clusters$||;
     317        print $FILE "$file\n";
     318    }
     319    close ($FILE);
     320    if ($status) {
     321        print "failed to create cluster file $outdir/clusters.list\n";
     322        return 1;
     323    }
     324
     325    my $command = "$VerifyStreaks --out $outdir --clusters $outdir/clusters.list $baseroot.root.streakMap";
     326
     327    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     328        run(command => $command, verbose => $verbose);
     329    unless ($success) {
     330        print "failed to run VerifyStreaks:\n";
     331        return 1;
     332    }
     333
     334    return 0;
     335}
    280336
    281337sub open_list_file {
Note: See TracChangeset for help on using the changeset viewer.