Changeset 22430
- Timestamp:
- Feb 24, 2009, 12:00:25 PM (17 years ago)
- Location:
- trunk/ippScripts/scripts
- Files:
-
- 22 edited
-
camera_exp.pl (modified) (6 diffs)
-
chip_imfile.pl (modified) (5 diffs)
-
detrend_correct_imfile.pl (modified) (9 diffs)
-
detrend_norm_apply.pl (modified) (7 diffs)
-
detrend_norm_calc.pl (modified) (9 diffs)
-
detrend_norm_exp.pl (modified) (3 diffs)
-
detrend_process_exp.pl (modified) (3 diffs)
-
detrend_process_imfile.pl (modified) (4 diffs)
-
detrend_reject_exp.pl (modified) (4 diffs)
-
detrend_resid_exp.pl (modified) (3 diffs)
-
detrend_resid_imfile.pl (modified) (5 diffs)
-
detrend_stack.pl (modified) (5 diffs)
-
diff_skycell.pl (modified) (13 diffs)
-
fake_imfile.pl (modified) (3 diffs)
-
magic_destreak.pl (modified) (6 diffs)
-
magic_mask.pl (modified) (3 diffs)
-
magic_process.pl (modified) (6 diffs)
-
magic_tree.pl (modified) (6 diffs)
-
register_exp.pl (modified) (5 diffs)
-
stack_skycell.pl (modified) (6 diffs)
-
warp_overlap.pl (modified) (2 diffs)
-
warp_skycell.pl (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/camera_exp.pl
r20661 r22430 27 27 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); 28 28 use Pod::Usage qw( pod2usage ); 29 30 # Look for programs we need 31 my $missing_tools; 32 my $camtool = can_run('camtool') or (warn "Can't find camtool" and $missing_tools = 1); 33 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1); 34 my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1); 35 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1); 36 my $psastro = can_run('psastro') or (warn "Can't find psastro" and $missing_tools = 1); 37 my $addstar = can_run('addstar') or (warn "Can't find addstar" and $missing_tools = 1); 38 if ($missing_tools) { 39 warn("Can't find required tools."); 40 exit($PS_EXIT_CONFIG_ERROR); 41 } 29 42 30 43 my ( $exp_tag, $cam_id, $camera, $outroot, $recipe, $dbname, $reduction, $dvodb, $verbose, $no_update, … … 57 70 defined $camera; 58 71 72 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 73 $SIG{__DIE__} = sub { die @_ if $^S; 74 my_die( $_[0], $cam_id, $PS_EXIT_UNKNOWN_ERROR ); }; 75 59 76 $ipprc->define_camera($camera); 60 77 … … 84 101 my $recipe_addstar = $ipprc->reduction($reduction, 'ADDSTAR'); # Recipe to use 85 102 &my_die("Unrecognised ADDSTAR recipe", $cam_id, $PS_EXIT_CONFIG_ERROR) unless defined $recipe1; 86 87 # Look for programs we need88 my $missing_tools;89 my $camtool = can_run('camtool') or (warn "Can't find camtool" and $missing_tools = 1);90 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1);91 my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1);92 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);93 94 # test for addstar and psastro:95 my $psastro = can_run('psastro') or (warn "Can't find psastro" and $missing_tools = 1);96 my $addstar = can_run('addstar') or (warn "Can't find addstar" and $missing_tools = 1);97 98 if ($missing_tools) {99 warn("Can't find required tools.");100 exit($PS_EXIT_CONFIG_ERROR);101 }102 103 103 104 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files … … 272 273 273 274 if ($do_stats) { 274 my $fpaStatsReal = $ipprc->file_resolve($fpaStats);275 &my_die("Couldn't find expected output file: $fpaStats", $cam_id, $PS_EXIT_SYS_ERROR) unless -f $fpaStatsReal;276 277 # parse stats from metadata278 $command = "$ppStatsFromMetadata $fpaStatsReal - CAMERA_EXP_FPA";279 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =280 run(command => $command, verbose => $verbose);281 unless ($success) {282 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);283 &my_die("Unable to perform ppStatsFromMetadata: $error_code", $cam_id, $error_code);284 }285 foreach my $line (@$stdout_buf) {286 $cmdflags .= " $line";287 }288 chomp $cmdflags;275 my $fpaStatsReal = $ipprc->file_resolve($fpaStats); 276 &my_die("Couldn't find expected output file: $fpaStats", $cam_id, $PS_EXIT_SYS_ERROR) unless -f $fpaStatsReal; 277 278 # parse stats from metadata 279 $command = "$ppStatsFromMetadata $fpaStatsReal - CAMERA_EXP_FPA"; 280 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 281 run(command => $command, verbose => $verbose); 282 unless ($success) { 283 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 284 &my_die("Unable to perform ppStatsFromMetadata: $error_code", $cam_id, $error_code); 285 } 286 foreach my $line (@$stdout_buf) { 287 $cmdflags .= " $line"; 288 } 289 chomp $cmdflags; 289 290 } 290 291 … … 323 324 $command .= " $realFile"; 324 325 325 my $mjd_addstar_start = DateTime->now->mjd; # MJD of starting script326 my $mjd_addstar_start = DateTime->now->mjd; # MJD of starting script 326 327 327 328 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 331 332 &my_die("Unable to perform addstar: $error_code", $cam_id, $error_code); 332 333 } 333 $dtime_addstar = 86400.0*(DateTime->now->mjd - $mjd_addstar_start); # MJD of starting script334 $dtime_addstar = 86400.0*(DateTime->now->mjd - $mjd_addstar_start); # MJD of starting script 334 335 } 335 336 } -
trunk/ippScripts/scripts/chip_imfile.pl
r21371 r22430 25 25 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); 26 26 use Pod::Usage qw( pod2usage ); 27 28 # Look for programs we need 29 my $missing_tools; 30 my $chiptool = can_run('chiptool') or (warn "Can't find chiptool" and $missing_tools = 1); 31 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1); 32 my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1); 33 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1); 34 if ($missing_tools) { 35 warn("Can't find required tools."); 36 exit($PS_EXIT_CONFIG_ERROR); 37 } 27 38 28 39 # Parse the command-line arguments … … 53 64 defined $chip_id and 54 65 defined $class_id and 55 defined $chip_imfile_id and 66 defined $chip_imfile_id and 56 67 defined $uri and 57 68 defined $camera and 58 69 defined $outroot and 59 70 defined $run_state; 71 72 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 73 $SIG{__DIE__} = sub { die @_ if $^S; 74 my_die( $_[0], $exp_id, $chip_id, $class_id, $PS_EXIT_UNKNOWN_ERROR ); }; 60 75 61 76 $ipprc->define_camera($camera); … … 69 84 print STDOUT "Starting script $0 on $host\n\n"; 70 85 print STDOUT "COMMAND IS: @ARGV\n\n"; 71 }72 73 # Look for programs we need74 my $missing_tools;75 my $chiptool = can_run('chiptool') or (warn "Can't find chiptool" and $missing_tools = 1);76 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1);77 my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1);78 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);79 if ($missing_tools) {80 warn("Can't find required tools.");81 exit($PS_EXIT_CONFIG_ERROR);82 86 } 83 87 … … 132 136 $command .= " -threads $threads" if defined $threads; 133 137 $command .= " -dbname $dbname" if defined $dbname; 134 $command .= " -image_id $chip_imfile_id" if defined $chip_imfile_id;135 $command .= " -source_id $source_id" if defined $source_id;138 $command .= " -image_id $chip_imfile_id" if defined $chip_imfile_id; 139 $command .= " -source_id $source_id" if defined $source_id; 136 140 $command .= " -dumpconfig $configuration"; 137 141 $command .= " -tracedest $traceDest -log $logDest"; … … 142 146 $command .= " -threads $threads" if defined $threads; 143 147 $command .= " -dbname $dbname" if defined $dbname; 144 $command .= " -image_id $chip_imfile_id" if defined $chip_imfile_id;145 $command .= " -source_id $source_id" if defined $source_id;148 $command .= " -image_id $chip_imfile_id" if defined $chip_imfile_id; 149 $command .= " -source_id $source_id" if defined $source_id; 146 150 $command .= " -tracedest $traceDest -log $logDest"; 147 151 $command .= " -Db PPIMAGE:PHOTOM FALSE"; -
trunk/ippScripts/scripts/detrend_correct_imfile.pl
r20378 r22430 24 24 use Pod::Usage qw( pod2usage ); 25 25 26 # Look for programs we need 27 my $missing_tools; 28 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 29 my $dvoApplyCorr = can_run('dvoApplyCorr') or (warn "Can't find dvoApplyCorr" and $missing_tools = 1); 30 if ($missing_tools) { 31 warn("Can't find required tools."); 32 exit($PS_EXIT_CONFIG_ERROR); 33 } 34 26 35 my ( $det_id, $class_id, $det_type, $input_uri, $camera, $dbname, 27 36 $verbose, $no_update, $no_op, $outroot, $redirect, $corr_uri ); … … 43 52 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 44 53 pod2usage( -msg => "Required options: --det_id --class_id --det_type --input_uri --camera --outroot", 45 -exitval => 3)54 -exitval => 3) 46 55 unless defined $det_id 47 56 and defined $class_id … … 50 59 and defined $outroot 51 60 and defined $camera; 61 62 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 63 $SIG{__DIE__} = sub { die @_ if $^S; 64 my_die( $_[0], $det_id, $class_id, $PS_EXIT_UNKNOWN_ERROR ); }; 52 65 53 66 # XXX this exits with status = 0 on failure … … 60 73 } 61 74 62 # Recipes to use as a function of detrend type 63 # XXX there are no recipe options for dvoApplyCorr... 75 # Recipes to use as a function of detrend type 76 # XXX there are no recipe options for dvoApplyCorr... 64 77 # XXX in the future, we may define corrections other than the flat-field correction 65 78 # $reduction = "DETREND" unless defined $reduction; … … 69 82 # det_type is type of the CORRECTED (output) file 70 83 if ($det_type ne "FLAT") { warn ("unexpected input detrend type: correcting data of type $det_type"); } 71 72 # Look for programs we need73 my $missing_tools;74 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1);75 my $dvoApplyCorr = can_run('dvoApplyCorr') or (warn "Can't find dvoApplyCorr" and $missing_tools = 1);76 if ($missing_tools) {77 warn("Can't find required tools.");78 exit($PS_EXIT_CONFIG_ERROR);79 }80 84 81 85 &my_die("Couldn't find input file: $input_uri\n", $det_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($input_uri); … … 91 95 92 96 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 93 run(command => $command, verbose => $verbose);97 run(command => $command, verbose => $verbose); 94 98 unless ($success) { 95 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);96 &my_die("Unable to perform ppImage: $error_code", $det_id, $class_id, $error_code);99 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 100 &my_die("Unable to perform ppImage: $error_code", $det_id, $class_id, $error_code); 97 101 } 98 102 … … 111 115 unless ($no_update) { 112 116 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 113 run(command => $command, verbose => $verbose);117 run(command => $command, verbose => $verbose); 114 118 unless ($success) { 115 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);116 warn("Unable to perform dettool -addcorrectimfile: $error_code\n");117 exit($error_code);119 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 120 warn("Unable to perform dettool -addcorrectimfile: $error_code\n"); 121 exit($error_code); 118 122 } 119 123 } else { … … 124 128 { 125 129 my $msg = shift; # Warning message on die 126 my $det_id = shift; # Detrend identifier130 my $det_id = shift; # Detrend identifier 127 131 my $class_id = shift; # Class identifier 128 132 my $exit_code = shift; # Exit code to add … … 130 134 carp($msg); 131 135 if (defined $det_id and defined $class_id and not $no_update) { 132 my $command = "$dettool -addcorrectimfile";133 $command .= " -det_id $det_id";134 $command .= " -class_id $class_id";135 $command .= " -path_base $outroot";136 $command .= " -code $exit_code";137 $command .= " -dbname $dbname" if defined $dbname;136 my $command = "$dettool -addcorrectimfile"; 137 $command .= " -det_id $det_id"; 138 $command .= " -class_id $class_id"; 139 $command .= " -path_base $outroot"; 140 $command .= " -code $exit_code"; 141 $command .= " -dbname $dbname" if defined $dbname; 138 142 system ($command); 139 143 } -
trunk/ippScripts/scripts/detrend_norm_apply.pl
r19942 r22430 22 22 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); 23 23 use Pod::Usage qw( pod2usage ); 24 25 # Look for programs we need 26 my $missing_tools; 27 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 28 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1); 29 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1); 30 if ($missing_tools) { 31 warn("Can't find required tools."); 32 exit($PS_EXIT_CONFIG_ERROR); 33 } 24 34 25 35 # Parse the command-line … … 54 64 defined $outroot; 55 65 66 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 67 $SIG{__DIE__} = sub { die @_ if $^S; 68 my_die( $_[0], $det_id, $iter, $class_id, $PS_EXIT_UNKNOWN_ERROR ); }; 69 56 70 $ipprc->define_camera($camera); 57 71 58 my $logDest = $ipprc->filename("LOG.IMFILE", $outroot, $class_id) 72 my $logDest = $ipprc->filename("LOG.IMFILE", $outroot, $class_id) 59 73 or &my_die("Missing entry from camera config", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR); 60 74 $ipprc->redirect_output($logDest) if $redirect; … … 64 78 # Define which detrend types we normalise 65 79 use constant DETTYPE => { 66 'bias' => 'bias',67 'dark' => 'dark',80 'bias' => 'bias', 81 'dark' => 'dark', 68 82 'dark_premask' => 'dark', 69 'shutter' => 'shutter',83 'shutter' => 'shutter', 70 84 'flat_premask' => 'flat', 71 85 'domeflat_premask' => 'flat', … … 73 87 'flat_raw' => 'flat', 74 88 'domeflat_raw' => 'flat', 75 'skyflat_raw' => 'flat', 76 'flat' => 'flat',77 'domeflat' => 'flat',78 'skyflat' => 'flat',79 'fringe' => 'fringe',80 'mask' => 'mask',81 'darkmask' => 'mask',82 'flatmask' => 'mask',83 }; 89 'skyflat_raw' => 'flat', 90 'flat' => 'flat', 91 'domeflat' => 'flat', 92 'skyflat' => 'flat', 93 'fringe' => 'fringe', 94 'mask' => 'mask', 95 'darkmask' => 'mask', 96 'flatmask' => 'mask', 97 }; 84 98 85 99 # convert supplied detrend type to a controlled namespace 86 100 &my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $class_id, $PS_EXIT_PROG_ERROR) unless exists DETTYPE()->{lc($det_type)}; 87 101 my $det_type_real = DETTYPE()->{lc($det_type)}; 88 89 # Look for programs we need90 my $missing_tools;91 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1);92 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1);93 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);94 if ($missing_tools) {95 warn("Can't find required tools.");96 exit($PS_EXIT_CONFIG_ERROR);97 }98 102 99 103 &my_die("Couldn't find input file: $input_uri\n", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($input_uri); … … 124 128 # we cannot use ppImage to load a normalized mask : just copy it and build the jpeg images 125 129 if ($det_type_real eq 'mask') { 126 $RECIPE_PPIMAGE = 'PPIMAGE_BIN';127 my $input_real = $ipprc->file_resolve($input_uri, 0);128 my $output_real = $ipprc->file_resolve($output, 1);129 system ("cp $input_real $output_real");130 $RECIPE_PPIMAGE = 'PPIMAGE_BIN'; 131 my $input_real = $ipprc->file_resolve($input_uri, 0); 132 my $output_real = $ipprc->file_resolve($output, 1); 133 system ("cp $input_real $output_real"); 130 134 } 131 135 … … 162 166 } 163 167 foreach my $line (@$stdout_buf) { 164 $cmdflags .= " $line";168 $cmdflags .= " $line"; 165 169 } 166 170 chomp $cmdflags; … … 204 208 $command .= " -iteration $iter"; 205 209 $command .= " -class_id $class_id"; 206 $command .= " -path_base $outroot";210 $command .= " -path_base $outroot"; 207 211 $command .= " -code $exit_code"; 208 212 $command .= " -dbname $dbname" if defined $dbname; -
trunk/ippScripts/scripts/detrend_norm_calc.pl
r19374 r22430 25 25 use Pod::Usage qw( pod2usage ); 26 26 27 # Look for programs we need 28 my $missing_tools; 29 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 30 my $ppNormCalc = can_run('ppNormCalc') or (warn "Can't find ppNormCalc" and $missing_tools = 1); 31 if ($missing_tools) { 32 warn("Can't find required tools."); 33 exit($PS_EXIT_CONFIG_ERROR); 34 } 35 27 36 # Parse command-line arguments 28 37 my ($det_id, $iter, $detType, $outroot, $dbname, $verbose, $no_update, $no_op, $redirect ); 29 38 GetOptions( 30 'det_id|d=s' => \$det_id, # Detrend id31 'iteration|i=s' => \$iter, # Iteration32 'det_type|t=s' => \$detType, # Detrend type33 'outroot|w=s' => \$outroot, # output file base name34 'dbname|d=s' => \$dbname, # Database name35 'verbose' => \$verbose, # Print to stdout36 'no-update' => \$no_update, # Don't update the database?37 'no-op' => \$no_op, # Don't do operations39 'det_id|d=s' => \$det_id, # Detrend id 40 'iteration|i=s' => \$iter, # Iteration 41 'det_type|t=s' => \$detType, # Detrend type 42 'outroot|w=s' => \$outroot, # output file base name 43 'dbname|d=s' => \$dbname, # Database name 44 'verbose' => \$verbose, # Print to stdout 45 'no-update' => \$no_update, # Don't update the database? 46 'no-op' => \$no_op, # Don't do operations 38 47 'redirect-output' => \$redirect, 39 48 ) or pod2usage( 2 ); … … 41 50 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 42 51 pod2usage( -msg => "Required options --det_id --iteration --det_type --outroot", 43 -exitval => 3,44 ) unless 45 defined $det_id and 46 defined $iter and 52 -exitval => 3, 53 ) unless 54 defined $det_id and 55 defined $iter and 47 56 defined $detType and 48 57 defined $outroot; 49 58 59 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 60 $SIG{__DIE__} = sub { die @_ if $^S; 61 my_die( $_[0], $det_id, $iter, $PS_EXIT_UNKNOWN_ERROR ); }; 62 50 63 my $logfile = $outroot . ".log"; 51 64 … … 56 69 # Define which detrend types we normalise 57 70 use constant NORMALIZE => { 58 'bias' => 0,59 'dark' => 0,71 'bias' => 0, 72 'dark' => 0, 60 73 'dark_premask' => 0, 61 'shutter' => 0,74 'shutter' => 0, 62 75 'flat_premask' => 1, 63 76 'domeflat_premask' => 1, … … 66 79 'domeflat_raw' => 1, 67 80 'skyflat_raw' => 1, 68 'flat' => 1, 69 'domeflat' => 1, 70 'skyflat' => 1, 71 'fringe' => 0, 72 'mask' => 0, 73 'darkmask' => 0, 74 'flatmask' => 0, 75 }; 76 77 # Look for programs we need 78 my $missing_tools; 79 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 80 my $ppNormCalc = can_run('ppNormCalc') or (warn "Can't find ppNormCalc" and $missing_tools = 1); 81 if ($missing_tools) { 82 warn("Can't find required tools."); 83 exit($PS_EXIT_CONFIG_ERROR); 84 } 81 'flat' => 1, 82 'domeflat' => 1, 83 'skyflat' => 1, 84 'fringe' => 0, 85 'mask' => 0, 86 'darkmask' => 0, 87 'flatmask' => 0, 88 }; 85 89 86 90 &my_die("Unrecognised detrend type: $detType", $det_id, $iter, $PS_EXIT_PROG_ERROR) unless exists NORMALIZE()->{lc($detType)}; … … 89 93 90 94 # Get the list of inputs 91 my @files; # The input files95 my @files; # The input files 92 96 { 93 97 my $command = "$dettool -processedimfile"; … … 99 103 print "Running [$command]...\n" if $verbose; 100 104 if (not run(\@command, \$stdin, \$stdout, \$stderr)) { 101 &my_die("Unable to perform dettool -processedimfile on detrend $det_id/$iter: $?",102 $det_id, $iter, $PS_EXIT_SYS_ERROR);105 &my_die("Unable to perform dettool -processedimfile on detrend $det_id/$iter: $?", 106 $det_id, $iter, $PS_EXIT_SYS_ERROR); 103 107 } 104 108 print $stdout . "\n" if $verbose; 105 109 106 110 # Because of the length, need to split into individual metadatas --- it parses SO much quicker! 107 111 my @whole = split /\n/, $stdout; 108 112 my @single = (); 109 113 while ( scalar @whole > 0 ) { 110 my $value = shift @whole;111 push @single, $value;112 if ($value =~ /^\s*END\s*$/) {113 push @single, "\n";114 115 my $list = parse_md_list( $mdcParser->parse( join( "\n", @single ) ) );116 &my_die("Unable to parse output from dettool", $det_id, $iter, $PS_EXIT_PROG_ERROR) unless117 defined $list;118 push @files, @$list;119 @single = ();120 }121 } 122 } 123 124 my $norms; # MDC with normalisations114 my $value = shift @whole; 115 push @single, $value; 116 if ($value =~ /^\s*END\s*$/) { 117 push @single, "\n"; 118 119 my $list = parse_md_list( $mdcParser->parse( join( "\n", @single ) ) ); 120 &my_die("Unable to parse output from dettool", $det_id, $iter, $PS_EXIT_PROG_ERROR) unless 121 defined $list; 122 push @files, @$list; 123 @single = (); 124 } 125 } 126 } 127 128 my $norms; # MDC with normalisations 125 129 if (NORMALIZE()->{lc($detType)} and not $no_op) { 126 130 127 131 my %matrix; # Matrix of statistics as a function of exposures and classes 128 132 foreach my $file (@files) { 129 my $exp_id = $file->{'exp_id'}; # Exposure ID130 my $class_id = $file->{'class_id'}; # Class ID131 my $stat = $file->{STATISTIC()}; # Statistic of interest132 133 # Create matrix elements134 $matrix{$exp_id} = {} if not defined $matrix{$exp_id};135 $matrix{$exp_id}->{$class_id} = $stat;136 } 137 133 my $exp_id = $file->{'exp_id'}; # Exposure ID 134 my $class_id = $file->{'class_id'}; # Class ID 135 my $stat = $file->{STATISTIC()}; # Statistic of interest 136 137 # Create matrix elements 138 $matrix{$exp_id} = {} if not defined $matrix{$exp_id}; 139 $matrix{$exp_id}->{$class_id} = $stat; 140 } 141 138 142 # Generate the input for ppNormCalc 139 my $normData; # Normalisation data143 my $normData; # Normalisation data 140 144 foreach my $exp_id (keys %matrix) { 141 $normData .= "$exp_id\tMETADATA\n";142 foreach my $class_id (keys %{$matrix{$exp_id}}) {143 $normData .= "\t" . $class_id . "\tF32\t" . $matrix{$exp_id}->{$class_id} . "\n";144 }145 $normData .= "END\n\n";145 $normData .= "$exp_id\tMETADATA\n"; 146 foreach my $class_id (keys %{$matrix{$exp_id}}) { 147 $normData .= "\t" . $class_id . "\tF32\t" . $matrix{$exp_id}->{$class_id} . "\n"; 148 } 149 $normData .= "END\n\n"; 146 150 } 147 151 148 152 # Run ppNormCalc 149 153 { 150 my ( $stdout, $stderr ); # Buffers for running program151 my @command = split /\s+/, $ppNormCalc;152 print "Running [$ppNormCalc]...\n" if $verbose;153 if (not run(\@command, \$normData, \$stdout, \$stderr)) {154 &my_die("Unable to perform ppNormCalc: $?", $det_id, $iter, $PS_EXIT_SYS_ERROR);155 }156 print $stdout . "\n" if $verbose;157 158 # Parse the output159 $norms = $mdcParser->parse($stdout);160 &my_die("Unable to parse metadata config doc", $det_id, $iter, $PS_EXIT_PROG_ERROR) unless $norms;154 my ( $stdout, $stderr ); # Buffers for running program 155 my @command = split /\s+/, $ppNormCalc; 156 print "Running [$ppNormCalc]...\n" if $verbose; 157 if (not run(\@command, \$normData, \$stdout, \$stderr)) { 158 &my_die("Unable to perform ppNormCalc: $?", $det_id, $iter, $PS_EXIT_SYS_ERROR); 159 } 160 print $stdout . "\n" if $verbose; 161 162 # Parse the output 163 $norms = $mdcParser->parse($stdout); 164 &my_die("Unable to parse metadata config doc", $det_id, $iter, $PS_EXIT_PROG_ERROR) unless $norms; 161 165 } 162 166 163 167 } else { 164 168 # It's something that doesn't need normalisation --- just push in a normalisation of 1 165 my %classes; # List of unique classes169 my %classes; # List of unique classes 166 170 foreach my $file (@files) { 167 my $class_id = $file->{'class_id'}; # Class Id168 $classes{$class_id} = 1;169 } 170 171 my $class_id = $file->{'class_id'}; # Class Id 172 $classes{$class_id} = 1; 173 } 174 171 175 foreach my $class_id (keys %classes) { 172 my %mdValue;# Metadata value for this class id173 $mdValue{name} = $class_id;174 $mdValue{value} = 1.0;175 push @$norms, \%mdValue;176 my %mdValue; # Metadata value for this class id 177 $mdValue{name} = $class_id; 178 $mdValue{value} = 1.0; 179 push @$norms, \%mdValue; 176 180 } 177 181 } … … 186 190 foreach my $normItem (@$norms) { 187 191 188 my $className = $normItem->{name}; # Name of component189 my $normalisation = $normItem->{value}; # Normalisation for component190 191 if ($normalisation == 0.0 or lc($normalisation) eq 'nan') {192 warn("Class $className has bad normalisation: $normalisation");193 exit($PS_EXIT_SYS_ERROR);194 }195 196 my $command = $commandBase;197 $command .= " -class_id $className";198 $command .= " -norm $normalisation";199 200 my @command = split /\s+/, $command;201 202 my ( $stdin, $stdout, $stderr ); # Buffers for running program203 print "Running [$command]...\n" if $verbose;204 if (not run \@command, \$stdin, \$stdout, \$stderr) {205 warn("Unable to perform dettool -addnormstat for $className: $?");206 exit($PS_EXIT_SYS_ERROR);207 }208 print $stdout . "\n" if $verbose;192 my $className = $normItem->{name}; # Name of component 193 my $normalisation = $normItem->{value}; # Normalisation for component 194 195 if ($normalisation == 0.0 or lc($normalisation) eq 'nan') { 196 warn("Class $className has bad normalisation: $normalisation"); 197 exit($PS_EXIT_SYS_ERROR); 198 } 199 200 my $command = $commandBase; 201 $command .= " -class_id $className"; 202 $command .= " -norm $normalisation"; 203 204 my @command = split /\s+/, $command; 205 206 my ( $stdin, $stdout, $stderr ); # Buffers for running program 207 print "Running [$command]...\n" if $verbose; 208 if (not run \@command, \$stdin, \$stdout, \$stderr) { 209 warn("Unable to perform dettool -addnormstat for $className: $?"); 210 exit($PS_EXIT_SYS_ERROR); 211 } 212 print $stdout . "\n" if $verbose; 209 213 } 210 214 } else { … … 212 216 foreach my $normItem (@$norms) { 213 217 214 my $className = $normItem->{name}; # Name of component215 my $normalisation = $normItem->{value}; # Normalisation for component216 217 if ($normalisation == 0.0 or lc($normalisation) eq 'nan') {218 warn("Class $className has bad normalisation: $normalisation");219 exit($PS_EXIT_SYS_ERROR);220 }221 print "$className : $normalisation\n";218 my $className = $normItem->{name}; # Name of component 219 my $normalisation = $normItem->{value}; # Normalisation for component 220 221 if ($normalisation == 0.0 or lc($normalisation) eq 'nan') { 222 warn("Class $className has bad normalisation: $normalisation"); 223 exit($PS_EXIT_SYS_ERROR); 224 } 225 print "$className : $normalisation\n"; 222 226 } 223 227 } … … 225 229 sub my_die 226 230 { 227 my $msg = shift; # Warning message on die228 my $det_id = shift; # Detrend identifier229 my $iter = shift; # Iteration230 my $exit_code = shift; # Exit code to add231 my $msg = shift; # Warning message on die 232 my $det_id = shift; # Detrend identifier 233 my $iter = shift; # Iteration 234 my $exit_code = shift; # Exit code to add 231 235 232 236 carp($msg); 233 237 if (defined $det_id and defined $iter and not $no_update) { 234 my $command = "$dettool -addnormalizedstat";235 $command .= " -det_id $det_id";236 $command .= " -iteration $iter";237 # XXX EAM : we should add this to the db : $command .= " -path_base $outroot";238 $command .= " -code $exit_code";239 $command .= " -dbname $dbname" if defined $dbname;238 my $command = "$dettool -addnormalizedstat"; 239 $command .= " -det_id $det_id"; 240 $command .= " -iteration $iter"; 241 # XXX EAM : we should add this to the db : $command .= " -path_base $outroot"; 242 $command .= " -code $exit_code"; 243 $command .= " -dbname $dbname" if defined $dbname; 240 244 system ($command); 241 245 } -
trunk/ippScripts/scripts/detrend_norm_exp.pl
r20120 r22430 24 24 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); 25 25 use Pod::Usage qw( pod2usage ); 26 27 # Look for programs we need 28 my $missing_tools; 29 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 30 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1); 31 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1); 32 if ($missing_tools) { 33 warn("Can't find required tools."); 34 exit($PS_EXIT_CONFIG_ERROR); 35 } 26 36 27 37 my ($det_id, $iter, $det_type, $camera, $outroot, $dbname, $reduction, $verbose, $no_update, $no_op, $redirect, $save_temps); … … 50 60 defined $outroot; 51 61 62 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 63 $SIG{__DIE__} = sub { die @_ if $^S; 64 my_die( $_[0], $det_id, $iter, $PS_EXIT_UNKNOWN_ERROR ); }; 65 52 66 my $logfile = $outroot . ".log"; 53 67 … … 60 74 my $recipe = $ipprc->reduction($reduction, uc($det_type) . '_JPEG_IMAGE'); 61 75 &my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $PS_EXIT_PROG_ERROR) unless defined $recipe; 62 63 # Look for programs we need64 my $missing_tools;65 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1);66 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1);67 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);68 if ($missing_tools) {69 warn("Can't find required tools.");70 exit($PS_EXIT_CONFIG_ERROR);71 }72 76 73 77 # Get list of component files -
trunk/ippScripts/scripts/detrend_process_exp.pl
r20120 r22430 24 24 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); 25 25 use Pod::Usage qw( pod2usage ); 26 27 # Look for programs we need 28 my $missing_tools; 29 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 30 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1); 31 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1); 32 if ($missing_tools) { 33 warn("Can't find required tools."); 34 exit($PS_EXIT_CONFIG_ERROR); 35 } 26 36 27 37 my ( $det_id, $exp_id, $det_type, $exp_tag, $camera, $outroot, $dbname, $reduction, $verbose, $no_update, … … 53 63 defined $outroot; 54 64 65 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 66 $SIG{__DIE__} = sub { die @_ if $^S; 67 my_die( $_[0], $det_id, $exp_id, $PS_EXIT_UNKNOWN_ERROR ); }; 68 55 69 $ipprc->define_camera($camera); 56 70 … … 66 80 my $recipe = $ipprc->reduction($reduction, uc($det_type) . '_JPEG_IMAGE'); # Recipe to use 67 81 &my_die("Unrecognised detrend type: $det_type", $det_id, $exp_id, $PS_EXIT_PROG_ERROR) unless defined $recipe; 68 69 # Look for programs we need70 my $missing_tools;71 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1);72 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1);73 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);74 if ($missing_tools) {75 warn("Can't find required tools.");76 exit($PS_EXIT_CONFIG_ERROR);77 }78 82 79 83 my $cmdflags; -
trunk/ippScripts/scripts/detrend_process_imfile.pl
r19942 r22430 22 22 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); 23 23 use Pod::Usage qw( pod2usage ); 24 25 # Look for programs we need 26 my $missing_tools; 27 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 28 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1); 29 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1); 30 if ($missing_tools) { 31 warn("Can't find required tools."); 32 exit($PS_EXIT_CONFIG_ERROR); 33 } 24 34 25 35 my ( $det_id, $exp_id, $class_id, $det_type, $exp_tag, $input_uri, $camera, $outroot, $dbname, $reduction, … … 55 65 defined $outroot; 56 66 67 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 68 $SIG{__DIE__} = sub { die @_ if $^S; 69 my_die( $_[0], $det_id, $exp_id, $class_id, $PS_EXIT_UNKNOWN_ERROR ); }; 70 57 71 # XXX this exits with status = 0 on failure 58 72 $ipprc->define_camera($camera); … … 66 80 my $ppimage_recipe = $ipprc->reduction($reduction, uc($det_type) . '_PROCESS'); # Recipe name for ppImage 67 81 my $jpeg_recipe = $ipprc->reduction($reduction, uc($det_type) . '_JPEG_IMAGE'); # Recipe name for JPEG 68 69 # Look for programs we need70 my $missing_tools;71 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1);72 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1);73 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);74 if ($missing_tools) {75 warn("Can't find required tools.");76 exit($PS_EXIT_CONFIG_ERROR);77 }78 82 79 83 &my_die("Couldn't find input file: $input_uri\n", $det_id, $exp_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($input_uri); … … 128 132 } 129 133 foreach my $line (@$stdout_buf) { 130 $cmdflags .= " $line";134 $cmdflags .= " $line"; 131 135 } 132 136 chomp $cmdflags; -
trunk/ippScripts/scripts/detrend_reject_exp.pl
r18562 r22430 27 27 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); 28 28 use Pod::Usage qw( pod2usage ); 29 30 # Look for programs we need 31 my $missing_tools; 32 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 33 if ($missing_tools) { 34 warn("Can't find required tools."); 35 exit($PS_EXIT_CONFIG_ERROR); 36 } 29 37 30 38 my ($det_id, $iter, $det_type, $camera, $outroot, $filter, $dbname, $verbose, $no_update, $no_op, $redirect); … … 52 60 defined $outroot; 53 61 62 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 63 $SIG{__DIE__} = sub { die @_ if $^S; 64 my_die( $_[0], $det_id, $iter, $PS_EXIT_UNKNOWN_ERROR ); }; 65 54 66 # check for existing directory, generate if needed 55 67 $ipprc->outroot_prepare($outroot); … … 89 101 my $rejstats = PS::IPP::Metadata::Stats->new($REJSTATS); # Stats parser 90 102 91 # Look for programs we need92 my $missing_tools;93 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1);94 if ($missing_tools) {95 warn("Can't find required tools.");96 exit($PS_EXIT_CONFIG_ERROR);97 }98 99 103 # Get list of component files 100 104 my ($exposures, $command, $success, $error_code, $full_buf, $stdout_buf, $stderr_buf); … … 345 349 $command .= " -det_id $det_id"; 346 350 $command .= " -iteration $iter"; 347 # XXX EAM : we should add this to the db : $command .= " -path_base $outroot";351 # XXX EAM : we should add this to the db : $command .= " -path_base $outroot"; 348 352 $command .= " -code $exit_code"; 349 353 $command .= " -dbname $dbname" if defined $dbname; -
trunk/ippScripts/scripts/detrend_resid_exp.pl
r20120 r22430 35 35 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); # option parsing 36 36 use Pod::Usage qw( pod2usage ); 37 38 # Look for programs we need 39 my $missing_tools; 40 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 41 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1); 42 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1); 43 if ($missing_tools) { 44 warn("Can't find required tools."); 45 exit($PS_EXIT_CONFIG_ERROR); 46 } 37 47 38 48 # parse the command-line options … … 69 79 defined $outroot; 70 80 81 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 82 $SIG{__DIE__} = sub { die @_ if $^S; 83 my_die( $_[0], $det_id, $iter, $exp_id, $PS_EXIT_UNKNOWN_ERROR ); }; 84 71 85 # load IPP config information for the specified camera 72 86 $ipprc->define_camera($camera); … … 81 95 my $recipe = $ipprc->reduction($reduction, uc($det_type) . '_JPEG_RESID'); # Recipe to use 82 96 &my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $PS_EXIT_PROG_ERROR) unless defined $recipe; 83 84 # Look for programs we need85 my $missing_tools;86 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1);87 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1);88 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);89 if ($missing_tools) {90 warn("Can't find required tools.");91 exit($PS_EXIT_CONFIG_ERROR);92 }93 97 94 98 # Get list of imfile files -
trunk/ippScripts/scripts/detrend_resid_imfile.pl
r19781 r22430 22 22 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); 23 23 use Pod::Usage qw( pod2usage ); 24 25 # Look for programs we need 26 my $missing_tools; 27 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 28 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1); 29 my $ppStats = can_run('ppStats') or (warn "Can't find ppStats" and $missing_tools = 1); 30 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1); 31 if ($missing_tools) { 32 warn("Can't find required tools."); 33 exit($PS_EXIT_CONFIG_ERROR); 34 } 24 35 25 36 my ( $det_id, $iter, $ref_det_id, $ref_iter, $exp_id, $exp_tag, $class_id, $det_type, $detrend, $input_uri, $camera, $mode, $outroot, … … 65 76 defined $detrend; 66 77 78 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 79 $SIG{__DIE__} = sub { die @_ if $^S; 80 my_die( $_[0], $det_id, $iter, $exp_id, $class_id, $PS_EXIT_UNKNOWN_ERROR ); }; 81 67 82 $ipprc->define_camera($camera); 68 83 my $logDest = $ipprc->filename("LOG.IMFILE", $outroot, $class_id); … … 109 124 }; 110 125 111 # Look for programs we need112 my $missing_tools;113 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1);114 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1);115 my $ppStats = can_run('ppStats') or (warn "Can't find ppStats" and $missing_tools = 1);116 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);117 if ($missing_tools) {118 warn("Can't find required tools.");119 exit($PS_EXIT_CONFIG_ERROR);120 }121 122 126 # outroot examples (HOST components must be set) 123 127 # file://data/ipp004.0/gpc1/20080130 … … 179 183 } 180 184 foreach my $line (@$stdout_buf) { 181 $cmdflags .= " $line";185 $cmdflags .= " $line"; 182 186 } 183 187 chomp $cmdflags; … … 192 196 } 193 197 foreach my $line (@$stdout_buf) { 194 $cmdflags .= " $line";198 $cmdflags .= " $line"; 195 199 } 196 200 chomp $cmdflags; -
trunk/ippScripts/scripts/detrend_stack.pl
r21371 r22430 23 23 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); 24 24 use Pod::Usage qw( pod2usage ); 25 26 # Look for programs we need 27 my $missing_tools; 28 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 29 my $ppMerge = can_run('ppMerge') or (warn "Can't find ppMerge" and $missing_tools = 1); 30 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1); 31 if ($missing_tools) { 32 warn("Can't find required tools."); 33 exit($PS_EXIT_CONFIG_ERROR); 34 } 25 35 26 36 my ( $det_id, $iter, $class_id, $det_type, $camera, $outroot, $dbname, $reduction, $threads, $verbose, $save_temps, … … 59 69 or &my_die("Missing entry in file rules", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR); 60 70 71 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 72 $SIG{__DIE__} = sub { die @_ if $^S; 73 my_die( $_[0], $det_id, $iter, $class_id, $PS_EXIT_UNKNOWN_ERROR ); }; 74 61 75 # optionally redirect the outputs from this script to LOG.IMFILE 62 76 $ipprc->redirect_output($logDest) if $redirect; … … 65 79 $reduction = "DETREND" unless defined $reduction; 66 80 my $recipe = $ipprc->reduction($reduction, $det_type . '_STACK'); # Recipe name to use 67 68 # Look for programs we need69 my $missing_tools;70 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1);71 my $ppMerge = can_run('ppMerge') or (warn "Can't find ppMerge" and $missing_tools = 1);72 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);73 if ($missing_tools) {74 warn("Can't find required tools.");75 exit($PS_EXIT_CONFIG_ERROR);76 }77 81 78 82 # The output file rule name depends on the detrend type … … 219 223 } 220 224 foreach my $line (@$stdout_buf) { 221 $cmdflags .= " $line";225 $cmdflags .= " $line"; 222 226 } 223 227 chomp $cmdflags; … … 261 265 $command .= " -iteration $iter"; 262 266 $command .= " -class_id $class_id"; 263 # XXX EAM : we should add this to the db : $command .= " -path_base $outroot";267 # XXX EAM : we should add this to the db : $command .= " -path_base $outroot"; 264 268 $command .= " -code $exit_code"; 265 269 $command .= " -dbname $dbname" if defined $dbname; -
trunk/ippScripts/scripts/diff_skycell.pl
r21395 r22430 27 27 use Pod::Usage qw( pod2usage ); 28 28 29 # Look for programs we need 30 my $missing_tools; 31 my $difftool = can_run('difftool') or (warn "Can't find difftool" and $missing_tools = 1); 32 my $ppSub = can_run('ppSub') or (warn "Can't find ppSub" and $missing_tools = 1); 33 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1); 34 if ($missing_tools) { 35 warn("Can't find required tools."); 36 exit($PS_EXIT_CONFIG_ERROR); 37 } 38 29 39 my ($diff_id, $dbname, $threads, $outroot, $reduction, $verbose, $no_update, $no_op, $redirect); 30 40 my ($skycell_id, $diff_skyfile_id); 31 41 GetOptions( 32 42 'diff_id=s' => \$diff_id, # Diff identifier 33 'skycell_id=s' => \$skycell_id, # Diffidentifier43 'skycell_id=s' => \$skycell_id, # Skycell identifier 34 44 'diff_skyfile_id=s' => \$diff_skyfile_id, # Diff identifier 35 45 'dbname|d=s' => \$dbname, # Database name … … 52 62 and defined $outroot; 53 63 64 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 65 $SIG{__DIE__} = sub { die @_ if $^S; 66 my_die( $_[0], $diff_id, $skycell_id, $PS_EXIT_UNKNOWN_ERROR ); }; 67 54 68 # XXX camera is not known here; cannot use filerules... 55 69 # my $logDest = $ipprc->filename("LOG.EXP", $outroot); 56 57 70 my $logDest = "$outroot.log"; 58 71 $ipprc->redirect_output($logDest) if $redirect; 59 72 60 73 my $source_id = $ipprc->source_id($dbname, $PS_TABLE_ID_DIFF); 61 62 # Look for programs we need63 my $missing_tools;64 my $difftool = can_run('difftool') or (warn "Can't find difftool" and $missing_tools = 1);65 my $ppSub = can_run('ppSub') or (warn "Can't find ppSub" and $missing_tools = 1);66 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);67 if ($missing_tools) {68 warn("Can't find required tools.");69 exit($PS_EXIT_CONFIG_ERROR);70 }71 74 72 75 # Get list of components for subtraction … … 80 83 unless ($success) { 81 84 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 82 &my_die("Unable to perform difftool -inputskyfile: $error_code", $diff_id, $ error_code);85 &my_die("Unable to perform difftool -inputskyfile: $error_code", $diff_id, $skycell_id, $error_code); 83 86 } 84 87 85 88 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 86 &my_die("Unable to parse metadata config doc", $diff_id, $ PS_EXIT_PROG_ERROR);89 &my_die("Unable to parse metadata config doc", $diff_id, $skycell_id, $PS_EXIT_PROG_ERROR); 87 90 $files = parse_md_list($metadata) or 88 &my_die("Unable to parse metadata list", $diff_id, $PS_EXIT_PROG_ERROR); 89 } 90 91 &my_die("Subtraction list does not contain exactly two elements", $diff_id, $PS_EXIT_SYS_ERROR) unless 92 scalar @$files == 2; 91 &my_die("Unable to parse metadata list", $diff_id, $skycell_id, $PS_EXIT_PROG_ERROR); 92 } 93 94 &my_die("Subtraction list does not contain exactly two elements", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless scalar @$files == 2; 93 95 94 96 # Identify the input and the template … … 123 125 } 124 126 if (defined $tess_id) { 125 &my_die("Tesselation identifiers don't match", $diff_id, $ PS_EXIT_SYS_ERROR) unless127 &my_die("Tesselation identifiers don't match", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless 126 128 $file->{tess_id} eq $tess_id; 127 129 } else { … … 129 131 } 130 132 if (defined $skycell_id) { 131 &my_die("Skycell identifiers don't match", $diff_id, $ PS_EXIT_SYS_ERROR) unless133 &my_die("Skycell identifiers don't match", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless 132 134 $file->{skycell_id} eq $skycell_id; 133 135 } else { … … 135 137 } 136 138 if (defined $camera) { 137 &my_die("Cameras don't match", $diff_id, $ PS_EXIT_SYS_ERROR) unless $file->{camera} eq $camera;139 &my_die("Cameras don't match", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $file->{camera} eq $camera; 138 140 } else { 139 141 $camera = $file->{camera}; … … 142 144 } 143 145 144 &my_die("Unable to identify template", $diff_id, $ PS_EXIT_SYS_ERROR) unless defined $template;145 &my_die("Unable to identify input", $diff_id, $ PS_EXIT_SYS_ERROR) unless defined $input;146 &my_die("Unable to identify camera", $diff_id, $ PS_EXIT_SYS_ERROR) unless defined $camera;146 &my_die("Unable to identify template", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless defined $template; 147 &my_die("Unable to identify input", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless defined $input; 148 &my_die("Unable to identify camera", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless defined $camera; 147 149 $ipprc->define_camera($camera); 148 150 … … 152 154 my $recipe_psphot = $ipprc->reduction($reduction, 'DIFF_PSPHOT'); # Recipe to use for psphot 153 155 unless ($recipe_ppSub and $recipe_psphot) { 154 &my_die("Couldn't find selected reduction for DIFF_PPSUB and DIFF_PSPHOT: $reduction\n", $diff_id, $ PS_EXIT_CONFIG_ERROR);156 &my_die("Couldn't find selected reduction for DIFF_PPSUB and DIFF_PSPHOT: $reduction\n", $diff_id, $skycell_id, $PS_EXIT_CONFIG_ERROR); 155 157 } 156 158 … … 177 179 print "templateSources: $templateSources\n"; 178 180 179 &my_die("Couldn't find input: $template", $diff_id, $ PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($template);180 &my_die("Couldn't find input: $templateMask", $diff_id, $ PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($templateMask);181 &my_die("Couldn't find input: $templateVariance", $diff_id, $ PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($templateVariance);182 &my_die("Couldn't find input: $input", $diff_id, $ PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($input);183 &my_die("Couldn't find input: $inputMask", $diff_id, $ PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inputMask);184 &my_die("Couldn't find input: $inputVariance", $diff_id, $ PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inputVariance);185 &my_die("Couldn't find input: $templateSources", $diff_id, $ PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($templateSources);181 &my_die("Couldn't find input: $template", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($template); 182 &my_die("Couldn't find input: $templateMask", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($templateMask); 183 &my_die("Couldn't find input: $templateVariance", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($templateVariance); 184 &my_die("Couldn't find input: $input", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($input); 185 &my_die("Couldn't find input: $inputMask", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inputMask); 186 &my_die("Couldn't find input: $inputVariance", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($inputVariance); 187 &my_die("Couldn't find input: $templateSources", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($templateSources); 186 188 187 189 # Get the output filenames … … 223 225 unless ($success) { 224 226 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 225 &my_die("Unable to perform ppSub: $error_code", $diff_id, $ error_code);226 } 227 &my_die("Couldn't find expected output file: $outputName", $diff_id, $ PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputName);228 &my_die("Couldn't find expected output file: $outputMask", $diff_id, $ PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputMask);229 &my_die("Couldn't find expected output file: $outputVariance", $diff_id, $ PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputVariance);230 # &my_die("Couldn't find expected output file: $outputSources", $diff_id, $ PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputSources);231 # &my_die("Couldn't find expected output file: $bin1Name", $diff_id, $ PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($bin1Name);232 # &my_die("Couldn't find expected output file: $bin2Name", $diff_id, $ PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($bin2Name);227 &my_die("Unable to perform ppSub: $error_code", $diff_id, $skycell_id, $error_code); 228 } 229 &my_die("Couldn't find expected output file: $outputName", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputName); 230 &my_die("Couldn't find expected output file: $outputMask", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputMask); 231 &my_die("Couldn't find expected output file: $outputVariance", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputVariance); 232 # &my_die("Couldn't find expected output file: $outputSources", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputSources); 233 # &my_die("Couldn't find expected output file: $bin1Name", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($bin1Name); 234 # &my_die("Couldn't find expected output file: $bin2Name", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($bin2Name); 233 235 234 236 my $outputStatsReal = $ipprc->file_resolve($outputStats); 235 &my_die("Couldn't find expected output file: $outputStats", $diff_id, $ PS_EXIT_SYS_ERROR) unless -f $outputStatsReal;237 &my_die("Couldn't find expected output file: $outputStats", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless -f $outputStatsReal; 236 238 237 239 # measure chip stats … … 241 243 unless ($success) { 242 244 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 243 &my_die("Unable to perform ppStatsFromMetadata: $error_code", $diff_id, $ error_code);245 &my_die("Unable to perform ppStatsFromMetadata: $error_code", $diff_id, $skycell_id, $error_code); 244 246 } 245 247 foreach my $line (@$stdout_buf) { … … 263 265 unless ($success) { 264 266 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 265 &my_die("Unable to perform difftool -adddiffskyfile: $error_code", $diff_id, $ error_code);267 &my_die("Unable to perform difftool -adddiffskyfile: $error_code", $diff_id, $skycell_id, $error_code); 266 268 } 267 269 } … … 273 275 my $msg = shift; # Warning message on die 274 276 my $diff_id = shift; # Diff identifier 277 my $skycell_id = shift; # Skycell identifier 275 278 my $exit_code = shift; # Exit code to add 276 279 277 280 warn($msg); 278 if (defined $diff_id and not $no_update) {281 if (defined $diff_id and defined $skycell_id and not $no_update) { 279 282 my $command = "$difftool -adddiffskyfile -diff_id $diff_id -skycell_id $skycell_id -code $exit_code"; 280 283 $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400)); -
trunk/ippScripts/scripts/fake_imfile.pl
r21371 r22430 41 41 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); 42 42 use Pod::Usage qw( pod2usage ); 43 44 # Look for programs we need 45 my $missing_tools; 46 my $faketool = can_run('faketool') or (warn "Can't find faketool" and $missing_tools = 1); 47 my $ppSim = can_run('ppSim') or (warn "Can't find ppSim" and $missing_tools = 1); 48 my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1); 49 if ($missing_tools) { 50 warn("Can't find required tools."); 51 exit($PS_EXIT_CONFIG_ERROR); 52 } 43 53 44 54 # Parse the command-line arguments … … 72 82 defined $outroot; 73 83 84 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 85 $SIG{__DIE__} = sub { die @_ if $^S; 86 my_die( $_[0], $exp_id, $fake_id, $class_id, $PS_EXIT_UNKNOWN_ERROR ); }; 87 74 88 $ipprc->define_camera($camera); 75 89 … … 83 97 unless ($recipe) { 84 98 &my_die("Couldn't find selected reduction for FAKE: $reduction\n", $exp_id, $fake_id, $class_id, $PS_EXIT_CONFIG_ERROR); 85 }86 87 # Look for programs we need88 my $missing_tools;89 my $faketool = can_run('faketool') or (warn "Can't find faketool" and $missing_tools = 1);90 my $ppSim = can_run('ppSim') or (warn "Can't find ppSim" and $missing_tools = 1);91 my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1);92 if ($missing_tools) {93 warn("Can't find required tools.");94 exit($PS_EXIT_CONFIG_ERROR);95 99 } 96 100 -
trunk/ippScripts/scripts/magic_destreak.pl
r21435 r22430 26 26 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); 27 27 use Pod::Usage qw( pod2usage ); 28 29 # Look for programs we need 30 my $missing_tools; 31 my $magicdstool = can_run('magicdstool') or (warn "Can't find magicdstool" and $missing_tools = 1); 32 my $streaksremove = can_run('streaksremove') or (warn "Can't find streaksremove" and $missing_tools = 1); 33 if ($missing_tools) { 34 warn("Can't find required tools."); 35 exit($PS_EXIT_CONFIG_ERROR); 36 } 28 37 29 38 # Parse the command-line arguments … … 66 75 defined $component and 67 76 defined $outroot; 68 77 78 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 79 $SIG{__DIE__} = sub { die @_ if $^S; 80 my_die( $_[0], $magic_ds_id, $component, $PS_EXIT_UNKNOWN_ERROR ); }; 81 69 82 70 83 my ($skycell_args, $class_id, $skycell_id); … … 87 100 88 101 89 # Look for programs we need90 my $missing_tools;91 my $magicdstool = can_run('magicdstool') or (warn "Can't find magicdstool" and $missing_tools = 1);92 my $streaksremove = can_run('streaksremove') or (warn "Can't find streaksremove" and $missing_tools = 1);93 if ($missing_tools) {94 warn("Can't find required tools.");95 exit($PS_EXIT_CONFIG_ERROR);96 }97 98 102 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 99 103 … … 128 132 if (! -e $outroot ) { 129 133 my $code = system "mkdir -p $outroot"; 130 &my_die("cannot create output directory $outroot", $magic_ds_id, $component, 134 &my_die("cannot create output directory $outroot", $magic_ds_id, $component, 131 135 $code >> 8) if $code; 132 136 } … … 143 147 if (! -e $recoveryroot ) { 144 148 my $code = system "mkdir -p $recoveryroot"; 145 &my_die("cannot create output directory $outroot", $magic_ds_id, $component, 149 &my_die("cannot create output directory $outroot", $magic_ds_id, $component, 146 150 $code >> 8) if $code; 147 151 } … … 151 155 152 156 # get skycell list if needed 153 my ($sfh, $skycell_list); 157 my ($sfh, $skycell_list); 154 158 if ($skycell_args) { 155 159 my $command = "$magicdstool -magic_ds_id $magic_ds_id -getskycells $skycell_args"; -
trunk/ippScripts/scripts/magic_mask.pl
r20673 r22430 28 28 use Pod::Usage qw( pod2usage ); 29 29 30 # Look for programs we need 31 my $missing_tools; 32 my $magictool = can_run('magictool') or (warn "Can't find magictool" and $missing_tools = 1); 33 my $streaksremove = can_run('streaksremove') or (warn "Can't find streaksremove" and $missing_tools = 1); 34 if ($missing_tools) { 35 warn("Can't find required tools."); 36 exit($PS_EXIT_CONFIG_ERROR); 37 } 38 30 39 # Parse the command-line arguments 31 40 my ($magic_id, $camera, $dbname, $outroot, $save_temps, $verbose, $no_update, $no_op, $logfile); … … 49 58 defined $outroot; 50 59 60 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 61 $SIG{__DIE__} = sub { die @_ if $^S; 62 my_die( $_[0], $magic_id, $PS_EXIT_UNKNOWN_ERROR ); }; 63 51 64 $ipprc->define_camera($camera); 52 65 53 66 $ipprc->redirect_output($logfile) if $logfile; 54 55 # Look for programs we need56 my $missing_tools;57 my $magictool = can_run('magictool') or (warn "Can't find magictool" and $missing_tools = 1);58 my $streaksremove = can_run('streaksremove') or (warn "Can't find streaksremove" and $missing_tools = 1);59 if ($missing_tools) {60 warn("Can't find required tools.");61 exit($PS_EXIT_CONFIG_ERROR);62 }63 67 64 68 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files … … 85 89 ### Do the heavy lifting 86 90 { 87 my $command = "$streaks --streaks"; # Command to execute91 my $command = "$streaksremove --streaks"; # Command to execute 88 92 my @basenames; # List of base names 89 93 -
trunk/ippScripts/scripts/magic_process.pl
r21371 r22430 28 28 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); 29 29 use Pod::Usage qw( pod2usage ); 30 31 # Look for programs we need 32 my $missing_tools; 33 my $magictool = can_run('magictool') or (warn "Can't find magictool" and $missing_tools = 1); 34 my $removestreaks = can_run('RemoveStreaks') or (warn "Can't find RemoveStreaks" and $missing_tools = 1); 35 if ($missing_tools) { 36 warn("Can't find required tools."); 37 exit($PS_EXIT_CONFIG_ERROR); 38 } 30 39 31 40 # Parse the command-line arguments … … 53 62 defined $outroot; 54 63 64 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 65 $SIG{__DIE__} = sub { die @_ if $^S; 66 my_die( $_[0], $magic_id, $node, $PS_EXIT_UNKNOWN_ERROR ); }; 67 55 68 $ipprc->define_camera($camera); 56 69 … … 66 79 # resolve any path:// or file:// in outroot 67 80 $outroot = $ipprc->file_resolve($outroot); 68 81 69 82 $ipprc->redirect_output($logfile) if $logfile; 70 71 # Look for programs we need72 my $missing_tools;73 my $magictool = can_run('magictool') or (warn "Can't find magictool" and $missing_tools = 1);74 my $removestreaks = can_run('RemoveStreaks') or (warn "Can't find RemoveStreaks" and $missing_tools = 1);75 if ($missing_tools) {76 warn("Can't find required tools.");77 exit($PS_EXIT_CONFIG_ERROR);78 }79 83 80 84 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files … … 145 149 # this causes major file pollution, but avoids multi-level queries 146 150 # at higher level nodes. 147 151 148 152 my ($in_fh, $input_list) = open_list_file($outroot, "input.list"); 149 153 print $in_fh "$outroot\n"; … … 252 256 253 257 my $fh; 254 open $fh, "<$resolved" or 258 open $fh, "<$resolved" or 255 259 &my_die("failed to open streaks file $streaks_file", $magic_id, $node, $PS_EXIT_UNKNOWN_ERROR); 256 260 # the first line in the streaks file contains the number of streaks found … … 259 263 close $fh; 260 264 print "$num_streaks streaks found on magicRun $magic_id\n" if $verbose; 261 265 262 266 my $command = "$magictool -addmask"; 263 267 $command .= " -magic_id $magic_id"; -
trunk/ippScripts/scripts/magic_tree.pl
r20762 r22430 31 31 32 32 use constant MAX_FIELDS => 4; # Maximum number of fields to be in a node 33 34 # Look for programs we need 35 my $missing_tools; 36 my $magictool = can_run('magictool') or (warn "Can't find magictool" and $missing_tools = 1); 37 my $warptool = can_run('warptool') or (warn "Can't find warptool" and $missing_tools = 1); 38 if ($missing_tools) { 39 warn("Can't find required tools."); 40 exit($PS_EXIT_CONFIG_ERROR); 41 } 33 42 34 43 # Parse the command-line arguments … … 61 70 defined $outroot; 62 71 72 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 73 $SIG{__DIE__} = sub { die @_ if $^S; 74 my_die( $_[0], $magic_id, $PS_EXIT_UNKNOWN_ERROR ); }; 75 63 76 $ipprc->define_camera($camera); 64 77 65 78 $ipprc->redirect_output($logfile) if $logfile; 66 67 # Look for programs we need68 my $missing_tools;69 my $magictool = can_run('magictool') or (warn "Can't find magictool" and $missing_tools = 1);70 my $warptool = can_run('warptool') or (warn "Can't find warptool" and $missing_tools = 1);71 if ($missing_tools) {72 warn("Can't find required tools.");73 exit($PS_EXIT_CONFIG_ERROR);74 }75 79 76 80 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files … … 96 100 &my_die("Unable to parse metadata list", $magic_id, $PS_EXIT_PROG_ERROR); 97 101 98 # make a hash indexed by skycell_id 102 # make a hash indexed by skycell_id 99 103 foreach my $warp ( @$warps ) { 100 104 my $skycell_id = $warp->{skycell_id}; … … 156 160 157 161 my ($header, $status) = (undef, 0); 158 my $fits = Astro::FITS::CFITSIO::open_file( $skyfileResolved, READONLY, $status ); 162 my $fits = Astro::FITS::CFITSIO::open_file( $skyfileResolved, READONLY, $status ); 159 163 &my_die("failed to open skycell file: $skyfileResolved: $status", $magic_id, $PS_EXIT_SYS_ERROR) if $status; 160 164 161 165 ($header, $status) = Astro::FITS::CFITSIO::fits_read_header( $fits ); 162 166 163 167 &my_die("Unable to read skycell header: $status", $magic_id, $PS_EXIT_SYS_ERROR) if $status; 164 168 … … 171 175 $naxis2 = $$header{'NAXIS2'} or &my_die("Can't find NAXIS2", $magic_id, $PS_EXIT_SYS_ERROR); 172 176 } else { 173 # if the skyfile is compressed then the WCS won't be in the primary header, move to the 177 # if the skyfile is compressed then the WCS won't be in the primary header, move to the 174 178 # extension 175 179 my $hdutype; … … 257 261 my $node = shift @tasks; 258 262 divide_node($node, \@tasks); 259 } 263 } 260 264 261 265 ### Format tree for magictool -
trunk/ippScripts/scripts/register_exp.pl
r20429 r22430 27 27 my $ipprc = PS::IPP::Config->new(); 28 28 29 # Look for commands we need 30 my $missing_tools; 31 my $regtool = can_run('regtool') or (warn "can't find regtool" and $missing_tools = 1); 32 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1); 33 if ($missing_tools) { 34 warn ("Can't find required tools"); 35 exit($PS_EXIT_CONFIG_ERROR); 36 } 37 29 38 my ($cache, $exp_id, $exp_tag, $label, $dvodb, $end_stage, $tess_id, $dbname, $verbose, $no_update, $no_op, $save_temps, $logfile); 30 39 GetOptions( … … 33 42 'exp_tag|t=s' => \$exp_tag, 34 43 'dbname|d=s' => \$dbname, # Database name 35 'label=s' => \$label, 36 'dvodb=s' => \$dvodb, 37 'end_stage=s' => \$end_stage, 38 'tess_id=s' => \$tess_id, 44 'label=s' => \$label, 45 'dvodb=s' => \$dvodb, 46 'end_stage=s' => \$end_stage, 47 'tess_id=s' => \$tess_id, 39 48 'verbose' => \$verbose, # Print to stdout 40 49 'no-update' => \$no_update, … … 44 53 ) or pod2usage( 2 ); 45 54 55 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 56 $SIG{__DIE__} = sub { die @_ if $^S; 57 my_die( $_[0], $exp_id, $PS_EXIT_UNKNOWN_ERROR ); }; 58 46 59 $ipprc->redirect_output($logfile) if $logfile; 47 60 … … 55 68 my @SCIENCE = ( "object", "science", "light" ); # Observation types to NOT mark as detrend 56 69 my $DETREND_FLAG = "-end_stage reg"; # Flag to use to mark detrend exposure 57 58 # Look for commands we need59 my $missing_tools;60 my $regtool = can_run('regtool') or (warn "can't find regtool" and $missing_tools = 1);61 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);62 63 if ($missing_tools) {64 warn ("Can't find required tools");65 exit($PS_EXIT_CONFIG_ERROR);66 }67 70 68 71 # setup cache interface … … 123 126 $command .= " -exp_tag $exp_tag"; 124 127 $command .= " -hostname $host" if defined $host; 125 $command .= " -dbname $dbname" if defined $dbname;126 $command .= " -label $label" if defined $label;127 $command .= " -dvodb $dvodb" if defined $dvodb;128 $command .= " -dbname $dbname" if defined $dbname; 129 $command .= " -label $label" if defined $label; 130 $command .= " -dvodb $dvodb" if defined $dvodb; 128 131 $command .= " -end_stage $end_stage" if defined $end_stage; 129 132 $command .= " -tess_id $tess_id" if defined $tess_id; -
trunk/ippScripts/scripts/stack_skycell.pl
r21371 r22430 29 29 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); 30 30 use Pod::Usage qw( pod2usage ); 31 32 # Look for programs we need 33 my $missing_tools; 34 my $stacktool = can_run('stacktool') or (warn "Can't find stacktool" and $missing_tools = 1); 35 my $ppStack = can_run('ppStack') or (warn "Can't find ppStack" and $missing_tools = 1); 36 my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1); 37 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1); 38 if ($missing_tools) { 39 warn("Can't find required tools."); 40 exit($PS_EXIT_CONFIG_ERROR); 41 } 31 42 32 43 my ($stack_id, $dbname, $outroot, $debug, $run_state, $threads, $reduction, $verbose, $no_update, $no_op, $redirect, $save_temps); … … 55 66 and defined $run_state; 56 67 68 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 69 $SIG{__DIE__} = sub { die @_ if $^S; 70 my_die( $_[0], $stack_id, $PS_EXIT_UNKNOWN_ERROR ); }; 71 57 72 # XXX camera is not known here; cannot use filerules... 58 73 # my $logDest = $ipprc->filename("LOG.EXP", $outroot); 59 60 74 my $logDest = "$outroot.log"; 61 75 … … 72 86 my $image_id = $stack_id; 73 87 my $source_id = $ipprc->source_id($dbname, $PS_TABLE_ID_STACK); 74 75 # Look for programs we need76 my $missing_tools;77 my $stacktool = can_run('stacktool') or (warn "Can't find stacktool" and $missing_tools = 1);78 my $ppStack = can_run('ppStack') or (warn "Can't find ppStack" and $missing_tools = 1);79 my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1);80 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);81 if ($missing_tools) {82 warn("Can't find required tools.");83 exit($PS_EXIT_CONFIG_ERROR);84 }85 88 86 89 # Get list of components for stacking … … 300 303 301 304 unless ($my_die_called) { 302 $my_die_called = 1;303 delete_temps() unless ($save_temps);305 $my_die_called = 1; 306 delete_temps() unless ($save_temps); 304 307 } 305 308 … … 324 327 { 325 328 unless ($temp_images_exist) { 326 print "No temporary images yet generated\n";327 return 1;329 print "No temporary images yet generated\n"; 330 return 1; 328 331 } 329 332 … … 334 337 unless ($success) { 335 338 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 336 &my_die("Unable to perform ppConfigDump: $error_code", $stack_id, $error_code);339 &my_die("Unable to perform ppConfigDump: $error_code", $stack_id, $error_code); 337 340 } 338 341 my $md = $mdcParser->parse(join "", @$stdout_buf) or 339 &my_die("Unable to parse metadata config doc", $stack_id, $PS_EXIT_PROG_ERROR);342 &my_die("Unable to parse metadata config doc", $stack_id, $PS_EXIT_PROG_ERROR); 340 343 341 344 my $temp_delete = metadataLookupBool($md, 'TEMP.DELETE'); # Delete temporary files? -
trunk/ippScripts/scripts/warp_overlap.pl
r20655 r22430 25 25 26 26 my $ipprc = PS::IPP::Config->new(); # IPP configuration 27 28 # Look for programs we need 29 my $missing_tools; 30 my $warptool = can_run('warptool') or (warn "Can't find warptool" and $missing_tools = 1); 31 my $dvoImageOverlaps = can_run('dvoImageOverlaps') or (warn "Can't find dvoImageOverlaps" and $missing_tools = 1); 32 my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1); 33 if ($missing_tools) { 34 warn("Can't find required tools."); 35 exit($PS_EXIT_CONFIG_ERROR); 36 } 27 37 28 38 my ($warp_id, $camera, $tess_dir, $dbname, $verbose, $no_update, $no_op, $logfile, $save_temps); … … 49 59 and defined $tess_dir; 50 60 61 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 62 $SIG{__DIE__} = sub { die @_ if $^S; 63 my_die( $_[0], $warp_id, $PS_EXIT_UNKNOWN_ERROR ); }; 64 51 65 $ipprc->define_camera($camera); 52 53 # Look for programs we need54 my $missing_tools;55 my $warptool = can_run('warptool') or (warn "Can't find warptool" and $missing_tools = 1);56 my $dvoImageOverlaps = can_run('dvoImageOverlaps') or (warn "Can't find dvoImageOverlaps" and $missing_tools = 1);57 my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1);58 if ($missing_tools) {59 warn("Can't find required tools.");60 exit($PS_EXIT_CONFIG_ERROR);61 }62 66 63 67 &my_die("Tessellation identifier not provided: $tess_dir", $warp_id, $PS_EXIT_SYS_ERROR) unless $tess_dir ne "NULL"; -
trunk/ippScripts/scripts/warp_skycell.pl
r21371 r22430 26 26 27 27 my $ipprc = PS::IPP::Config->new(); # IPP configuration 28 29 # Look for programs we need 30 my $missing_tools; 31 my $warptool = can_run('warptool') or (warn "Can't find warptool" and $missing_tools = 1); 32 my $pswarp = can_run('pswarp') or (warn "Can't find pswarp" and $missing_tools = 1); 33 my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1); 34 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1); 35 if ($missing_tools) { 36 warn("Can't find required tools."); 37 exit($PS_EXIT_CONFIG_ERROR); 38 } 28 39 29 40 my ($warp_id, $skycell_id, $warp_skyfile_id, $tess_dir, $camera, $dbname, $outroot, $threads, $run_state, $verbose, $no_update, $no_op, $redirect, $save_temps); … … 57 68 and defined $run_state; 58 69 70 # Unhandled exceptions should be passed on to my_die so they get pushed into the database 71 $SIG{__DIE__} = sub { die @_ if $^S; 72 my_die( $_[0], $warp_id, $skycell_id, $tess_dir, $PS_EXIT_UNKNOWN_ERROR ); }; 73 59 74 $ipprc->define_camera($camera); 60 75 … … 65 80 66 81 my $source_id = $ipprc->source_id($dbname, $PS_TABLE_ID_WARP); 67 68 # Look for programs we need69 my $missing_tools;70 my $warptool = can_run('warptool') or (warn "Can't find warptool" and $missing_tools = 1);71 my $pswarp = can_run('pswarp') or (warn "Can't find pswarp" and $missing_tools = 1);72 my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1);73 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);74 if ($missing_tools) {75 warn("Can't find required tools.");76 exit($PS_EXIT_CONFIG_ERROR);77 }78 82 79 83 # Get list of component imfiles for exposure
Note:
See TracChangeset
for help on using the changeset viewer.
