Changeset 28003 for branches/pap/ippScripts/scripts
- Timestamp:
- May 18, 2010, 12:49:05 PM (16 years ago)
- Location:
- branches/pap
- Files:
-
- 49 edited
- 1 copied
-
. (modified) (1 prop)
-
ippScripts/scripts/addstar_run.pl (modified) (1 diff)
-
ippScripts/scripts/automate_stacks.pl (modified) (18 diffs)
-
ippScripts/scripts/calibrate_dvo.pl (modified) (1 diff)
-
ippScripts/scripts/camera_exp.pl (modified) (1 diff)
-
ippScripts/scripts/chip_imfile.pl (modified) (1 diff)
-
ippScripts/scripts/detrend_correct_imfile.pl (modified) (1 diff)
-
ippScripts/scripts/detrend_norm_apply.pl (modified) (1 diff)
-
ippScripts/scripts/detrend_norm_calc.pl (modified) (2 diffs)
-
ippScripts/scripts/detrend_norm_exp.pl (modified) (1 diff)
-
ippScripts/scripts/detrend_process_exp.pl (modified) (1 diff)
-
ippScripts/scripts/detrend_process_imfile.pl (modified) (1 diff)
-
ippScripts/scripts/detrend_reject_exp.pl (modified) (1 diff)
-
ippScripts/scripts/detrend_resid_imfile.pl (modified) (1 diff)
-
ippScripts/scripts/detrend_stack.pl (modified) (1 diff)
-
ippScripts/scripts/diff_skycell.pl (modified) (2 diffs)
-
ippScripts/scripts/dist_advancerun.pl (modified) (2 diffs)
-
ippScripts/scripts/dist_bundle.pl (modified) (7 diffs)
-
ippScripts/scripts/dist_cleanup.pl (modified) (1 diff)
-
ippScripts/scripts/dist_component.pl (modified) (1 diff)
-
ippScripts/scripts/dist_defineruns.pl (modified) (1 diff)
-
ippScripts/scripts/dist_make_fileset.pl (modified) (4 diffs)
-
ippScripts/scripts/dqstats_bundle.pl (modified) (6 diffs)
-
ippScripts/scripts/fake_imfile.pl (modified) (1 diff)
-
ippScripts/scripts/flatcorr_init.pl (modified) (9 diffs)
-
ippScripts/scripts/flatcorr_proc.pl (modified) (13 diffs)
-
ippScripts/scripts/ipp_cleanup.pl (modified) (24 diffs)
-
ippScripts/scripts/ipp_detrend_combine.pl (modified) (8 diffs)
-
ippScripts/scripts/lossy_compress_imfile.pl (modified) (6 diffs)
-
ippScripts/scripts/magic_destreak.pl (modified) (9 diffs)
-
ippScripts/scripts/magic_destreak_cleanup.pl (modified) (5 diffs)
-
ippScripts/scripts/magic_destreak_defineruns.pl (modified) (1 diff)
-
ippScripts/scripts/magic_destreak_revert.pl (modified) (9 diffs)
-
ippScripts/scripts/magic_process.pl (modified) (5 diffs)
-
ippScripts/scripts/magic_tree.pl (modified) (1 diff)
-
ippScripts/scripts/make_burntool_pcontrol.pl (modified) (11 diffs)
-
ippScripts/scripts/publish_file.pl (modified) (1 diff)
-
ippScripts/scripts/rcserver_checkstatus.pl (modified) (1 diff)
-
ippScripts/scripts/receive_advance.pl (modified) (3 diffs)
-
ippScripts/scripts/receive_file.pl (modified) (6 diffs)
-
ippScripts/scripts/receive_fileset.pl (modified) (1 diff)
-
ippScripts/scripts/receive_setstatus.pl (modified) (2 diffs)
-
ippScripts/scripts/receive_source.pl (modified) (1 diff)
-
ippScripts/scripts/register_exp.pl (modified) (2 diffs)
-
ippScripts/scripts/register_imfile.pl (modified) (3 diffs)
-
ippScripts/scripts/stack_skycell.pl (modified) (1 diff)
-
ippScripts/scripts/staticsky.pl (copied) (copied from trunk/ippScripts/scripts/staticsky.pl )
-
ippScripts/scripts/tdl_generate.pl (modified) (2 diffs)
-
ippScripts/scripts/warp_overlap.pl (modified) (1 diff)
-
ippScripts/scripts/warp_skycell.pl (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/pap
- Property svn:mergeinfo changed
-
branches/pap/ippScripts/scripts/addstar_run.pl
r26112 r28003 8 8 use Sys::Hostname; 9 9 my $host = hostname(); 10 my $date = `date`; 10 11 print "\n\n"; 11 print "Starting script $0 on $host \n\n";12 print "Starting script $0 on $host at $date\n\n"; 12 13 13 14 use DateTime; -
branches/pap/ippScripts/scripts/automate_stacks.pl
r27631 r28003 56 56 # Grab options 57 57 my ( $date, $camera, $dbname, $logfile, $verbose, $manual); 58 my ( $help, $isburning, $force_stack_count, $test_mode, $this_target_only, $this_filter_only );58 my ( $help, $isburning, $force_stack_count, $test_mode, $this_target_only, $this_filter_only, $check_mode); 59 59 my ( $check_registration, $define_burntool, $queue_burntool, $check_chips, $queue_chips); 60 60 my ( $check_stacks, $queue_stacks, $check_diffs, $queue_diffs, $clean_old); … … 67 67 'logfile=s' => \$logfile, 68 68 'verbose' => \$verbose, 69 'debug' => \$debug, 69 70 'isburning' => \$isburning, 70 71 'force_stack_count' => \$force_stack_count, 72 'check' => \$check_mode, 71 73 'test_mode' => \$test_mode, 72 74 'this_target_only=s' => \$this_target_only, … … 115 117 defined $queue_chips or defined $queue_stacks or 116 118 defined $check_chips or defined $check_stacks or 117 defined $test_mode or defined $clean_old ;119 defined $test_mode or defined $clean_old or defined $check_mode; 118 120 119 121 # Configurable parameters from our config file. … … 126 128 my %stackable_list = (); 127 129 my %reduction_class = (); 128 my $retention_time = 9000; 129 130 my %clean_commands = (); 131 my %clean_retention = (); 132 my %noclean_list = (); 130 133 # Grab the configuration data. 131 134 my $conf_cmd = "$ppConfigDump -dump-recipe NIGHTLY_SCIENCE -"; … … 140 143 my $metadata = $mdcParser->parse(join "", @$stdout_buf); 141 144 foreach my $entry (@{ $metadata }) { 142 if (${ $entry }{name} eq 'RETENTION_TIME') { 143 $retention_time = ${ $entry }{value}; 144 } 145 if (@{ $entry }{name} eq 'CLEAN_MODES') { 146 my @mode_data = @{ ${ $entry }{value} }; 147 my $this_mode = ''; 148 foreach my $mentry (@mode_data) { 149 if (${ $mentry }{name} eq 'MODE') { 150 $this_mode = ${ $mentry }{value}; 151 } 152 elsif (${ $mentry }{name} eq 'COMMAND') { 153 $clean_commands{$this_mode} = ${ $mentry }{value}; 154 } 155 elsif (${ $mentry }{name} eq 'RETENTION_TIME') { 156 $clean_retention{$this_mode} = ${ $mentry }{value}; 157 } 158 } 159 } 160 # if (${ $entry }{name} eq 'RETENTION_TIME') { 161 # $retention_time = ${ $entry }{value}; 162 # } 145 163 elsif (${ $entry }{name} eq 'FILTERS') { 146 164 push @filter_list, ${ $entry }{value}; … … 172 190 $reduction_class{$this_target} = ${ $tentry }{value}; 173 191 } 192 elsif (${ $tentry }{name} eq 'NOCLEAN') { 193 $noclean_list{$this_target} = ${ $tentry }{value}; 194 } 174 195 } 175 196 } … … 217 238 if (defined($test_mode)) { 218 239 $debug = 1; 219 } 220 221 if (defined($check_registration) || defined($test_mode)) { 240 my $z; 241 foreach $z (@target_list) { 242 print "TARGET: $z $tessID_list{$z} $obsmode_list{$z} $object_list{$z} $comment_list{$z} $stackable_list{$z} $reduction_class{$z}\n"; 243 } 244 foreach $z (@filter_list) { 245 print "FILTER: $z\n"; 246 } 247 foreach $z (keys (%clean_commands)) { 248 print "CLEAN: $z $clean_commands{$z} $clean_retention{$z}\n"; 249 } 250 251 } 252 253 if (defined($check_registration) || defined($test_mode) || defined($check_mode)) { 222 254 $metadata_out{nsState} = 'NEW'; 223 255 my ($Nsummit_exp,$Nfaults) = check_summit_copy($date); 224 256 return_metadata($date); 225 unless (defined($test_mode) ) { exit(0); }257 unless (defined($test_mode) || defined($check_mode)) { exit(0); } 226 258 } 227 259 if (defined($define_burntool) || defined($test_mode)) { … … 236 268 unless (defined($test_mode)) { exit(0); } 237 269 } 238 if (defined($check_chips) || defined($test_mode) ) {270 if (defined($check_chips) || defined($test_mode) || defined($check_mode)) { 239 271 $metadata_out{nsState} = 'QUEUECHIPS'; 240 272 &execute_chips($date,"pretend"); … … 243 275 } 244 276 return_metadata($date); 245 unless (defined($test_mode) ) { exit(0); }277 unless (defined($test_mode) || defined($check_mode)) { exit(0); } 246 278 } 247 279 if (defined($queue_chips)) { … … 251 283 exit(0); 252 284 } 253 if (defined($check_stacks) || defined($test_mode) ) {285 if (defined($check_stacks) || defined($test_mode) || defined($check_mode)) { 254 286 $metadata_out{nsState} = 'TOWARP'; 255 287 &execute_stacks($date,"pretend"); … … 258 290 } 259 291 return_metadata($date); 260 unless (defined($test_mode) ) { exit(0); }292 unless (defined($test_mode) || defined($check_mode)) { exit(0); } 261 293 } 262 294 if (defined($queue_stacks)) { 263 295 $metadata_out{nsState} = 'STACKING'; 264 296 &execute_stacks($date); 297 if ($metadata_out{nsState} eq 'QUEUESTACKING') { 298 $metadata_out{nsState} = 'STACKING_POSSIBLE_ERROR'; 299 } 265 300 return_metadata($date); 266 301 exit(0); … … 420 455 } 421 456 422 if ($#{ $stderr_buf } > -1) {423 $metadata_out{nsState} = 'ERROR';424 return(1);425 }457 # if ($#{ $stderr_buf } > -1) { 458 # $metadata_out{nsState} = 'ERROR'; 459 # return(1); 460 # } 426 461 427 462 my $N = 0; … … 429 464 foreach my $row (@burntool_entries) { 430 465 my ($trash,$start,$end); 431 ($trash,$trash,$start,$end) = (split /\s+/,$row); 432 466 (undef,$trash,$start,$end) = (split /\s+/,$row); 467 if ($trash ne 'burntool') { 468 $metadata_out{nsState} = 'ERROR'; 469 return(1); 470 } 433 471 for (my $class_counter = 0; $class_counter < 60; $class_counter++) { 434 472 $metadata_out{"bt${N}Begin"} = $start; … … 650 688 my @input_exposures = split /\n/, (join '', @$stdout_buf); 651 689 foreach my $entry (@input_exposures) { 652 my ($ skycell, @trash) = split /\s+/, $entry;690 my ($warp_tess_id,$skycell, @trash) = split /\s+/, $entry; 653 691 @trash = verify_uniqueness_stack($skycell,$date,$target,$filter); 654 692 $Nalready += $trash[0]; … … 681 719 my ($Nexposures,$NprocChips,$NprocWarps,$Nalready) = pre_stack_queue($date,$target,$filter); 682 720 if ((!defined($force_stack_count))&&($NprocChips != $NprocWarps)) { # This makes me sad. :( 683 # print STDERR "execute_stacks: Target $target on $date is not fully processed. ($NprocChips $NprocWarps)\n"; 721 if ($debug == 1) { 722 print STDERR "execute_stacks: Target $target on $date is not fully processed. ($NprocChips $NprocWarps)\n"; 723 } 684 724 $metadata_out{nsState} = 'FORCETOWARP'; 685 725 next; 686 726 } 687 727 if ($Nexposures == 0) { 688 # print STDERR "execute_stacks: Target $target in filter $filter on $date has no exposures.\n"; 728 if ($debug == 1) { 729 print STDERR "execute_stacks: Target $target in filter $filter on $date has no exposures.\n"; 730 } 689 731 next; 690 732 } 691 733 if ($Nalready != 0) { 692 # print STDERR "execute_stacks: Not queueing $target in filter $filter on $date due to already existing stacks.\n"; 734 if ($debug == 1) { 735 print STDERR "execute_stacks: Not queueing $target in filter $filter on $date due to already existing stacks.\n"; 736 } 737 unless ($metadata_out{nsState} eq 'FORCETOWARP') { 738 $metadata_out{nsState} = 'STACKING'; 739 } 693 740 next; 694 741 } 695 unless ( $metadata_out{nsState} eq 'FORCETOWARP') {742 unless (($metadata_out{nsState} eq 'FORCETOWARP')||($metadata_out{nsState} eq 'STACKING')) { 696 743 $metadata_out{nsState} = 'QUEUESTACKS'; 697 744 } 698 745 unless(defined($pretend)) { 699 # print STDERR "execute_stacks: Target $target in filter $filter on $date has exposures and will be queued.\n"; 746 if ($debug == 1) { 747 print STDERR "execute_stacks: Target $target in filter $filter on $date has exposures and will be queued.\n"; 748 } 700 749 stack_queue($date,$target,$filter); 701 750 } … … 716 765 my $date = shift; 717 766 my $target = shift; 767 my $mode = shift; 768 769 my $command = $clean_commands{$mode}; 770 my $retention_time = $clean_retention{$mode}; 718 771 719 772 my ($year,$month,$day) = split /-/,$date; … … 725 778 726 779 my ($label,$workdir,$obs_mode,$object,$comment,$tess_id,$dist_group,$data_group,$reduction) = get_tool_parameters($cleaning_date,$target); 727 728 my $args .= " -dbname gpc1 -updaterun -set_state goto_cleaned -state full -data_group $data_group ";780 my $args = $command; 781 $args .= " -dbname gpc1 -updaterun -set_state goto_cleaned -state full -set_label goto_cleaned -label $label -data_group $data_group "; 729 782 if ($debug == 1) { 730 783 $args .= ' -pretend '; … … 737 790 my $pretend = shift; 738 791 739 foreach my $target (@target_list) { 740 my ($cleaning_date,$args) = construct_cleantool_args($date,$target); 741 742 my $command = $chiptool . $args; 743 print STDERR "$command\n"; 744 if (!(defined($pretend) || $debug == 1)) { 792 foreach my $mode (keys (%clean_commands)) { 793 foreach my $target (@target_list) { 794 if (exists($noclean_list{$target})) { 795 next; 796 } 797 my ($cleaning_date,$command) = construct_cleantool_args($date,$target,$mode); 798 799 print STDERR "$command\n"; 800 if (!(defined($pretend) || $debug == 1)) { 745 801 # print STDERR "BEAR IS DRIVING!?\n"; 746 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 747 run ( command => $command, verbose => $verbose ); 748 unless ($success) { 749 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 750 &my_die("Unable to perform stacktool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR); 751 } 752 } 753 $command = $warptool . $args; 754 print STDERR "$command\n"; 755 if (!(defined($pretend) || $debug == 1)) { 756 # print STDERR "BEAR IS DRIVING $pretend $debug!?\n"; 757 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 758 run ( command => $command, verbose => $verbose ); 759 unless ($success) { 760 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 761 &my_die("Unable to perform stacktool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR); 762 } 763 } 802 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 803 run ( command => $command, verbose => $verbose ); 804 unless ($success) { 805 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 806 &my_die("Unable to perform stacktool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR); 807 } 808 } 809 } 764 810 } 765 811 return(0); -
branches/pap/ippScripts/scripts/calibrate_dvo.pl
r23186 r28003 8 8 use Sys::Hostname; 9 9 my $host = hostname(); 10 my $date = `date`; 10 11 print "\n\n"; 11 print "Starting script $0 on $host \n\n";12 print "Starting script $0 on $host at $date\n\n"; 12 13 13 14 use vars qw( $VERSION ); -
branches/pap/ippScripts/scripts/camera_exp.pl
r27555 r28003 8 8 use Sys::Hostname; 9 9 my $host = hostname(); 10 my $date = `date`; 10 11 print "\n\n"; 11 print "Starting script $0 on $host \n\n";12 print "Starting script $0 on $host at $date\n\n"; 12 13 13 14 use DateTime; -
branches/pap/ippScripts/scripts/chip_imfile.pl
r27180 r28003 8 8 use Sys::Hostname; 9 9 my $host = hostname(); 10 my $date = `date`; 10 11 print "\n\n"; 11 print "Starting script $0 on $host \n\n";12 print "Starting script $0 on $host at $date\n\n"; 12 13 13 14 use DateTime; -
branches/pap/ippScripts/scripts/detrend_correct_imfile.pl
r27180 r28003 8 8 use Sys::Hostname; 9 9 my $host = hostname(); 10 my $date = `date`; 10 11 print "\n\n"; 11 print "Starting script $0 on $host\n\n"; 12 print "command: @ARGV\n\n"; 12 print "Starting script $0 on $host at $date\n\n"; 13 13 14 14 use vars qw( $VERSION ); -
branches/pap/ippScripts/scripts/detrend_norm_apply.pl
r27180 r28003 8 8 use Sys::Hostname; 9 9 my $host = hostname(); 10 my $date = `date`; 10 11 print "\n\n"; 11 print "Starting script $0 on $host \n\n";12 print "Starting script $0 on $host at $date\n\n"; 12 13 13 14 use vars qw( $VERSION ); -
branches/pap/ippScripts/scripts/detrend_norm_calc.pl
r26514 r28003 8 8 use Sys::Hostname; 9 9 my $host = hostname(); 10 my $date = `date`; 10 11 print "\n\n"; 11 print "Starting script $0 on $host \n\n";12 print "Starting script $0 on $host at $date\n\n"; 12 13 13 14 use vars qw( $VERSION ); … … 56 57 57 58 # force det_type to be upper-case in this script 58 my$det_type = uc($det_type);59 $det_type = uc($det_type); 59 60 60 61 my $ipprc = PS::IPP::Config->new() or my_die( "Unable to set up", $det_id, $iter, $PS_EXIT_CONFIG_ERROR ); # IPP configuration -
branches/pap/ippScripts/scripts/detrend_norm_exp.pl
r27180 r28003 8 8 use Sys::Hostname; 9 9 my $host = hostname(); 10 my $date = `date`; 10 11 print "\n\n"; 11 print "Starting script $0 on $host \n\n";12 print "Starting script $0 on $host at $date\n\n"; 12 13 13 14 use vars qw( $VERSION ); -
branches/pap/ippScripts/scripts/detrend_process_exp.pl
r27180 r28003 8 8 use Sys::Hostname; 9 9 my $host = hostname(); 10 my $date = `date`; 10 11 print "\n\n"; 11 print "Starting script $0 on $host \n\n";12 print "Starting script $0 on $host at $date\n\n"; 12 13 13 14 use vars qw( $VERSION ); -
branches/pap/ippScripts/scripts/detrend_process_imfile.pl
r27180 r28003 8 8 use Sys::Hostname; 9 9 my $host = hostname(); 10 my $date = `date`; 10 11 print "\n\n"; 11 print "Starting script $0 on $host \n\n";12 print "Starting script $0 on $host at $date\n\n"; 12 13 13 14 use vars qw( $VERSION ); -
branches/pap/ippScripts/scripts/detrend_reject_exp.pl
r24764 r28003 8 8 use Sys::Hostname; 9 9 my $host = hostname(); 10 my $date = `date`; 10 11 print "\n\n"; 11 print "Starting script $0 on $host \n\n";12 print "Starting script $0 on $host at $date\n\n"; 12 13 13 14 use vars qw( $VERSION ); -
branches/pap/ippScripts/scripts/detrend_resid_imfile.pl
r27180 r28003 8 8 use Sys::Hostname; 9 9 my $host = hostname(); 10 my $date = `date`; 10 11 print "\n\n"; 11 print "Starting script $0 on $host \n\n";12 print "Starting script $0 on $host at $date\n\n"; 12 13 13 14 use vars qw( $VERSION ); -
branches/pap/ippScripts/scripts/detrend_stack.pl
r27180 r28003 8 8 use Sys::Hostname; 9 9 my $host = hostname(); 10 my $date = `date`; 10 11 print "\n\n"; 11 print "Starting script $0 on $host \n\n";12 print "Starting script $0 on $host at $date\n\n"; 12 13 13 14 use vars qw( $VERSION ); -
branches/pap/ippScripts/scripts/diff_skycell.pl
r27596 r28003 7 7 use Sys::Hostname; 8 8 my $host = hostname(); 9 my $date = `date`; 9 10 print "\n\n"; 10 print "Starting script $0 on $host \n\n";11 print "Starting script $0 on $host at $date\n\n"; 11 12 12 13 use DateTime; … … 398 399 $command .= " -hostname $host" if defined $host; 399 400 $command .= " -path_base $outroot" if defined $outroot; 400 $command .= " -dbname $dbname" if defined $dbname;401 401 } else { 402 402 $command .= " -updatediffskyfile"; 403 403 } 404 $command .= " -dbname $dbname" if defined $dbname; 404 405 run(command => $command, verbose => $verbose); 405 406 } -
branches/pap/ippScripts/scripts/dist_advancerun.pl
r27016 r28003 8 8 use Sys::Hostname; 9 9 my $host = hostname(); 10 my $date = `date`; 10 11 print "\n\n"; 11 print "Starting script $0 on $host \n\n";12 print "Starting script $0 on $host at $date\n\n"; 12 13 13 14 use vars qw( $VERSION ); … … 174 175 } 175 176 &my_die("unable to find path", $dist_id, $PS_EXIT_UNKNOWN_ERROR) if !$path; 176 my $component_dir = find_componentdir($destdir, $path); 177 my $component_dir = find_componentdir($destdir, $path); 177 178 # print MANIFEST "$component METADATA\n"; 178 179 print MANIFEST "\t" , "$component", "\tSTR\t", $component_dir, "\n"; 179 180 } 180 181 print MANIFEST "END\n\n"; 181 close MANIFEST or 182 close MANIFEST or 182 183 &my_die("Unable to close dirinfo file $dirinfo", $dist_id, $PS_EXIT_UNKNOWN_ERROR); 183 184 } -
branches/pap/ippScripts/scripts/dist_bundle.pl
r27449 r28003 8 8 use Sys::Hostname; 9 9 my $host = hostname(); 10 my $date = `date`; 10 11 # print "\n\n"; 11 # print "Starting script $0 on $host \n\n";12 # print "Starting script $0 on $host at $date\n\n"; 12 13 13 14 use vars qw( $VERSION ); … … 115 116 116 117 # Get the list of data products for this component 117 # note: We my_die in get_file_list if something goes wrong. 118 # note: We my_die in get_file_list if something goes wrong. 118 119 119 120 my $file_list = get_file_list($stage, $component, $path_base, $clean); … … 193 194 $num_files++; 194 195 if ($image_type && $nan_masked_pixels) { 195 # save the 196 # save the 196 197 if ($image_type eq 'image') { 197 198 $image = $file_name; … … 222 223 # One last check as to whether magic has been applied to the inputs 223 224 224 # Note: the sql for disttool -pendingcomponent won't select a component that 225 # Note: the sql for disttool -pendingcomponent won't select a component that 225 226 # requires magic and hasn't been magicked, but we check again here 226 227 … … 327 328 ### Pau. 328 329 329 # return the image type (image, mask, or variance) if this file rule refers to 330 # return the image type (image, mask, or variance) if this file rule refers to 330 331 # one of the big fits files that are not included in a clean distribution 331 332 sub get_image_type { … … 360 361 sub open_with_retries { 361 362 my $name = shift; 362 363 363 364 my $tries = 1; 364 365 my $max_tries = 5; … … 372 373 } 373 374 } 374 375 375 376 &my_die("failed to open $name after $max_tries tries\n", $component, 376 377 $PS_EXIT_DATA_ERROR) if (!$opened); -
branches/pap/ippScripts/scripts/dist_cleanup.pl
r26096 r28003 8 8 use Sys::Hostname; 9 9 my $host = hostname(); 10 my $date = `date`; 10 11 print "\n\n"; 11 print "Starting script $0 on $host \n\n";12 print "Starting script $0 on $host at $date\n\n"; 12 13 13 14 use vars qw( $VERSION ); -
branches/pap/ippScripts/scripts/dist_component.pl
r27449 r28003 8 8 use Sys::Hostname; 9 9 my $host = hostname(); 10 my $date = `date`; 10 11 print "\n\n"; 11 print "Starting script $0 on $host \n\n";12 print "Starting script $0 on $host at $date\n\n"; 12 13 13 14 use vars qw( $VERSION ); -
branches/pap/ippScripts/scripts/dist_defineruns.pl
r26998 r28003 11 11 use Sys::Hostname; 12 12 my $host = hostname(); 13 my $date = `date`; 13 14 print "\n\n"; 14 print "Starting script $0 on $host \n\n";15 print "Starting script $0 on $host at $date\n\n"; 15 16 16 17 use vars qw( $VERSION ); -
branches/pap/ippScripts/scripts/dist_make_fileset.pl
r27014 r28003 8 8 use Sys::Hostname; 9 9 my $host = hostname(); 10 my $date = `date`; 10 11 print "\n\n"; 11 print "Starting script $0 on $host \n\n";12 print "Starting script $0 on $host at $date\n\n"; 12 13 13 14 use vars qw( $VERSION ); … … 46 47 'dist_id=s' => \$dist_id, # distribution run identifier 47 48 'dist_dir=s' => \$dist_dir, # directory containing dist run outputs 48 'target_id=s' => \$target_id, # 49 'target_id=s' => \$target_id, # 49 50 'stage=s' => \$stage, # raw, chip, camera, fake, warp, stack, or diff 50 51 'stage_id=s' => \$stage_id, # exp_id, chip_id, etc. … … 209 210 my $dsn = "DBI:mysql:host=$dbserver;database=$dbname"; 210 211 211 my $dbh = DBI->connect($dsn, $dbuser, $dbpassword) 212 my $dbh = DBI->connect($dsn, $dbuser, $dbpassword) 212 213 or die "Cannot connect to database.\n"; 213 214 … … 227 228 228 229 # 229 # we are a long ways away from the rawExp in the pipeline. Rather than do some 230 # we are a long ways away from the rawExp in the pipeline. Rather than do some 230 231 # very long joins in disttool, we look up the exp_name in the database using DBI 231 232 # 232 233 my $dbh = getDBHandle($ipprc, $dbname); 233 234 234 my $query; 235 my $query; 235 236 236 237 if ($stage eq 'raw') { -
branches/pap/ippScripts/scripts/dqstats_bundle.pl
r27308 r28003 8 8 use Sys::Hostname; 9 9 my $host = hostname(); 10 my $date = `date`; 10 11 print "\n\n"; 11 print "Starting script $0 on $host \n\n";12 print "Starting script $0 on $host at $date\n\n"; 12 13 13 14 use DateTime; … … 37 38 my ( $dqstats_id, $camera, $uri, $dbname, $verbose, $no_update, $no_op, $redirect, $save_temps); 38 39 GetOptions( 39 'dqstats_id=s' => \$dqstats_id, # dqstatsrun ID40 'camera|c=s' => \$camera, # camera41 'dbname|d=s' => \$dbname, # database name42 'uri=s' => \$uri, # output file destination43 'verbose' => \$verbose, # print to stdout44 'no-update' => \$no_update, # Update the database45 'no-op' => \$no_op, # don't do the operations46 'redirect-output' => \$redirect, 47 'save-temps' => \$save_temps, # save temporary files48 ) or pod2usage( 2 );40 'dqstats_id=s' => \$dqstats_id, # dqstatsrun ID 41 'camera|c=s' => \$camera, # camera 42 'dbname|d=s' => \$dbname, # database name 43 'uri=s' => \$uri, # output file destination 44 'verbose' => \$verbose, # print to stdout 45 'no-update' => \$no_update, # Update the database 46 'no-op' => \$no_op, # don't do the operations 47 'redirect-output' => \$redirect, 48 'save-temps' => \$save_temps, # save temporary files 49 ) or pod2usage( 2 ); 49 50 50 51 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 51 52 pod2usage( -msg => "Required options --dqstats_id --camera", 52 -exitval => 3,53 ) unless53 -exitval => 3, 54 ) unless 54 55 defined $dqstats_id and 55 56 defined $camera; 56 57 57 my $ipprc = PS::IPP::Config->new( $camera ) 58 my $ipprc = PS::IPP::Config->new( $camera ) 58 59 or my_die( "Unable to set up", $dqstats_id, $PS_EXIT_CONFIG_ERROR ); # IPP config 59 #my $logDest = $ipprc->filename("LOG.EXP", $uri) 60 #my $logDest = $ipprc->filename("LOG.EXP", $uri) 60 61 # or my_die("Missing entry from camera config", $dqstats_id, $PS_EXIT_CONFIG_ERROR); 61 62 62 63 if ($redirect) { 63 # $ipprc->redirect_output($logDest) 64 # or my_die( "Unable to redirect output", $dqstats_id, $PS_EXIT_SYS_ERROR );64 # $ipprc->redirect_output($logDest) 65 # or my_die( "Unable to redirect output", $dqstats_id, $PS_EXIT_SYS_ERROR ); 65 66 print "\n\n"; 66 67 print "Starting script $0 on $host\n\n"; … … 84 85 unless ($no_op) { 85 86 # This bit needs to make the bundle. 86 87 87 88 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 88 run(command => $bundle_command, verbose => $verbose);89 run(command => $bundle_command, verbose => $verbose); 89 90 unless ($success) { 90 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);91 &my_die("Unable to create the bundle.: $error_code", $dqstats_id, $error_code);91 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 92 &my_die("Unable to create the bundle.: $error_code", $dqstats_id, $error_code); 92 93 } 93 94 94 95 # Parse stdout_buf to get output file name 95 96 ## Begin partial 96 97 my ($tempFile, $tempName) = tempfile( "/tmp/dqstats.XXXX", 97 UNLINK => !$save_temps, SUFFIX => 'dsin' );98 UNLINK => !$save_temps, SUFFIX => 'dsin' ); 98 99 print $tempFile $uri . '|||notset' . "\n"; 99 100 … … 102 103 # It can't be that simple, can it? This should probably add a fault on failure. 103 104 ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 104 run(command => $register_cmd, verbose => $verbose);105 run(command => $register_cmd, verbose => $verbose); 105 106 unless ($success) { 106 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);107 &my_die("Unable to register the bundle.: $error_code", $dqstats_id, $error_code);107 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 108 &my_die("Unable to register the bundle.: $error_code", $dqstats_id, $error_code); 108 109 } 109 110 110 111 # We no longer need the file generated by dqstatstool. 111 112 unlink($uri); … … 118 119 # This bit needs to set the database state to full 119 120 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 120 run(command => $update_command, verbose => $verbose);121 run(command => $update_command, verbose => $verbose); 121 122 unless ($success) { 122 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);123 warn("Unable to add result to database: $error_code\n");124 exit($error_code);123 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 124 warn("Unable to add result to database: $error_code\n"); 125 exit($error_code); 125 126 } 126 127 } else { … … 139 140 carp($msg); 140 141 if (defined $dqstats_id and not $no_update) { 141 # There is no fault handling, which may be a mistake. This is where a fault coding would be.142 # There is no fault handling, which may be a mistake. This is where a fault coding would be. 142 143 # my $command = "$addtool -add_id $add_id"; 143 144 # $command .= " -addprocessedexp"; -
branches/pap/ippScripts/scripts/fake_imfile.pl
r23688 r28003 24 24 use Sys::Hostname; 25 25 my $host = hostname(); 26 my $date = `date`; 26 27 print "\n\n"; 27 print "Starting script $0 on $host \n\n";28 print "Starting script $0 on $host at $date\n\n"; 28 29 29 30 use DateTime; -
branches/pap/ippScripts/scripts/flatcorr_init.pl
r20100 r28003 1 1 #!/usr/bin/env perl 2 2 3 ## USAGE:flatcorr_init.pl 3 ## USAGE:flatcorr_init.pl 4 4 ## given dbname, dvodb, filter, time range, camera, telescope, etc? 5 5 ## select matching images and register as a new flatcorr run … … 24 24 use Sys::Hostname; 25 25 my $host = hostname(); 26 my $date = `date`; 26 27 print "\n\n"; 27 print "Starting script $0 on $host \n\n";28 print "Starting script $0 on $host at $date\n\n"; 28 29 29 30 use vars qw( $VERSION ); … … 68 69 my $caltool = can_run('caltool') or (warn "Can't find caltool" and $missing_tools = 1); 69 70 70 if ($missing_tools) { 71 if ($missing_tools) { 71 72 warn ("Can't find required tools"); 72 exit($PS_EXIT_CONFIG_ERROR); 73 exit($PS_EXIT_CONFIG_ERROR); 73 74 } 74 75 … … 90 91 cache_run(command => $command, verbose => 1); 91 92 92 unless ($success) { 93 unless ($success) { 93 94 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 94 95 &my_die ("Unable to perform addstar -resort on region $region: $error_code", $dvo_id, $region, "RESORT", $status, $dbname); … … 99 100 { 100 101 foreach my $filter (@filters) { 101 my $command = "$relphot $filter";102 $command .= "-D CATDIR $catdir";103 $command .= "-region $RAs $RAe $DECs $DECe";104 105 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =106 cache_run(command => $command, verbose => 1);107 108 unless ($success) { 109 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);110 &my_die ("Unable to perform addstar -resort on region $region: $error_code", $dvo_id, $region, "RELPHOT", $status, $dbname);111 }102 my $command = "$relphot $filter"; 103 $command .= "-D CATDIR $catdir"; 104 $command .= "-region $RAs $RAe $DECs $DECe"; 105 106 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 107 cache_run(command => $command, verbose => 1); 108 109 unless ($success) { 110 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 111 &my_die ("Unable to perform addstar -resort on region $region: $error_code", $dvo_id, $region, "RELPHOT", $status, $dbname); 112 } 112 113 } 113 114 } … … 117 118 if (0) { 118 119 foreach my $filter (@filters) { 119 my $command = "$uniphot $filter";120 $command .= "-D CATDIR $catdir";121 $command .= "-region $RAs $RAe $DECs $DECe";122 123 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =124 cache_run(command => $command, verbose => 1);125 126 unless ($success) { 127 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);128 &my_die ("Unable to perform addstar -resort on region $region: $error_code", $dvo_id, $region, "UNIPHOT", $status, $dbname);129 }120 my $command = "$uniphot $filter"; 121 $command .= "-D CATDIR $catdir"; 122 $command .= "-region $RAs $RAe $DECs $DECe"; 123 124 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 125 cache_run(command => $command, verbose => 1); 126 127 unless ($success) { 128 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 129 &my_die ("Unable to perform addstar -resort on region $region: $error_code", $dvo_id, $region, "UNIPHOT", $status, $dbname); 130 } 130 131 } 131 132 } … … 137 138 138 139 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 139 cache_run(command => $command, verbose => 1);140 141 unless ($success) { 142 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);143 &my_die ("Unable to perform addstar -resort on region $region: $error_code", $dvo_id, $region, "RELASTRO.OBJECTS", $status, $dbname);140 cache_run(command => $command, verbose => 1); 141 142 unless ($success) { 143 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 144 &my_die ("Unable to perform addstar -resort on region $region: $error_code", $dvo_id, $region, "RELASTRO.OBJECTS", $status, $dbname); 144 145 } 145 146 } … … 151 152 152 153 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 153 cache_run(command => $command, verbose => 1);154 155 unless ($success) { 156 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);157 &my_die ("Unable to perform addstar -resort on region $region: $error_code", $dvo_id, $region, "RELASTRO.IMAGES", $status, $dbname);154 cache_run(command => $command, verbose => 1); 155 156 unless ($success) { 157 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 158 &my_die ("Unable to perform addstar -resort on region $region: $error_code", $dvo_id, $region, "RELASTRO.IMAGES", $status, $dbname); 158 159 } 159 160 } … … 185 186 my $region = shift; 186 187 my $last_step = shift; 187 my $status = shift;188 my $dbname = shift;188 my $status = shift; 189 my $dbname = shift; 189 190 190 191 carp($msg); 191 192 if (defined $dvo_id && defined $region && defined $last_step && defined $status and not $no_update) { 192 193 my $command = "$caltool -addcalrun"; 193 $command .= " -dvo_id $dvo_id";194 $command .= " -dvo_id $dvo_id"; 194 195 $command .= " -region $region"; 195 $command .= " -last_step $last_step";196 $command .= " -status $status";196 $command .= " -last_step $last_step"; 197 $command .= " -status $status"; 197 198 $command .= " -dbname $dbname" if defined $dbname; 198 199 system ($command); -
branches/pap/ippScripts/scripts/flatcorr_proc.pl
r25916 r28003 11 11 # dvoMakeCorr -file outgrid.fits -ref ref.fits outcorr 12 12 13 # dettool -register -det_type FLATCORR -filelevel (level) -workdir -inst, etc 14 15 # foreach $imfile () 13 # dettool -register -det_type FLATCORR -filelevel (level) -workdir -inst, etc 14 15 # foreach $imfile () 16 16 # dettool -register_imfile -uri, etc, etc 17 17 … … 23 23 use Sys::Hostname; 24 24 my $host = hostname(); 25 my $date = `date`; 25 26 print "\n\n"; 26 print "Starting script $0 on $host \n\n";27 print "Starting script $0 on $host at $date\n\n"; 27 28 28 29 use vars qw( $VERSION ); … … 74 75 my $addstar = can_run('addstar') or (warn "Can't find addstar" and $missing_tools = 1); 75 76 my $dvoMakeCorr = can_run('dvoMakeCorr') or (warn "Can't find dvoMakeCorr" and $missing_tools = 1); 76 my $detselect = can_run('detselect') or (warn "Can't find detselect" and $missing_tools = 1);77 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1);78 my $flatcorr = can_run('flatcorr') or (warn "Can't find flatcorr" and $missing_tools = 1);79 80 if ($missing_tools) { 77 my $detselect = can_run('detselect') or (warn "Can't find detselect" and $missing_tools = 1); 78 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 79 my $flatcorr = can_run('flatcorr') or (warn "Can't find flatcorr" and $missing_tools = 1); 80 81 if ($missing_tools) { 81 82 warn ("Can't find required tools"); 82 exit($PS_EXIT_CONFIG_ERROR); 83 exit($PS_EXIT_CONFIG_ERROR); 83 84 } 84 85 … … 95 96 $ipprc->outroot_prepare($outcorr); 96 97 97 if (not -e "$dvodb/flatcorr") { 98 if (not -e "$dvodb/flatcorr") { 98 99 mkdir "$dvodb/flatcorr" or &my_die ("Unable to make output directory for relphot $dvodb/flatcorr", $corr_id, 3); 99 100 } … … 104 105 my ($DECs, $DECe) = split (",", $coords[1]); 105 106 106 # Run addstar -resort to ensure the db is indexed 107 # Run addstar -resort to ensure the db is indexed 107 108 # XXX addstar should be able to recognize and skip indexed tables 108 109 { 109 my $command = "$addstar -resort"; 110 my $command = "$addstar -resort"; 110 111 $command .= " -D CATDIR $dvodb"; 111 112 $command .= " -region $RAs $RAe $DECs $DECe"; 112 113 113 114 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 114 run(command => $command, verbose => $verbose);115 116 unless ($success) { 117 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);118 &my_die ("Unable to perform addstar -resort for dvodb $dvodb on region $region: $error_code", $corr_id, $error_code);115 run(command => $command, verbose => $verbose); 116 117 unless ($success) { 118 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 119 &my_die ("Unable to perform addstar -resort for dvodb $dvodb on region $region: $error_code", $corr_id, $error_code); 119 120 } 120 121 } … … 135 136 136 137 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 137 run(command => $command, verbose => $verbose);138 139 unless ($success) { 140 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);141 &my_die ("Unable to perform relphot -grid for dvodb $dvodb on region $region: $error_code", $corr_id, $error_code);138 run(command => $command, verbose => $verbose); 139 140 unless ($success) { 141 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 142 &my_die ("Unable to perform relphot -grid for dvodb $dvodb on region $region: $error_code", $corr_id, $error_code); 142 143 } 143 144 } … … 176 177 177 178 # Push the results into the database 178 { 179 { 179 180 my $command = "$flatcorr -addprocess"; 180 181 $command .= " -corr_id $corr_id"; … … 184 185 unless ($no_update) { 185 186 186 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =187 run(command => $command, verbose => $verbose);188 unless ($success) {189 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);190 warn ("Unable to perform regtool -addprocessedimfile: $error_code");191 exit($error_code);192 }187 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 188 run(command => $command, verbose => $verbose); 189 unless ($success) { 190 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 191 warn ("Unable to perform regtool -addprocessedimfile: $error_code"); 192 exit($error_code); 193 } 193 194 } else { 194 print "skipping command: $command\n";195 print "skipping command: $command\n"; 195 196 } 196 197 } … … 218 219 &my_die("Unable to parse metadata list", $corr_id, $PS_EXIT_PROG_ERROR); 219 220 220 # check for existence 221 # check for existence 221 222 my $file = $$files[0]; 222 223 my $chip_id = $file->{chip_id}; … … 228 229 # flatcorr -inputimfile -chip_id $chip_id 229 230 sub get_imfiles { 230 my $chip_id = shift; 231 my $chip_id = shift; 231 232 232 233 my $command = "$flatcorr -inputimfile"; … … 273 274 274 275 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 275 run(command => $command, verbose => $verbose);276 277 unless ($success) { 278 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);279 &my_die ("Unable to register new detrend: $error_code", $corr_id, $PS_EXIT_PROG_ERROR);276 run(command => $command, verbose => $verbose); 277 278 unless ($success) { 279 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 280 &my_die ("Unable to register new detrend: $error_code", $corr_id, $PS_EXIT_PROG_ERROR); 280 281 } 281 282 … … 298 299 299 300 foreach my $file (@$files) { 300 # create the detrend correction for the imfiles based on the input imfiles301 my $reffile = $file->{uri};302 my $class_id = $file->{class_id};303 304 my $uri = $ipprc->filename("DVOCORR.OUTPUT", $outcorr, $class_id);305 unless ($uri) {306 &my_die ("Unable to find DVOCORR.OUTPUT in filerules", $corr_id, $PS_EXIT_PROG_ERROR);307 }308 309 my $command = "$dvoMakeCorr $outcorr";310 $command .= " -file $outgrid.fits";311 $command .= " -ref $reffile";312 313 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =314 run(command => $command, verbose => $verbose);315 316 unless ($success) { 317 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);318 &my_die ("Unable to perform dvoMakeCorr: $error_code", $corr_id, $PS_EXIT_PROG_ERROR);319 }320 321 # register the detrend correction imfile322 $command = "$dettool -register_detrend_imfile";323 $command .= " -det_id $det_id";324 $command .= " -class_id $class_id";325 $command .= " -uri $uri";326 $command .= " -dbname $dbname" if defined $dbname;327 328 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =329 run(command => $command, verbose => $verbose);330 331 unless ($success) { 332 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);333 &my_die ("Unable to register new detrend: $error_code", $corr_id, $PS_EXIT_PROG_ERROR);334 }301 # create the detrend correction for the imfiles based on the input imfiles 302 my $reffile = $file->{uri}; 303 my $class_id = $file->{class_id}; 304 305 my $uri = $ipprc->filename("DVOCORR.OUTPUT", $outcorr, $class_id); 306 unless ($uri) { 307 &my_die ("Unable to find DVOCORR.OUTPUT in filerules", $corr_id, $PS_EXIT_PROG_ERROR); 308 } 309 310 my $command = "$dvoMakeCorr $outcorr"; 311 $command .= " -file $outgrid.fits"; 312 $command .= " -ref $reffile"; 313 314 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 315 run(command => $command, verbose => $verbose); 316 317 unless ($success) { 318 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 319 &my_die ("Unable to perform dvoMakeCorr: $error_code", $corr_id, $PS_EXIT_PROG_ERROR); 320 } 321 322 # register the detrend correction imfile 323 $command = "$dettool -register_detrend_imfile"; 324 $command .= " -det_id $det_id"; 325 $command .= " -class_id $class_id"; 326 $command .= " -uri $uri"; 327 $command .= " -dbname $dbname" if defined $dbname; 328 329 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 330 run(command => $command, verbose => $verbose); 331 332 unless ($success) { 333 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 334 &my_die ("Unable to register new detrend: $error_code", $corr_id, $PS_EXIT_PROG_ERROR); 335 } 335 336 } 336 337 } … … 345 346 if (not $no_update) { 346 347 my $command = "$flatcorr -addprocess"; 347 $command .= " -corr_id $corr_id";348 $command .= " -corr_id $corr_id"; 348 349 $command .= " -fault $exit_code"; 349 350 $command .= " -hostname $host" if defined $host; -
branches/pap/ippScripts/scripts/ipp_cleanup.pl
r27638 r28003 14 14 use File::Spec; 15 15 use PS::IPP::Config 1.01 qw( :standard ); 16 use PS::IPP::Metadata::List qw( parse_md_list );17 16 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); 18 17 use Pod::Usage qw( pod2usage ); … … 108 107 } 109 108 110 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 109 # extract the metadata for the files into a hash list 110 $imfiles = $mdcParser->parse_list(join "", @$stdout_buf) or 111 111 &my_die("Unable to parse metadata config doc", "chip", $stage_id, $PS_EXIT_PROG_ERROR); 112 113 # extract the metadata for the files into a hash list114 $imfiles = parse_md_list($metadata) or115 &my_die("Unable to parse metadata list", "chip", $stage_id, $PS_EXIT_PROG_ERROR);116 112 117 113 # loop over all of the imfiles, determine the path_base and class_id for each … … 196 192 # Tell magicdstool that we've cleaned up this data, so it needs to do the same if it needs to do the same. 197 193 my $magicdstool = can_run('magicdstool') or die "Can't find magicdstool"; 198 $command = "$magicdstool -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned -s tate full";194 $command = "$magicdstool -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned -set_label goto_cleaned"; 199 195 $command .= " -dbname $dbname" if defined $dbname; 200 196 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 249 245 &my_die("Unable to perform camtool: $error_code", "camera", $stage_id, $error_code); 250 246 } 251 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or247 $exps = $mdcParser->parse_list(join "", @$stdout_buf) or 252 248 &my_die("Unable to parse metadata config doc", "camera", $stage_id, $PS_EXIT_PROG_ERROR); 253 254 $exps = parse_md_list($metadata) or255 &my_die("Unable to parse metadata list", "camera", $stage_id, $PS_EXIT_PROG_ERROR);256 249 257 250 my $n_exps = @$exps; … … 316 309 # Tell magicdstool that we've cleaned up this data, so it needs to do the same if it needs to do the same. 317 310 my $magicdstool = can_run('magicdstool') or die "Can't find magicdstool"; 318 $command = "$magicdstool -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned -s tate full";311 $command = "$magicdstool -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned -set_label goto_cleaned"; 319 312 $command .= " -dbname $dbname" if defined $dbname; 320 313 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 375 368 exit(0); 376 369 } 377 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or370 $skyfiles = $mdcParser->parse_list(join "", @$stdout_buf) or 378 371 &my_die("Unable to parse metadata config doc", "warp", $stage_id, $PS_EXIT_PROG_ERROR); 379 380 $skyfiles = parse_md_list($metadata) or381 &my_die("Unable to parse metadata list", "warp", $stage_id, $PS_EXIT_PROG_ERROR);382 372 383 373 my @files = (); … … 457 447 # Tell magicdstool that we've cleaned up this data, so it needs to do the same if it needs to do the same. 458 448 my $magicdstool = can_run('magicdstool') or die "Can't find magicdstool"; 459 $command = "$magicdstool -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned -s tate full";449 $command = "$magicdstool -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned -set_label goto_cleaned"; 460 450 $command .= " -dbname $dbname" if defined $dbname; 461 451 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 515 505 } 516 506 517 my $metadata = $mdcParser->parse(join "", @{ $stdout_buf }) or507 $skyfiles = $mdcParser->parse_list(join "", @{ $stdout_buf }) or 518 508 &my_die("Unable to parse metadata config doc", "stack", $stage_id, $PS_EXIT_PROG_ERROR); 519 520 $skyfiles = parse_md_list($metadata) or521 &my_die("Unable to parse metadata list", "stack", $stage_id, $PS_EXIT_PROG_ERROR);522 509 523 510 my @files = (); … … 594 581 # Tell magicdstool that we've cleaned up this data, so it needs to do the same if it needs to do the same. 595 582 my $magicdstool = can_run('magicdstool') or die "Can't find magicdstool"; 596 $command = "$magicdstool -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned -s tate full";583 $command = "$magicdstool -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned -set_label goto_cleaned"; 597 584 $command .= " -dbname $dbname" if defined $dbname; 598 585 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 652 639 } 653 640 654 my $metadata = $mdcParser->parse(join "", @{ $stdout_buf }) or641 $skyfiles = $mdcParser->parse_list(join "", @{ $stdout_buf }) or 655 642 &my_die("Unable to parse metadata config doc", "diff", $stage_id, $PS_EXIT_PROG_ERROR); 656 657 $skyfiles = parse_md_list($metadata) or658 &my_die("Unable to parse metadata list", "diff", $stage_id, $PS_EXIT_PROG_ERROR);659 643 660 644 my @files = (); … … 747 731 # Tell magicdstool that we've cleaned up this data, so it needs to do the same if it needs to do the same. 748 732 my $magicdstool = can_run('magicdstool') or die "Can't find magicdstool"; 749 $command = "$magicdstool -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned -s tate full";733 $command = "$magicdstool -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned -set_label goto_cleaned"; 750 734 $command .= " -dbname $dbname" if defined $dbname; 751 735 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 806 790 } 807 791 808 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 792 # extract the metadata for the files into a hash list 793 $imfiles = $mdcParser->parse_list(join "", @$stdout_buf) or 809 794 &my_die("Unable to parse metadata config doc", "fake", $stage_id, $PS_EXIT_PROG_ERROR); 810 811 # extract the metadata for the files into a hash list812 $imfiles = parse_md_list($metadata) or813 &my_die("Unable to parse metadata list", "fake", $stage_id, $PS_EXIT_PROG_ERROR);814 795 815 796 # loop over all of the imfiles, determine the path_base and class_id for each … … 927 908 928 909 929 $metadata = $mdcParser->parse(join "", @$stdout_buf) or 910 # extract the metadata for the files into a hash list 911 $imfiles = $mdcParser->parse_list(join "", @$stdout_buf) or 930 912 &my_die("Unable to parse metadata config doc", "$stage", $stage_id, $PS_EXIT_PROG_ERROR); 931 932 # extract the metadata for the files into a hash list933 $imfiles = parse_md_list($metadata) or934 &my_die("Unable to parse metadata list", "$stage", $stage_id, $PS_EXIT_PROG_ERROR);935 913 } 936 914 # loop over all of the imfiles, determine the path_base and class_id for each … … 1013 991 } 1014 992 if (@$stdout_buf != 0) { 1015 $metadata = $mdcParser->parse(join "", @$stdout_buf) or993 my $exps = $mdcParser->parse_list(join "", @$stdout_buf) or 1016 994 &my_die("Unable to parse metadata config doc", "$stage (detProcessedExp)", $stage_id, $PS_EXIT_PROG_ERROR); 1017 my $exps = parse_md_list($metadata) or1018 &my_die("Unable to parse metadata list", "$stage (detProcessedExp)", $stage_id, $PS_EXIT_PROG_ERROR);1019 995 1020 996 foreach my $exp (@$exps) { … … 1068 1044 # if there are no detResidImfiles (@$stdout_buf == 0), then silently exit. 1069 1045 if (@$stdout_buf != 0) { 1070 $metadata = $mdcParser->parse(join "", @$stdout_buf) or 1046 # extract the metadata for the files into a hash list 1047 $imfiles = $mdcParser->parse_list(join "", @$stdout_buf) or 1071 1048 &my_die("Unable to parse metadata config doc", "$stage", $stage_id, $PS_EXIT_PROG_ERROR); 1072 1073 # extract the metadata for the files into a hash list1074 $imfiles = parse_md_list($metadata) or1075 &my_die("Unable to parse metadata list", "$stage", $stage_id, $PS_EXIT_PROG_ERROR);1076 1049 } 1077 1050 # loop over all of the imfiles, determine the path_base and class_id for each … … 1156 1129 } 1157 1130 if (@$stdout_buf != 0) { 1158 $metadata = $mdcParser->parse(join "", @$stdout_buf) or1131 my $exps = $mdcParser->parse_list(join "", @$stdout_buf) or 1159 1132 &my_die("Unable to parse metadata config doc", "$stage (detResidExp)", $stage_id, $PS_EXIT_PROG_ERROR); 1160 my $exps = parse_md_list($metadata) or1161 &my_die("Unable to parse metadata list", "$stage (detResidExp)", $stage_id, $PS_EXIT_PROG_ERROR);1162 1133 1163 1134 foreach my $exp (@$exps) { … … 1202 1173 &my_die("Unable to perform dettool: $error_code", "$stage", $stage_id, $error_code); 1203 1174 } 1204 my $metadata = $mdcParser->parse(join "", @{ $stdout_buf }) or1175 $stacks = $mdcParser->parse_list(join "", @{ $stdout_buf }) or 1205 1176 &my_die("Unable to parse metadata config doc", "$stage", $stage_id, $PS_EXIT_PROG_ERROR); 1206 1207 $stacks = parse_md_list($metadata) or1208 &my_die("Unable to parse metadata list", "$stage", $stage_id, $PS_EXIT_PROG_ERROR);1209 1177 1210 1178 my @files = (); … … 1286 1254 } 1287 1255 if (@$stdout_buf != 0) { 1288 $metadata = $mdcParser->parse(join "", @$stdout_buf) or1256 my $exps = $mdcParser->parse_list(join "", @$stdout_buf) or 1289 1257 &my_die("Unable to parse metadata config doc", "$stage (detRunSummary)", $stage_id, $PS_EXIT_PROG_ERROR); 1290 my $exps = parse_md_list($metadata) or1291 &my_die("Unable to parse metadata list", "$stage (detRunSummary)", $stage_id, $PS_EXIT_PROG_ERROR);1292 1258 1293 1259 foreach my $exp (@$exps) { … … 1327 1293 &my_die("Unable to perform dettool: $error_code", "$stage", $stage_id, $error_code); 1328 1294 } 1329 my $ metadata = $mdcParser->parse(join "", @$stdout_buf) or1295 my $exps = $mdcParser->parse_list(join "", @$stdout_buf) or 1330 1296 &my_die("Unable to parse metadata config doc", "$stage", $stage_id, $PS_EXIT_PROG_ERROR); 1331 1332 my $exps = parse_md_list($metadata) or1333 &my_die("Unable to parse metadata list", "$stage", $stage_id, $PS_EXIT_PROG_ERROR);1334 1297 1335 1298 foreach my $exp (@$exps) { … … 1380 1343 } 1381 1344 if (@$stdout_buf != 0) { 1382 $ metadata = $mdcParser->parse(join "", @$stdout_buf) or1345 $exps = $mdcParser->parse_list(join "", @$stdout_buf) or 1383 1346 &my_die("Unable to parse metadata config doc", "$stage (detRunSummary)", $stage_id, $PS_EXIT_PROG_ERROR); 1384 $exps = parse_md_list($metadata) or1385 &my_die("Unable to parse metadata list", "$stage (detRunSummary)", $stage_id, $PS_EXIT_PROG_ERROR);1386 1347 1387 1348 foreach my $exp (@$exps) { … … 1425 1386 &my_die("Unable to perform dettool: $error_code", "$stage", $stage_id, $error_code); 1426 1387 } 1427 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or1388 $exps = $mdcParser->parse_list(join "", @$stdout_buf) or 1428 1389 &my_die("Unable to parse metadata config doc", "$stage", $stage_id, $PS_EXIT_PROG_ERROR); 1429 1430 $exps = parse_md_list($metadata) or1431 &my_die("Unable to parse metadata list", "$stage", $stage_id, $PS_EXIT_PROG_ERROR);1432 1390 1433 1391 foreach my $exp (@$exps) { … … 1511 1469 } 1512 1470 if (@$stdout_buf != 0) { 1513 $ metadata = $mdcParser->parse(join "", @$stdout_buf) or1471 $exps = $mdcParser->parse_list(join "", @$stdout_buf) or 1514 1472 &my_die("Unable to parse metadata config doc", "$stage (detRunSummary)", $stage_id, $PS_EXIT_PROG_ERROR); 1515 $exps = parse_md_list($metadata) or1516 &my_die("Unable to parse metadata list", "$stage (detRunSummary)", $stage_id, $PS_EXIT_PROG_ERROR);1517 1473 1518 1474 foreach my $exp (@$exps) { … … 1559 1515 exit 0; 1560 1516 } 1561 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or1517 $exps = $mdcParser->parse_list(join "", @$stdout_buf) or 1562 1518 &my_die("Unable to parse metadata config doc", "$stage", $stage_id, $PS_EXIT_PROG_ERROR); 1563 1564 $exps = parse_md_list($metadata) or1565 &my_die("Unable to parse metadata list", "$stage", $stage_id, $PS_EXIT_PROG_ERROR);1566 1519 1567 1520 foreach my $exp (@$exps) { … … 1643 1596 } 1644 1597 if (@$stdout_buf != 0) { 1645 $ metadata = $mdcParser->parse(join "", @$stdout_buf) or1598 $exps = $mdcParser->parse_list(join "", @$stdout_buf) or 1646 1599 &my_die("Unable to parse metadata config doc", "$stage (detRunSummary)", $stage_id, $PS_EXIT_PROG_ERROR); 1647 $exps = parse_md_list($metadata) or1648 &my_die("Unable to parse metadata list", "$stage (detRunSummary)", $stage_id, $PS_EXIT_PROG_ERROR);1649 1600 1650 1601 foreach my $exp (@$exps) { -
branches/pap/ippScripts/scripts/ipp_detrend_combine.pl
r17671 r28003 7 7 use Sys::Hostname; 8 8 my $host = hostname(); 9 my $date = `date`; 9 10 print "\n\n"; 10 print "Starting script $0 on $host \n\n";11 print "Starting script $0 on $host at $date\n\n"; 11 12 12 13 use vars qw( $VERSION ); … … 32 33 $workdir, $dbname, $no_update); 33 34 GetOptions( 34 'det_type=s' => \$det_type, # Detrend type for new detrend35 'filelevel=s' => \$filelevel, # File level for new detrend36 'inst=s' => \$inst, # Instrument for new detrend37 'telescope=s' => \$telescope, # Telescope for new detrend38 'filter=s' => \$filter,# Filter name for new detrend39 'det_id1=s'=> \$det_id1, # Detrend id for detrend 140 'iteration1=s' => \$iter1, # Iteration for detrend 141 'det_id2=s'=> \$det_id2, # Detrend id for detrend 242 'iteration2=s' => \$iter2, # Iteration for detrend 243 'operation=s' => \$operation, # Operation to perform on files44 'mask' => \$mask, # Operation is on a mask45 'workdir=s' => \$workdir, # Working directory for output files46 'dbname=s' => \$dbname,# Database name47 'no-update' => \$no_update, # Don't update the database48 ) or pod2usage( 2 );35 'det_type=s' => \$det_type, # Detrend type for new detrend 36 'filelevel=s' => \$filelevel, # File level for new detrend 37 'inst=s' => \$inst, # Instrument for new detrend 38 'telescope=s' => \$telescope, # Telescope for new detrend 39 'filter=s' => \$filter, # Filter name for new detrend 40 'det_id1=s' => \$det_id1, # Detrend id for detrend 1 41 'iteration1=s' => \$iter1, # Iteration for detrend 1 42 'det_id2=s' => \$det_id2, # Detrend id for detrend 2 43 'iteration2=s' => \$iter2, # Iteration for detrend 2 44 'operation=s' => \$operation, # Operation to perform on files 45 'mask' => \$mask, # Operation is on a mask 46 'workdir=s' => \$workdir, # Working directory for output files 47 'dbname=s' => \$dbname, # Database name 48 'no-update' => \$no_update, # Don't update the database 49 ) or pod2usage( 2 ); 49 50 50 51 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 51 52 pod2usage( -msg => "Required options --det_type --filelevel --inst --telescope --det_id1 --iteration1 --det_id2 --iteration2 --workdir", 52 -exitval => 3,53 )53 -exitval => 3, 54 ) 54 55 unless defined $det_type 55 56 and defined $filelevel … … 65 66 $ipprc->define_camera($inst); 66 67 67 my $STATS = 68 [ 68 my $STATS = 69 [ 69 70 # PPSTATS KEYWORD STATISTIC CHIPTOOL FLAG 70 71 { name => "ROBUST_MEDIAN", type => "mean", flag => "-bg", dtype => "float" }, … … 90 91 die("File lists for detrends have differing lengths") unless scalar keys %$files1 == scalar keys %$files2; 91 92 92 my ($det_id, $iter); # Detrend identifier for the new detrend93 my ($det_id, $iter); # Detrend identifier for the new detrend 93 94 unless ($no_update) { 94 95 my $command = "$dettool -register_detrend -det_type $det_type -filelevel $filelevel -workdir $workdir " . 95 "-inst $inst -telescope $telescope"; # Command to run96 "-inst $inst -telescope $telescope"; # Command to run 96 97 $command .= " -filter $filter" if defined $filter; 97 98 $command .= " -dbname $dbname" if defined $dbname; 98 99 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 99 run(command => $command, verbose => 1);100 run(command => $command, verbose => 1); 100 101 unless ($success) { 101 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);102 die("Unable to run dettool -register_detrend: $error_code");102 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 103 die("Unable to run dettool -register_detrend: $error_code"); 103 104 } 104 105 … … 137 138 $command .= " -dbname $dbname" if defined $dbname; 138 139 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 139 run(command => $command, verbose => 1);140 run(command => $command, verbose => 1); 140 141 unless ($success) { 141 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);142 die("Unable to run ppArith: $error_code");142 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 143 die("Unable to run ppArith: $error_code"); 143 144 } 144 145 … … 149 150 my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser 150 151 { 151 my $statsFile;# File handle152 open $statsFile, $ipprc->file_resolve($outStats) or die("Can't open stats file $outStats: $!");153 my @contents = <$statsFile>; # Contents of file154 close $statsFile;155 156 my $metadata = $mdcParser->parse(join "", @contents) or die("Unable to parse metadata config doc");157 158 unless ($stats->parse($metadata)) {159 &my_die("Failure extracting metadata from the statistics output file.\n");160 }152 my $statsFile; # File handle 153 open $statsFile, $ipprc->file_resolve($outStats) or die("Can't open stats file $outStats: $!"); 154 my @contents = <$statsFile>; # Contents of file 155 close $statsFile; 156 157 my $metadata = $mdcParser->parse(join "", @contents) or die("Unable to parse metadata config doc"); 158 159 unless ($stats->parse($metadata)) { 160 &my_die("Failure extracting metadata from the statistics output file.\n"); 161 } 161 162 } 162 163 163 164 # Register the imfile 164 165 unless ($no_update) { 165 my $command = "$dettool -register_detrend_imfile -det_id $det_id "; # Command to run166 $command .= " -class_id $class_id -uri $outName -path_base $outRoot";167 $command .= $stats->cmdflags();168 $command .= " -dbname $dbname" if defined $dbname;169 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =170 run(command => $command, verbose => 1);171 unless ($success) {172 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);173 die("Unable to run dettool -register_detrend_imfile: $error_code");174 }166 my $command = "$dettool -register_detrend_imfile -det_id $det_id "; # Command to run 167 $command .= " -class_id $class_id -uri $outName -path_base $outRoot"; 168 $command .= $stats->cmdflags(); 169 $command .= " -dbname $dbname" if defined $dbname; 170 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 171 run(command => $command, verbose => 1); 172 unless ($success) { 173 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 174 die("Unable to run dettool -register_detrend_imfile: $error_code"); 175 } 175 176 } 176 177 } … … 183 184 sub filelist 184 185 { 185 my $det_id = shift; # Detrend identifier186 my $iter = shift; # Iteration186 my $det_id = shift; # Detrend identifier 187 my $iter = shift; # Iteration 187 188 188 189 my $command = "$detselect -select -det_id $det_id -iteration $iter"; # Command to run 189 190 $command .= " -dbname $dbname" if defined $dbname; 190 191 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 191 run(command => $command, verbose => 1);192 run(command => $command, verbose => 1); 192 193 unless ($success) { 193 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);194 die("Unable to run detselect: $error_code");194 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 195 die("Unable to run detselect: $error_code"); 195 196 } 196 197 … … 202 203 203 204 foreach my $item ( @$list ) { 204 my $class_id = $item->{class_id};205 die("Multiple definitions of class_id=$class_id found for det_id=$det_id, iteration=$iter\n") if206 defined $files{$class_id};207 $files{$class_id} = parse_md_list($md);205 my $class_id = $item->{class_id}; 206 die("Multiple definitions of class_id=$class_id found for det_id=$det_id, iteration=$iter\n") if 207 defined $files{$class_id}; 208 $files{$class_id} = parse_md_list($md); 208 209 } 209 210 -
branches/pap/ippScripts/scripts/lossy_compress_imfile.pl
r27193 r28003 8 8 use Sys::Hostname; 9 9 my $host = hostname(); 10 my $date = `date`; 10 11 print "\n\n"; 11 print "Starting script $0 on $host \n\n";12 print "Starting script $0 on $host at $date\n\n"; 12 13 13 14 use vars qw( $VERSION ); … … 86 87 if ($state eq 'goto_compressed') { 87 88 # Find the actual filename for this run: 88 &my_die("Couldn't find input file: $uri\n", $exp_id,$exp_name,$class_id,$uri,$PS_EXIT_SYS_ERROR) 89 unless ($ipprc->file_exists($uri));89 &my_die("Couldn't find input file: $uri\n", $exp_id,$exp_name,$class_id,$uri,$PS_EXIT_SYS_ERROR) 90 unless ($ipprc->file_exists($uri)); 90 91 my $uriReal = $ipprc->file_resolve( $uri ); 91 92 92 93 # Create a compressed version: 93 94 my $compUri = $uri . ".fz"; 94 &my_die("Output compressed file already exists: $compUri\n", $exp_id,$exp_name,$class_id,$uri,$PS_EXIT_SYS_ERROR) 95 if ($ipprc->file_exists($compUri));95 &my_die("Output compressed file already exists: $compUri\n", $exp_id,$exp_name,$class_id,$uri,$PS_EXIT_SYS_ERROR) 96 if ($ipprc->file_exists($compUri)); 96 97 my $compReal= $ipprc->file_resolve( $compUri, 'create'); 97 98 # Apparently we need to funpack before fpacking. Probably should have realized that beforehand. 98 99 my $tempfile = new File::Temp ( TEMPLATE => "${exp_name}.XXXX", 99 DIR => '/tmp/',100 UNLINK => !$save_temps,101 SUFFIX => '.fits');100 DIR => '/tmp/', 101 UNLINK => !$save_temps, 102 SUFFIX => '.fits'); 102 103 my $tempReal = $tempfile->filename; 103 104 104 105 my $uncompress_command = "$funpack -S $uriReal > $tempReal"; 105 106 my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf) = 106 run(command => $uncompress_command, verbose => $verbose);107 run(command => $uncompress_command, verbose => $verbose); 107 108 unless ($success) { 108 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);109 &my_die("Unable to uncompress file: $uri -> $compUri: $error_code", 110 $exp_id,$exp_name,$class_id,$uri, $PS_EXIT_SYS_ERROR);109 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 110 &my_die("Unable to uncompress file: $uri -> $compUri: $error_code", 111 $exp_id,$exp_name,$class_id,$uri, $PS_EXIT_SYS_ERROR); 111 112 } 112 113 my $compress_command = "$fpack -h -s 8 -S $tempReal > $compReal"; 113 114 print STDERR "$compReal $uriReal $compress_command\n"; 114 115 ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf) = 115 run(command => $compress_command, verbose => $verbose);116 run(command => $compress_command, verbose => $verbose); 116 117 unless ($success) { 117 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);118 &my_die("Unable to compress file: $uri -> $compUri: $error_code", 119 $exp_id,$exp_name,$class_id,$uri, $PS_EXIT_SYS_ERROR);118 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 119 &my_die("Unable to compress file: $uri -> $compUri: $error_code", 120 $exp_id,$exp_name,$class_id,$uri, $PS_EXIT_SYS_ERROR); 120 121 } 121 122 my $database_command = "$regtool -updateprocessedimfile -exp_id $exp_id -class_id $class_id -set_state compressed"; … … 123 124 124 125 &my_die("Expected output compressed file not found: $compUri\n", $exp_id,$exp_name,$class_id, $uri,$PS_EXIT_SYS_ERROR) 125 unless ($ipprc->file_exists($compUri));126 unless ($ipprc->file_exists($compUri)); 126 127 127 128 if ($no_update || $no_op) { 128 print STDERR "NOUPDATE: $database_command\n";129 print STDERR "NOUPDATE: $database_command\n"; 129 130 } 130 131 else { 131 ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf) =132 run(command => $database_command, verbose => $verbose);133 unless ($success) {134 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);135 &my_die("Unable to update database file: $uri -> $compUri: $error_code", 136 $exp_id,$exp_name,$class_id,$uri, $PS_EXIT_SYS_ERROR);137 }132 ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf) = 133 run(command => $database_command, verbose => $verbose); 134 unless ($success) { 135 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 136 &my_die("Unable to update database file: $uri -> $compUri: $error_code", 137 $exp_id,$exp_name,$class_id,$uri, $PS_EXIT_SYS_ERROR); 138 } 138 139 } 139 140 exit(0); … … 149 150 # Confirm we have both files 150 151 &my_die("Couldn't find original file: $uri\n", $exp_id,$exp_name,$class_id,$uri,$PS_EXIT_SYS_ERROR) 151 unless($ipprc->file_exists($uri));152 unless($ipprc->file_exists($uri)); 152 153 my $uriReal = $ipprc->file_resolve( $uri ); 153 154 154 155 my $compUri = $uri . ".fz"; 155 156 unless($ipprc->file_exists($compUri)) { 156 &my_die("Couldn't find compressed version of the file: $compUri\n", 157 $exp_id,$exp_name,$class_id,$uri,$PS_EXIT_SYS_ERROR);158 159 # If that die is removed, this will compress things as well.160 # 161 # &my_die("Output compressed file already exists: $compUri\n",162 # $exp_id,$exp_name,$class_id,$uri,$PS_EXIT_SYS_ERROR)163 # if ($ipprc->file_exists($compUri));164 # my $compReal= $ipprc->file_resolve( $compUri, 'create');165 166 # my $compress_command = "$fpack -h -s 8 -S $uriReal > $compReal";167 # print STDERR "$compReal $uriReal $compress_command\n";168 # my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf) =169 # run(command => $compress_command, verbose => $verbose);170 # unless ($success) {171 # $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);172 # &my_die("Unable to compress file: $uri -> $compUri: $error_code",173 # $exp_id,$exp_name,$class_id,$uri, $PS_EXIT_SYS_ERROR);174 # }157 &my_die("Couldn't find compressed version of the file: $compUri\n", 158 $exp_id,$exp_name,$class_id,$uri,$PS_EXIT_SYS_ERROR); 159 160 # If that die is removed, this will compress things as well. 161 # 162 # &my_die("Output compressed file already exists: $compUri\n", 163 # $exp_id,$exp_name,$class_id,$uri,$PS_EXIT_SYS_ERROR) 164 # if ($ipprc->file_exists($compUri)); 165 # my $compReal= $ipprc->file_resolve( $compUri, 'create'); 166 167 # my $compress_command = "$fpack -h -s 8 -S $uriReal > $compReal"; 168 # print STDERR "$compReal $uriReal $compress_command\n"; 169 # my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf) = 170 # run(command => $compress_command, verbose => $verbose); 171 # unless ($success) { 172 # $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 173 # &my_die("Unable to compress file: $uri -> $compUri: $error_code", 174 # $exp_id,$exp_name,$class_id,$uri, $PS_EXIT_SYS_ERROR); 175 # } 175 176 } 176 177 … … 181 182 182 183 unless ($no_op) { 183 $neb->replicate($compUri);184 $neb->swap($uri,$compUri) or185 &my_die("Nebulous swap failed between $uri and $compUri", 186 $exp_id,$exp_name,$class_id,$uri,$PS_EXIT_SYS_ERROR);187 } 188 # Update database 184 $neb->replicate($compUri); 185 $neb->swap($uri,$compUri) or 186 &my_die("Nebulous swap failed between $uri and $compUri", 187 $exp_id,$exp_name,$class_id,$uri,$PS_EXIT_SYS_ERROR); 188 } 189 # Update database 189 190 190 191 my $database_command = "$regtool -updateprocessedimfile -exp_id $exp_id -class_id $class_id -set_state lossy "; … … 192 193 193 194 $database_command .= " -dbname $dbname" if defined $dbname; 194 195 195 196 if ($no_update || $no_op) { 196 print STDERR "NOUPDATE: $database_command\n";197 print STDERR "NOUPDATE: $database_command\n"; 197 198 } 198 199 else { 199 my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf) =200 run(command => $database_command, verbose => $verbose);201 unless($success) {202 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);203 $neb->swap($uri,$compUri) or204 &my_die("DB update failed and Nebulous swap-back failed between $uri and $compUri", 205 $exp_id,$exp_name,$class_id,$uri,$PS_EXIT_SYS_ERROR);206 &my_die("Unable to update database file: $uri -> $compUri: $error_code", 207 $exp_id,$exp_name,$class_id,$uri, $PS_EXIT_SYS_ERROR);208 }209 # remove original version200 my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf) = 201 run(command => $database_command, verbose => $verbose); 202 unless($success) { 203 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 204 $neb->swap($uri,$compUri) or 205 &my_die("DB update failed and Nebulous swap-back failed between $uri and $compUri", 206 $exp_id,$exp_name,$class_id,$uri,$PS_EXIT_SYS_ERROR); 207 &my_die("Unable to update database file: $uri -> $compUri: $error_code", 208 $exp_id,$exp_name,$class_id,$uri, $PS_EXIT_SYS_ERROR); 209 } 210 # remove original version 210 211 $neb->delete($compUri); 211 212 } -
branches/pap/ippScripts/scripts/magic_destreak.pl
r27396 r28003 8 8 use Sys::Hostname; 9 9 my $host = hostname(); 10 my $date = `date`; 10 11 print "\n\n"; 11 print "Starting script $0 on $host \n\n";12 print "Starting script $0 on $host at $date\n\n"; 12 13 13 14 use vars qw( $VERSION ); … … 41 42 # Parse the command-line arguments 42 43 my ($magic_ds_id, $camera, $streaks, $inv_streaks, $exp_id, $stage, $stage_id, $component, $uri, $path_base, $cam_path_base, $cam_reduction); 43 my ($outroot, $recoveryroot );44 my ($outroot, $recoveryroot, $magicked); 44 45 my ($replace, $release); 45 46 my ($dbname, $save_temps, $verbose, $no_update, $no_op, $logfile); … … 61 62 'recoveryroot=s' => \$recoveryroot,# "directory" for saving the images of excised pixels 62 63 'replace=s' => \$replace, # replace the input images with the results. 64 'magicked=s' => \$magicked, # magicked state of the run 63 65 'release' => \$release, # NAN masked pixels for release 64 66 'save-temps' => \$save_temps, # Save temporary files? … … 71 73 72 74 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 73 pod2usage( -msg => "Required options: --magic_ds_id --camera --streaks --stage --stage_id --component --uri --path_base --outroot ",75 pod2usage( -msg => "Required options: --magic_ds_id --camera --streaks --stage --stage_id --component --uri --path_base --outroot --magicked", 74 76 -exitval => 3) unless 75 77 defined $magic_ds_id and … … 82 84 defined $uri and 83 85 defined $path_base and 84 defined $outroot; 86 defined $outroot and 87 defined $magicked; 85 88 86 89 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR ); # IPP configuration … … 209 212 &my_die("Unable to parse metadata list", $magic_ds_id, $component, $PS_EXIT_PROG_ERROR); 210 213 211 $temp_dir = tempdir( CLEANUP => !$save_temps);212 214 ($sfh, $skycell_list) = tempfile( "/tmp/skycell_list.XXXX", UNLINK => !$save_temps); 213 215 … … 218 220 } else { 219 221 # diff run must have been cleaned up, need to create this skycell file on the fly 222 if (!defined $temp_dir ) { 223 $temp_dir = tempdir( CLEANUP => !$save_temps); 224 } 220 225 my $skycell_id = $skycell->{skycell_id}; 221 226 $skycell_uri = "$temp_dir/$skycell_id"; … … 247 252 my $command = "$ppConfigDump -camera $camera -recipe PSASTRO $recipe_psastro -dump-recipe PSASTRO -"; 248 253 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 249 run(command => $command, verbose => $verbose); 254 # note verbose == 0 to avoid polluting log files with almost always useless information 255 run(command => $command, verbose => 0); 250 256 unless ($success) { 251 257 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); … … 266 272 $astrom = $ipprc->filename("PSASTRO.OUTPUT", $cam_path_base); 267 273 268 if ($dynamicMasks) { 274 # if magicked is non-zero we are updating a previously magicked component. In this case we don't 275 # touch the camera mask 276 if (!$magicked and $dynamicMasks) { 269 277 $mask = $ipprc->filename("PSASTRO.OUTPUT.MASK", $cam_path_base, $class_id); 270 278 $ch_mask = $ipprc->filename("PPIMAGE.CHIP.MASK", $path_base, $class_id); -
branches/pap/ippScripts/scripts/magic_destreak_cleanup.pl
r27604 r28003 8 8 use Sys::Hostname; 9 9 my $host = hostname(); 10 my $date = `date`; 10 11 print "\n\n"; 11 print "Starting script $0 on $host \n\n";12 print "Starting script $0 on $host at $date\n\n"; 12 13 13 14 use vars qw( $VERSION ); … … 62 63 $ipprc->redirect_output($logfile) or my_die( "Unable to redirect output", $magic_ds_id, $PS_EXIT_SYS_ERROR ) if $logfile; 63 64 64 if (0) {65 my $nebulousServer = metadataLookupStr( $ipprc->{_siteConfig}, 'NEB_SERVER' );66 &my_die("cannot find NEB_SERVER in site configuration", $magic_ds_id, $PS_EXIT_CONFIG_ERROR) if !$nebulousServer;67 68 my $nebulous = eval { Nebulous::Client->new( proxy => $nebulousServer ); };69 if ($@ or not defined $nebulous) {70 &my_die ("Unable to create a Nebulous::Client object with proxy $nebulousServer", $magic_ds_id, $PS_EXIT_CONFIG_ERROR);71 }72 }73 65 74 66 $dbname = metadataLookupStr( $ipprc->{_siteConfig}, 'DBNAME' ) if !$dbname; … … 107 99 108 100 101 &my_die("cleanup not supported for camera stage", $magic_ds_id, $PS_EXIT_PROG_ERROR) if $stage eq "camera"; 102 103 109 104 &my_die("unexpected run state found: $state", $magic_ds_id, $PS_EXIT_CONFIG_ERROR) if $state ne "goto_cleaned"; 110 105 &my_die("clean not allowed for raw stage, use goto_restore", $magic_ds_id, $PS_EXIT_CONFIG_ERROR) if $stage eq "raw"; … … 129 124 $dbh->disconnect() or warn $dbh->errstr; 130 125 126 # We no longer clean up the camera stage mask files, but the code was left in place in case 127 # we change our minds. 128 my $cleanup_cam_mask = 0; 129 131 130 my $dynamicMasks; # Use dynamic masks? 132 131 foreach my $comp (@components) { … … 139 138 if ($stage eq "chip") { 140 139 # Check to see if we're using dynamic masks 141 if ( !defined $dynamicMasks) {140 if ($cleanup_cam_mask && !defined $dynamicMasks) { 142 141 # Get the PSASTRO recipe 143 142 my $command = "$ppConfigDump -camera $camera -recipe PSASTRO $recipe_psastro -dump-recipe PSASTRO -"; -
branches/pap/ippScripts/scripts/magic_destreak_defineruns.pl
r26030 r28003 11 11 use Sys::Hostname; 12 12 my $host = hostname(); 13 my $date = `date`; 13 14 print "\n\n"; 14 print "Starting script $0 on $host \n\n";15 print "Starting script $0 on $host at $date\n\n"; 15 16 16 17 use vars qw( $VERSION ); -
branches/pap/ippScripts/scripts/magic_destreak_revert.pl
r27598 r28003 8 8 use Sys::Hostname; 9 9 my $host = hostname(); 10 my $date = `date`; 10 11 print "\n\n"; 11 print "Starting script $0 on $host \n\n";12 print "Starting script $0 on $host at $date\n\n"; 12 13 13 14 use vars qw( $VERSION ); … … 37 38 38 39 # Parse the command-line arguments 39 my ($magic_ds_id, $camera, $streaks, $stage, $stage_id, $component, $uri, $path_base, $bothways, $cam_path_base, $cam_reduction );40 my ($magic_ds_id, $camera, $streaks, $stage, $stage_id, $component, $uri, $path_base, $bothways, $cam_path_base, $cam_reduction, $magicked); 40 41 my ($outroot, $recoveryroot, $replace, $release, $bytes, $md5sum); 41 42 my ($dbname, $save_temps, $verbose, $no_update, $no_op, $logfile); … … 54 55 'replace=s' => \$replace, # replace the input images with the results. 55 56 'bothways=s' => \$bothways, # run has inverse files (bothways diff) 57 'magicked=s' => \$magicked, # magicked state of the run 56 58 'save-temps' => \$save_temps, # Save temporary files? 57 59 'dbname=s' => \$dbname, # Database name … … 63 65 64 66 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 65 pod2usage( -msg => "Required options: --magic_ds_id --camera --stage --stage_id --component --path_base --outroot ",67 pod2usage( -msg => "Required options: --magic_ds_id --camera --stage --stage_id --component --path_base --outroot --magicked", 66 68 -exitval => 3) unless 67 69 defined $magic_ds_id and … … 71 73 defined $component and 72 74 defined $path_base and 75 defined $magicked and 73 76 defined $outroot; 74 77 … … 76 79 77 80 &my_die("cam_path_base is required for chip stage", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR) if ($stage eq 'chip' and !$cam_path_base); 81 82 78 83 79 84 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR ); # IPP configuration … … 168 173 my $command = "$ppConfigDump -camera $camera -recipe PSASTRO $recipe_psastro -dump-recipe PSASTRO -"; 169 174 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 170 run(command => $command, verbose => $verbose); 175 # note verbose == 0 to keep from polluting log file with lots of usually useless information 176 run(command => $command, verbose => 0); 171 177 unless ($success) { 172 178 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); … … 181 187 } 182 188 189 $image = $ipprc->filename("PPIMAGE.CHIP", $path_base, $class_id); 190 $weight = $ipprc->filename("PPIMAGE.CHIP.VARIANCE", $path_base, $class_id); 191 183 192 # we use the mask output from the camera stage for input and replace 184 193 # the output of the chip stage with that mask as well. 185 $image = $ipprc->filename("PPIMAGE.CHIP", $path_base, $class_id); 186 $weight = $ipprc->filename("PPIMAGE.CHIP.VARIANCE", $path_base, $class_id); 187 188 if ($dynamicMasks) { 194 # Note that when destreaking as part of an update $magicked is non-zero. 195 # In this case we do not touch the camera stage mask so there is no need to revert it 196 if (!$magicked and $dynamicMasks) { 189 197 $mask = $ipprc->filename("PSASTRO.OUTPUT.MASK", $cam_path_base, $class_id); 190 198 $ch_mask = $ipprc->filename("PPIMAGE.CHIP.MASK", $path_base, $class_id); … … 194 202 195 203 $bimage = $ipprc->filename("PPIMAGE.CHIP", $backup_path_base, $class_id); 196 # This is kludgey but correct204 # This is somewhat kludgey but it works whether the mask is camera mask or chip mask 197 205 $bmask = dirname($backup_path_base) . "/SR_" . basename($mask); 198 206 $bch_mask= $ipprc->filename("PPIMAGE.CHIP.MASK", $backup_path_base, $class_id); -
branches/pap/ippScripts/scripts/magic_process.pl
r27634 r28003 8 8 use Sys::Hostname; 9 9 my $host = hostname(); 10 my $date = `date`; 10 11 print "\n\n"; 11 print "Starting script $0 on $host \n\n";12 print "Starting script $0 on $host at $date\n\n"; 12 13 13 14 use vars qw( $VERSION ); … … 98 99 } 99 100 100 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or101 $inputs = $mdcParser->parse_list(join "", @$stdout_buf) or 101 102 &my_die("Unable to parse metadata config doc", $magic_id, $node, $PS_EXIT_PROG_ERROR); 102 103 $inputs = parse_md_list($metadata) or104 &my_die("Unable to parse metadata list", $magic_id, $node, $PS_EXIT_PROG_ERROR);105 103 } 106 104 107 105 108 106 my @outputs; 107 my $inverse; # Using inverse diff? 109 108 ### Do the heavy lifting 110 109 { … … 262 261 cat_list_to_list($mfh, $in_path_base, "mask.list"); 263 262 cat_list_to_list($wfh, $in_path_base, "weight.list"); 263 264 if ($innode->{inverse}) { 265 $inverse = 1; 266 } 264 267 } 265 268 close $in_fh; … … 329 332 } 330 333 } 334 331 335 if ($node eq "root") { 332 336 my $streaks_file = "$outroot.streaks"; … … 347 351 &run_verifystreaks($baseroot); 348 352 349 my $command = "$magictool -addmask"; 350 $command .= " -magic_id $magic_id"; 351 $command .= " -uri $streaks_file"; 352 $command .= " -streaks $num_streaks"; 353 $command .= " -dbname $dbname" if defined $dbname; 354 355 # Add the processed file to the database 356 unless ($no_update) { 353 my $exp_id; # Exposure identifier 354 my $cam_path; # Camera stage path_base 355 { 356 my $command = "magictool -exposure -magic_id $magic_id"; 357 $command .= " -inverse" if defined $inverse; 358 $command .= " -dbname $dbname" if defined $dbname; 357 359 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 358 360 run(command => $command, verbose => $verbose); 359 unless ($success) { 360 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 361 # This isn't going to work because our result was already entered. 362 &my_die("Unable to perform magictool -addmask: $error_code", $magic_id, $node, $error_code); 363 } 364 } else { 365 print "Skipping command: $command\n"; 361 my $exposures = $mdcParser->parse_list(join "", @$stdout_buf); 362 my $exp = $$exposures[0]; # Exposure of interest (should only be one) 363 364 $exp_id = $exp->{exp_id}; 365 $cam_path = $exp->{path_base}; 366 } 367 368 { 369 my $astrom = $ipprc->filename("PSASTRO.OUTPUT", $cam_path); # Astrometry file 370 my $streaks = "$outroot.streaks"; # Streaks file 371 my $clusters = "$baseroot.verify/${exp_id}_clusterPos.txt"; # Clusters file 372 373 my $command = "ppCoord -astrom $astrom -streaks $streaks"; 374 if ($ipprc->file_exists($clusters)) { 375 $command .= " -clusters $clusters"; 376 } 377 378 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 379 run(command => $command, verbose => $verbose); 380 open my $coords, "> $outroot.coords"; 381 print $coords join("", @$stdout_buf); 382 close $coords; 383 } 384 385 386 { 387 my $command = "$magictool -addmask"; 388 $command .= " -magic_id $magic_id"; 389 $command .= " -uri $streaks_file"; 390 $command .= " -streaks $num_streaks"; 391 $command .= " -dbname $dbname" if defined $dbname; 392 393 # Add the processed file to the database 394 unless ($no_update) { 395 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 396 run(command => $command, verbose => $verbose); 397 unless ($success) { 398 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 399 # This isn't going to work because our result was already entered. 400 &my_die("Unable to perform magictool -addmask: $error_code", $magic_id, $node, $error_code); 401 } 402 } else { 403 print "Skipping command: $command\n"; 404 } 366 405 } 367 406 } -
branches/pap/ippScripts/scripts/magic_tree.pl
r27596 r28003 8 8 use Sys::Hostname; 9 9 my $host = hostname(); 10 my $date = `date`; 10 11 print "\n\n"; 11 print "Starting script $0 on $host \n\n";12 print "Starting script $0 on $host at $date\n\n"; 12 13 13 14 use vars qw( $VERSION ); -
branches/pap/ippScripts/scripts/make_burntool_pcontrol.pl
r27033 r28003 1 #!/usr/bin/ perl -w1 #!/usr/bin/env perl 2 2 # script to generate a pcontrol.pro file to run burntool on a set of data. 3 3 4 4 use DBI; 5 use warnings; 5 6 use DateTime; 6 7 use Getopt::Std; 8 use PS::IPP::Metadata::List qw( parse_md_list ); 9 use PS::IPP::Config 1.01 qw( :standard ); 10 use IPC::Cmd 0.36 qw( can_run run); 7 11 8 12 use constant DB_SOCKET => '/var/run/mysqld/mysqld.sock'; … … 35 39 ) or die "Unable to connect to database $DBI::errstr\n"; 36 40 41 my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1); 42 if ($missing_tools) { 43 die "Cannot find required tools."; 44 } 37 45 # Determine what the value of "BURNTOOL.STATE.GOOD" currently is: 38 46 $burntoolStateGood = 999; 39 open(LAZY," ppConfigDump -camera GPC1 -dump-camera - |") || die "Can't run ppConfigDump\n";47 open(LAZY,"$ppConfigDump -camera GPC1 -dump-camera - |") || die "Can't run ppConfigDump\n"; 40 48 while(<LAZY>) { 41 49 chomp; … … 46 54 } 47 55 close(LAZY); 48 #unless( $burntoolStateGood == 999) { 49 # print STDERR "GOOD == $burntoolStateGood\n"; 50 #} 51 52 53 # List of which obs_modes are "science" and which are something else. 54 %science = ('MD' => 1, '3PI' => 1, 'STS' => 1, 'CAL' => 1, 'M31' => 1, 'SS' => 1, 55 'ENGINEERING' => 0, 'NULL' => 0, 'Unknown' => 1, ' ' => 0); 56 57 # Read the nightly science config file and use that to determine which data is science 58 my $verbose = 0; 59 my $conf_cmd = "$ppConfigDump -dump-recipe NIGHTLY_SCIENCE -"; 60 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 61 run(command => $conf_cmd, verbose => $verbose); 62 unless ($success) { 63 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 64 &my_die("Unable to perform ppConfigDUmp: $error_code", $date, $PS_EXIT_SYS_ERROR); 65 } 66 67 my @target_list; 68 my %object_list; 69 my $comment_list; 70 71 my $mdcParser = PS::IPP::Metadata::Config->new; 72 my $metadata = $mdcParser->parse(join "", @$stdout_buf); 73 foreach my $entry (@{ $metadata }) { 74 if (${ $entry }{name} eq 'TARGETS') { 75 my @target_data = @{ ${ $entry }{value} }; 76 my $this_target = ''; 77 78 foreach my $tentry (@target_data) { 79 if (${ $tentry }{name} eq 'NAME') { 80 $this_target = ${ $tentry }{value}; 81 push @target_list, $this_target; 82 $obsmode_list{$this_target} = '.*'; 83 $object_list{$this_target} = '.*'; 84 $comment_list{$this_target} = '.*'; 85 } 86 elsif (${ $tentry }{name} eq 'OBSMODE') { 87 $obsmode_list{$this_target} = ${ $tentry }{value}; 88 $obsmode_list{$this_target} =~ s/%//; 89 } 90 elsif (${ $tentry }{name} eq 'OBJECT') { 91 $object_list{$this_target} = ${ $tentry }{value}; 92 $object_list{$this_target} =~ s/%//; 93 } 94 elsif (${ $tentry }{name} eq 'COMMENT') { 95 $comment_list{$this_target} = ${ $tentry }{value}; 96 $comment_list{$this_target} =~ s/%//; 97 } 98 } 99 } 100 } 56 101 if (exists($opt{P})) { 57 $science{Unknown} = 1; 102 push @target_list, 'PR'; 103 $obsmode_list{'PR'} = 'Unknown'; 104 $object_list{'PR'} = '.*'; 105 $comment_list{'PR'} = '.*'; 58 106 } 59 107 … … 119 167 120 168 # Find _ALL_ observations within the date range we care about 121 $sth = "SELECT exp_id,dateobs,pon_time,exp_type,obs_mode,comment FROM rawExp WHERE " .169 $sth = "SELECT exp_id,dateobs,pon_time,exp_type,obs_mode,comment,object FROM rawExp WHERE " . 122 170 "dateobs >= '${date_min}' AND dateobs <= '${date_max}' order by dateobs"; 123 171 … … 133 181 foreach $row_ref (@{ $data_ref }) { 134 182 135 ($exp_id,$dateobs,$pontime,$exp_type,$obs_mode,$comment ) = @{ $row_ref };183 ($exp_id,$dateobs,$pontime,$exp_type,$obs_mode,$comment,$object) = @{ $row_ref }; 136 184 # Fix nulls in the database 137 185 if (!defined($obs_mode)) { 138 186 $obs_mode = ' '; 139 187 } 188 if (!defined($object)) { 189 $object = ' '; 190 } 140 191 if (!defined($comment)) { 141 192 $comment = ' '; … … 144 195 ($date,$time) = split / /, $dateobs; 145 196 ($year,$month,$day) = split /-/, $date; 146 ($hour,$minute,$second) = split /:/, $time; 197 ($hour,$minute,$second) = split /:/, $time; # / # This stops emacs run-on syntax highlights. 147 198 148 199 $dt = DateTime->new( year => $year, month => $month, day => $day, … … 155 206 $et = $dt->epoch(); 156 207 157 158 if (!exists($science{$obs_mode})) { 159 $science{$obs_mode} = 0; 160 } 161 if ((($science{$obs_mode} == 1)&&($comment !~ /Daytime/))|| 162 (($science{$obs_mode} == 0)&&( 163 ($comment =~ /MD/)||($comment =~ /ThreePi/)|| 164 ($comment =~ /STS/i)||($comment =~ /M31/)||($comment =~ /Stellar Transit/)|| 165 ($comment =~ /CAL/i)||($comment =~ /SS/)||($comment =~ /SVS/)|| 166 ($comment =~ /Sweetspot/)||($comment =~ /virgo/i)||($comment =~ /kepler/)|| 167 ($comment =~ /sdss/)))) 168 { 208 if (is_science($exp_type,$obs_mode,$object,$comment)) { 169 209 if ($start_s[-1] == 0) { 170 210 $start_s[-1] = $et - 1800; … … 194 234 # Scan again and count how many exposures are between windows 195 235 foreach $row_ref (@{ $data_ref }) { 196 ($exp_id,$dateobs,$pontime,$exp_type,$obs_mode,$comment ) = @{ $row_ref };236 ($exp_id,$dateobs,$pontime,$exp_type,$obs_mode,$comment,$object) = @{ $row_ref }; 197 237 if (!defined($obs_mode)) { 198 238 $obs_mode = ' '; … … 204 244 ($date,$time) = split / /, $dateobs; 205 245 ($year,$month,$day) = split /-/, $date; 206 ($hour,$minute,$second) = split /:/, $time; 246 ($hour,$minute,$second) = split /:/, $time; # / # another emacs syntax highlight bug. 207 247 208 248 $dt = DateTime->new( year => $year, month => $month, day => $day, … … 215 255 $et = $dt->epoch(); 216 256 217 if (!exists($science{$obs_mode})) {218 die "No mode >>$obs_mode<<\n";219 }220 221 257 for ($i = 0; $i <= $#start_s; $i++) { 222 if (($et < $start_s[$i])&&( $science{$obs_mode}== 0)) {258 if (($et < $start_s[$i])&&(is_science($exp_type,$obs_mode,$object,$comment) == 0)) { 223 259 if ($i == 0) { 224 260 $skips[$i]++; … … 278 314 unless(exists($opt{b}) || ($N_ranges == 0)) { 279 315 print_epilogue(); 316 } 317 318 319 # Subroutine to use the configuration file data and the exposure data to determine whether or not something is "science" 320 sub is_science { 321 # if (is_science($exp_type,$obs_mode,$object,$comment)) { 322 my ($exp_type,$obs_mode,$object,$comment) = @_; 323 my $return_value = 0; 324 unless($object) { 325 $object = ''; 326 } 327 if ($exp_type eq 'OBJECT') { 328 foreach my $target (@target_list) { 329 # print STDERR "$target $obsmode_list{$target} $exp_type $obs_mode $object $comment\n"; 330 if (($obs_mode =~ /$obsmode_list{$target}/)&& 331 ($object =~ /$object_list{$target}/)&& 332 ($comment =~ /$comment_list{$target}/)) { 333 $return_value = 1; 334 } 335 # print ">$return_value $exp_type $obs_mode $object $comment $target $obsmode_list{$target} $object_list{$target} $comment_list{$target}\n"; 336 if ($return_value) { 337 return($return_value); 338 } 339 } 340 } 341 return(0); 280 342 } 281 343 -
branches/pap/ippScripts/scripts/publish_file.pl
r27286 r28003 7 7 use Sys::Hostname; 8 8 my $host = hostname(); 9 print "Starting script $0 on $host\n\n"; 9 my $date = `date`; 10 print "\n\n"; 11 print "Starting script $0 on $host at $date\n\n"; 10 12 11 13 use DateTime; -
branches/pap/ippScripts/scripts/rcserver_checkstatus.pl
r25567 r28003 8 8 use Sys::Hostname; 9 9 my $host = hostname(); 10 my $date = `date`; 10 11 print "\n\n"; 11 print "Starting script $0 on $host \n\n";12 print "Starting script $0 on $host at $date\n\n"; 12 13 13 14 use vars qw( $VERSION ); -
branches/pap/ippScripts/scripts/receive_advance.pl
r24127 r28003 7 7 use Sys::Hostname; 8 8 my $host = hostname(); 9 print "Starting script $0 on $host\n\n"; 9 my $date = `date`; 10 print "\n\n"; 11 print "Starting script $0 on $host at $date\n\n"; 10 12 11 13 use DateTime; … … 58 60 &my_die( "Unable to set up", $fileset_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration 59 61 60 # update the fileset entry 61 62 if ($dbinfo_uri and ($dbinfo_uri ne "NULL")) { 62 my $import_run_to_db = 0; 63 if ($import_run_to_db and $dbinfo_uri and ($dbinfo_uri ne "NULL")) { 63 64 my $filename = basename($dbinfo_uri); 64 65 my ($stage) = $filename =~ m|^dbinfo\.(\S+)\.\d+\.mdc$|; # Stage of interest … … 100 101 } 101 102 103 # update the fileset entry 102 104 # All done 103 105 { -
branches/pap/ippScripts/scripts/receive_file.pl
r25940 r28003 7 7 use Sys::Hostname; 8 8 my $host = hostname(); 9 print "Starting script $0 on $host\n\n"; 9 my $date = `date`; 10 print "\n\n"; 11 print "Starting script $0 on $host at $date\n\n"; 10 12 11 13 use DateTime; … … 124 126 print "dirinfo resolved is: $resolved\n" if $verbose; 125 127 126 open OUT, ">$resolved" 128 open OUT, ">$resolved" 127 129 or &my_die( "failed to open $resolved\n", $file_id, $PS_EXIT_UNKNOWN_ERROR); 128 130 print OUT @$dirinfo_lines … … 130 132 close OUT 131 133 or &my_die( "failed to close $resolved\n", $file_id, $PS_EXIT_UNKNOWN_ERROR); 132 134 133 135 # update the fileset to allow processing of other files 134 136 my $command = "$receivetool -updatefileset -fileset_id $fileset_id"; … … 160 162 &my_die( "failed to resolve $dbinfo_uri\n", $file_id, $PS_EXIT_UNKNOWN_ERROR) if !$resolved; 161 163 162 open OUT, ">$resolved" 164 open OUT, ">$resolved" 163 165 or &my_die( "failed to open $resolved\n", $file_id, $PS_EXIT_UNKNOWN_ERROR); 164 166 … … 227 229 $current_component = $value; 228 230 $component_dir = $components->{$current_component}; 229 &my_die( "$component_dir is null for $value in $filename: $runType\n", 231 &my_die( "$component_dir is null for $value in $filename: $runType\n", 230 232 $file_id, $PS_EXIT_UNKNOWN_ERROR) if !$component_dir; 231 233 } elsif ($name eq 'workdir') { … … 237 239 $new_value = basename($value); 238 240 } elsif ((($name eq 'uri') or ($name eq 'path_base')) and ($value ne 'NULL')) { 239 &my_die( "$component_dir is null and we need it for $name", 241 &my_die( "$component_dir is null and we need it for $name", 240 242 $file_id, $PS_EXIT_PROG_ERROR) if !$component_dir; 241 243 -
branches/pap/ippScripts/scripts/receive_fileset.pl
r24786 r28003 7 7 use Sys::Hostname; 8 8 my $host = hostname(); 9 print "Starting script $0 on $host\n\n"; 9 my $date = `date`; 10 print "\n\n"; 11 print "Starting script $0 on $host at $date\n\n"; 10 12 11 13 use DateTime; -
branches/pap/ippScripts/scripts/receive_setstatus.pl
r24038 r28003 8 8 use Sys::Hostname; 9 9 my $host = hostname(); 10 my $date = `date`; 10 11 print "\n\n"; 11 print "Starting script $0 on $host \n\n";12 print "Starting script $0 on $host at $date\n\n"; 12 13 13 14 use vars qw( $VERSION ); … … 74 75 $fileargs = " --list - --copy --abspath"; 75 76 } 76 77 77 78 # XXX need to create a fileset type for this 78 79 my $command = "echo $regline | dsreg --add $status_fs_name --product $status_product --type notset"; -
branches/pap/ippScripts/scripts/receive_source.pl
r24744 r28003 7 7 use Sys::Hostname; 8 8 my $host = hostname(); 9 print "Starting script $0 on $host\n\n"; 9 my $date = `date`; 10 print "\n\n"; 11 print "Starting script $0 on $host at $date\n\n"; 10 12 11 13 use DateTime; -
branches/pap/ippScripts/scripts/register_exp.pl
r23688 r28003 8 8 use Sys::Hostname; 9 9 my $host = hostname(); 10 my $date = `date`; 10 11 print "\n\n"; 11 print "Starting script $0 on $host \n\n";12 print "Starting script $0 on $host at $date\n\n"; 12 13 13 14 use vars qw( $VERSION ); … … 126 127 $command .= " -end_stage $end_stage" if defined $end_stage; 127 128 $command .= " -tess_id $tess_id" if defined $tess_id; 129 $command .= " -state full"; 128 130 $command .= " $cmdflags"; 129 131 -
branches/pap/ippScripts/scripts/register_imfile.pl
r26378 r28003 8 8 use Sys::Hostname; 9 9 my $host = hostname(); 10 my $date = `date`; 10 11 print "\n\n"; 11 print "Starting script $0 on $host \n\n";12 print "Starting script $0 on $host at $date\n\n"; 12 13 13 14 use vars qw( $VERSION ); … … 115 116 my $burntoolStateGood = 0; 116 117 foreach my $line (split /\n/, $out1) { 117 if ($line =~ /FPA.BURNTOOL.APPLIED/) {118 $line =~ s/^\s+//;119 $burntoolState = (split /\s+/, $line)[2];120 }121 if ($line =~ /FPA.CAMERA/) {122 $line =~ s/^\s+//;123 if ((split /\s+/, $line)[2] eq 'GPC1') {124 $isGPC1 = 1;125 }126 }118 if ($line =~ /FPA.BURNTOOL.APPLIED/) { 119 $line =~ s/^\s+//; 120 $burntoolState = (split /\s+/, $line)[2]; 121 } 122 if ($line =~ /FPA.CAMERA/) { 123 $line =~ s/^\s+//; 124 if ((split /\s+/, $line)[2] eq 'GPC1') { 125 $isGPC1 = 1; 126 } 127 } 127 128 } 128 129 if ($isGPC1 != 1) { 129 $burntoolState = 0; # If it's not GPC1, you shouldn't have run burntool.130 $burntoolState = 0; # If it's not GPC1, you shouldn't have run burntool. 130 131 } 131 132 elsif (($isGPC1 == 1) && ($burntoolState == 1)) { 132 # print STDERR "In the good region: >>$burntoolState<<\n";133 my $ppConfigDump_cmd = "$ppConfigDump -camera GPC1 -dump-camera -";134 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =135 IPC::Cmd::run(command => $ppConfigDump_cmd, verbose => $verbose);136 unless ($success) {137 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);138 warn ("Unable to perform ppConfigDump");139 exit($error_code);140 }141 142 # This is ugly, but doing a full parse for one entry is a bit wasteful.143 foreach my $line (split /\n/, (join "", @$stdout_buf)) {144 if ($line =~ /BURNTOOL.STATE.GOOD/) {145 $line =~ s/^\s+//;146 $burntoolStateGood = (split /\s+/, $line)[2];147 last;148 }149 }150 $burntoolState = $burntoolStateGood; # Positive because this has the header table.151 133 # print STDERR "In the good region: >>$burntoolState<<\n"; 134 my $ppConfigDump_cmd = "$ppConfigDump -camera GPC1 -dump-camera -"; 135 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 136 IPC::Cmd::run(command => $ppConfigDump_cmd, verbose => $verbose); 137 unless ($success) { 138 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 139 warn ("Unable to perform ppConfigDump"); 140 exit($error_code); 141 } 142 143 # This is ugly, but doing a full parse for one entry is a bit wasteful. 144 foreach my $line (split /\n/, (join "", @$stdout_buf)) { 145 if ($line =~ /BURNTOOL.STATE.GOOD/) { 146 $line =~ s/^\s+//; 147 $burntoolStateGood = (split /\s+/, $line)[2]; 148 last; 149 } 150 } 151 $burntoolState = $burntoolStateGood; # Positive because this has the header table. 152 152 153 } 153 154 $cmdflags .= " -burntool_state $burntoolState "; … … 173 174 $command .= " -hostname $host" if defined $host; 174 175 $command .= " -dbname $dbname" if defined $dbname; 176 $command .= " -data_state full"; 175 177 $command .= " $cmdflags"; 176 178 -
branches/pap/ippScripts/scripts/stack_skycell.pl
r27180 r28003 8 8 use Sys::Hostname; 9 9 my $host = hostname(); 10 my $date = `date`; 10 11 print "\n\n"; 11 print "Starting script $0 on $host \n\n";12 print "Starting script $0 on $host at $date\n\n"; 12 13 13 14 use DateTime; -
branches/pap/ippScripts/scripts/tdl_generate.pl
r21202 r28003 13 13 use Sys::Hostname; 14 14 my $host = hostname(); 15 my $date = `date`; 15 16 #print "\n\n"; 16 #print "Starting script $0 on $host \n\n";17 #print "Starting script $0 on $host at $date\n\n"; 17 18 18 19 use vars qw( $VERSION ); … … 58 59 # resolve any path:// or file:// in outroot 59 60 $outroot = $ipprc->file_resolve($outroot); 60 61 61 62 # Look for programs we need 62 63 my $missing_tools; -
branches/pap/ippScripts/scripts/warp_overlap.pl
r23688 r28003 8 8 use Sys::Hostname; 9 9 my $host = hostname(); 10 my $date = `date`; 10 11 print "\n\n"; 11 print "Starting script $0 on $host \n\n";12 print "Starting script $0 on $host at $date\n\n"; 12 13 13 14 use vars qw( $VERSION ); -
branches/pap/ippScripts/scripts/warp_skycell.pl
r27180 r28003 7 7 use Sys::Hostname; 8 8 my $host = hostname(); 9 my $date = `date`; 9 10 print "\n\n"; 10 print "Starting script $0 on $host \n\n";11 print "Starting script $0 on $host at $date\n\n"; 11 12 12 13 use DateTime; … … 299 300 $command .= " -tess_id $tess_dir"; 300 301 $command .= " -path_base $outroot"; # needed for logfile lookups 301 $command .= " - magicked $magicked" if $magicked;302 $command .= " -set_magicked $magicked" if $magicked; 302 303 303 304 $command .= " -uri $outputImage" if !$quality; … … 321 322 $command .= " -warp_id $warp_id"; 322 323 $command .= " -skycell_id $skycell_id"; 324 $command .= " -set_magicked $magicked" if $magicked; 323 325 $command .= " -dbname $dbname" if defined $dbname; 324 326
Note:
See TracChangeset
for help on using the changeset viewer.
