IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 23, 2008, 5:10:21 PM (18 years ago)
Author:
Paul Price
Message:

Adding hostname to database values.

File:
1 edited

Legend:

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

    r17671 r17803  
    2828     $no_update, $no_op );
    2929GetOptions(
    30            'exp_id=s'      => \$exp_id,    # Exposure identifier
    31            'exp_tag=s'     => \$exp_tag,   # Exposure identifier
    32            'chip_id=s'     => \$chip_id,   # Chiptool identifier
    33            'class_id=s'    => \$class_id,  # Class identifier
    34            'uri|u=s'       => \$uri,       # Input FITS file
    35            'camera|c=s'    => \$camera,    # Camera
    36            'outroot|w=s'   => \$outroot,   # output file base name
    37            'dbname|d=s'    => \$dbname,    # Database name
    38            'reduction=s'   => \$reduction, # Reduction class
    39            'verbose'       => \$verbose,   # Print to stdout
    40            'no-update'     => \$no_update, # Don't update the database?
    41            'no-op'         => \$no_op,     # Don't do any operations?
    42            ) or pod2usage( 2 );
     30           'exp_id=s'      => \$exp_id,    # Exposure identifier
     31           'exp_tag=s'     => \$exp_tag,   # Exposure identifier
     32           'chip_id=s'     => \$chip_id,   # Chiptool identifier
     33           'class_id=s'    => \$class_id,  # Class identifier
     34           'uri|u=s'       => \$uri,       # Input FITS file
     35           'camera|c=s'    => \$camera,    # Camera
     36           'outroot|w=s'   => \$outroot,   # output file base name
     37           'dbname|d=s'    => \$dbname,    # Database name
     38           'reduction=s'   => \$reduction, # Reduction class
     39           'verbose'       => \$verbose,   # Print to stdout
     40           'no-update'     => \$no_update, # Don't update the database?
     41           'no-op'         => \$no_op,     # Don't do any operations?
     42           ) or pod2usage( 2 );
    4343
    4444pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    4545pod2usage( -msg => "Required options: --exp_id --exp_tag --chip_id --class_id --uri --camera --outroot",
    46            -exitval => 3) unless
     46           -exitval => 3) unless
    4747    defined $exp_id and
    4848    defined $exp_tag and
     
    7474       { name => "ROBUST_MEDIAN",  type => "stdev", flag => "-bg_mean_stdev",  dtype => "float" },
    7575       { name => "ROBUST_STDEV",   type => "rms",   flag => "-bg_stdev",       dtype => "float" },
    76        { name => "OVER_VAL",       type => "mean",  flag => "-bias",           dtype => "float" },
     76       { name => "OVER_VAL",       type => "mean",  flag => "-bias",           dtype => "float" },
    7777       { name => "OVER_VAL",       type => "stdev", flag => "-bias_stdev",     dtype => "float" },
    7878       { name => "FRINGE_0",       type => "rms",   flag => "-fringe_0",       dtype => "float" },
     
    107107}
    108108
    109 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
     109my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
    110110
    111111&my_die("Couldn't find input file: $uri\n", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($uri);
     
    124124my $outputWeight  = $ipprc->filename("PPIMAGE.CHIP.WEIGHT", $outroot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $chip_id, $class_id, $PS_EXIT_CONFIG_ERROR);
    125125my $outputBin1    = $ipprc->filename("PPIMAGE.BIN1",        $outroot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $chip_id, $class_id, $PS_EXIT_CONFIG_ERROR);
    126 my $outputBin2    = $ipprc->filename("PPIMAGE.BIN2",        $outroot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $chip_id, $class_id, $PS_EXIT_CONFIG_ERROR);
    127 my $outputStats   = $ipprc->filename("PPIMAGE.STATS",       $outroot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $chip_id, $class_id, $PS_EXIT_CONFIG_ERROR);
    128 my $traceDest     = $ipprc->filename("TRACE.IMFILE",        $outroot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $chip_id, $class_id, $PS_EXIT_CONFIG_ERROR);
    129 my $logDest       = $ipprc->filename("LOG.IMFILE",          $outroot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $chip_id, $class_id, $PS_EXIT_CONFIG_ERROR);
     126my $outputBin2    = $ipprc->filename("PPIMAGE.BIN2",        $outroot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $chip_id, $class_id, $PS_EXIT_CONFIG_ERROR);
     127my $outputStats   = $ipprc->filename("PPIMAGE.STATS",       $outroot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $chip_id, $class_id, $PS_EXIT_CONFIG_ERROR);
     128my $traceDest     = $ipprc->filename("TRACE.IMFILE",        $outroot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $chip_id, $class_id, $PS_EXIT_CONFIG_ERROR);
     129my $logDest       = $ipprc->filename("LOG.IMFILE",          $outroot, $class_id) or &my_die("Missing entry from camera config", $exp_id, $chip_id, $class_id, $PS_EXIT_CONFIG_ERROR);
    130130
    131131# Run ppImage
     
    141141
    142142    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    143         run(command => $command, verbose => $verbose);
     143        run(command => $command, verbose => $verbose);
    144144    unless ($success) {
    145         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    146         &my_die("Unable to perform ppImage: $error_code", $exp_id, $chip_id, $class_id, $error_code);
     145        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     146        &my_die("Unable to perform ppImage: $error_code", $exp_id, $chip_id, $class_id, $error_code);
    147147    }
    148148
     
    150150    $command = "$ppConfigDump -camera $camera -dump-recipe PPIMAGE -recipe PPIMAGE $recipe -";
    151151    ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    152         run(command => $command, verbose => $verbose);
     152        run(command => $command, verbose => $verbose);
    153153    unless ($success) {
    154         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    155         &my_die("Unable to perform ppConfigDump: $error_code", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
     154        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     155        &my_die("Unable to perform ppConfigDump: $error_code", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
    156156    }
    157157    my $recipeData = $mdcParser->parse(join "", @$stdout_buf) or
    158         &my_die("Unable to parse metadata config doc", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
     158        &my_die("Unable to parse metadata config doc", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
    159159
    160160    ## allow the output images to be optional, depending on the recipe / reduction class
    161161    my $outputImageExpect = metadataLookupBool($recipeData, 'CHIP.FITS');
    162162    if ($outputImageExpect) {
    163         &my_die("Couldn't find expected output file: $outputImage\n",  $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputImage);
     163        &my_die("Couldn't find expected output file: $outputImage\n",  $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputImage);
    164164    }
    165165
    166166    my $outputMaskExpect = metadataLookupBool($recipeData, 'CHIP.MASK.FITS');
    167167    if ($outputMaskExpect) {
    168         &my_die("Couldn't find expected output file: $outputMask\n",   $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputMask);
     168        &my_die("Couldn't find expected output file: $outputMask\n",   $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputMask);
    169169    }
    170170
    171171    my $outputWeightExpect = metadataLookupBool($recipeData, 'CHIP.WEIGHT.FITS');
    172172    if ($outputWeightExpect) {
    173         &my_die("Couldn't find expected output file: $outputWeight\n", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputWeight);
     173        &my_die("Couldn't find expected output file: $outputWeight\n", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputWeight);
    174174    }
    175175
     
    179179
    180180    # Get the statistics on the processed image
    181     my $statsFile;              # File handle
     181    my $statsFile;              # File handle
    182182    open $statsFile, $ipprc->file_resolve($outputStats) or &my_die("Can't open statistics file $outputStats: $!", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR);
    183183    my @contents = <$statsFile>; # Contents of file
     
    185185
    186186    # parse the statistics MDC file
    187     my $mdcParser = PS::IPP::Metadata::Config->new();   # Parser for metadata config files
     187    my $mdcParser = PS::IPP::Metadata::Config->new();   # Parser for metadata config files
    188188    my $metadata = $mdcParser->parse(join "", @contents);
    189189    unless ($metadata) {
    190         &my_die("Unable to parse metadata config doc", $exp_id, $chip_id, $class_id, $PS_EXIT_PROG_ERROR);
     190        &my_die("Unable to parse metadata config doc", $exp_id, $chip_id, $class_id, $PS_EXIT_PROG_ERROR);
    191191    }
    192192
    193193    # extract the stats from the metadata
    194194    unless ($stats->parse($metadata)) {
    195         &my_die("Failure extracting metadata from the statistics output file.\n", $exp_id, $chip_id, $class_id, $PS_EXIT_PROG_ERROR);
     195        &my_die("Failure extracting metadata from the statistics output file.\n", $exp_id, $chip_id, $class_id, $PS_EXIT_PROG_ERROR);
    196196    }
    197197}
     
    204204$command .= " -uri $outputImage";
    205205$command .= " -path_base $outroot";
     206$command .= " -hostname $host" if defined $host;
    206207$command .= " -dbname $dbname" if defined $dbname;
    207208$command .= $stats->cmdflags();
     
    210211unless ($no_update) {
    211212    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    212         run(command => $command, verbose => $verbose);
     213        run(command => $command, verbose => $verbose);
    213214    unless ($success) {
    214         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    215         warn("Unable to perform chiptool -addprocessedimfile: $error_code\n");
    216         exit($error_code);
     215        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     216        warn("Unable to perform chiptool -addprocessedimfile: $error_code\n");
     217        exit($error_code);
    217218    }
    218219} else {
     
    230231    carp($msg);
    231232    if (defined $chip_id and defined $class_id and not $no_update) {
    232         my $command = "$chiptool -addprocessedimfile";
    233         $command .= " -exp_id $exp_id";
    234         $command .= " -chip_id $chip_id";
    235         $command .= " -class_id $class_id";
    236         $command .= " -code $exit_code";
    237         $command .= " -uri $outputImage";
    238         $command .= " -dbname $dbname" if defined $dbname;
     233        my $command = "$chiptool -addprocessedimfile";
     234        $command .= " -exp_id $exp_id";
     235        $command .= " -chip_id $chip_id";
     236        $command .= " -class_id $class_id";
     237        $command .= " -code $exit_code";
     238        $command .= " -uri $outputImage";
     239        $command .= " -hostname $host" if defined $host;
     240        $command .= " -dbname $dbname" if defined $dbname;
    239241        system ($command);
    240242    }
Note: See TracChangeset for help on using the changeset viewer.