0

我尝试在软盘中加载、更新和写入新的输入文件。我尝试了很多事情,但我做不到。这是我的代码:

rchFile = os.path.join(modflowModel.model_ws, "hydrogeology.rch")

info = modflowModel.get_nrow_ncol_nlay_nper()
if "RCH" in modflowModel.get_package_list():
    rchObject = ModflowRch.load(rchFile, modflowModel)
    rchData = rchObject.rech
else:
    rchData = dict()
    for ts in range(info[3]):
        rchData[ts] = np.zeros((info[0], info[1]))

for feat in iterator:
    for ts in range(info[3]):
        currValue = "random value"
        rchData[ts][feat["row"]-1, feat["column"]-1] = currValue

rchObject = ModflowRch(modflowModel, nrchop=3, ipakcb=None, rech=rchData, irch=0, extension='rch', unitnumber=None, filenames="hydrogeology.rch")

rchPath = os.path.join(modflowModel.model_ws, 'rch.shp')
rchObject.export(f=rchPath)
# rchObject.write_file()
# modflowModel.add_package(rchObject)
modflowModel.write_input() 

modflowModel是和flopy.modflow.Modflow对象。代码末尾的注释是我尝试编写更新的新输入但不起作用的行。

4

2 回答 2

2

当你说它不起作用时,你到底得到了什么错误?我经常用这样的软盘修改强制包:

m = flopy.modflow.Modflow.load()
for kper in range(m.nper):
    arr = m.rch.rech[kper].array
    arr *= 0.8 # or something
    m.rch.rech[kper] = arr
于 2019-11-05T18:48:15.947 回答
0

我发现了我的错误。modflowModel.write_input()效果很好。加载模型对象时出现问题Modflow.load(...)。现在我在需要的地方加载模型。因为如果我加载另一个 py 等,我可能会感到model_ws困惑。

于 2019-11-06T11:32:42.303 回答