From 1d831ae5ec24e6e2c63ff51296460333c7dac25e Mon Sep 17 00:00:00 2001 From: biljanaorescanin Date: Thu, 18 Sep 2025 14:19:57 -0400 Subject: [PATCH] add v14 bcs and update topo path --- pre/remap_restart/remap_questions.py | 4 +-- pre/remap_restart/remap_utils.py | 37 +++++++++++++++++++--------- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/pre/remap_restart/remap_questions.py b/pre/remap_restart/remap_questions.py index 481c3f0..44f42f3 100755 --- a/pre/remap_restart/remap_questions.py +++ b/pre/remap_restart/remap_questions.py @@ -308,7 +308,7 @@ def ask_questions(): "name": "output:shared:bc_version", "message": message_bc_other_new, "choices": choices_bc_other, - "when": lambda x: x["output:shared:bc_version"] == 'Other' and x["input:shared:bc_version"] not in ['v06','v11','v12'], + "when": lambda x: x["output:shared:bc_version"] == 'Other' and x["input:shared:bc_version"] not in ['v06','v11','v12','v14'], }, { @@ -316,7 +316,7 @@ def ask_questions(): "name": "output:shared:bc_version", "message": "\nSelect BCs version for new restarts:\n", "choices": choices_bc_other, - "when": lambda x: x["output:shared:bc_version"] == 'Other' and x["input:shared:bc_version"] in ['v06','v11','v12'], + "when": lambda x: x["output:shared:bc_version"] == 'Other' and x["input:shared:bc_version"] in ['v06','v11','v12','v14'], }, { diff --git a/pre/remap_restart/remap_utils.py b/pre/remap_restart/remap_utils.py index 783302a..cbe58ee 100755 --- a/pre/remap_restart/remap_utils.py +++ b/pre/remap_restart/remap_utils.py @@ -13,6 +13,7 @@ import shlex import netCDF4 as nc import linecache +import re # shared global variables @@ -31,9 +32,9 @@ choices_bc_ops = ['NL3', 'ICA', 'GM4', 'Other'] -choices_bc_other = ['v06','v11','v12'] +choices_bc_other = ['v06','v11','v12','v14'] -choices_bc_cmd = ['NL3', 'ICA', 'GM4', 'v06', 'v11','v12'] +choices_bc_cmd = ['NL3', 'ICA', 'GM4', 'v06', 'v11','v12', 'v14'] choices_omodel = ['data', 'MOM5', 'MOM6'] @@ -93,7 +94,8 @@ v06: NL3 + JPL veg height + PEATMAP + MODIS snow alb\n v11: NL3 + JPL veg height + PEATMAP + MODIS snow alb v2\n - v12: NL3 + JPL veg height + PEATMAP + MODIS snow alb v2 + Argentina peatland fix \n\n'''\ + v12: NL3 + JPL veg height + PEATMAP + MODIS snow alb v2 + Argentina peatland fix \n + v14: v12 + Coupled MOM6/v2 ocean bathymetry (OM4) and v2 topography for atmosphere \n\n'''\ message_bc_other_in = ("Select BCs version of input restarts:\n" + message_bc_other) message_bc_other_new = ("Select BCs version for new restarts:\n" + message_bc_other) @@ -618,16 +620,29 @@ def get_default_bc_base(): return choices_bc_base[0] return choices_bc_base[1] + def get_topodir(bc_base, bc_version, agrid=None, ogrid=None, omodel=None, stretch=None): - gridStr = get_resolutions(agrid=agrid, ogrid=ogrid, omodel=omodel,stretch=stretch) - agrid_name = gridStr.split('_')[0] - bc_topo = '' - if 'GM4' == bc_version: - bc_topo = bc_base + '/' + bc_version + '/TOPO/TOPO_' + agrid_name - else: - bc_topo = bc_base + '/' + bc_version + '/TOPO/TOPO_' + agrid_name + '/smoothed' + gridStr = get_resolutions(agrid=agrid, ogrid=ogrid, omodel=omodel, stretch=stretch) + agrid_name = gridStr.split('_')[0] + + v = str(bc_version).strip().upper() + + # GM4 stays on legacy tiles tree + if v.startswith('GM4'): + return os.path.join(str(bc_base), 'GM4', 'TOPO', f'TOPO_{agrid_name}') + + # v2 from v14+, else v1 + m = re.search(r'(\d+)', v) + ver_num = int(m.group(1)) if m else None + stream = 'v2' if (ver_num is not None and ver_num >= 14) else 'v1' + + # Derive new topo base from bc_base; fallback to default if pattern not found + bc_base_str = str(bc_base or '') + topo_base = re.sub(r'/fvInput/ExtData/esm/tiles/?$', '/make_bcs_inputs/atmosphere', bc_base_str) + if topo_base == bc_base_str or not topo_base: + topo_base = '/discover/nobackup/projects/gmao/bcs_shared/make_bcs_inputs/atmosphere' - return bc_topo + return os.path.join(topo_base, 'TOPO', stream, agrid_name, 'smoothed') def get_landdir(bc_base, bc_version, agrid=None, ogrid=None, omodel=None, stretch=None, grid=None): gridStr = get_resolutions(agrid=agrid, ogrid=ogrid, omodel=omodel,stretch=stretch, grid=grid)