IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 22430


Ignore:
Timestamp:
Feb 24, 2009, 12:00:25 PM (17 years ago)
Author:
Paul Price
Message:

Adding handling for missed exceptions, similar to register_imfile.pl --- the idea is to have exceptions trigger the my_die functions so that errors are recorded in the database, and don't go on forever.

Location:
trunk/ippScripts/scripts
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippScripts/scripts/camera_exp.pl

    r20661 r22430  
    2727use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
    2828use Pod::Usage qw( pod2usage );
     29
     30# Look for programs we need
     31my $missing_tools;
     32my $camtool = can_run('camtool') or (warn "Can't find camtool" and $missing_tools = 1);
     33my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1);
     34my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1);
     35my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
     36my $psastro = can_run('psastro') or (warn "Can't find psastro" and $missing_tools = 1);
     37my $addstar = can_run('addstar') or (warn "Can't find addstar" and $missing_tools = 1);
     38if ($missing_tools) {
     39    warn("Can't find required tools.");
     40    exit($PS_EXIT_CONFIG_ERROR);
     41}
    2942
    3043my ( $exp_tag, $cam_id, $camera, $outroot, $recipe, $dbname, $reduction, $dvodb, $verbose, $no_update,
     
    5770    defined $camera;
    5871
     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
    5976$ipprc->define_camera($camera);
    6077
     
    84101my $recipe_addstar = $ipprc->reduction($reduction, 'ADDSTAR'); # Recipe to use
    85102&my_die("Unrecognised ADDSTAR recipe", $cam_id, $PS_EXIT_CONFIG_ERROR) unless defined $recipe1;
    86 
    87 # Look for programs we need
    88 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 }
    102103
    103104my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
     
    272273
    273274        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 metadata
    278             $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;
    289290        }
    290291
     
    323324            $command .= " $realFile";
    324325
    325             my $mjd_addstar_start = DateTime->now->mjd;   # MJD of starting script
     326            my $mjd_addstar_start = DateTime->now->mjd;   # MJD of starting script
    326327
    327328            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     
    331332                &my_die("Unable to perform addstar: $error_code", $cam_id, $error_code);
    332333            }
    333             $dtime_addstar = 86400.0*(DateTime->now->mjd - $mjd_addstar_start);   # MJD of starting script
     334            $dtime_addstar = 86400.0*(DateTime->now->mjd - $mjd_addstar_start);   # MJD of starting script
    334335        }
    335336    }
  • trunk/ippScripts/scripts/chip_imfile.pl

    r21371 r22430  
    2525use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
    2626use Pod::Usage qw( pod2usage );
     27
     28# Look for programs we need
     29my $missing_tools;
     30my $chiptool = can_run('chiptool') or (warn "Can't find chiptool" and $missing_tools = 1);
     31my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1);
     32my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1);
     33my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
     34if ($missing_tools) {
     35    warn("Can't find required tools.");
     36    exit($PS_EXIT_CONFIG_ERROR);
     37}
    2738
    2839# Parse the command-line arguments
     
    5364    defined $chip_id and
    5465    defined $class_id and
    55     defined $chip_imfile_id and 
     66    defined $chip_imfile_id and
    5667    defined $uri and
    5768    defined $camera and
    5869    defined $outroot and
    5970    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 ); };
    6075
    6176$ipprc->define_camera($camera);
     
    6984    print STDOUT "Starting script $0 on $host\n\n";
    7085    print STDOUT "COMMAND IS: @ARGV\n\n";
    71 }
    72 
    73 # Look for programs we need
    74 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);
    8286}
    8387
     
    132136        $command .= " -threads $threads" if defined $threads;
    133137        $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;
    136140        $command .= " -dumpconfig $configuration";
    137141        $command .= " -tracedest $traceDest -log $logDest";
     
    142146        $command .= " -threads $threads" if defined $threads;
    143147        $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;
    146150        $command .= " -tracedest $traceDest -log $logDest";
    147151        $command .= " -Db PPIMAGE:PHOTOM FALSE";
  • trunk/ippScripts/scripts/detrend_correct_imfile.pl

    r20378 r22430  
    2424use Pod::Usage qw( pod2usage );
    2525
     26# Look for programs we need
     27my $missing_tools;
     28my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1);
     29my $dvoApplyCorr = can_run('dvoApplyCorr') or (warn "Can't find dvoApplyCorr" and $missing_tools = 1);
     30if ($missing_tools) {
     31    warn("Can't find required tools.");
     32    exit($PS_EXIT_CONFIG_ERROR);
     33}
     34
    2635my ( $det_id, $class_id, $det_type, $input_uri, $camera, $dbname,
    2736     $verbose, $no_update, $no_op, $outroot, $redirect, $corr_uri );
     
    4352pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    4453pod2usage( -msg => "Required options: --det_id --class_id --det_type --input_uri --camera --outroot",
    45            -exitval => 3)
     54           -exitval => 3)
    4655    unless defined $det_id
    4756    and defined $class_id
     
    5059    and defined $outroot
    5160    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 ); };
    5265
    5366# XXX this exits with status = 0 on failure
     
    6073}
    6174
    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...
    6477# XXX in the future, we may define corrections other than the flat-field correction
    6578# $reduction = "DETREND" unless defined $reduction;
     
    6982# det_type is type of the CORRECTED (output) file
    7083if ($det_type ne "FLAT") { warn ("unexpected input detrend type: correcting data of type $det_type"); }
    71 
    72 # Look for programs we need
    73 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 }
    8084
    8185&my_die("Couldn't find input file: $input_uri\n", $det_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($input_uri);
     
    9195
    9296    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    93         run(command => $command, verbose => $verbose);
     97        run(command => $command, verbose => $verbose);
    9498    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);
    97101    }
    98102
     
    111115unless ($no_update) {
    112116    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    113         run(command => $command, verbose => $verbose);
     117        run(command => $command, verbose => $verbose);
    114118    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);
    118122    }
    119123} else {
     
    124128{
    125129    my $msg = shift; # Warning message on die
    126     my $det_id = shift;         # Detrend identifier
     130    my $det_id = shift;         # Detrend identifier
    127131    my $class_id = shift; # Class identifier
    128132    my $exit_code = shift; # Exit code to add
     
    130134    carp($msg);
    131135    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;
    138142        system ($command);
    139143    }
  • trunk/ippScripts/scripts/detrend_norm_apply.pl

    r19942 r22430  
    2222use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
    2323use Pod::Usage qw( pod2usage );
     24
     25# Look for programs we need
     26my $missing_tools;
     27my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1);
     28my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1);
     29my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
     30if ($missing_tools) {
     31    warn("Can't find required tools.");
     32    exit($PS_EXIT_CONFIG_ERROR);
     33}
    2434
    2535# Parse the command-line
     
    5464    defined $outroot;
    5565
     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
    5670$ipprc->define_camera($camera);
    5771
    58 my $logDest = $ipprc->filename("LOG.IMFILE", $outroot, $class_id) 
     72my $logDest = $ipprc->filename("LOG.IMFILE", $outroot, $class_id)
    5973        or &my_die("Missing entry from camera config", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR);
    6074$ipprc->redirect_output($logDest) if $redirect;
     
    6478# Define which detrend types we normalise
    6579use constant DETTYPE => {
    66     'bias'             => 'bias',
    67     'dark'             => 'dark',   
     80    'bias'             => 'bias',
     81    'dark'             => 'dark',
    6882    'dark_premask'     => 'dark',
    69     'shutter'          => 'shutter',
     83    'shutter'          => 'shutter',
    7084    'flat_premask'     => 'flat',
    7185    'domeflat_premask' => 'flat',
     
    7387    'flat_raw'         => 'flat',
    7488    '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    };
    8498
    8599# convert supplied detrend type to a controlled namespace
    86100&my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $class_id, $PS_EXIT_PROG_ERROR) unless exists DETTYPE()->{lc($det_type)};
    87101my $det_type_real = DETTYPE()->{lc($det_type)};
    88 
    89 # Look for programs we need
    90 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 }
    98102
    99103&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);
     
    124128    # we cannot use ppImage to load a normalized mask : just copy it and build the jpeg images
    125129    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");
    130134    }
    131135
     
    162166    }
    163167    foreach my $line (@$stdout_buf) {
    164         $cmdflags .= " $line";
     168        $cmdflags .= " $line";
    165169    }
    166170    chomp $cmdflags;
     
    204208        $command .= " -iteration $iter";
    205209        $command .= " -class_id $class_id";
    206         $command .= " -path_base $outroot";
     210        $command .= " -path_base $outroot";
    207211        $command .= " -code $exit_code";
    208212        $command .= " -dbname $dbname" if defined $dbname;
  • trunk/ippScripts/scripts/detrend_norm_calc.pl

    r19374 r22430  
    2525use Pod::Usage qw( pod2usage );
    2626
     27# Look for programs we need
     28my $missing_tools;
     29my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1);
     30my $ppNormCalc = can_run('ppNormCalc') or (warn "Can't find ppNormCalc" and $missing_tools = 1);
     31if ($missing_tools) {
     32    warn("Can't find required tools.");
     33    exit($PS_EXIT_CONFIG_ERROR);
     34}
     35
    2736# Parse command-line arguments
    2837my ($det_id, $iter, $detType, $outroot, $dbname, $verbose, $no_update, $no_op, $redirect );
    2938GetOptions(
    30     'det_id|d=s'        => \$det_id,    # Detrend id                         
    31     'iteration|i=s'     => \$iter,      # Iteration                         
    32     'det_type|t=s'      => \$detType,   # Detrend type                       
    33     'outroot|w=s'       => \$outroot,   # output file base name
    34     'dbname|d=s'        => \$dbname,    # Database name                     
    35     'verbose'           => \$verbose,   # Print to stdout
    36     'no-update'         => \$no_update, # Don't update the database?         
    37     'no-op'             => \$no_op,     # Don't do operations               
     39    '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
    3847    'redirect-output'   => \$redirect,
    3948    ) or pod2usage( 2 );
     
    4150pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    4251pod2usage( -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
    4756    defined $detType and
    4857    defined $outroot;
    4958
     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
    5063my $logfile = $outroot . ".log";
    5164
     
    5669# Define which detrend types we normalise
    5770use constant NORMALIZE => {
    58     'bias'             => 0,
    59     'dark'             => 0,   
     71    'bias'             => 0,
     72    'dark'             => 0,
    6073    'dark_premask'     => 0,
    61     'shutter'          => 0,
     74    'shutter'          => 0,
    6275    'flat_premask'     => 1,
    6376    'domeflat_premask' => 1,
     
    6679    'domeflat_raw'     => 1,
    6780    '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    };
    8589
    8690&my_die("Unrecognised detrend type: $detType", $det_id, $iter, $PS_EXIT_PROG_ERROR) unless exists NORMALIZE()->{lc($detType)};
     
    8993
    9094# Get the list of inputs
    91 my @files;                      # The input files
     95my @files;                      # The input files
    9296{
    9397    my $command = "$dettool -processedimfile";
     
    99103    print "Running [$command]...\n" if $verbose;
    100104    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);
    103107    }
    104108    print $stdout . "\n" if $verbose;
    105    
     109
    106110    # Because of the length, need to split into individual metadatas --- it parses SO much quicker!
    107111    my @whole = split /\n/, $stdout;
    108112    my @single = ();
    109113    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) unless
    117                 defined $list;
    118             push @files, @$list;
    119             @single = ();
    120         }
    121     }
    122 }
    123 
    124 my $norms;                      # MDC with normalisations
     114        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
     128my $norms;                      # MDC with normalisations
    125129if (NORMALIZE()->{lc($detType)} and not $no_op) {
    126130
    127131    my %matrix; # Matrix of statistics as a function of exposures and classes
    128132    foreach my $file (@files) {
    129         my $exp_id = $file->{'exp_id'}; # Exposure ID
    130         my $class_id = $file->{'class_id'}; # Class ID
    131         my $stat = $file->{STATISTIC()}; # Statistic of interest
    132        
    133         # Create matrix elements
    134         $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
    138142    # Generate the input for ppNormCalc
    139     my $normData;                       # Normalisation data
     143    my $normData;                       # Normalisation data
    140144    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";
    146150    }
    147151
    148152    # Run ppNormCalc
    149153    {
    150         my ( $stdout, $stderr ); # Buffers for running program
    151         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 output
    159         $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;
    161165    }
    162166
    163167} else {
    164168    # It's something that doesn't need normalisation --- just push in a normalisation of 1
    165     my %classes;                # List of unique classes
     169    my %classes;                # List of unique classes
    166170    foreach my $file (@files) {
    167         my $class_id = $file->{'class_id'}; # Class Id
    168         $classes{$class_id} = 1;
    169     }
    170    
     171        my $class_id = $file->{'class_id'}; # Class Id
     172        $classes{$class_id} = 1;
     173    }
     174
    171175    foreach my $class_id (keys %classes) {
    172         my %mdValue;    # Metadata value for this class id
    173         $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;
    176180    }
    177181}
     
    186190    foreach my $normItem (@$norms) {
    187191
    188         my $className = $normItem->{name}; # Name of component
    189         my $normalisation = $normItem->{value}; # Normalisation for component
    190 
    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 program
    203         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;
    209213    }
    210214} else {
     
    212216    foreach my $normItem (@$norms) {
    213217
    214         my $className = $normItem->{name}; # Name of component
    215         my $normalisation = $normItem->{value}; # Normalisation for component
    216 
    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";
    222226    }
    223227}
     
    225229sub my_die
    226230{
    227     my $msg = shift;            # Warning message on die
    228     my $det_id = shift;         # Detrend identifier
    229     my $iter = shift;           # Iteration
    230     my $exit_code = shift;      # Exit code to add
     231    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
    231235
    232236    carp($msg);
    233237    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;
    240244        system ($command);
    241245    }
  • trunk/ippScripts/scripts/detrend_norm_exp.pl

    r20120 r22430  
    2424use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
    2525use Pod::Usage qw( pod2usage );
     26
     27# Look for programs we need
     28my $missing_tools;
     29my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1);
     30my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1);
     31my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
     32if ($missing_tools) {
     33    warn("Can't find required tools.");
     34    exit($PS_EXIT_CONFIG_ERROR);
     35}
    2636
    2737my ($det_id, $iter, $det_type, $camera, $outroot, $dbname, $reduction, $verbose, $no_update, $no_op, $redirect, $save_temps);
     
    5060    defined $outroot;
    5161
     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
    5266my $logfile = $outroot . ".log";
    5367
     
    6074my $recipe = $ipprc->reduction($reduction, uc($det_type) . '_JPEG_IMAGE');
    6175&my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $PS_EXIT_PROG_ERROR) unless defined $recipe;
    62 
    63 # Look for programs we need
    64 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 }
    7276
    7377# Get list of component files
  • trunk/ippScripts/scripts/detrend_process_exp.pl

    r20120 r22430  
    2424use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
    2525use Pod::Usage qw( pod2usage );
     26
     27# Look for programs we need
     28my $missing_tools;
     29my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1);
     30my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1);
     31my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
     32if ($missing_tools) {
     33    warn("Can't find required tools.");
     34    exit($PS_EXIT_CONFIG_ERROR);
     35}
    2636
    2737my ( $det_id, $exp_id, $det_type, $exp_tag, $camera, $outroot, $dbname, $reduction, $verbose, $no_update,
     
    5363    defined $outroot;
    5464
     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
    5569$ipprc->define_camera($camera);
    5670
     
    6680my $recipe = $ipprc->reduction($reduction, uc($det_type) . '_JPEG_IMAGE'); # Recipe to use
    6781&my_die("Unrecognised detrend type: $det_type", $det_id, $exp_id, $PS_EXIT_PROG_ERROR) unless defined $recipe;
    68 
    69 # Look for programs we need
    70 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 }
    7882
    7983my $cmdflags;
  • trunk/ippScripts/scripts/detrend_process_imfile.pl

    r19942 r22430  
    2222use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
    2323use Pod::Usage qw( pod2usage );
     24
     25# Look for programs we need
     26my $missing_tools;
     27my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1);
     28my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1);
     29my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
     30if ($missing_tools) {
     31    warn("Can't find required tools.");
     32    exit($PS_EXIT_CONFIG_ERROR);
     33}
    2434
    2535my ( $det_id, $exp_id, $class_id, $det_type, $exp_tag, $input_uri, $camera, $outroot, $dbname, $reduction,
     
    5565    defined $outroot;
    5666
     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
    5771# XXX this exits with status = 0 on failure
    5872$ipprc->define_camera($camera);
     
    6680my $ppimage_recipe = $ipprc->reduction($reduction, uc($det_type) . '_PROCESS'); # Recipe name for ppImage
    6781my $jpeg_recipe = $ipprc->reduction($reduction, uc($det_type) . '_JPEG_IMAGE'); # Recipe name for JPEG
    68 
    69 # Look for programs we need
    70 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 }
    7882
    7983&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);
     
    128132    }
    129133    foreach my $line (@$stdout_buf) {
    130         $cmdflags .= " $line";
     134        $cmdflags .= " $line";
    131135    }
    132136    chomp $cmdflags;
  • trunk/ippScripts/scripts/detrend_reject_exp.pl

    r18562 r22430  
    2727use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
    2828use Pod::Usage qw( pod2usage );
     29
     30# Look for programs we need
     31my $missing_tools;
     32my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1);
     33if ($missing_tools) {
     34    warn("Can't find required tools.");
     35    exit($PS_EXIT_CONFIG_ERROR);
     36}
    2937
    3038my ($det_id, $iter, $det_type, $camera, $outroot, $filter, $dbname, $verbose, $no_update, $no_op, $redirect);
     
    5260    defined $outroot;
    5361
     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
    5466# check for existing directory, generate if needed
    5567$ipprc->outroot_prepare($outroot);
     
    89101my $rejstats = PS::IPP::Metadata::Stats->new($REJSTATS); # Stats parser
    90102
    91 # Look for programs we need
    92 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 
    99103# Get list of component files
    100104my ($exposures, $command, $success, $error_code, $full_buf, $stdout_buf, $stderr_buf);
     
    345349        $command .= " -det_id $det_id";
    346350        $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";
    348352        $command .= " -code $exit_code";
    349353        $command .= " -dbname $dbname" if defined $dbname;
  • trunk/ippScripts/scripts/detrend_resid_exp.pl

    r20120 r22430  
    3535use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); # option parsing
    3636use Pod::Usage qw( pod2usage );
     37
     38# Look for programs we need
     39my $missing_tools;
     40my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1);
     41my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1);
     42my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
     43if ($missing_tools) {
     44    warn("Can't find required tools.");
     45    exit($PS_EXIT_CONFIG_ERROR);
     46}
    3747
    3848# parse the command-line options
     
    6979    defined $outroot;
    7080
     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
    7185# load IPP config information for the specified camera
    7286$ipprc->define_camera($camera);
     
    8195my $recipe = $ipprc->reduction($reduction, uc($det_type) . '_JPEG_RESID'); # Recipe to use
    8296&my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $PS_EXIT_PROG_ERROR) unless defined $recipe;
    83 
    84 # Look for programs we need
    85 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 }
    9397
    9498# Get list of imfile files
  • trunk/ippScripts/scripts/detrend_resid_imfile.pl

    r19781 r22430  
    2222use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
    2323use Pod::Usage qw( pod2usage );
     24
     25# Look for programs we need
     26my $missing_tools;
     27my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1);
     28my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1);
     29my $ppStats = can_run('ppStats') or (warn "Can't find ppStats" and $missing_tools = 1);
     30my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
     31if ($missing_tools) {
     32    warn("Can't find required tools.");
     33    exit($PS_EXIT_CONFIG_ERROR);
     34}
    2435
    2536my ( $det_id, $iter, $ref_det_id, $ref_iter, $exp_id, $exp_tag, $class_id, $det_type, $detrend, $input_uri, $camera, $mode, $outroot,
     
    6576    defined $detrend;
    6677
     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
    6782$ipprc->define_camera($camera);
    6883my $logDest     = $ipprc->filename("LOG.IMFILE", $outroot, $class_id);
     
    109124};
    110125
    111 # Look for programs we need
    112 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 
    122126# outroot examples (HOST components must be set)
    123127# file://data/ipp004.0/gpc1/20080130
     
    179183    }
    180184    foreach my $line (@$stdout_buf) {
    181         $cmdflags .= " $line";
     185        $cmdflags .= " $line";
    182186    }
    183187    chomp $cmdflags;
     
    192196    }
    193197    foreach my $line (@$stdout_buf) {
    194         $cmdflags .= " $line";
     198        $cmdflags .= " $line";
    195199    }
    196200    chomp $cmdflags;
  • trunk/ippScripts/scripts/detrend_stack.pl

    r21371 r22430  
    2323use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
    2424use Pod::Usage qw( pod2usage );
     25
     26# Look for programs we need
     27my $missing_tools;
     28my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1);
     29my $ppMerge = can_run('ppMerge') or (warn "Can't find ppMerge" and $missing_tools = 1);
     30my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
     31if ($missing_tools) {
     32    warn("Can't find required tools.");
     33    exit($PS_EXIT_CONFIG_ERROR);
     34}
    2535
    2636my ( $det_id, $iter, $class_id, $det_type, $camera, $outroot, $dbname, $reduction, $threads, $verbose, $save_temps,
     
    5969    or &my_die("Missing entry in file rules", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR);
    6070
     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
    6175# optionally redirect the outputs from this script to LOG.IMFILE
    6276$ipprc->redirect_output($logDest) if $redirect;
     
    6579$reduction = "DETREND" unless defined $reduction;
    6680my $recipe = $ipprc->reduction($reduction, $det_type . '_STACK'); # Recipe name to use
    67 
    68 # Look for programs we need
    69 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 }
    7781
    7882# The output file rule name depends on the detrend type
     
    219223    }
    220224    foreach my $line (@$stdout_buf) {
    221         $cmdflags .= " $line";
     225        $cmdflags .= " $line";
    222226    }
    223227    chomp $cmdflags;
     
    261265        $command .= " -iteration $iter";
    262266        $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";
    264268        $command .= " -code $exit_code";
    265269        $command .= " -dbname $dbname" if defined $dbname;
  • trunk/ippScripts/scripts/diff_skycell.pl

    r21395 r22430  
    2727use Pod::Usage qw( pod2usage );
    2828
     29# Look for programs we need
     30my $missing_tools;
     31my $difftool = can_run('difftool') or (warn "Can't find difftool" and $missing_tools = 1);
     32my $ppSub = can_run('ppSub') or (warn "Can't find ppSub" and $missing_tools = 1);
     33my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
     34if ($missing_tools) {
     35    warn("Can't find required tools.");
     36    exit($PS_EXIT_CONFIG_ERROR);
     37}
     38
    2939my ($diff_id, $dbname, $threads, $outroot, $reduction, $verbose, $no_update, $no_op, $redirect);
    3040my ($skycell_id, $diff_skyfile_id);
    3141GetOptions(
    3242    'diff_id=s'         => \$diff_id, # Diff identifier
    33     'skycell_id=s'      => \$skycell_id, # Diff identifier
     43    'skycell_id=s'      => \$skycell_id, # Skycell identifier
    3444    'diff_skyfile_id=s' => \$diff_skyfile_id, # Diff identifier
    3545    'dbname|d=s'        => \$dbname, # Database name
     
    5262    and defined $outroot;
    5363
     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
    5468# XXX camera is not known here; cannot use filerules...
    5569# my $logDest = $ipprc->filename("LOG.EXP", $outroot);
    56 
    5770my $logDest = "$outroot.log";
    5871$ipprc->redirect_output($logDest) if $redirect;
    5972
    6073my $source_id = $ipprc->source_id($dbname, $PS_TABLE_ID_DIFF);
    61 
    62 # Look for programs we need
    63 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 }
    7174
    7275# Get list of components for subtraction
     
    8083    unless ($success) {
    8184        $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);
    8386    }
    8487
    8588    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);
    8790    $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;
    9395
    9496# Identify the input and the template
     
    123125    }
    124126    if (defined $tess_id) {
    125         &my_die("Tesselation identifiers don't match", $diff_id, $PS_EXIT_SYS_ERROR) unless
     127        &my_die("Tesselation identifiers don't match", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless
    126128            $file->{tess_id} eq $tess_id;
    127129    } else {
     
    129131    }
    130132    if (defined $skycell_id) {
    131         &my_die("Skycell identifiers don't match", $diff_id, $PS_EXIT_SYS_ERROR) unless
     133        &my_die("Skycell identifiers don't match", $diff_id, $skycell_id, $PS_EXIT_SYS_ERROR) unless
    132134            $file->{skycell_id} eq $skycell_id;
    133135    } else {
     
    135137    }
    136138    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;
    138140    } else {
    139141        $camera = $file->{camera};
     
    142144}
    143145
    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;
    147149$ipprc->define_camera($camera);
    148150
     
    152154my $recipe_psphot  = $ipprc->reduction($reduction, 'DIFF_PSPHOT'); # Recipe to use for psphot
    153155unless ($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);
    155157}
    156158
     
    177179print "templateSources: $templateSources\n";
    178180
    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);
    186188
    187189# Get the output filenames
     
    223225    unless ($success) {
    224226        $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);
    233235
    234236    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;
    236238
    237239    # measure chip stats
     
    241243    unless ($success) {
    242244        $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);
    244246    }
    245247    foreach my $line (@$stdout_buf) {
     
    263265        unless ($success) {
    264266            $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);
    266268        }
    267269    }
     
    273275    my $msg = shift;            # Warning message on die
    274276    my $diff_id = shift;        # Diff identifier
     277    my $skycell_id = shift;     # Skycell identifier
    275278    my $exit_code = shift;      # Exit code to add
    276279
    277280    warn($msg);
    278     if (defined $diff_id and not $no_update) {
     281    if (defined $diff_id and defined $skycell_id and not $no_update) {
    279282        my $command = "$difftool -adddiffskyfile -diff_id $diff_id -skycell_id $skycell_id -code $exit_code";
    280283        $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400));
  • trunk/ippScripts/scripts/fake_imfile.pl

    r21371 r22430  
    4141use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
    4242use Pod::Usage qw( pod2usage );
     43
     44# Look for programs we need
     45my $missing_tools;
     46my $faketool = can_run('faketool') or (warn "Can't find faketool" and $missing_tools = 1);
     47my $ppSim = can_run('ppSim') or (warn "Can't find ppSim" and $missing_tools = 1);
     48my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1);
     49if ($missing_tools) {
     50    warn("Can't find required tools.");
     51    exit($PS_EXIT_CONFIG_ERROR);
     52}
    4353
    4454# Parse the command-line arguments
     
    7282    defined $outroot;
    7383
     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
    7488$ipprc->define_camera($camera);
    7589
     
    8397unless ($recipe) {
    8498    &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 need
    88 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);
    9599}
    96100
  • trunk/ippScripts/scripts/magic_destreak.pl

    r21435 r22430  
    2626use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
    2727use Pod::Usage qw( pod2usage );
     28
     29# Look for programs we need
     30my $missing_tools;
     31my $magicdstool   = can_run('magicdstool') or (warn "Can't find magicdstool" and $missing_tools = 1);
     32my $streaksremove = can_run('streaksremove') or (warn "Can't find streaksremove" and $missing_tools = 1);
     33if ($missing_tools) {
     34    warn("Can't find required tools.");
     35    exit($PS_EXIT_CONFIG_ERROR);
     36}
    2837
    2938# Parse the command-line arguments
     
    6675    defined $component and
    6776    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
    6982
    7083my ($skycell_args, $class_id, $skycell_id);
     
    87100
    88101
    89 # Look for programs we need
    90 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 
    98102my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
    99103
     
    128132    if (! -e $outroot ) {
    129133        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,
    131135                $code >> 8) if $code;
    132136    }
     
    143147        if (! -e $recoveryroot ) {
    144148            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,
    146150                    $code >> 8) if $code;
    147151        }
     
    151155
    152156# get skycell list if needed
    153 my ($sfh, $skycell_list);         
     157my ($sfh, $skycell_list);
    154158if ($skycell_args) {
    155159    my $command = "$magicdstool -magic_ds_id $magic_ds_id -getskycells $skycell_args";
  • trunk/ippScripts/scripts/magic_mask.pl

    r20673 r22430  
    2828use Pod::Usage qw( pod2usage );
    2929
     30# Look for programs we need
     31my $missing_tools;
     32my $magictool = can_run('magictool') or (warn "Can't find magictool" and $missing_tools = 1);
     33my $streaksremove = can_run('streaksremove') or (warn "Can't find streaksremove" and $missing_tools = 1);
     34if ($missing_tools) {
     35    warn("Can't find required tools.");
     36    exit($PS_EXIT_CONFIG_ERROR);
     37}
     38
    3039# Parse the command-line arguments
    3140my ($magic_id, $camera, $dbname, $outroot, $save_temps, $verbose, $no_update, $no_op, $logfile);
     
    4958    defined $outroot;
    5059
     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
    5164$ipprc->define_camera($camera);
    5265
    5366$ipprc->redirect_output($logfile) if $logfile;
    54 
    55 # Look for programs we need
    56 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 }
    6367
    6468my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
     
    8589### Do the heavy lifting
    8690{
    87     my $command = "$streaks --streaks"; # Command to execute
     91    my $command = "$streaksremove --streaks"; # Command to execute
    8892    my @basenames;              # List of base names
    8993
  • trunk/ippScripts/scripts/magic_process.pl

    r21371 r22430  
    2828use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
    2929use Pod::Usage qw( pod2usage );
     30
     31# Look for programs we need
     32my $missing_tools;
     33my $magictool      = can_run('magictool') or (warn "Can't find magictool" and $missing_tools = 1);
     34my $removestreaks = can_run('RemoveStreaks') or (warn "Can't find RemoveStreaks" and $missing_tools = 1);
     35if ($missing_tools) {
     36    warn("Can't find required tools.");
     37    exit($PS_EXIT_CONFIG_ERROR);
     38}
    3039
    3140# Parse the command-line arguments
     
    5362    defined $outroot;
    5463
     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
    5568$ipprc->define_camera($camera);
    5669
     
    6679# resolve any path:// or file:// in outroot
    6780$outroot = $ipprc->file_resolve($outroot);
    68    
     81
    6982$ipprc->redirect_output($logfile) if $logfile;
    70 
    71 # Look for programs we need
    72 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 }
    7983
    8084my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
     
    145149        # this causes major file pollution, but avoids multi-level queries
    146150        # at higher level nodes.
    147        
     151
    148152        my ($in_fh, $input_list)  = open_list_file($outroot, "input.list");
    149153        print $in_fh "$outroot\n";
     
    252256
    253257    my $fh;
    254     open $fh, "<$resolved" or 
     258    open $fh, "<$resolved" or
    255259        &my_die("failed to open streaks file $streaks_file", $magic_id, $node, $PS_EXIT_UNKNOWN_ERROR);
    256260    # the first line in the streaks file contains the number of streaks found
     
    259263    close $fh;
    260264    print "$num_streaks streaks found on magicRun $magic_id\n" if $verbose;
    261    
     265
    262266    my $command = "$magictool -addmask";
    263267    $command   .= " -magic_id $magic_id";
  • trunk/ippScripts/scripts/magic_tree.pl

    r20762 r22430  
    3131
    3232use constant MAX_FIELDS => 4;   # Maximum number of fields to be in a node
     33
     34# Look for programs we need
     35my $missing_tools;
     36my $magictool = can_run('magictool') or (warn "Can't find magictool" and $missing_tools = 1);
     37my $warptool = can_run('warptool') or (warn "Can't find warptool" and $missing_tools = 1);
     38if ($missing_tools) {
     39    warn("Can't find required tools.");
     40    exit($PS_EXIT_CONFIG_ERROR);
     41}
    3342
    3443# Parse the command-line arguments
     
    6170    defined $outroot;
    6271
     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
    6376$ipprc->define_camera($camera);
    6477
    6578$ipprc->redirect_output($logfile) if $logfile;
    66 
    67 # Look for programs we need
    68 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 }
    7579
    7680my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
     
    96100        &my_die("Unable to parse metadata list", $magic_id, $PS_EXIT_PROG_ERROR);
    97101
    98     # make a hash indexed by skycell_id 
     102    # make a hash indexed by skycell_id
    99103    foreach my $warp ( @$warps ) {
    100104        my $skycell_id = $warp->{skycell_id};
     
    156160
    157161    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 );
    159163    &my_die("failed to open skycell file: $skyfileResolved: $status", $magic_id, $PS_EXIT_SYS_ERROR) if $status;
    160164
    161165    ($header, $status) = Astro::FITS::CFITSIO::fits_read_header( $fits );
    162    
     166
    163167    &my_die("Unable to read skycell header: $status", $magic_id, $PS_EXIT_SYS_ERROR) if $status;
    164168
     
    171175        $naxis2 = $$header{'NAXIS2'} or &my_die("Can't find NAXIS2", $magic_id, $PS_EXIT_SYS_ERROR);
    172176    } 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
    174178        # extension
    175179        my $hdutype;
     
    257261    my $node = shift @tasks;
    258262    divide_node($node, \@tasks);
    259 } 
     263}
    260264
    261265### Format tree for magictool
  • trunk/ippScripts/scripts/register_exp.pl

    r20429 r22430  
    2727my $ipprc = PS::IPP::Config->new();
    2828
     29# Look for commands we need
     30my $missing_tools;
     31my $regtool = can_run('regtool') or (warn "can't find regtool" and $missing_tools = 1);
     32my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
     33if ($missing_tools) {
     34    warn ("Can't find required tools");
     35    exit($PS_EXIT_CONFIG_ERROR);
     36}
     37
    2938my ($cache, $exp_id, $exp_tag, $label, $dvodb, $end_stage, $tess_id, $dbname, $verbose, $no_update, $no_op, $save_temps, $logfile);
    3039GetOptions(
     
    3342    'exp_tag|t=s'   => \$exp_tag,
    3443    '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,
    3948    'verbose'       => \$verbose,   # Print to stdout
    4049    'no-update'     => \$no_update,
     
    4453) or pod2usage( 2 );
    4554
     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
    4659$ipprc->redirect_output($logfile) if $logfile;
    4760
     
    5568my @SCIENCE = ( "object", "science", "light" ); # Observation types to NOT mark as detrend
    5669my $DETREND_FLAG = "-end_stage reg"; # Flag to use to mark detrend exposure
    57 
    58 # Look for commands we need
    59 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 }
    6770
    6871# setup cache interface
     
    123126$command .= " -exp_tag $exp_tag";
    124127$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;
    128131$command .= " -end_stage $end_stage" if defined $end_stage;
    129132$command .= " -tess_id   $tess_id"   if defined $tess_id;
  • trunk/ippScripts/scripts/stack_skycell.pl

    r21371 r22430  
    2929use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
    3030use Pod::Usage qw( pod2usage );
     31
     32# Look for programs we need
     33my $missing_tools;
     34my $stacktool = can_run('stacktool') or (warn "Can't find stacktool" and $missing_tools = 1);
     35my $ppStack = can_run('ppStack') or (warn "Can't find ppStack" and $missing_tools = 1);
     36my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1);
     37my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
     38if ($missing_tools) {
     39    warn("Can't find required tools.");
     40    exit($PS_EXIT_CONFIG_ERROR);
     41}
    3142
    3243my ($stack_id, $dbname, $outroot, $debug, $run_state, $threads, $reduction, $verbose, $no_update, $no_op, $redirect, $save_temps);
     
    5566    and defined $run_state;
    5667
     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
    5772# XXX camera is not known here; cannot use filerules...
    5873# my $logDest = $ipprc->filename("LOG.EXP", $outroot);
    59 
    6074my $logDest = "$outroot.log";
    6175
     
    7286my $image_id = $stack_id;
    7387my $source_id = $ipprc->source_id($dbname, $PS_TABLE_ID_STACK);
    74 
    75 # Look for programs we need
    76 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 }
    8588
    8689# Get list of components for stacking
     
    300303
    301304    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);
    304307    }
    305308
     
    324327{
    325328    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;
    328331    }
    329332
     
    334337    unless ($success) {
    335338        $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);
    337340    }
    338341    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);
    340343
    341344    my $temp_delete = metadataLookupBool($md, 'TEMP.DELETE'); # Delete temporary files?
  • trunk/ippScripts/scripts/warp_overlap.pl

    r20655 r22430  
    2525
    2626my $ipprc = PS::IPP::Config->new(); # IPP configuration
     27
     28# Look for programs we need
     29my $missing_tools;
     30my $warptool = can_run('warptool') or (warn "Can't find warptool" and $missing_tools = 1);
     31my $dvoImageOverlaps = can_run('dvoImageOverlaps') or (warn "Can't find dvoImageOverlaps" and $missing_tools = 1);
     32my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1);
     33if ($missing_tools) {
     34    warn("Can't find required tools.");
     35    exit($PS_EXIT_CONFIG_ERROR);
     36}
    2737
    2838my ($warp_id, $camera, $tess_dir, $dbname, $verbose, $no_update, $no_op, $logfile, $save_temps);
     
    4959    and defined $tess_dir;
    5060
     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
    5165$ipprc->define_camera($camera);
    52 
    53 # Look for programs we need
    54 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 }
    6266
    6367&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  
    2626
    2727my $ipprc = PS::IPP::Config->new(); # IPP configuration
     28
     29# Look for programs we need
     30my $missing_tools;
     31my $warptool = can_run('warptool') or (warn "Can't find warptool" and $missing_tools = 1);
     32my $pswarp = can_run('pswarp') or (warn "Can't find pswarp" and $missing_tools = 1);
     33my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1);
     34my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
     35if ($missing_tools) {
     36    warn("Can't find required tools.");
     37    exit($PS_EXIT_CONFIG_ERROR);
     38}
    2839
    2940my ($warp_id, $skycell_id, $warp_skyfile_id, $tess_dir, $camera, $dbname, $outroot, $threads, $run_state, $verbose, $no_update, $no_op, $redirect, $save_temps);
     
    5768    and defined $run_state;
    5869
     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
    5974$ipprc->define_camera($camera);
    6075
     
    6580
    6681my $source_id = $ipprc->source_id($dbname, $PS_TABLE_ID_WARP);
    67 
    68 # Look for programs we need
    69 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 }
    7882
    7983# Get list of component imfiles for exposure
Note: See TracChangeset for help on using the changeset viewer.