Changeset 28154
- Timestamp:
- May 28, 2010, 8:26:37 AM (16 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 7 edited
-
ippScripts/scripts/staticsky.pl (modified) (13 diffs)
-
ippTasks/Makefile.am (modified) (1 diff)
-
ippTasks/staticsky.pro (added)
-
ippTools/share/Makefile.am (modified) (1 diff)
-
ippTools/share/staticskytool_revert.sql (added)
-
ippTools/share/staticskytool_todo.sql (modified) (1 diff)
-
ippTools/src (modified) (1 prop)
-
ippTools/src/staticskytool.c (modified) (9 diffs)
-
ippTools/src/staticskytoolConfig.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/staticsky.pl
r28096 r28154 38 38 } 39 39 40 my ($sky_id, $camera, $dbname, $threads, $outroot, $reduction, $inverse, $run_state, $verbose, $no_update, $no_op, $redirect, $save_temps); 40 # XXX test: 41 print "run staticsky.pl @ARGV\n"; 42 # exit 0; 43 44 my ($sky_id, $camera, $dbname, $threads, $outroot, $reduction, $verbose, $no_update, $no_op, $redirect, $save_temps); 41 45 GetOptions( 42 46 'sky_id=s' => \$sky_id, # Diff identifier … … 44 48 'dbname|d=s' => \$dbname, # Database name 45 49 'threads=s' => \$threads, # Number of threads to use 46 'run-state=s' => \$run_state, # state for run: 'new' or 'update'47 50 'outroot=s' => \$outroot, # Output root name 48 51 'reduction=s' => \$reduction, # Reduction class … … 56 59 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 57 60 pod2usage( 58 -msg => "Required options: --sky_id --outroot --camera (--run_state)",61 -msg => "Required options: --sky_id --outroot --camera", 59 62 -exitval => 3, 60 63 ) unless … … 62 65 defined $outroot and 63 66 defined $camera; 64 # and defined $run_state;65 67 66 68 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $sky_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration 67 69 68 70 my $logDest = $ipprc->filename("LOG.EXP", $outroot); 69 # $logDest .= ".update" if $run_state eq "update";70 71 $ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $sky_id, $PS_EXIT_SYS_ERROR ) if $redirect; 71 72 … … 85 86 unless ($success) { 86 87 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 87 &my_die("Unable to perform difftool -inputskyfile: $error_code", $sky_id, $error_code);88 &my_die("Unable to perform staticskytool -inputs: $error_code", $sky_id, $error_code); 88 89 } 89 90 … … 152 153 print "recipe_psphot: $recipe_psphot\n"; 153 154 154 my $cmdflags;155 156 # Perform s ubtraction155 # my $cmdflags; 156 157 # Perform stack photometry analysis 157 158 { 158 159 my $command = "$psphotStack $outroot"; … … 167 168 168 169 unless ($no_op) { 169 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 170 run(command => $command, verbose => $verbose); 171 unless ($success) { 172 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 173 &my_die("Unable to perform ppSub: $error_code", $sky_id, $error_code); 174 } 170 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $command, verbose => $verbose); 171 unless ($success) { 172 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 173 &my_die("Unable to perform psphotStack: $error_code", $sky_id, $error_code); 174 } 175 175 176 176 # my $outputStatsReal = $ipprc->file_resolve($outputStats); … … 190 190 # chomp $cmdflags; 191 191 192 my ($quality) = $cmdflags =~ /-quality (\d+)/; # Quality flag 193 192 # my ($quality) = $cmdflags =~ /-quality (\d+)/; # Quality flag 193 194 my $quality = 0; 194 195 if (!$quality) { 195 196 … … 197 198 # we have one set of output files per input file set 198 199 for (my $i = 0; $i < @$files; $i++) { 199 my $outputName = $ipprc->filename("PSPHOT.STACK.OUTPUT.IMAGE", $outroot );200 my $outputMask = $ipprc->filename("PSPHOT.STACK.OUTPUT.MASK", $outroot );201 my $outputVariance = $ipprc->filename("PSPHOT.STACK.OUTPUT.VARIANCE", $outroot );202 my $outputSources = $ipprc->filename("PSPHOT.STACK.OUTPUT", $outroot );200 my $outputName = $ipprc->filename("PSPHOT.STACK.OUTPUT.IMAGE", $outroot, $i); 201 my $outputMask = $ipprc->filename("PSPHOT.STACK.OUTPUT.MASK", $outroot, $i); 202 my $outputVariance = $ipprc->filename("PSPHOT.STACK.OUTPUT.VARIANCE", $outroot, $i); 203 my $outputSources = $ipprc->filename("PSPHOT.STACK.OUTPUT", $outroot, $i); 203 204 204 205 &my_die("Couldn't find expected output file: $outputName", $sky_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputName); … … 211 212 #my $outputStats = $ipprc->filename("SKYCELL.STATS", $outroot); 212 213 #my $traceDest = $ipprc->filename("TRACE.EXP", $outroot); 213 214 # if ($run_state eq 'update') {215 # $traceDest .= '.update';216 # $outputStats .= '.update';217 # }218 214 219 215 my $chisqName = $ipprc->filename("PSPHOT.CHISQ.IMAGE", $outroot); … … 235 231 { 236 232 my $command = "$staticskytool -sky_id $sky_id"; 237 # if ($run_state eq 'new') {238 233 $command .= " -addresult -path_base $outroot"; 239 234 $command .= " -num_inputs $nInputs"; 240 $command .= " $cmdflags";235 # $command .= " $cmdflags"; 241 236 $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400)); 242 237 $command .= " -hostname $host" if defined $host; 243 # } else {244 # $command .= " -tofullskyfile";245 # }246 238 $command .= " -dbname $dbname" if defined $dbname; 247 239 … … 250 242 unless ($success) { 251 243 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 252 my $err_message = $run_state eq "update" ? 253 "Unable to perform difftool -adddiffskyfile" : 254 "Unable to perform difftool -tofullskyfile"; 255 &my_die("$err_message: $error_code", $sky_id, $error_code); 244 my $err_message = "Unable to perform staticskytool -addresult"; 245 warn($err_message); 246 exit $error_code; 256 247 } 257 248 } … … 270 261 if (defined $sky_id and not $no_update) { 271 262 my $command = "$staticskytool -sky_id $sky_id -fault $exit_code"; 272 if ($run_state eq 'new') { 273 $command .= " -adddiffskyfile"; 274 $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400)); 275 $command .= " -hostname $host" if defined $host; 276 $command .= " -path_base $outroot" if defined $outroot; 277 $command .= " -dbname $dbname" if defined $dbname; 278 } else { 279 $command .= " -updatediffskyfile"; 280 } 263 $command .= " -addresult"; 264 $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400)); 265 $command .= " -hostname $host" if defined $host; 266 $command .= " -path_base $outroot" if defined $outroot; 267 $command .= " -dbname $dbname" if defined $dbname; 281 268 run(command => $command, verbose => $verbose); 282 269 } -
trunk/ippTasks/Makefile.am
r27149 r28154 20 20 diff.pro \ 21 21 stack.pro \ 22 staticsky.pro \ 22 23 summit.copy.pro \ 23 24 survey.pro \ -
trunk/ippTools/share/Makefile.am
r28091 r28154 294 294 staticskytool_todo.sql \ 295 295 staticskytool_result.sql \ 296 staticskytool_revert.sql \ 296 297 warptool_change_skyfile_data_state.sql \ 297 298 warptool_change_run_state.sql \ -
trunk/ippTools/share/staticskytool_todo.sql
r28091 r28154 4 4 staticskyRun.reduction, 5 5 staticskyRun.label, 6 staticskyRun.state 6 staticskyRun.state, 7 stackRun.tess_id, 8 stackRun.skycell_id 7 9 FROM staticskyRun 8 10 JOIN staticskyInput USING (sky_id) -
trunk/ippTools/src
- Property svn:ignore
-
old new 38 38 stamp-h1 39 39 warptool 40 40 staticskytool
-
- Property svn:ignore
-
trunk/ippTools/src/staticskytool.c
r28096 r28154 42 42 static bool importrunMode(pxConfig *config); 43 43 44 static bool setstaticskyRunState(pxConfig *config, psS64 sky_id, const char *state); 45 44 46 # define MODECASE(caseName, func) \ 45 47 case caseName: \ … … 129 131 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 130 132 PXOPT_LOOKUP_BOOL(pretend, config->args, "-pretend", false); 133 PXOPT_LOOKUP_BOOL(check_inputs, config->args, "-check_inputs", false); 131 134 132 135 psString select = pxDataGet("staticskytool_definebyquery_select.sql"); … … 255 258 psWarning("staticskytool ERROR: no rows found for known tess_id, skycell_id?"); 256 259 continue; 260 } 261 262 if (check_inputs) { 263 // negative simple so the default is true 264 if (!ippdbPrintMetadatas(stdout, inputs, "staticskyInput", !simple)) { 265 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 266 psFree(output); 267 psFree(where); 268 return false; 269 } 270 psFree(inputs); 271 continue; 257 272 } 258 273 … … 550 565 } 551 566 567 if (!fault) { 568 if (!setstaticskyRunState(config, sky_id, "full")) { 569 if (!psDBRollback(config->dbh)) { 570 psError(PS_ERR_UNKNOWN, false, "database error"); 571 } 572 psError(PS_ERR_UNKNOWN, false, "failed to change staticskyRun state"); 573 return false; 574 } 575 } 576 552 577 // point of no return 553 578 if (!psDBCommit(config->dbh)) { … … 643 668 PS_ASSERT_PTR_NON_NULL(config, false); 644 669 645 # if (0)646 670 psMetadata *where = psMetadataAlloc(); 647 PXOPT_COPY_S64(config->args, where, "-s tack_id", "stackSumSkyfile.stack_id", "==");648 pxAddLabelSearchArgs(config, where, "-label", "sta ckRun.label", "==");649 PXOPT_COPY_S16(config->args, where, "-fault", "sta ckSumSkyfile.fault", "==");671 PXOPT_COPY_S64(config->args, where, "-sky_id", "staticskyResult.sky_id", "=="); 672 pxAddLabelSearchArgs(config, where, "-label", "staticskyRun.label", "=="); 673 PXOPT_COPY_S16(config->args, where, "-fault", "staticskyResult.fault", "=="); 650 674 651 675 if (!psListLength(where->list) && !psMetadataLookupBool(NULL, config->args, "-all")) { … … 656 680 657 681 // Delete product 658 psString delete = pxDataGet("staticskytool_revert sumskyfile_delete.sql");682 psString delete = pxDataGet("staticskytool_revert.sql"); 659 683 if (!delete) { 660 684 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); … … 680 704 681 705 psFree(where); 682 # endif683 684 706 return true; 685 707 } 686 708 687 # if (0)688 static bool updateresultState(pxConfig *config)689 {690 // check that state is a valid string value691 if (!pxIsValidState(state)) {692 psError(PS_ERR_UNKNOWN, false, "invalid stackRun state: %s", state);693 return false;694 }695 696 char *query = "UPDATE stackRun SET state = '%s' WHERE stack_id = %"PRId64;697 if (!p_psDBRunQueryF(config->dbh, query, state, stack_id)) {698 psError(PS_ERR_UNKNOWN, false,699 "failed to change state for stack_id %"PRId64, stack_id);700 return false;701 }702 return true;703 }704 # endif705 706 709 static bool updateresult(pxConfig *config) 707 710 { 708 711 PS_ASSERT_PTR_NON_NULL(config, false); 709 712 710 # if (0)711 713 PXOPT_LOOKUP_S16(fault, config->args, "-fault", true, false); 712 714 713 715 psMetadata *where = psMetadataAlloc(); 714 PXOPT_COPY_S64(config->args, where, "-s tack_id", "stack_id", "==");715 716 if (!pxSetFaultCode(config->dbh, "sta ckSumSkyfile", where, fault)) {716 PXOPT_COPY_S64(config->args, where, "-sky_id", "sky_id", "=="); 717 718 if (!pxSetFaultCode(config->dbh, "staticskyResult", where, fault)) { 717 719 psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag"); 718 720 psFree (where); … … 720 722 } 721 723 psFree (where); 722 723 # endif724 724 return true; 725 725 } … … 898 898 # endif 899 899 return true; 900 } 901 902 static bool setstaticskyRunState(pxConfig *config, psS64 sky_id, const char *state) 903 { 904 PS_ASSERT_PTR_NON_NULL(state, false); 905 906 // check that state is a valid string value 907 if (!pxIsValidState(state)) { 908 psError(PS_ERR_UNKNOWN, false, "invalid staticskyRun state: %s", state); 909 return false; 910 } 911 912 char *query = "UPDATE staticskyRun SET state = '%s' WHERE sky_id = %"PRId64; 913 if (!p_psDBRunQueryF(config->dbh, query, state, sky_id)) { 914 psError(PS_ERR_UNKNOWN, false, "failed to change state for sky_id %"PRId64, sky_id); 915 return false; 916 } 917 return true; 918 900 919 } 901 920 -
trunk/ippTools/src/staticskytoolConfig.c
r28096 r28154 61 61 psMetadataAddTime(definebyqueryArgs, PS_LIST_TAIL, "-set_registered", 0, "time detrend run was registered", now); 62 62 psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-pretend", 0, "do not actually modify the database", false); 63 psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-check_inputs", 0, "list inputs, do not modify database", false); 63 64 psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 64 65
Note:
See TracChangeset
for help on using the changeset viewer.
