Unidata / netcdf-java

The Unidata netcdf-java library
https://docs.unidata.ucar.edu/netcdf-java/current/userguide/index.html
BSD 3-Clause "New" or "Revised" License
144 stars 70 forks source link

[v7.x]: BUFR: Negative and unknown enum value #759

Open lesserwhirls opened 3 years ago

lesserwhirls commented 3 years ago

Versions impacted by the bug

v5.x, v6.x, v7.x

What went wrong?

Report from mailing list:

Hi,

I am using netcdf-java 5.3.3 to read various bufr-files. It works very well, but 2 things are strange:

  1. Compared to other tools, I got sometimes different values for the variable obs.Radiosonde_type, -114 in this case. This is a invalid value, since the values of this enum are only positive.

  2. I also got Unknown enum value for several enums, for example obs.Radiosonde_type. In netcdf-java 5.4.1 these values are NULL. I am not sure, if this a problem with your library, since many (not all) enums can be transformed to string (NetcdfDatasets does this job) and only BUFRdisplay was able to transform obs.Radiosonde_type for me.

Here are my test results:

After searching for Vaisala RS41/AUTOSONDE (Finland) in your repository, I found this:

https://github.com/Unidata/netcdf-java/blob/94e4415435e4d1acc2de658297592c7518b1bdf4/cdm-core/src/main/resources/resources/wmo/Common_C02_20181107_en.xml#L948-L955

This file is or should be used here:

https://github.com/Unidata/netcdf-java/blob/94e4415435e4d1acc2de658297592c7518b1bdf4/cdm-core/src/main/java/ucar/nc2/internal/wmo/CommonCodeTable.java#L72

Unfortunately only C1, C3 and C12 are active at the moment. C2 is commented out. This explains the Unknown enum value.

Relevant stack trace

No response

Relevant log messages

No response

If you have an example file that you can share, please attach it to this issue.

If so, may we include it in our test datasets to help ensure the bug does not return once fixed? Note: the test datasets are publicly accessible without restriction.

Yes

Code of Conduct

lesserwhirls commented 3 years ago

Test file: Z__C_LSSW_20210701010100_aero1,IUSD01_LSSW_010000____RASO.zip

lesserwhirls commented 3 years ago

Thank you for your report @netty-jawn!

ghost commented 3 years ago

Thanks!

ghost commented 3 years ago

Any progress in this issue?

Regarding the negative number: The -114 is not so wrong at all. The Windows calculator gave me this binary representation of both values:

 142 =                                                         10001110
-114 = 1111111111111111111111111111111111111111111111111111111110001110
JP95Git commented 2 years ago

@JP95Git