Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def convert_hyfab_to_esmf(hyfab_gpkg: pathlib.Path, esmf_mesh_output: pathlib.Pa

# Eventually, we'll add code to slice catchment ids
# but for now just use feature ids
element_ids = np.array(np.array([elem.split('-')[1] for elem in np.array(hyfab.divide_id.values, dtype=str)], dtype=float), dtype=int)
element_ids = np.array(np.array([elem for elem in np.array(hyfab.div_id.values, dtype=str)], dtype=float), dtype=int)
hyfab_coords = np.empty((len(element_ids), 2), dtype=float)
hyfab_coords[:, 0] = element_ids
hyfab_coords[:, 1] = element_ids
Expand Down
38 changes: 27 additions & 11 deletions NextGen_Forcings_Engine_BMI/NextGen_Forcings_Engine/bmi_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,16 +216,16 @@ def initialize(self, config_file: str, output_path: str | None = None) -> None:
self._job_meta = ConfigOptions(self.cfg_bmi)

# Parse the configuration options
try:
self._job_meta.validate_config(self.cfg_bmi)
except KeyboardInterrupt as e:
err_handler.err_out_screen("User keyboard interrupt", e)
except ImportError as e:
err_handler.err_out_screen("Missing Python packages", e)
except InterruptedError as e:
err_handler.err_out_screen("External kill signal detected", e)
except Exception as e:
err_handler.err_out_screen("Unhandled exception", e)
# try:
# self._job_meta.validate_config(self.cfg_bmi)
# except KeyboardInterrupt as e:
# err_handler.err_out_screen("User keyboard interrupt", e)
# except ImportError as e:
# err_handler.err_out_screen("Missing Python packages", e)
# except InterruptedError as e:
# err_handler.err_out_screen("External kill signal detected", e)
# except Exception as e:
# err_handler.err_out_screen("Unhandled exception", e)

# Set NWM version and config, if provided in the config
if self.cfg_bmi.get("NWM_VERSION") is not None:
Expand Down Expand Up @@ -389,8 +389,24 @@ def initialize_with_params(
:param output_path: The output path for model results. If omitted, a default path will be generated.
:raises ValueError: If an invalid grid type is specified, an exception is raised.
"""
# This is required prior to the first log message.
LOG.bind()

bmi_cfg_file = Path(config_file).resolve()
if not bmi_cfg_file.is_file():
LOG.critical(f"Config file {bmi_cfg_file} not found, nothing to do...")
raise RuntimeError(
f"Config file {bmi_cfg_file} not found, nothing to do..."
)

LOG.info(f"Reading config file: {bmi_cfg_file}")
with bmi_cfg_file.open("r") as fp:
cfg = yaml.safe_load(fp)

self.cfg_bmi = parse_config(cfg)
# Set the job metadata parameters (b_date, geogrid) using config_options
self._job_meta = ConfigOptions(self.cfg_bmi, b_date=b_date, geogrid_arg=geogrid)
self.cfg_bmi = parse_config(cfg)
self._job_meta = ConfigOptions(self.cfg_bmi, b_date=b_date, geogrid=geogrid)

# Now that _job_meta is set, call initialize() to set up the core model
self.initialize(config_file, output_path=output_path)
Expand Down
Loading