stcorp / visan

Visualisation and analysis application for atmospheric data
BSD 3-Clause "New" or "Revised" License
7 stars 5 forks source link

CLibraryError() when imorting data #4

Closed RobinKohrs closed 4 years ago

RobinKohrs commented 4 years ago

I'm sorry if this is a really naive question. But I just can't manage to import my file: S5P_OFFL_L2__NO2____20190316T001448_20190316T015618_07358_01_010202_20190322T020430.nc with harp.import_product():

It always gives me this error: raceback (most recent call last): File "<input>", line 1, in <module> File "/home/robin/miniconda3/envs/visan/lib/python3.7/site-packages/harp/_harppy.py", line 1134, in import_product raise CLibraryError() harp._harppy.CLibraryError: error parsing unit database (/home/robin/miniconda3/envs/visan/share/harp/udunits2.xml)

Does anyone might have a clue what I could do? Any help is super appreciated:) Thanks a lot:)

svniemeijer commented 4 years ago

Unfortunately, we are not able to reproduce this problem. Can you let me know what Linux version you are using? And how do you start visan? Do you do this from the command line while within the visan conda environment?

lforesta commented 4 years ago

I have the same issue. I run visan from the command line within its dedicated conda environment. I am running Ubuntu 18.04 [I had a conversation about this with @svniemeijer via email, but writing here too]

Any chance this can be due to different GDAL versions? I have GDAL 2.2.3 installed system-wide, and I see GDAL 2.3.3 in the visan env. Maybe a function in Harp is accessing the wrong GDAL library?

RobinKohrs commented 4 years ago

I'm using Ubuntu 18.04 as well. When I type ''gdalinfo --version' I also get GDAL 2.3.3, released 2018/12/14. Is there any way to find out if I have multiple versions of gdal somewhere installed? I started the visan-Gui from within the conda environment. I do this, because I wanted to use the function wplot to follow the tutorial from RUS. When I import harp into a interactive python shell I can import the data with harp.import_product(), but then I dont't know how to call/use wplot

lforesta commented 4 years ago

@RobinKohrs I guess you ran that command from the conda env where you installed visan, right? You can run it out of that environment and see if you have a different version installed system-wide (if at all). This was just my guess anyway, maybe it's not related to the issue.

svniemeijer commented 4 years ago

Note that neither HARP nor VISAN uses GDAL, so this should not have any impact. I will try to replicate the issue using Ubuntu 18.04.

svniemeijer commented 4 years ago

We have been able to reproduce the issue and found its cause.

It is a locale problem. If you run the following in VISAN you will get a locale back that does not use the '.' as decimal separator:

import locale
locale.getlocale(locale.LC_NUMERIC)

This is causing a problem in the xml reading of udunits2 in harp, which relies on strtod (which is locale aware) to interpret floating point values.

The locale is not set by VISAN directly, but somewhere underneath (likely by wxPython). It is not set by Python, which is why running HARP within Python itself still works.

We will try to find a solution, but this will likely be within harp (as a patch to the embedded udunits2 library) and not within visan.

RobinKohrs commented 4 years ago

Thank you very much for the effort and the help!!:) I need to confess that I don't know exactly what locale actually is, but I understand the cause now. Thanks a lot!

svniemeijer commented 4 years ago

We implemented a fix for this in HARP itself: https://github.com/stcorp/harp/commit/b48ba1b8e6b4155eec233ce4b70345408953d556

New releases were already in the pipeline and should follow soon.