-
Notifications
You must be signed in to change notification settings - Fork 77
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
to_netcdf problem with echopype installed using pip install #801
Comments
@emiliom Is anyone looking into this? |
Not yet. Have you tried using conda? |
I went through the process installing conda. Fail to run the demo, echopype_tour.ipynb, though: ModuleNotFoundError Traceback (most recent call last) ModuleNotFoundError: No module named 'geopandas' |
@erikatbeof : not sure what you're running into there. Try |
I tried that, -of course, and it's not installed. But I got the impression that using conda would be a easy, a 'one' line solution. It appears not to be. In the contrast codas is clunky. I advise you to make your code working well with pip -an abandon conda. |
@erikatbeof : Heh, I don't think abandoning conda is the right solution, and if you are reluctant to fix your environment it is your choice though unfortunate. The problem you're running into is external to the echopype codebase and is due to netcdf4. To see that, create the following environment that has nothing to do with echopype: $ conda create -n min_test -c conda-forge python=3.9 ipykernel -y
$ conda activate min_test
$ pip install netcdf4 xarray Once you have this, do the following like in the first comment: import numpy as np
import xarray as xr
x = np.array([1,2],dtype='U') #This results in RuntimeError.
#x = np.array([1,2],dtype='f') #This is working well.
da = xr.DataArray(x,name="x")
encoding={'x': {'zlib': True, 'complevel': 4}}
da.to_netcdf(path="output.nc", encoding=encoding) # this will error out If you create this below environment instead: $ conda create -n min_test -c conda-forge python=3.9 ipykernel netcdf4 -y # use netcdf4 from conda-forge
$ conda activate min_test
$ pip install netcdf4 xarray The above |
Looks like the core of this issue comes from the underlying The true cause of the issue is that |
Thank you @lsetiawan ! Your PR #843 (pinning netcdf4 to <1.6) fixes the issue. This fix will make it into the next echopype release, so that |
This is resolved now. Closing. |
When using echopype installed using
pip install echopype
, there is a problem when saving an xarray dataset to netcdf. The problem involves the compression of unicode strings, and it's extraneous to echopype proper. It was reported in #789.I'm describing the problem in more detail here, copying directly from that other issue. Both environments were created with echopype 0.6.2.
This simple freestanding code illustrates the problem:
This environment generates the error using the sample code:
In contrast, with this similar environment where echopype is installed from the conda package, the same code runs without errors:
The text was updated successfully, but these errors were encountered: