IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 11817


Ignore:
Timestamp:
Feb 14, 2007, 5:55:34 PM (19 years ago)
Author:
Paul Price
Message:

Updating warp script to use latest workflow; fixing variables.

File:
1 edited

Legend:

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

    r11671 r11817  
    3232use Pod::Usage qw( pod2usage );
    3333
    34 my ($det_id, $exp_tag, $class_id, $p3_version, $uri, $camera, $dbname, $workdir, $no_update);
     34my ($p4_id, $skycell_id, $camera, $dbname, $workdir, $no_update);
    3535GetOptions(
    3636    'p4_id|i=s'         => \$p4_id, # Phase 4 identifier
    37     'exp_tag|e=s'       => \$exp_tag, # Exposure tag
    38     'class_id|i=s'      => \$class_id, # Class identifier
    39     'p3_version|i=s'    => \$p3_version, # Phaser 3 version
    40     'uri|u=s'           => \$uri, # URI for input file
     37    'skycell_id|s=s'    => \$skycell_id, # Skycell identifier
    4138    'camera|c=s'        => \$camera, # Camera name
    4239    'dbname|d=s'        => \$dbname, # Database name
     
    4744pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    4845pod2usage(
    49     -msg => "Required options: --p4_id --exp_tag --class_id --p3_version --uri --camera",
     46    -msg => "Required options: --p4_id --skycell_id --camera",
    5047    -exitval => 3,
    5148) unless defined $p4_id
    52     and defined $exp_tag
    53     and defined $class_id
    54     and defined $p3_version
    55     and defined $uri
     49    and defined $skycell_id
    5650    and defined $camera;
    5751
    58 # XXX this exits with status = 0 on failure
    5952$ipprc->define_camera($camera);
    6053
     
    6861}
    6962
     63# Get list of component imfiles for exposure
     64my $imfiles;
     65{
     66    my $command = "$p4tool -imfile -p4_id $p4_id -skycell_id $skycell_id";
     67    $command .= " -dbname $dbname" if defined $dbname;
     68    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     69        run(command => $command, verbose => 1);
     70    unless ($success) {
     71        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     72        &my_die("Unable to perform p4tool -imfile: $error_code", $p4_id, $skycell_id, $error_code);
     73    }
     74
     75    my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
     76        &my_die("Unable to parse metadata config doc", $p4_id, $skycell_id, $PS_EXIT_PROG_ERROR);
     77    $imfiles = parse_md_list($metadata) or
     78        &my_die("Unable to parse metadata list", $p4_id, $skycell_id, $PS_EXIT_PROG_ERROR);
     79}
     80
    7081### Output file name
    7182if (defined $workdir) {
    7283    $workdir = $ipprc->convert_filename_absolute( $workdir );
    7384} else {
    74     my ($vol, $dir, $file) = File::Spec->splitpath( $uri );
     85    my ($vol, $dir, $file) = File::Spec->splitpath( $$imfiles[0]->{uri} );
    7586    $workdir = $dir;
    7687}
    77 my $outputFile = "$exp_tag.warp.$det_id"; # Root name
    78 my $outputRoot = File::Spec->catfile( $workdir, $exp_tag, $outputFile );
    79 my $outputImage = $ipprc->filename("PSWARP.OUTPUT", $outputRoot, $class_id);
    80 my $outputBin1 = $ipprc->filename("PSWARP.BIN1", $outputRoot, $class_id);
    81 my $outputBin2 = $ipprc->filename("PSWARP.BIN2", $outputRoot, $class_id);
     88my $outputFile = "$skycell_id.warp.$p4_id"; # Root name
     89my $outputRoot = File::Spec->catfile( $workdir, $outputFile );
     90my $outputImage = $ipprc->filename("PSWARP.OUTPUT", $outputRoot, $skycell_id );
     91my $outputBin1 = $ipprc->filename("PSWARP.BIN1", $outputRoot, $skycell_id );
     92my $outputBin2 = $ipprc->filename("PSWARP.BIN2", $outputRoot, $skycell_id );
     93my $outputStats = $outputRoot . '.stats';
     94my $listName = $outputRoot . '.list';
    8295
    83 my $outputStats = $outputRoot . '.' . $class_id . '.stats';
     96# Get list of filenames
     97open my $listFile, '>' . $listName;
     98foreach my $imfile (@$imfiles) {
     99    my $uri = $ipprc->convert_filename_absolute( $file->{uri} );
    84100
    85 $uri = $ipprc->convert_filename_absolute( $uri );
     101    print $listFile $uri . "\n";
     102}
     103close $listFile;
    86104
    87105# Run pswarp
     
    92110    unless ($success) {
    93111        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    94         &my_die("Unable to perform pswarp: $error_code", $p4_id, $exp_tag, $class_id, $p3_version, $error_code);
     112        &my_die("Unable to perform pswarp: $error_code", $p4_id, $skycell_id, $error_code);
    95113    }
    96     &my_die("Couldn't find expected output file: $outputImage", $p4_id, $exp_tag, $class_id, $p3_version, $PS_EXIT_SYS_ERROR) unless -f $outputImage;
    97     &my_die("Couldn't find expected output file: $outputStats", $p4_id, $exp_tag, $class_id, $p3_version, $PS_EXIT_SYS_ERROR) unless -f $outputStats;
    98     &my_die("Couldn't find expected output file: $outputBin1", $p4_id, $exp_tag, $class_id, $p3_version, $PS_EXIT_SYS_ERROR) unless -f $outputBin1;
    99     &my_die("Couldn't find expected output file: $outputBin2", $p4_id, $exp_tag, $class_id, $p3_version, $PS_EXIT_SYS_ERROR) unless -f $outputBin2;
     114    &my_die("Couldn't find expected output file: $outputImage", $p4_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless -f $outputImage;
     115    &my_die("Couldn't find expected output file: $outputStats", $p4_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless -f $outputStats;
     116    &my_die("Couldn't find expected output file: $outputBin1", $p4_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless -f $outputBin1;
     117    &my_die("Couldn't find expected output file: $outputBin2", $p4_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless -f $outputBin2;
    100118}
    101119
     
    109127    my $mdcParser = PS::IPP::Metadata::Config->new;     # Parser for metadata config files
    110128    my $metadata = $mdcParser->parse(join "", @contents)
    111         or &my_die("Unable to parse metadata config", $p4_id, $exp_tag, $class_id, $p3_version, $PS_EXIT_PROG_ERROR);
     129        or &my_die("Unable to parse metadata config", $p4_id, $skycell_id, $PS_EXIT_PROG_ERROR);
    112130    $stats = PS::IPP::Metadata::Stats->new(); # Stats parser
    113     $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $p4_id, $exp_tag, $class_id, $p3_version, $PS_EXIT_PROG_ERROR);
     131    $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $p4_id, $skycell_id, $PS_EXIT_PROG_ERROR);
    114132}
    115133
     
    121139# Add the processed file to the database
    122140unless ($no_update) {
    123     my $command = "$p4tool -addwarpedimfile -p4_id $p4_id -exp_tag $exp_tag " .
    124         "-class_id $class_id -p3_version $p3_version -uri $outputImage -b1_uri $outputRoot";  # Command to run dettool
     141    my $command = "$p4tool -warped -p4_id $p4_id -skycell_id $skycell_id" .
     142        " -uri $outputImage -b1_uri $outputRoot";  # Command to run dettool
    125143    $command .= " -bg " . $stats->bg_mean();
    126144    $command .= " -bg_mean_stdev " . $stats->bg_mean_stdev();
     
    142160    my $msg = shift;            # Warning message on die
    143161    my $p4_id = shift;          # Phase 4 identifier
    144     my $exp_tag = shift;        # Exposure tag
    145     my $class_id = shift;       # Class identifier
    146     my $p3_version = shift;     # Phase 3 version
     162    my $skycell_id = shift;     # Skycell identifier
    147163    my $exit_code = shift;      # Exit code to add
    148164
    149165    warn($msg);
    150     if ($det_id and $exp_tag and $class_id) {
    151         my $command = "$p4tool -addwarpedimfile -p4_id $p4_id -exp_tag $exp_tag -class_id $class_id -p3_version $p3_version -code $exit_code";
     166    if ($p4_id and $skycell_id) {
     167        my $command = "$p4tool -warped -p4_id $p4_id -skycell_id $skycell_id -code $exit_code";
    152168        $command .= " -dbname $dbname" if defined $dbname;
    153169        system ($command);
Note: See TracChangeset for help on using the changeset viewer.