From 4d68f79725cd5a234abef4c758abf26856aa3b4d Mon Sep 17 00:00:00 2001 From: Joshua Larsen Date: Fri, 22 Nov 2019 12:10:09 -0700 Subject: [PATCH] fix(ModflowDis.sr): rotate model prior to calculating xll and yll from xul and yul. modflowpy#733 --- autotest/t007_test.py | 26 ++++++++++++++++++++++++++ flopy/modflow/mfdis.py | 2 ++ 2 files changed, 28 insertions(+) diff --git a/autotest/t007_test.py b/autotest/t007_test.py index a46e4c1742..9d777fba80 100644 --- a/autotest/t007_test.py +++ b/autotest/t007_test.py @@ -545,6 +545,32 @@ def test_sr(): raise AssertionError() +def test_dis_sr(): + import flopy + import numpy as np + + delr = 640 + delc = 640 + nrow = np.ceil(59040. / delc).astype(int) + ncol = np.ceil(33128. / delr).astype(int) + nlay = 3 + + xul = 2746975.089 + yul = 1171446.45 + rotation = -39 + bg = flopy.modflow.Modflow(modelname='base') + dis = flopy.modflow.ModflowDis(bg, nlay=nlay, nrow=nrow, ncol=ncol, + delr=delr, delc=delc, lenuni=1, + rotation=rotation, xul=xul, yul=yul, + proj4_str='epsg:2243') + + if abs(dis.sr.xul - xul) > 0.01: + raise AssertionError() + + if abs(dis.sr.yul - yul) > 0.01: + raise AssertionError() + + def test_mg(): import flopy from flopy.utils import geometry diff --git a/flopy/modflow/mfdis.py b/flopy/modflow/mfdis.py index c54f108953..8d6393dc60 100644 --- a/flopy/modflow/mfdis.py +++ b/flopy/modflow/mfdis.py @@ -211,6 +211,8 @@ def __init__(self, model, nlay=1, nrow=2, ncol=2, nper=1, delr=1.0, xll = None yll = None mg = model.modelgrid + if rotation is not None: + mg.set_coord_info(xoff=None, yoff=None, angrot=rotation) if xul is not None: xll = mg._xul_to_xll(xul) if yul is not None: