Skip to content

Commit 5fa18cb

Browse files
committed
fix reshape of 3d arrays
1 parent 88ef9f8 commit 5fa18cb

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

ogcore/utils.py

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -999,16 +999,6 @@ def extrapolate_arrays(param_in, dims=None, item="Parameter Name"):
999999
param_in.reshape(1, dims[1], dims[2]),
10001000
(dims[0], 1, 1),
10011001
)
1002-
# param_out = np.concatenate(
1003-
# (
1004-
# param_in,
1005-
# np.tile(
1006-
# param_in[-1, :, :].reshape(1, dims[1], dims[2]),
1007-
# (dims[1], 1, 1),
1008-
# ),
1009-
# ),
1010-
# axis=0,
1011-
# )
10121002
# case if T by S input
10131003
elif param_in.shape[0] == dims[0] - dims[1]:
10141004
param_in = (
@@ -1034,15 +1024,18 @@ def extrapolate_arrays(param_in, dims=None, item="Parameter Name"):
10341024
assert False
10351025
elif param_in.ndim == 3:
10361026
# this is the case where input varies by T, S, J
1037-
param_out = np.concatenate(
1038-
(
1039-
param_in,
1040-
np.tile(
1041-
param_in[-1, :, :].reshape(1, dims[1], dims[2]),
1042-
(dims[1], 1, 1),
1027+
if param_in.shape[0] > dims[0]:
1028+
param_out = param_in[: dims[0], :, :]
1029+
else:
1030+
param_out = np.concatenate(
1031+
(
1032+
param_in,
1033+
np.tile(
1034+
param_in[-1, :, :].reshape(1, dims[1], dims[2]),
1035+
(dims[0] - param_in.shape[0], 1, 1),
1036+
),
10431037
),
1044-
),
1045-
axis=0,
1046-
)
1038+
axis=0,
1039+
)
10471040

10481041
return param_out

0 commit comments

Comments
 (0)