Skip to content

Commit

Permalink
Add boundaries to config
Browse files Browse the repository at this point in the history
  • Loading branch information
manishvenu committed Oct 22, 2024
1 parent 8476f28 commit 9b322b0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 6 additions & 4 deletions regional_mom6/regional_mom6.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ def create_experiment_from_config(
expt.layout = None
expt.minimum_depth = config_dict["minimum_depth"]
expt.tidal_constituents = config_dict["tidal_constituents"]
expt.boundaries = config_dict["boundaries"]

if create_hgrid_and_vgrid:
print("Creating hgrid and vgrid....")
Expand Down Expand Up @@ -1089,6 +1090,7 @@ def write_config_file(self, path=None, export=True, quiet=False):
"layout": self.layout,
"minimum_depth": self.minimum_depth,
"tidal_constituents": self.tidal_constituents,
"boundaries": self.boundaries,
}
if export:
if path is not None:
Expand Down Expand Up @@ -1555,6 +1557,10 @@ def setup_ocean_state_boundaries(
Either ``'A'`` (default), ``'B'``, or ``'C'``.
boundary_type (Optional[str]): Type of box around region. Currently, only ``'rectangular'`` is supported.
"""
if boundary_type != "rectangular":
raise ValueError(
"Only rectangular boundaries are supported by this method. To set up more complex boundary shapes you can manually call the 'simple_boundary' method for each boundary."
)
for i in self.boundaries:
if i not in ["south", "north", "west", "east"]:
raise ValueError(
Expand All @@ -1570,10 +1576,6 @@ def setup_ocean_state_boundaries(
raise ValueError(
"This method only supports up to four boundaries. To set up more complex boundary shapes you can manually call the 'simple_boundary' method for each boundary."
)
if boundary_type != "rectangular":
raise ValueError(
"Only rectangular boundaries are supported by this method. To set up more complex boundary shapes you can manually call the 'simple_boundary' method for each boundary."
)

# Now iterate through our four boundaries
for orientation in self.boundaries:
Expand Down
2 changes: 2 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def test_write_config():
mom_input_dir=input_dir,
toolpath_dir="",
expt_name="test",
boundaries=["south", "north"],
)
config_dict = expt.write_config_file()
assert config_dict["longitude_extent"] == tuple(longitude_extent)
Expand All @@ -62,6 +63,7 @@ def test_write_config():
assert config_dict["repeat_year_forcing"] == False
assert config_dict["tidal_constituents"] == ["M2"]
assert config_dict["expt_name"] == "test"
assert config_dict["boundaries"] == ["south", "north"]
shutil.rmtree(run_dir)
shutil.rmtree(input_dir)
shutil.rmtree(data_path)
Expand Down

0 comments on commit 9b322b0

Please sign in to comment.