Changeset 11817 for trunk/ippScripts/scripts/phase4_warp.pl
- Timestamp:
- Feb 14, 2007, 5:55:34 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/phase4_warp.pl (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/phase4_warp.pl
r11671 r11817 32 32 use Pod::Usage qw( pod2usage ); 33 33 34 my ($ det_id, $exp_tag, $class_id, $p3_version, $uri, $camera, $dbname, $workdir, $no_update);34 my ($p4_id, $skycell_id, $camera, $dbname, $workdir, $no_update); 35 35 GetOptions( 36 36 '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 41 38 'camera|c=s' => \$camera, # Camera name 42 39 'dbname|d=s' => \$dbname, # Database name … … 47 44 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 48 45 pod2usage( 49 -msg => "Required options: --p4_id -- exp_tag --class_id --p3_version --uri--camera",46 -msg => "Required options: --p4_id --skycell_id --camera", 50 47 -exitval => 3, 51 48 ) 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 56 50 and defined $camera; 57 51 58 # XXX this exits with status = 0 on failure59 52 $ipprc->define_camera($camera); 60 53 … … 68 61 } 69 62 63 # Get list of component imfiles for exposure 64 my $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 70 81 ### Output file name 71 82 if (defined $workdir) { 72 83 $workdir = $ipprc->convert_filename_absolute( $workdir ); 73 84 } else { 74 my ($vol, $dir, $file) = File::Spec->splitpath( $ uri);85 my ($vol, $dir, $file) = File::Spec->splitpath( $$imfiles[0]->{uri} ); 75 86 $workdir = $dir; 76 87 } 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); 88 my $outputFile = "$skycell_id.warp.$p4_id"; # Root name 89 my $outputRoot = File::Spec->catfile( $workdir, $outputFile ); 90 my $outputImage = $ipprc->filename("PSWARP.OUTPUT", $outputRoot, $skycell_id ); 91 my $outputBin1 = $ipprc->filename("PSWARP.BIN1", $outputRoot, $skycell_id ); 92 my $outputBin2 = $ipprc->filename("PSWARP.BIN2", $outputRoot, $skycell_id ); 93 my $outputStats = $outputRoot . '.stats'; 94 my $listName = $outputRoot . '.list'; 82 95 83 my $outputStats = $outputRoot . '.' . $class_id . '.stats'; 96 # Get list of filenames 97 open my $listFile, '>' . $listName; 98 foreach my $imfile (@$imfiles) { 99 my $uri = $ipprc->convert_filename_absolute( $file->{uri} ); 84 100 85 $uri = $ipprc->convert_filename_absolute( $uri ); 101 print $listFile $uri . "\n"; 102 } 103 close $listFile; 86 104 87 105 # Run pswarp … … 92 110 unless ($success) { 93 111 $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); 95 113 } 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; 100 118 } 101 119 … … 109 127 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 110 128 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); 112 130 $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); 114 132 } 115 133 … … 121 139 # Add the processed file to the database 122 140 unless ($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 dettool141 my $command = "$p4tool -warped -p4_id $p4_id -skycell_id $skycell_id" . 142 " -uri $outputImage -b1_uri $outputRoot"; # Command to run dettool 125 143 $command .= " -bg " . $stats->bg_mean(); 126 144 $command .= " -bg_mean_stdev " . $stats->bg_mean_stdev(); … … 142 160 my $msg = shift; # Warning message on die 143 161 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 147 163 my $exit_code = shift; # Exit code to add 148 164 149 165 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"; 152 168 $command .= " -dbname $dbname" if defined $dbname; 153 169 system ($command);
Note:
See TracChangeset
for help on using the changeset viewer.
