Unidata / thredds

THREDDS Data Server v4.6
https://www.unidata.ucar.edu/software/tds/v4.6/index.html
265 stars 179 forks source link

Bug report: HDF4 16-bit unsigned integer data can not be read #628

Closed Yaqiang closed 8 years ago

Yaqiang commented 8 years ago

HDF4 16-bit unsigned integer data can not be read using netCDF Java 4.6.6. The error message:

    at ucar.nc2.iosp.IospHelper.makePrimitiveArray(IospHelper.java:678)
at ucar.nc2.iosp.IospHelper.readDataFill(IospHelper.java:78)
at ucar.nc2.iosp.hdf4.H4iosp.readData(H4iosp.java:104)
at ucar.nc2.NetcdfFile.readData(NetcdfFile.java:2020)
at ucar.nc2.Variable.reallyRead(Variable.java:874)
at ucar.nc2.Variable._read(Variable.java:845)
at ucar.nc2.Variable._read(Variable.java:886)
at ucar.nc2.Variable.read(Variable.java:709)

java.lang.ClassCastException: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Short

The sample file can be downloaded here: http://www.meteothinker.com/downloads/files/NOAA11_AVHRR_198902_01.MOS_L2B_NSMC.HDF

lesserwhirls commented 8 years ago

Thanks @Yaqiang - I'll take a look and see what is going on here.

JohnLCaron commented 8 years ago

same as #638

rschmunk commented 8 years ago

@Yaqiang, The data in the file's single array has values that are typically in the range 27000-30000, except where the _FillValue appears instead. However, there is a valid range attribute of 220S, 350S.

Is there some sort of scaling that is supposed to be implemented to get the final data values?

JohnLCaron commented 8 years ago

ushort 10-day_averaged_land_surface_temperature(height=5000, width=8000); :Unit = "Kelvins"; :valid_range = 220S, 350S; // short :_FillValue = 65535; // int :Gains = 0.01f; // float :Offsets = 0S; // short :long_name = "10-day averaged land surface temperature";

let me guess: real_value = Gains * stored_value + Offsets ??

oh, and valid_range actually refers to real_values ....

On Thu, Sep 22, 2016 at 3:09 PM, R. Schmunk notifications@github.com wrote:

Yaqiang, The data in the file's single array has values that are typically in the range 27000-30000, except where the _FillValue appears instead. However, there is a valid range attribute of 220S, 350S.

Is there some sort of scaling that is supposed to be implemented to get the final data values?

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/Unidata/thredds/issues/628#issuecomment-249028535, or mute the thread https://github.com/notifications/unsubscribe-auth/AAlcwEmv0xPocjkJVmjS_0llOBsjr-pEks5qsu5ygaJpZM4J2d1M .

Yaqiang commented 8 years ago

Thanks for your email. I think you are in right way to get real values.

Regards Yaqiang


Dr. Yaqiang Wang Chinese Academy of Meteorological Sciences (CAMS) 46, Zhong-Guan-Cun South Avenue Beijing, 100081 China               yaqiang.wang@gmail.com

http://www.meteothinker.com https://www.researchgate.net/profile/Yaqiang_Wang5


From: John Caron Date: 2016-09-23 08:50 To: Unidata/thredds CC: Yaqiang Wang; Mention Subject: Re: [Unidata/thredds] Bug report: HDF4 16-bit unsigned integer data can not be read (#628) ushort 10-day_averaged_land_surface_temperature(height=5000, width=8000); :Unit = "Kelvins"; :valid_range = 220S, 350S; // short :_FillValue = 65535; // int :Gains = 0.01f; // float :Offsets = 0S; // short :long_name = "10-day averaged land surface temperature";

let me guess: real_value = Gains * stored_value + Offsets ??

oh, and valid_range actually refers to real_values ....

On Thu, Sep 22, 2016 at 3:09 PM, R. Schmunk notifications@github.com wrote:

Yaqiang, The data in the file's single array has values that are typically in the range 27000-30000, except where the _FillValue appears instead. However, there is a valid range attribute of 220S, 350S.

Is there some sort of scaling that is supposed to be implemented to get the final data values?

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/Unidata/thredds/issues/628#issuecomment-249028535, or mute the thread https://github.com/notifications/unsubscribe-auth/AAlcwEmv0xPocjkJVmjS_0llOBsjr-pEks5qsu5ygaJpZM4J2d1M .

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.