Skip to content

Conversation

@jtgrasb
Copy link
Contributor

@jtgrasb jtgrasb commented Jun 13, 2022

This PR addresses issue #875. The issue has 2 parts:

  1. Body name string vs. cell array formatting
  • Old .nc files have body names formatted as strings while new ones have body names formatted as cell arrays
  • Fix: The simple fix for this is to unpack each element of the body names.
  1. Complex indices format
  • Old .nc files have horizontal vectors of for specifying order of the complex dimension, while new ones have vertical vectors.
  • Fix: Check whether name is a string to check version, and read in order of the complex dimension based on new vs. old version.

@jtgrasb jtgrasb added Bug bug in WEC-Sim source, high priority BEM/BEMIO related to BEMIO or BEM hydro data labels Jun 13, 2022
@kmruehl kmruehl requested a review from dav-og June 15, 2022 14:36
@kmruehl kmruehl requested review from akeeste and removed request for dav-og June 29, 2022 15:39
@jtgrasb jtgrasb marked this pull request as draft July 1, 2022 21:10
@jtgrasb
Copy link
Contributor Author

jtgrasb commented Jul 7, 2022

@akeeste I tried running the Capytaine with the example cases as well as the demo cases, and all of them came out with the "new" format. Were you using Capytaine 1.3 when you tried it?

@akeeste
Copy link
Contributor

akeeste commented Jul 13, 2022

@jtgrasb Yes I used Capytaine v1.3 with the demo.py file as is. However I still don't see any changes to how the body name or real/imaginary indices format in readCapytaine. Before merging this PR, I would like to better pinpoint what option causes this change and fix it on the Capytaine side if possible.

Adam

@jtgrasb
Copy link
Contributor Author

jtgrasb commented Jul 22, 2022

@akeeste This is strange. I have checked a lot of potential sources for this error, but can't seem to figure it out.

  • The .nc files already in our repo (sphere_full.nc, etc.) work fine with our current readCapytaine script.
  • Any new runs using the cases already set up without any changes (sphere.py, demo.py, etc.) lead to the "new" format with changes to the body name and real/imaginary indices.
  • We are both using Capytaine v1.3 so that doesn't seem to be the issue (I also tried updating to v1.4 and it didn't change anything)
  • I am using MATLAB 2021b, but I also tried MATLAB 2020b and actually got a different error shown below:
    image

Let me know if you have any ideas where these error might be coming from.

Thanks,
Jeff

@akeeste
Copy link
Contributor

akeeste commented Jul 22, 2022

@jtgrasb Thanks for the update. I'm not sure where our workflows are differing or why R2021b and R2020b give different errors. At the next team meeting let's assign a couple different developers to try and recreate this issue and pin down what is happening.

@mancellin
Copy link
Contributor

We are both using Capytaine v1.3 so that doesn't seem to be the issue (I also tried updating to v1.4 and it didn't change anything)

Nothing changed in these modules of Capytaine for years.

I expect the change to come from either xarray or the library used in the backend by xarray to export the netCDF file.
The choice of a backend engine by xarray depends on what is installed in your environment.

Maybe the "old" format could be reproduced using a conda environment with an old version of xarray and/or explicitely setting the engine argument of to_netcdf.

@kmruehl
Copy link
Collaborator

kmruehl commented Jul 28, 2022

@akeeste and @jtgrasb I can confirm this issue with the body name. I just reran the OSWEC case in Capytaine v1.4, and ran BEMIO in 2022a. I got the following error:

Error using split
First argument must be text.

Error in readCAPYTAINE (line 91)
hydro(F).body = split(hydro(F).body,'+');

Error in bemio (line 4)
hydro = readCAPYTAINE(hydro,'oswec.nc');

@mancellin's suggestion that these issues could be due to a change in one of the Capytaine dependencies, like xarray, is a likely cause.

@kmruehl kmruehl marked this pull request as ready for review July 28, 2022 21:25
@kmruehl
Copy link
Collaborator

kmruehl commented Jul 28, 2022

I can confirm that this PR resolves the issue for v1.4, and also works for the prior v1.3 release. I'm going to go and merge it so that dev is compatible with Capytaine v1.4 .

@jtgrasb and @akeeste please open a new PR if there are other issues that need to be resolved.

@kmruehl kmruehl self-requested a review July 28, 2022 21:27
@kmruehl kmruehl self-assigned this Jul 28, 2022
@kmruehl kmruehl merged commit 38ca214 into WEC-Sim:dev Jul 28, 2022
@jtgrasb jtgrasb deleted the capytaineFix branch September 6, 2022 18:16
akeeste added a commit to akeeste/WEC-Sim that referenced this pull request Sep 28, 2022
akeeste added a commit that referenced this pull request Sep 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BEM/BEMIO related to BEMIO or BEM hydro data Bug bug in WEC-Sim source, high priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants