使用 FloPy 从 MODFLOW-2000 二进制输出中提取沉降数据
Extract subsidence data from MODFLOW-2000 binary output using FloPy
我正在使用 MODFLOW-2000 运行 地面沉降模型。但是,沉降文件的输出是二进制数据。有什么方法可以使用 python 脚本将其转换为文本,因为我正在为模型做数百个场景。
SUB 包的二进制输出与 MODFLOW 二进制头文件的格式相同。您需要知道写入二进制文件的输出文本字符串的名称。请参阅 SUB 包 MODFLOW-2005 online documentation 中的 Table 1 以确定给定 SUB 包二进制文件的文本字符串。
下面展示了如何使用flopy
和numpy
将二进制沉降文件中的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])
我正在使用 MODFLOW-2000 运行 地面沉降模型。但是,沉降文件的输出是二进制数据。有什么方法可以使用 python 脚本将其转换为文本,因为我正在为模型做数百个场景。
SUB 包的二进制输出与 MODFLOW 二进制头文件的格式相同。您需要知道写入二进制文件的输出文本字符串的名称。请参阅 SUB 包 MODFLOW-2005 online documentation 中的 Table 1 以确定给定 SUB 包二进制文件的文本字符串。
下面展示了如何使用flopy
和numpy
将二进制沉降文件中的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])