Skip to content

Commit 510d100

Browse files
committed
Add bctide to prepare_schism
Hook bctide with main prepare schism tool. If btides section exist in main schism yaml, prepare_schism will generate bctide files
1 parent a9f7006 commit 510d100

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

schimpy/prepare_schism.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
FloorOptions,
1919
TVDOptions,
2020
)
21+
from schimpy.schism_yaml import load
22+
from schimpy.bctide import load_boundary
23+
2124
import dms_datastore.dstore_config as configs
2225
from packaging.version import Version, InvalidVersion
2326
import datetime
@@ -748,6 +751,7 @@ def process_prepare_yaml(in_fname, use_logging=True, write_echo=True):
748751
"flow_outputs",
749752
"station_output",
750753
"copy_resources",
754+
"bctides",
751755
] + schism_yaml.include_keywords
752756
logger.info("Processing the top level...")
753757
check_and_suggest(list(inputs.keys()), keys_top_level, logger)
@@ -768,6 +772,7 @@ def process_prepare_yaml(in_fname, use_logging=True, write_echo=True):
768772
def prepare_schism(args, use_logging=True):
769773
inputs, outdir, logger = process_prepare_yaml(args.main_inputfile, use_logging)
770774

775+
hgrid = None
771776
# Mesh section
772777
if item_exist(inputs, "mesh"):
773778
logger.info("Processing mesh section...")
@@ -790,10 +795,25 @@ def prepare_schism(args, use_logging=True):
790795
mesh_input_fpath = os.path.expanduser(mesh_items["mesh_inputfile"])
791796
s = create_schism_setup(mesh_input_fpath, logger)
792797
update_spatial_inputs(s, inputs, logger)
798+
hgrid = s.mesh
793799
else:
794800
raise ValueError("No mesh input file in the mesh section.")
795801
else:
796802
raise ValueError("No mesh section in the main input.")
803+
804+
if item_exist(inputs, "bctides"):
805+
logger.info("Processing bctides section...")
806+
bctides_items = inputs["bctides"]
807+
if hgrid is None:
808+
raise ValueError("Mesh must be processed before bctides section.")
809+
810+
# If mesh already loaded above, reuse it
811+
for bctides_out in bctides_items:
812+
logger.info(f"Processing bctides YAML: {bctides_out}")
813+
by = load_boundary(hgrid, bctides_items[bctides_out], None)
814+
# Output file name: use YAML path or key
815+
by.write_bctides(bctides_out)
816+
797817

798818
if item_exist(inputs, "copy_resources"):
799819
logger.info("Copying resources to output dir")

0 commit comments

Comments
 (0)