IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 26812


Ignore:
Timestamp:
Feb 8, 2010, 2:47:14 PM (16 years ago)
Author:
eugene
Message:

strip the NODE from the magic_process.pl baseroot and attach it to the outdir inside; if possible, run VerifyStreaks

Location:
branches/eam_branches/20091201
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20091201/ippScripts/scripts/magic_process.pl

    r25934 r26812  
    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 @files = <$baseroot.*.clusters>;
     308    unless (OPEN (FILE, ">$outdir/clusters.list")) {
     309        print "failed to create cluster file $outdir/clusters.list\n";
     310        return 1;
     311    }
     312    foreach my $file (@files) {
     313        print FILE "$file\n";
     314    }
     315    close (FILE);
     316    if ($status) {
     317        print "failed to create cluster file $outdir/clusters.list\n";
     318        return 1;
     319    }
     320
     321    my $command = "$VerifyStreaks --out $outdir --clusters $outdir/clusters.list $baseroot.root.streakMap";
     322
     323    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     324        run(command => $command, verbose => $verbose);
     325    unless ($success) {
     326        print "failed to run VerifyStreaks:\n stderr: $stderr_buff\n stdout: $stdout_buff";
     327        return 1;
     328    }
     329
     330    return 0;
     331}
    280332
    281333sub open_list_file {
  • branches/eam_branches/20091201/ippTasks/magic.pro

    r25419 r26812  
    283283    $WORKDIR = $WORKDIR_TEMPLATE
    284284
    285     sprintf outroot "%s/%s/%s.mgc.%s.%s" $WORKDIR $EXP_ID $EXP_ID $MAGIC_ID $NODE
    286 
    287     ## generate output log based on filerule (convert the URI to a PATH)
    288     ## caution with neb:// names here:
    289     # $logfile = `ipp_filename.pl --filerule LOG.EXP --camera $CAMERA --class_id $MAGIC_ID --basename $outroot`
    290     $logfile = $outroot.log
     285    sprintf baseroot "%s/%s/%s.mgc.%s" $WORKDIR $EXP_ID $EXP_ID $MAGIC_ID
     286
     287    $logfile = $baseroot.$NODE.log
    291288    if ("$logfile" == "")
    292289      echo "WARNING: logfile not defined in magic.process.run"
     
    299296    mkdir $outpath
    300297
    301     $run = magic_process.pl --magic_id $MAGIC_ID --camera $CAMERA --node $NODE --outroot $outroot --logfile $logfile
     298    $run = magic_process.pl --magic_id $MAGIC_ID --camera $CAMERA --node $NODE --baseroot $baseroot --logfile $logfile
    302299    add_standard_args run
    303300
Note: See TracChangeset for help on using the changeset viewer.