Skip to content

Commit

Permalink
Appended some small changes to account for 1d array shapes from unstr…
Browse files Browse the repository at this point in the history
…uctured grids (#560)
  • Loading branch information
jonathanqv authored Dec 10, 2024
1 parent 83a6f04 commit 65c273f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 2 additions & 0 deletions pyemu/utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1833,6 +1833,8 @@ def _process_array_file(model_file, df):
if pd.isna(mlt):
continue
mlt_data = np.loadtxt(mlt, ndmin=2)
if 1 in list(mlt_data.shape): # if 1d arrays
org_arr = org_arr.reshape(mlt_data.shape)
if org_arr.shape != mlt_data.shape:
raise Exception(
"shape of org file {}:{} differs from mlt file {}:{}".format(
Expand Down
11 changes: 7 additions & 4 deletions pyemu/utils/pst_from.py
Original file line number Diff line number Diff line change
Expand Up @@ -1291,7 +1291,7 @@ def add_py_function(
)
func_lines = []
search_str = "def " + function_name + "("
abet_set = set(string.printable) - {' '}
abet_set = set(string.printable) - {' ','\n','\t'}
with open(file_name, "r") as f:
while True:
line = f.readline()
Expand All @@ -1313,7 +1313,6 @@ def add_py_function(
break
func_lines.append(line)
break

self._function_lines_list.append(func_lines)
if is_pre_cmd is True:
self.pre_py_cmds.append(call_str)
Expand Down Expand Up @@ -2411,7 +2410,10 @@ def add_parameters(
if zone_array is None: # but need dummy zone array
nr, nc = file_dict[list(file_dict.keys())[0]].shape
zone_array = np.ones((nr, nc), dtype=int)

use_zone_array = False
else:
use_zone_array = True
# print(zone_array.shape)
# don't want to have to pass too much in on this pp_options dict,
# so define pp_filename here
pp_options['pp_filename'] = "{0}pp.dat".format(par_name_store) # todo could also be a pp_kwarg
Expand Down Expand Up @@ -2672,7 +2674,8 @@ def add_parameters(
else:
# put the sr dict info into a df
# but we only want to use the n
if zone_array is not None:
if use_zone_array:
print(np.unique(zone_array))
for zone in np.unique(zone_array):
if int(zone) == 0:
continue
Expand Down

0 comments on commit 65c273f

Please sign in to comment.