Skip to content

Commit

Permalink
Test with single dates
Browse files Browse the repository at this point in the history
  • Loading branch information
zmoon committed Sep 27, 2024
1 parent 99888ce commit 9fa7dd8
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions utils/python/nexus_nei2019_linker.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def link_file(src_file, tgt_file):
"--src_dir",
help=(
"Source Directory to Emission files "
"e.g., /scratch1/RDARCH/rda-arl-gpu/Barry.Baker/emissions/nexus/ on Hera."
"e.g., /scratch1/RDARCH/rda-arl-gpu/Barry.Baker/emissions/nexus on Hera."
),
type=str,
required=True,
Expand All @@ -99,9 +99,15 @@ def link_file(src_file, tgt_file):
"-t",
"--read_hemco_time",
help="Read HEMCO time file",
action="store_true",
default=True,
required=False,
)
parser.add_argument(
"--no_read_hemco_time",
action="store_false",
dest="read_hemco_time",
)
parser.add_argument(
"-tf",
"--time_file_path",
Expand All @@ -118,8 +124,8 @@ def link_file(src_file, tgt_file):
)
args = parser.parse_args()

src_dir = args.src_dir
work_dir = args.work_dir
src_dir = args.src_dir.rstrip("/")
work_dir = args.work_dir.rstrip("/")
version = args.nei_version

if args.read_hemco_time:
Expand All @@ -136,6 +142,7 @@ def link_file(src_file, tgt_file):
raise SystemExit(2)

file_map = get_file_map(src_dir, version)
print("file map size:", len(file_map))
if not file_map:
print(f"error: no files found in {src_dir} for version {version!r}")
raise SystemExit(1)
Expand All @@ -145,7 +152,7 @@ def link_file(src_file, tgt_file):
mo = d.month
iwd = d.isoweekday()

print(f"date: {d}, month: {mo}, iwd: {iwd}")
print(f"date: {d}, month: {mo}, isoweekday: {iwd}")
src = file_map.get((mo, iwd))
if src is None:
print(f"error: no file found for month {mo}, iwd {iwd}")
Expand All @@ -159,6 +166,7 @@ def link_file(src_file, tgt_file):
os.path.dirname(os.path.relpath(src_fp, src_dir)),
tgt_fn,
)
os.makedirs(os.path.dirname(tgt_fp), exist_ok=True)

print("linking", src_fp, "to", tgt_fp)
link_file(src_fp, tgt_fp)

0 comments on commit 9fa7dd8

Please sign in to comment.