Skip to content

Commit

Permalink
refactor(discretization.make_lgr_domain): add error trap for LGR grid…
Browse files Browse the repository at this point in the history
… corners outside of the parent model grid
  • Loading branch information
aleaf committed Jan 6, 2025
1 parent 965640f commit a2a514c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions mfsetup/discretization.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,16 @@ def make_lgr_idomain(parent_modelgrid, inset_modelgrid,
y1 = inset_modelgrid.ycellcenters[-1, -1]
pi1, pj1 = parent_modelgrid.intersect(x1, y1, forgive=True)
idomain = np.ones(parent_modelgrid.shape, dtype=int)
if any(np.isnan([pi0, pj0])):
raise ValueError(f"LGR model upper left corner {pi0}, {pj0} "
"is outside of the parent model domain! "
"Check the grid offset and dimensions."
)
if any(np.isnan([pi1, pj1])):
raise ValueError(f"LGR model lower right corner {pi0}, {pj0} "
"is outside of the parent model domain! "
"Check the grid offset and dimensions."
)
idomain[0:(np.array(ncppl) > 0).sum(),
pi0:pi1+1, pj0:pj1+1] = 0
return idomain
Expand Down

0 comments on commit a2a514c

Please sign in to comment.