IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 10296


Ignore:
Timestamp:
Nov 29, 2006, 1:43:22 PM (19 years ago)
Author:
Paul Price
Message:

Speeding up parsing of huge metadata.

File:
1 edited

Legend:

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

    r9869 r10296  
    5858
    5959# Get the list of inputs
    60 my $files;                      # The input files
     60my @files;                      # The input files
    6161{
    6262    my $command = "$dettool -processedimfile -det_id $detId"; # Command to run
     
    6868    print $stdout . "\n";
    6969   
    70     # Parse the output
    71     my $metadata = $mdcParser->parse($stdout)
    72         or die "unable to parse metadata config doc";
    73     $files = parse_md_list($metadata);
     70    # Because of the length, need to split into individual metadatas --- it parses SO much quicker!
     71    my @whole = split /\n/, $stdout;
     72    my @single = ();
     73    while ( scalar @whole > 0 ) {
     74        my $value = shift @whole;
     75        push @single, $value;
     76        if ($value =~ /^\s*END\s*$/) {
     77            push @single, "\n";
     78
     79            my $list = parse_md_list( $mdcParser->parse( join( "\n", @single ) ) ) or
     80                die "Unable to parse output from dettool.\n";
     81            push @files, $list;
     82        }
     83    }
    7484}
    75 
    7685
    7786my $norms;                      # MDC with normalisations
     
    7988
    8089    my %matrix; # Matrix of statistics as a function of exposures and classes
    81     foreach my $file (@$files) {
     90    foreach my $file (@files) {
    8291        my $expTag = $file->{'exp_tag'}; # Exposure ID
    8392        my $classId = $file->{'class_id'}; # Class ID
     
    116125    # It's something that doesn't need normalisation --- just push in a normalisation of 1
    117126    my %classes;                # List of unique classes
    118     foreach my $file (@$files) {
     127    foreach my $file (@files) {
    119128        my $classId = $file->{'class_id'}; # Class Id
    120129        $classes{$classId} = 1;
Note: See TracChangeset for help on using the changeset viewer.