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

BUG: xarray groupby now leaving extra dimension #364

Closed
michaelcdevin opened this issue Aug 2, 2024 · 1 comment
Closed

BUG: xarray groupby now leaving extra dimension #364

michaelcdevin opened this issue Aug 2, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@michaelcdevin
Copy link
Collaborator

In wec.core.solve, the xarray groupby method is used to iterate over the different phase realizations. Previously, this has squeezed out the realization dimension in the DataArray and WecOptTool has indexed the wave information in the solve steps under that assumption.

However, squeezing the dimension was only occurring for monotonically increasing DataArrays, which led to confusion among xarray users and the functionality is no longer default and has been deprecated. As a result, as of xarray v2024.07.0, the dimensions are not squeezed, leaving the realization dimension in waves and causing downstream dimension sizing issues involving numpy.concatenate:

ValueError: all the input arrays must have same number of dimensions, but the array at index 0 has 2 dimension(s) and the array at index 1 has 3 dimension(s)

---------------
Traceback:
---------------
wecopttool\core.py:825: in solve
    optim_res = minimize(**problem)
C:\Users\mcdevin\AppData\Local\mambaforge\envs\wot_dev_new\Lib\site-packages\scipy\optimize\_minimize.py:743: in minimize
    res = _minimize_slsqp(fun, x0, args, jac, bounds,
C:\Users\mcdevin\AppData\Local\mambaforge\envs\wot_dev_new\Lib\site-packages\scipy\optimize\_slsqp_py.py:333: in _minimize_slsqp
    meq = sum(map(len, [atleast_1d(c['fun'](x, *c['args']))
C:\Users\mcdevin\AppData\Local\mambaforge\envs\wot_dev_new\Lib\site-packages\scipy\optimize\_slsqp_py.py:333: in <listcomp>
    meq = sum(map(len, [atleast_1d(c['fun'](x, *c['args']))
wecopttool\core.py:789: in scaled_resid_fun
    return self.residual(x_wec, x_opt, wave)
wecopttool\core.py:598: in residual
    ri = ri - f(self, x_wec, x_opt, waves)
wecopttool\core.py:2025: in force
    force_fd = complex_to_real(wave_excitation(force_coeff, waves), False)
wecopttool\core.py:1703: in complex_to_real
    out = np.concatenate([out, d])
C:\Users\mcdevin\AppData\Local\mambaforge\envs\wot_dev_new\Lib\site-packages\autograd\numpy\numpy_wrapper.py:38: in <lambda>
    concatenate = lambda arr_list, axis=0 : concatenate_args(axis, *arr_list)
C:\Users\mcdevin\AppData\Local\mambaforge\envs\wot_dev_new\Lib\site-packages\autograd\tracer.py:48: in f_wrapped
    return f_raw(*args, **kwargs)
@michaelcdevin michaelcdevin added the bug Something isn't working label Aug 2, 2024
@michaelcdevin michaelcdevin self-assigned this Aug 2, 2024
@michaelcdevin
Copy link
Collaborator Author

Resolved in #365

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant