IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 2, 2006, 5:48:37 PM (20 years ago)
Author:
Paul Price
Message:

Changing over to using ppImage to do the normalisation. Adding statistics from ppImage into the database.

File:
1 edited

Legend:

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

    r9094 r9141  
    4343
    4444
     45use constant RECIPE => 'PPIMAGE_N'; # Recipe to use with ppImage
     46
    4547# Look for programs we need
    4648my $missing_tools;
    4749my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1);
    48 my $ppArith = can_run('ppArith') or (warn "Can't find ppArith" and $missing_tools = 1);
     50my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1);
    4951die "Can't find required tools.\n" if $missing_tools;
    5052
    5153# Output name
    52 my $output = $camera . '.' . $detType . '.norm.' . $detId . '.' . $iter . '.' . $classId . '.fits';
     54my $outputRoot = $camera . '.' . $detType . '.norm.' . $detId . '.' . $iter; # Root output name
     55my $output = $outputRoot . '.' . $classId . '.fits'; # Main output file
     56my $b1name = $outputRoot . '.' . $classId . '.b1.fits'; # Output file with binning 1
     57my $b2name = $outputRoot . '.' . $classId . '.b2.fits'; # Output file with binning 2
     58my $statName = $outputRoot . '.' . $classId . '.stats'; # Statistics file
    5359
    5460# Run ppArith
    55 my $norms;
    5661{
    57     my $command = "$ppArith -file1 $input -op * -constant $value -out $output"; # Command to run
     62    my $command = "$ppImage -file $input $outputRoot -norm $value -stat $statName -recipe PPIMAGE " . RECIPE(); # Command to run
    5863    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    5964        run(command => $command, verbose => 1);
    60     die "Unable to perform ppArith: $error_code\n" if not $success;
     65    die "Unable to perform ppImage: $error_code\n" if not $success;
    6166    die "Can't find expected output file: $output\n" if not -e $output;
     67    die "Can't find expected output file: $b1name\n" if not -e $b1name;
     68    die "Can't find expected output file: $b2name\n" if not -e $b2name;
     69    die "Can't find expected output file: $statName\n" if not -e $statName;
     70}
     71
     72# Get the statistics on the normalised image
     73my $stats;                      # Statistics from ppImage
     74{
     75    my $statsFile;              # File handle
     76    open $statsFile, $statsName or die "Can't open statistics file $statsName: $!\n";
     77    my @contents = <$statsFile>; # Contents of file
     78    close $statsFile;
     79    my $mdcParser = PS::IPP::Metadata::Config->new;     # Parser for metadata config files
     80    my $metadata = $mdcParser->parse(join "", @contents)
     81        or die "unable to parse metadata config";
     82    $stats = PS::IPP::Metadata::Stats->new(); # Stats parser
     83    $stats->parse($metadata) or die "Unable to find all values in statistics output.\n";
    6284}
    6385
     
    6688unless ($no_update) {
    6789    my $command = "$dettool -addnormalizedimfile -det_id $detId -iteration $iter -class_id $classId ".
    68         "-uri $output"; # Command to run
     90        "-uri $output -b1_uri $b1name -b2_uri $b2name"; # Command to run
     91    # Add the statistics triplet
     92    $command .= " -bg " . $stats->bg_mean();
     93    if (defined($stats->bg_stdev())) {
     94        $command .= " -bg_stdev " . $stats->bg_stdev();
     95    } else {
     96        # May be undefined if there's only a single imfile
     97        $command .= " -bg_stdev 0";
     98    }
     99    $command .= " -bg_mean_stdev " . $stats->bg_mean_stdev();
    69100    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    70101        run(command => $command, verbose => 1);
Note: See TracChangeset for help on using the changeset viewer.