Skip to content

Commit 993c7ac

Browse files
Merge pull request #204 from nsidc/regenerate-checksums
Add script to regenerate checksums
2 parents 1c7ff6d + 23615f4 commit 993c7ac

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

scripts/fix_dois_202512.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
On Dec. 11, 2025, we realized that the DOI for these products was wrong (used
44
the previous version). This script updates existing nc files to have the correct
55
DOI in order to avoid data reprocessing.
6+
7+
NOTE/WARNING: if this is ever re-used in the future, remember to update the
8+
output file checksums (`.mnf` files) after. This script does NOT update the
9+
associated checksum file - it just updates the DOI metadata. See the
10+
`regenerate_checksums.py` script.
611
"""
712

813
from pathlib import Path

scripts/regenerate_checksums.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"""Code to regenerate checksums of CDR output files.
2+
3+
To run, manually update the `DATA_DIR` to the G02202/G10016 complete output
4+
directory you want updated.
5+
"""
6+
7+
from multiprocessing import Pool
8+
from pathlib import Path
9+
10+
from pm_tb_data._types import Hemisphere
11+
12+
from seaice_ecdr.checksum import write_checksum_file
13+
14+
# DATA_DIR = Path("/share/apps/G10016_V4/v04r00/dev/trst2284/CDR/complete/")
15+
# DATA_DIR = Path("/share/apps/G02202_V6/v06r00_outputs/dev/trst2284/complete")
16+
# DATA_DIR = Path("/share/apps/G10016_V4/v04r00/production/CDR/complete")
17+
DATA_DIR = Path("/share/apps/G02202_V6/v06r00_outputs/production/complete/")
18+
19+
20+
def regenerate_for_hemisphere(hemisphere: Hemisphere):
21+
hemisphere_dir = DATA_DIR / hemisphere
22+
nc_fps = sorted(list(hemisphere_dir.rglob("*.nc")))
23+
24+
# Create associated checksum file.
25+
for nc_fp in nc_fps:
26+
subdir = nc_fp.parent.relative_to(hemisphere_dir)
27+
checksum_dir = hemisphere_dir / "checksums" / subdir
28+
write_checksum_file(input_filepath=nc_fp, output_dir=checksum_dir)
29+
30+
31+
if __name__ == "__main__":
32+
with Pool() as p:
33+
p.map(regenerate_for_hemisphere, ["north", "south"])

0 commit comments

Comments
 (0)