IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 6, 2023, 6:00:06 PM (3 years ago)
Author:
eugene
Message:

big re-work to allow repeat, iterated fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/eam/rawfix.20230221/src/check_md5s_dateobs.pl

    r42441 r42444  
    2020
    2121my $Nfail = 0;
     22my %failchips;
     23my %goodchips;
    2224
    2325foreach my $instfile (@instlist) {
     
    8082
    8183        if ($md5tru ne $md5obs) {
    82             print STDOUT "FAIL: $inst $state $md5tru $md5obs\n";
    83             $Nfail ++;
     84            &save_failure ($inst);
     85            if ($DEBUG > 2) { print STDOUT "FAIL: $inst $state $md5tru $md5obs\n"; }
    8486        } else {
    85             if ($DEBUG > 2) {
    86                 print STDOUT "$inst $state $md5tru = $md5obs\n";
    87             }
     87            &save_goodchip ($inst);
     88            if ($DEBUG > 2) { print STDOUT "$inst $state $md5tru = $md5obs\n"; }
    8889        }
    8990    }
    9091}
    9192
     93# save both good and fail chip lists
     94open (OUTFILE, ">$topdir/$dateword/goodchips.$stage.txt");
     95my @goodchipURIs = keys %goodchips;
     96foreach my $uri (@goodchipURIs) {
     97    print OUTFILE "$uri\n";
     98}
     99close (OUTFILE);
     100
     101open (OUTFILE, ">$topdir/$dateword/failchips.$stage.txt");
     102my @failchipURIs = keys %failchips;
     103foreach my $uri (@failchipURIs) {
     104    print OUTFILE "$uri\n";
     105}
     106close (OUTFILE);
     107
     108
     109## we only report an error if we could not find the md5sum files or if the inst and md5s
     110## files are inconsistent.  In that case, we cannot check the md5s for all instances
     111## if the md5sum is wrong for a chip, mark that chip and save it.  It will be skipped in fix_chip_locations
    92112if ($Nfail) {
    93113    print STDOUT "ERROR: $Nfail errors\n";
     
    105125    pod2usage( -msg => "Cannot determine target date, use --dateobs YYYY/MM/DD", -exitval => 2) unless defined $dateobs;
    106126    pod2usage( -msg => "Specify the top-level output directory with --topdir", -exitval => 2) unless defined $topdir;
    107     pod2usage( -msg => "Define the stage (v0, v1, etc) with --stage", -exitval => 2) unless defined $stage;
     127    pod2usage( -msg => "Define the stage (0, 1, etc) with --stage", -exitval => 2) unless defined $stage;
     128   
     129    # check that stage is an integer
     130    unless (is_integer ($stage)) { die "stage must be a non-negative integer\n"; }
     131    unless ($stage >= 0) { die "stage must be a non-negative integer\n"; }
    108132   
    109133    # check the date format (require YYYY/MM/DD and use that from 00:00:00 to 23:59:59 or take start and end?)
     
    126150    return $status;
    127151}
     152
     153sub neb_reverse {
     154
     155    my (@neb_path) = split /\//, $_[0];
     156    my $neb_key = $neb_path[-1];
     157
     158    # Remove ins_id
     159    $neb_key =~ s/^\d+\.//;
     160
     161    # Convert colons to slashes.
     162    $neb_key =~ s%:%/%g;
     163
     164    # strip ending .fz added for compressed .fits images
     165    $neb_key =~ s%.fz$%%;
     166    return $neb_key;
     167}
     168
     169sub save_failure {
     170    my $nebfile = &neb_reverse($_[0]);
     171    if (defined $failchips{$nebfile}) {
     172        $failchips{$nebfile} ++;
     173    } else {
     174        $failchips{$nebfile} = 1;
     175    }
     176    return;
     177}
     178
     179sub save_goodchip {
     180    my $nebfile = &neb_reverse($_[0]);
     181    if (defined $goodchips{$nebfile}) {
     182        $goodchips{$nebfile} ++;
     183    } else {
     184        $goodchips{$nebfile} = 1;
     185    }
     186    return;
     187}
     188
     189sub is_integer {
     190   defined $_[0] && $_[0] =~ /^[+-]?\d+$/;
     191}
Note: See TracChangeset for help on using the changeset viewer.