Changeset 36394
- Timestamp:
- Dec 12, 2013, 3:13:44 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/bills_branches/bills_201312/ippScripts/scripts/psphot_fullforce_warp.pl
r36374 r36394 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 --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 66 and (defined $path_base or defined $warp_id) # if we don't have warp's path_base we need warp_id … … 70 69 and defined $outroot; 71 70 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 ); 71 my $ipprc = PS::IPP::Config->new($camera) or my_die( "Unable to set up", $ff_id, $skycell_id, $PS_EXIT_CONFIG_ERROR ); 76 72 77 73 my $neb; … … 84 80 85 81 $ipprc->redirect_to_logfile($logDest) or my_die( "Unable to redirect output", 86 $ff w_id, $skycell_id, $PS_EXIT_SYS_ERROR ) if $redirect;82 $ff_id, $skycell_id, $PS_EXIT_SYS_ERROR ) if $redirect; 87 83 88 84 if (!$path_base) { … … 98 94 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 99 95 &my_die("Unable to perform warptool -warpskyfile -inputskyfile: $error_code", 100 $ff w_id, $skycell_id, $error_code);96 $ff_id, $skycell_id, $error_code); 101 97 } 102 98 103 99 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);100 &my_die("Unable to parse metadata config doc", $ff_id, $skycell_id, $PS_EXIT_PROG_ERROR); 105 101 $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)102 &my_die("Unable to parse metadata list", $ff_id, $skycell_id, $PS_EXIT_PROG_ERROR); 103 } 104 105 &my_die("Input list does not contain exactly one elements", $ff_id, $skycell_id, $PS_EXIT_SYS_ERROR) 110 106 unless scalar @$files == 1; 111 107 … … 113 109 114 110 $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)111 &my_die("Couldn't find input path in warptool output", $ff_id, $skycell_id, $PS_EXIT_UNKNOWN_ERROR) 116 112 unless defined $path_base; 117 113 … … 123 119 unless ($recipe_psphot) { 124 120 &my_die("Couldn't find selected reduction for PSPHOT: $reduction\n", 125 $ff w_id, $skycell_id, $PS_EXIT_CONFIG_ERROR);121 $ff_id, $skycell_id, $PS_EXIT_CONFIG_ERROR); 126 122 } 127 123 … … 134 130 print "recipe_psphot: $recipe_psphot\n"; 135 131 132 # use psf measured on input warp 133 # XXX: get this from recipe 134 my $useWarpPSF = 0; 135 136 136 my $input = $ipprc->filename('PSWARP.OUTPUT', $path_base); 137 137 my $inputMask = $ipprc->filename('PSWARP.OUTPUT.MASK', $path_base); 138 138 my $inputVariance = $ipprc->filename('PSWARP.OUTPUT.VARIANCE', $path_base); 139 my $inputPSF = $ ipprc->filename('PSPHOT.PSF.SKY.SAVE', $path_base);139 my $inputPSF = $useWarpPSF ? $ipprc->filename('PSPHOT.PSF.SKY.SAVE', $path_base) : ""; 140 140 my $inputSources = $ipprc->filename('PSPHOT.OUTPUT.CFF', $sourceroot); 141 141 … … 144 144 print "inputMask: $inputMask\n"; 145 145 print "inputVariance: $inputVariance\n"; 146 # print "inputPath: $path_base\n"; 147 print "inputPSF: $inputPSF\n"; 146 print "inputPSF: $inputPSF\n" if $inputPSF; 148 147 print "inputSources: $inputSources\n"; 149 148 } 150 149 151 150 # 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);151 &my_die("Couldn't find input: $input", $ff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($input); 152 &my_die("Couldn't find input: $inputMask", $ff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inputMask); 153 &my_die("Couldn't find input: $inputVariance", $ff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inputVariance); 154 &my_die("Couldn't find input: $inputPSF", $ff_id, $skycell_id, $PS_EXIT_SYS_ERROR) if ($inputPSF && !$ipprc->file_exists($inputPSF)); 155 &my_die("Couldn't find input: $inputSources", $ff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inputSources); 157 156 158 157 my $dump_config = 1; … … 193 192 unless ($success) { 194 193 $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);194 &my_die("Unable to perform ppSub: $error_code", $ff_id, $skycell_id, $error_code); 196 195 } 197 196 … … 207 206 unless ($success) { 208 207 $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);208 &my_die("Unable to perform ppStatsFromMetadata: $error_code", $ff_id, $skycell_id, $error_code); 210 209 } 211 210 foreach my $line (@$stdout_buf) { … … 226 225 # Add the result to the database 227 226 { 228 my $command = "$fftool -ff w_id $ffw_id -skycell_id $skycell_id";229 $command .= " -add warped-path_base $outroot";227 my $command = "$fftool -ff_id $ff_id"; 228 $command .= " -addresult -path_base $outroot"; 230 229 $command .= " $cmdflags"; 231 230 $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400)); … … 239 238 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 240 239 my $err_message = "Unable to perform fftool -addwarped" ; 241 &my_die("$err_message: $error_code", $ff w_id, $skycell_id, $error_code);240 &my_die("$err_message: $error_code", $ff_id, $skycell_id, $error_code); 242 241 } 243 242 } else { … … 262 261 my $error; 263 262 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);263 or &my_die("failed to prepare output file for: $filerule", $ff_id, $skycell_id, $error); 265 264 return $output; 266 265 } … … 275 274 } 276 275 277 &my_die("Couldn't find expected output file: $file", $ff w_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($file);276 &my_die("Couldn't find expected output file: $file", $ff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($file); 278 277 279 278 # Funpack to confirm we've really made things correctly 280 279 my $diskfile = $ipprc->file_resolve($file); 281 280 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);281 my $funpack = can_run('funpack') or &my_die ("Can't find funpack", $ff_id, $skycell_id, $PS_EXIT_SYS_ERROR); 283 282 my $check_command = "$funpack -S $diskfile > /dev/null"; 284 283 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 285 284 run(command => $check_command, verbose => $verbose); 286 285 if (!$success) { 287 &my_die("Output file not a valid fits file: $file", $ff w_id, $skycell_id, $PS_EXIT_SYS_ERROR);286 &my_die("Output file not a valid fits file: $file", $ff_id, $skycell_id, $PS_EXIT_SYS_ERROR); 288 287 } 289 288 } … … 291 290 292 291 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);292 $ipprc->replicate_file($file) or &my_die("failed to replicate: $file\n", $ff_id, $skycell_id, $PS_EXIT_SYS_ERROR); 294 293 } 295 294 } … … 299 298 { 300 299 my $msg = shift; # Warning message on die 301 my $ff w_id = shift; # full force warp identifier300 my $ff_id = shift; # full force warp identifier 302 301 my $skycell_id = shift; # Skycell identifier 303 302 my $exit_code = shift; # Exit code to add … … 306 305 307 306 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";307 if (defined $ff_id and defined $skycell_id) { 308 my $command = "$fftool -ff_id $ff_id -fault $exit_code"; 309 $command .= " -addresult"; 311 310 $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400)); 312 311 $command .= " -hostname $host" if defined $host;
Note:
See TracChangeset
for help on using the changeset viewer.
