From ncML to netCDF file using netCDF-Java: FillValue is not handled properly #1036
Comments
@DennisHeimbigner - can you take a look at this one? I seem to remember we fixed something like this awhile back, but I can't seem to find it. |
Dear Sean Arms and Dennis Heimbigner,
Please let me give you some background information.
I submitted the following related request in September 2017:
[netCDFJava #PCM-232977]: netCDF-Java ignores "_FlllValue" attribute in ncML
https://www.unidata.ucar.edu/support/help/MailArchives/netcdf/msg14081.html
However, when I had a look to it, I found another problem (I cannot define a particular “_FillValue” attribute value). And in addition, the status of the request above is already “closed”. Therefore I decided to submit this new request (#1036).
Thank you in advance.
Daniel Risquez.
|
@risquez You need to set the So, suppose I have this NcML: <?xml version="1.0" encoding="UTF-8"?>
<netcdf xmlns="http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2" enhance="all">
<variable name="my_short" shape="" type="short">
<attribute name="_FillValue" type="short" value="1"/>
</variable>
<variable name="my_ushort" shape="" type="short">
<attribute name="_Unsigned" value="true" />
<attribute name="_FillValue" type="short" value="1" isUnsigned="true" />
</variable>
</netcdf> If I use NetCDF-Java v4.6.11 to generate a NetCDF-4 file from it, as you have done, I get:
Better, but
Bingo. Everything seems to be working there (the underscore indicates that a datum matches the fill value declared for a variable). On version 5, you can also simplify your NcML somewhat. This will work just as well: <?xml version="1.0" encoding="UTF-8"?>
<netcdf xmlns="http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2" enhance="all">
<variable name="my_short" shape="" type="short">
<attribute name="_FillValue" type="short" value="1"/>
</variable>
<variable name="my_ushort" shape="" type="ushort">
<attribute name="_FillValue" type="ushort" value="1" />
</variable>
</netcdf> Note that we haven't yet released v5.0, but we're getting close. If you'd like to experiment with a recent snapshot build, you can grab one here. |
I tried both suggestions in my computer (add "enhanced" attribute and try the latest snapshot). Both work well as you indicate. Christian, thank you very much for your support. |
I would like to recall this issue, just to summarize its status. My problem is:
I understand that I have to choose:
Could you please confirm that my understanding is correct? Both ( |
@risquez |
This issue is still alive and well for us at EUMETSAT, as when Using @risquez made a nice overview using:
Setting different values for
As you can see, the attributes are preserved correctly, but no At the moment, this is a barrier for us to use netCDF-Java in our operations for Meteosat Third Generation. |
I am generating an empty netCDF file using the ncML description as input. However, I cannot define a FillValue.
This issue could be related to "Ncml mishandling signedness" #923.
I follow these steps:
java -Xmx1g -classpath netcdfAll-4.6.11.jar ucar.nc2.write.Nccopy --input test_FillValue.ncml --output test_FillValue.nc --format netcdf4
(Note: I am using the latest netCDF-Java library, 4.6.11 from 4/Dec/2017; and Java 1.8.0).
ncdump -s test_FillValue.nc
and the output is:
The value for short equals NC_FILL_SHORT=-32767, however NC_FILL_USHORT=65535, not 32769.
https://www.unidata.ucar.edu/software/netcdf/docs/netcdf_8h_source.html
And in any case, the "_FillValue" is defined in the ncML (="1"), therefore it should overwrite any default value.
Summarizing:
The text was updated successfully, but these errors were encountered: