Changeset 36441 for trunk/ippScripts/scripts/psphot_fullforce_warp.pl
- Timestamp:
- Jan 14, 2014, 2:28:47 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ippScripts/scripts/psphot_fullforce_warp.pl (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/bills_branches/bills_201312 (added) merged: 36383,36386,36388-36396,36406-36407,36409-36412,36415-36420,36422-36427,36433,36436-36439
- Property svn:mergeinfo changed
-
trunk/ippScripts/scripts/psphot_fullforce_warp.pl
r36374 r36441 31 31 my $psphotFullForce = can_run('psphotFullForce') or (warn "Can't find psphotFullForce" and $missing_tools = 1); 32 32 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1); 33 # XXX: fftool is yet to be written 34 my $fftool = "fftool"; # can_run('fftool') or (warn "Can't find fftool" and $missing_tools = 1); 33 my $fftool = can_run('fftool') or (warn "Can't find fftool" and $missing_tools = 1); 35 34 if ($missing_tools) { 36 35 warn("Can't find required tools."); … … 38 37 } 39 38 40 my ($ff w_id, $warp_id, $skycell_id, $path_base, $sourceroot, $camera);39 my ($ff_id, $warp_id, $skycell_id, $path_base, $sourceroot, $camera); 41 40 my ($outroot, $reduction); 42 41 my ($dbname, $threads, $verbose, $no_update, $no_op, $redirect); 43 42 44 43 GetOptions( 45 'ff w_id=s' => \$ffw_id,44 'ff_id=s' => \$ff_id, 46 45 'warp_id=s' => \$warp_id, # warp identifier 47 46 'skycell_id=s' => \$skycell_id,# Skycell identifier 48 47 'warp_path_base=s' => \$path_base, # path_base of the warp skycell 49 'source root=s'=> \$sourceroot,# path_base of sources48 'sources_path_base=s' => \$sourceroot,# path_base of sources 50 49 'camera=s' => \$camera, # camera name of sources 51 50 'dbname|d=s' => \$dbname, # Database name … … 61 60 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 62 61 pod2usage( 63 -msg => "Required options: --ff w_id --sourceroot --skycell_id --warp_path_base --outroot --camera",62 -msg => "Required options: --ff_id --warp_id --sourceroot --skycell_id --warp_path_base --outroot --camera", 64 63 -exitval => 3, 65 ) unless defined $ff w_id,64 ) unless defined $ff_id, 66 65 and defined $sourceroot 67 and (defined $path_base or defined $warp_id) # if we don't have warp's path_base we need warp_id 66 and defined $path_base 67 and defined $warp_id 68 68 and defined $skycell_id 69 69 and defined $camera 70 70 and defined $outroot; 71 71 72 # XXX: fftool is not ready to run commands that update the database 73 $no_update = 1; 74 75 my $ipprc = PS::IPP::Config->new($camera) or my_die( "Unable to set up", $ffw_id, $skycell_id, $PS_EXIT_CONFIG_ERROR ); 72 my $ipprc = PS::IPP::Config->new($camera) or my_die( "Unable to set up", $ff_id, $warp_id, $skycell_id, $PS_EXIT_CONFIG_ERROR ); 76 73 77 74 my $neb; … … 84 81 85 82 $ipprc->redirect_to_logfile($logDest) or my_die( "Unable to redirect output", 86 $ffw_id, $skycell_id, $PS_EXIT_SYS_ERROR ) if $redirect; 87 88 if (!$path_base) { 83 $ff_id, $warp_id, $skycell_id, $PS_EXIT_SYS_ERROR ) if $redirect; 84 85 if (0) { 86 # if (!$path_base) { 89 87 # If path_base is not supplied, look it up in the database. 90 88 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files … … 98 96 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 99 97 &my_die("Unable to perform warptool -warpskyfile -inputskyfile: $error_code", 100 $ff w_id, $skycell_id, $error_code);98 $ff_id, $warp_id, $skycell_id, $error_code); 101 99 } 102 100 103 101 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 104 &my_die("Unable to parse metadata config doc", $ff w_id, $skycell_id, $PS_EXIT_PROG_ERROR);102 &my_die("Unable to parse metadata config doc", $ff_id, $warp_id, $skycell_id, $PS_EXIT_PROG_ERROR); 105 103 $files = parse_md_list($metadata) or 106 &my_die("Unable to parse metadata list", $ff w_id, $skycell_id, $PS_EXIT_PROG_ERROR);107 } 108 109 &my_die("Input list does not contain exactly one elements", $ff w_id, $skycell_id, $PS_EXIT_SYS_ERROR)104 &my_die("Unable to parse metadata list", $ff_id, $warp_id, $skycell_id, $PS_EXIT_PROG_ERROR); 105 } 106 107 &my_die("Input list does not contain exactly one elements", $ff_id, $warp_id, $skycell_id, $PS_EXIT_SYS_ERROR) 110 108 unless scalar @$files == 1; 111 109 … … 113 111 114 112 $path_base = $warp->{path_base}; 115 &my_die("Couldn't find input path in warptool output", $ff w_id, $skycell_id, $PS_EXIT_UNKNOWN_ERROR)113 &my_die("Couldn't find input path in warptool output", $ff_id, $warp_id, $skycell_id, $PS_EXIT_UNKNOWN_ERROR) 116 114 unless defined $path_base; 117 115 … … 123 121 unless ($recipe_psphot) { 124 122 &my_die("Couldn't find selected reduction for PSPHOT: $reduction\n", 125 $ff w_id, $skycell_id, $PS_EXIT_CONFIG_ERROR);123 $ff_id, $warp_id, $skycell_id, $PS_EXIT_CONFIG_ERROR); 126 124 } 127 125 … … 134 132 print "recipe_psphot: $recipe_psphot\n"; 135 133 134 # use psf measured on input warp 135 # XXX: get this from recipe 136 my $useWarpPSF = 0; 137 136 138 my $input = $ipprc->filename('PSWARP.OUTPUT', $path_base); 137 139 my $inputMask = $ipprc->filename('PSWARP.OUTPUT.MASK', $path_base); 138 140 my $inputVariance = $ipprc->filename('PSWARP.OUTPUT.VARIANCE', $path_base); 139 my $inputPSF = $ ipprc->filename('PSPHOT.PSF.SKY.SAVE', $path_base);141 my $inputPSF = $useWarpPSF ? $ipprc->filename('PSPHOT.PSF.SKY.SAVE', $path_base) : ""; 140 142 my $inputSources = $ipprc->filename('PSPHOT.OUTPUT.CFF', $sourceroot); 141 143 … … 144 146 print "inputMask: $inputMask\n"; 145 147 print "inputVariance: $inputVariance\n"; 146 # print "inputPath: $path_base\n"; 147 print "inputPSF: $inputPSF\n"; 148 print "inputPSF: $inputPSF\n" if $inputPSF; 148 149 print "inputSources: $inputSources\n"; 149 150 } 150 151 151 152 # check that the inputs exist (and have non-zero size) 152 &my_die("Couldn't find input: $input", $ff w_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($input);153 &my_die("Couldn't find input: $inputMask", $ff w_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inputMask);154 &my_die("Couldn't find input: $inputVariance", $ff w_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inputVariance);155 &my_die("Couldn't find input: $inputPSF", $ff w_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inputPSF);156 &my_die("Couldn't find input: $inputSources", $ff w_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inputSources);153 &my_die("Couldn't find input: $input", $ff_id, $warp_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($input); 154 &my_die("Couldn't find input: $inputMask", $ff_id, $warp_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inputMask); 155 &my_die("Couldn't find input: $inputVariance", $ff_id, $warp_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inputVariance); 156 &my_die("Couldn't find input: $inputPSF", $ff_id, $warp_id, $skycell_id, $PS_EXIT_SYS_ERROR) if ($inputPSF && !$ipprc->file_exists($inputPSF)); 157 &my_die("Couldn't find input: $inputSources", $ff_id, $warp_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inputSources); 157 158 158 159 my $dump_config = 1; … … 193 194 unless ($success) { 194 195 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 195 &my_die("Unable to perform ppSub: $error_code", $ff w_id, $skycell_id, $error_code);196 &my_die("Unable to perform ppSub: $error_code", $ff_id, $warp_id, $skycell_id, $error_code); 196 197 } 197 198 … … 207 208 unless ($success) { 208 209 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 209 &my_die("Unable to perform ppStatsFromMetadata: $error_code", $ff w_id, $skycell_id, $error_code);210 &my_die("Unable to perform ppStatsFromMetadata: $error_code", $ff_id, $warp_id, $skycell_id, $error_code); 210 211 } 211 212 foreach my $line (@$stdout_buf) { … … 226 227 # Add the result to the database 227 228 { 228 my $command = "$fftool -ff w_id $ffw_id -skycell_id $skycell_id";229 $command .= " -add warped-path_base $outroot";229 my $command = "$fftool -ff_id $ff_id -warp_id $warp_id"; 230 $command .= " -addresult -path_base $outroot"; 230 231 $command .= " $cmdflags"; 231 232 $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400)); … … 239 240 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 240 241 my $err_message = "Unable to perform fftool -addwarped" ; 241 &my_die("$err_message: $error_code", $ff w_id, $skycell_id, $error_code);242 &my_die("$err_message: $error_code", $ff_id, $warp_id, $skycell_id, $error_code); 242 243 } 243 244 } else { … … 262 263 my $error; 263 264 my $output = $ipprc->prepare_output($filerule, $outroot, undef, $delete, \$error) 264 or &my_die("failed to prepare output file for: $filerule", $ff w_id, $skycell_id, $error);265 or &my_die("failed to prepare output file for: $filerule", $ff_id, $warp_id, $skycell_id, $error); 265 266 return $output; 266 267 } … … 275 276 } 276 277 277 &my_die("Couldn't find expected output file: $file", $ff w_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($file);278 &my_die("Couldn't find expected output file: $file", $ff_id, $warp_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($file); 278 279 279 280 # Funpack to confirm we've really made things correctly 280 281 my $diskfile = $ipprc->file_resolve($file); 281 282 if ($diskfile =~ /fits/) { 282 my $funpack = can_run('funpack') or &my_die ("Can't find funpack", $ff w_id, $skycell_id, $PS_EXIT_SYS_ERROR);283 my $funpack = can_run('funpack') or &my_die ("Can't find funpack", $ff_id, $warp_id, $skycell_id, $PS_EXIT_SYS_ERROR); 283 284 my $check_command = "$funpack -S $diskfile > /dev/null"; 284 285 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 285 286 run(command => $check_command, verbose => $verbose); 286 287 if (!$success) { 287 &my_die("Output file not a valid fits file: $file", $ff w_id, $skycell_id, $PS_EXIT_SYS_ERROR);288 &my_die("Output file not a valid fits file: $file", $ff_id, $warp_id, $skycell_id, $PS_EXIT_SYS_ERROR); 288 289 } 289 290 } … … 291 292 292 293 if ($replicate and $neb) { 293 $ipprc->replicate_file($file) or &my_die("failed to replicate: $file\n", $ff w_id, $skycell_id, $PS_EXIT_SYS_ERROR);294 $ipprc->replicate_file($file) or &my_die("failed to replicate: $file\n", $ff_id, $warp_id, $skycell_id, $PS_EXIT_SYS_ERROR); 294 295 } 295 296 } … … 299 300 { 300 301 my $msg = shift; # Warning message on die 301 my $ffw_id = shift; # full force warp identifier 302 my $ff_id = shift; # full force run identifier 303 my $warp_id = shift; # full force warp id 302 304 my $skycell_id = shift; # Skycell identifier 303 305 my $exit_code = shift; # Exit code to add … … 306 308 307 309 warn($msg); 308 if (defined $ff w_id and defined $skycell_id) {309 my $command = "$fftool -ff w_id $ffw_id -skycell_id $skycell_id -fault $exit_code";310 $command .= " -add ffskyfile";310 if (defined $ff_id and defined $skycell_id) { 311 my $command = "$fftool -ff_id $ff_id -warp_id $warp_id -fault $exit_code"; 312 $command .= " -addresult"; 311 313 $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400)); 312 314 $command .= " -hostname $host" if defined $host;
Note:
See TracChangeset
for help on using the changeset viewer.
