我正在尝试在 PyEMU 设置中设置参数,将外部数组文件用于使用 Flopy 生成的 MODLFOW 6 模型。该模型是一个二维横截面(50 层,1 行和 200 列)。
使用此代码:
filenames = 'gwf.npf_k_layer1.txt'
par_name_base = 'k_layer_1'
pargrp = 'k_layer_1'
pf.add_parameters(filenames=filenames,par_type="grid",
par_name_base=par_name_base,pargp=pargrp,
upper_bound=10.,lower_bound=0.1,ult_ubound=100,ult_lbound=0.01)
我收到以下错误消息:
2020-11-03 11:11:37.616421 starting: adding grid type multiplier style parameters for file(s) ['gwf.npf_k_layer1.txt']
2020-11-03 11:11:37.616421 starting: loading array p1_template\gwf.npf_k_layer1.txt
2020-11-03 11:11:37.618413 finished: loading array p1_template\gwf.npf_k_layer1.txt took: 0:00:00.001992
2020-11-03 11:11:37.618413 loaded array 'gwf.npf_k_layer1.txt' of shape (10, 20)
2020-11-03 11:11:37.620407 starting: writing array-based template file 'k_layer_1_inst0_grid.csv.tpl'
2020-11-03 11:11:37.621406 starting: writing template file k_layer_1_inst0_grid.csv.tpl for ['k_layer_1_inst:0']
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-10-d946b6aed7e4> in <module>
6 pf.add_parameters(filenames=filenames,par_type="grid",
7 par_name_base=par_name_base,pargp=pargrp,
----> 8 upper_bound=10.,lower_bound=0.1,ult_ubound=100,ult_lbound=0.01)
C:\ProgramData\Anaconda3\lib\site-packages\pyemu\utils\pst_from.py in add_parameters(self, filenames, par_type, zone_array, dist_type, sigma_range, upper_bound, lower_bound, transform, par_name_base, index_cols, use_cols, pargp, pp_space, use_pp_zones, num_eig_kl, spatial_reference, geostruct, datetime, mfile_fmt, mfile_skip, ult_ubound, ult_lbound, rebuild_pst, alt_inst_str, comment_char, par_style)
1504 gpname=pargp,
1505 input_filename=in_fileabs,
-> 1506 par_style=par_style,
1507 )
1508 self.logger.log(
C:\ProgramData\Anaconda3\lib\site-packages\pyemu\utils\pst_from.py in write_array_tpl(name, tpl_filename, suffix, par_type, zone_array, gpname, shape, longnames, fill_value, get_xy, input_filename, par_style)
2775 else:
2776 if get_xy is not None:
-> 2777 x, y = get_xy([i, j])
2778 xx.append(x)
2779 yy.append(y)
C:\ProgramData\Anaconda3\lib\site-packages\pyemu\utils\pst_from.py in _flopy_sr_get_xy(self, args, **kwargs)
205 else:
206 return (
--> 207 self._spatial_reference.xcentergrid[i, j],
208 self._spatial_reference.ycentergrid[i, j],
209 )
IndexError: index 1 is out of bounds for axis 0 with size 1
从错误消息中,我假设 PyEMU 正在尝试获取模型第 2 行(不存在)中的单元格的空间参考。
我注意到 FloPy 以 20 列和 10 行的格式记录单个模型层的外部文件(总共 200 个模型列)。PyEMU 设法写入相应 .tpl 文件的第一行(即前 20 个元素),但随后抛出错误消息。
这与我的 Flopy\MF6 文件设置中的错误有关吗?或者 PyEMU 在读取单行模型时有问题吗?还是我在某个地方犯了一些愚蠢的错误?
更新
在下面 JDub 的响应之后,尝试使用 1x200 格式(nrow X ncol)的重塑外部阵列。
返回以下异常:
---------------------------------------------------------------------------
Exception Traceback (most recent call last)
<ipython-input-13-242b6d0c98f3> in <module>
6 pf.add_parameters(filenames=filenames,par_type="grid",
7 par_name_base=par_name_base,pargp=pargrp,
----> 8 upper_bound=10.,lower_bound=0.1,ult_ubound=100,ult_lbound=0.01)
C:\ProgramData\Anaconda3\lib\site-packages\pyemu\utils\pst_from.py in add_parameters(self, filenames, par_type, zone_array, dist_type, sigma_range, upper_bound, lower_bound, transform, par_name_base, index_cols, use_cols, pargp, pp_space, use_pp_zones, num_eig_kl, spatial_reference, geostruct, datetime, mfile_fmt, mfile_skip, ult_ubound, ult_lbound, rebuild_pst, alt_inst_str, comment_char, par_style)
1504 gpname=pargp,
1505 input_filename=in_fileabs,
-> 1506 par_style=par_style,
1507 )
1508 self.logger.log(
C:\ProgramData\Anaconda3\lib\site-packages\pyemu\utils\pst_from.py in write_array_tpl(name, tpl_filename, suffix, par_type, zone_array, gpname, shape, longnames, fill_value, get_xy, input_filename, par_style)
2679 if len(shape) != 2:
2680 raise Exception(
-> 2681 "write_array_tpl() error: shape '{0}' not 2D" "".format(str(shape))
2682 )
2683
Exception: write_array_tpl() error: shape '(200,)' not 2D