From d8b31979ce5af38440cec9ed66bbbf43e7877ab6 Mon Sep 17 00:00:00 2001 From: "Navid C. Constantinou" Date: Thu, 9 May 2024 14:03:29 +0300 Subject: [PATCH] attempt to simplify IC --- demos/reanalysis-forced.ipynb | 12 +----------- regional_mom6/regional_mom6.py | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/demos/reanalysis-forced.ipynb b/demos/reanalysis-forced.ipynb index 82607591..a84ba3fa 100644 --- a/demos/reanalysis-forced.ipynb +++ b/demos/reanalysis-forced.ipynb @@ -288,17 +288,7 @@ " glorys_path / \"ic_unprocessed.nc\", # directory where the unprocessed initial condition is stored, as defined earlier\n", " ocean_varnames,\n", " arakawa_grid=\"A\"\n", - " )\n", - "\n", - "# Now iterate through our four boundaries \n", - "for i, orientation in enumerate([\"south\", \"north\", \"west\", \"east\"]):\n", - " expt.rectangular_boundary(\n", - " glorys_path / (orientation + \"_unprocessed.nc\"),\n", - " ocean_varnames,\n", - " orientation, # Needs to know the cardinal direction of the boundary\n", - " i + 1, # Just a number to identify the boundary. Indexes from 1 \n", - " arakawa_grid=\"A\"\n", - " )" + " ) " ] }, { diff --git a/regional_mom6/regional_mom6.py b/regional_mom6/regional_mom6.py index a28e8d4b..0104c7ee 100644 --- a/regional_mom6/regional_mom6.py +++ b/regional_mom6/regional_mom6.py @@ -567,7 +567,12 @@ def _make_vgrid(self): return vcoord def initial_condition( - self, ic_path, varnames, arakawa_grid="A", vcoord_type="height" + self, + ic_path, + varnames, + arakawa_grid="A", + vcoord_type="height", + boundaries=["south", "north", "west", "east"], ): """ Reads the initial condition from files in ``ic_path``, interpolates to the @@ -874,11 +879,23 @@ def initial_condition( "eta_t": {"_FillValue": None}, }, ) - print("done setting up initial condition.") self.ic_eta = eta_out self.ic_tracers = tracers_out self.ic_vels = vel_out + + # Now iterate through our four boundaries + for i, orientation in enumerate(boundaries, start=1): + self.rectangular_boundary( + glorys_path / (orientation + "_unprocessed.nc"), + ocean_varnames, + orientation, # The cardinal direction of the boundary + i, # A number to identify the boundary; indexes from 1 + arakawa_grid=arakawa_grid, + ) + + print("done setting up initial condition.") + return def rectangular_boundary(