- Timestamp:
- Apr 6, 2023, 6:00:06 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/eam/rawfix.20230221/src/check_md5s_dateobs.pl
r42441 r42444 20 20 21 21 my $Nfail = 0; 22 my %failchips; 23 my %goodchips; 22 24 23 25 foreach my $instfile (@instlist) { … … 80 82 81 83 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"; } 84 86 } 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"; } 88 89 } 89 90 } 90 91 } 91 92 93 # save both good and fail chip lists 94 open (OUTFILE, ">$topdir/$dateword/goodchips.$stage.txt"); 95 my @goodchipURIs = keys %goodchips; 96 foreach my $uri (@goodchipURIs) { 97 print OUTFILE "$uri\n"; 98 } 99 close (OUTFILE); 100 101 open (OUTFILE, ">$topdir/$dateword/failchips.$stage.txt"); 102 my @failchipURIs = keys %failchips; 103 foreach my $uri (@failchipURIs) { 104 print OUTFILE "$uri\n"; 105 } 106 close (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 92 112 if ($Nfail) { 93 113 print STDOUT "ERROR: $Nfail errors\n"; … … 105 125 pod2usage( -msg => "Cannot determine target date, use --dateobs YYYY/MM/DD", -exitval => 2) unless defined $dateobs; 106 126 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"; } 108 132 109 133 # check the date format (require YYYY/MM/DD and use that from 00:00:00 to 23:59:59 or take start and end?) … … 126 150 return $status; 127 151 } 152 153 sub 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 169 sub 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 179 sub 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 189 sub is_integer { 190 defined $_[0] && $_[0] =~ /^[+-]?\d+$/; 191 }
Note:
See TracChangeset
for help on using the changeset viewer.
