【问题标题】:Extract subsidence data from MODFLOW-2000 binary output using FloPy使用 FloPy 从 MODFLOW-2000 二进制输出中提取沉降数据
【发布时间】:2018-10-02 21:05:09
【问题描述】:

我正在使用 MODFLOW-2000 运行地面沉降模型。但是,沉降文件的输出是二进制数据。由于我正在为模型做数百个场景,有什么方法可以使用 python 脚本将其转换为文本。

【问题讨论】:

  • 已标记,请提供更多详细信息(如果您的问题是独一无二的或您的解决方案不起作用)或自行搜索 Stack Overflow。

标签: python flopy


【解决方案1】:

SUB 包的二进制输出与 MODFLOW 二进制头文件的格式相同。您需要知道写入二进制文件的输出文本字符串的名称。请参阅MODFLOW-2005 online documentation 中的表 1,了解 SUB 包以确定给定 SUB 包二进制文件的文本字符串。

下面展示了如何使用flopynumpy将二进制沉降文件中的Z DISPLACEMENT数据转换为ascii文件:

import numpy as np
import flopy

# open the binary file
sobj = flopy.utils.HeadFile('model.zdisplacement.bin', 
                            text='Z DISPLACEMENT')

# get all of the available times in the file
times = sobj.get_times()

# extract the data for the last time in the file
zd = sobj.get_data(totim=times[-1])

# save the z-displacement for the first layer (layer 0) to an ascii file
# zd is a 3D numpy array with a shape of (nlay, nrow, ncol)
np.savetxt('layer0.zdisplacement.txt', zd[0])

如果您有多个图层,则需要保存每个图层的数据。

您可以使用以下命令输出文件中的所有数据:

for t in sobj.get_times():
    zd = sobj.get_data(totim=t)
    for k in range(nlay):
        fpth = 'layer{}_{}.zdisplacement.txt'.format(k, t)
        np.savetxt(fpth, zd[k])

【讨论】:

  • 谢谢,休斯博士。但是,如何打印出所有的时间步长和应力周期呢?我尝试使用 sobj.get_alldata(),但它显​​示“预期 1D 或 2D 数组,得到 %dD 数组”% X.ndim) ValueError: Expected 1D or 2D array, got 3D array instead
  • @Z.Cao 可能的解决方案已添加到上面的答案中。
  • 非常感谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-01-26
  • 1970-01-01
  • 2020-10-31
  • 1970-01-01
  • 2016-01-10
  • 2012-11-14
相关资源
最近更新 更多