Skip to content

Commit 86cf97e

Browse files
committed
Script to update DOIs
1 parent 759def9 commit 86cf97e

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

scripts/fix_dois_202512.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"""Script to update DOIs for G02202 V6 and G10116 V4.
2+
3+
On Dec. 11, 2025, we realized that the DOI for these products was wrong (used
4+
the previous version). This script updates existing nc files to have the correct
5+
DOI in order to avoid data reprocessing.
6+
"""
7+
8+
from pathlib import Path
9+
10+
from netCDF4 import Dataset
11+
12+
FINAL_DATA_DIR = Path("/share/apps/G02202_V6/v06r00_outputs/dev/trst2284/complete")
13+
NRT_DATA_DIR = Path("/share/apps/G10016_V4/v04r00/dev/trst2284/CDR/complete/")
14+
15+
FINAL_DOI = "https://doi.org/10.7265/b18j-z797"
16+
NRT_DOI = "https://doi.org/10.7265/tm2n-1m33"
17+
18+
19+
def update_dois(data_dir, doi):
20+
print(f"Updating nc files in {data_dir} with doi {doi}")
21+
for nc_file in data_dir.rglob("*.nc"):
22+
with Dataset(str(nc_file), "a") as nc:
23+
if "id" in nc.ncattrs():
24+
nc.setncattr("id", doi)
25+
else:
26+
print(
27+
f"Did not update doi in {nc_file} because it lacked an `id` attr."
28+
)
29+
30+
31+
if __name__ == "__main__":
32+
update_dois(FINAL_DATA_DIR, FINAL_DOI)
33+
update_dois(NRT_DATA_DIR, NRT_DOI)

0 commit comments

Comments
 (0)