Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reshaped arrays require Fortran ordering #6

Open
mdpiper opened this issue Sep 1, 2021 · 0 comments
Open

Reshaped arrays require Fortran ordering #6

mdpiper opened this issue Sep 1, 2021 · 0 comments

Comments

@mdpiper
Copy link
Owner

mdpiper commented Sep 1, 2021

When redimensionalizing a BMI array from a Fortran model with numpy.reshape, the order keyword is needed, as shown here in line 59:

# View default initial temperature values.
val = np.empty(grid_size, dtype=np.float32)
m.get_value(var_name, val)
print(" - initial values (flattened):")
print(val)
print(" - initial values (gridded):")
print(val.reshape(grid_shape, order="F"))

This problem exists in both the BMI example (above) and the pymt example (line 55):

# Get the initial values of the variable.
print("Get initial values of {}...".format(var_name))
print(" - values, flattened:")
print(m.var[var_name].data)
print(" - values, redimensionalized:")
print(m.var[var_name].data.reshape(m.grid_shape(grid_id), order="F"))

A user shouldn't have to know what language a wrapped model is written in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant