Skip to content

Commit 874cd59

Browse files
committed
Add script to regenerate checksums
1 parent 1c7ff6d commit 874cd59

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

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)