[VERSION]: 5.5.3 - Enums are duplicated when generating NCML
bzah opened this issue · comments
Versions impacted by the bug
v5.x
What went wrong?
When generating NCML using:
java -classpath /usr/share/java/netcdfAll-5.5.3.jar rrad.nc -ncml > rrad.ncml
The resulting rrad.ncml contain multiple declaration of most Enums.
Minimal Reproducible Example
- Download
RCRC0001.zip
Eumetsat FCI test data at: https://sftp.eumetsat.int/public/folder/UsCVknVOOkSyCdgpMimJNQ/User-Materials/Test-Data/MTG/MTG_FCI_L1C_SpectrallyRepresentative_TD-360_May2022/COMPRESSED/ - Unzip for example
W_XX-EUMETSAT-Darmstadt,IMG+SAT,MTI1+FCI-1C-RRAD-FDHSI-FD--CHK-BODY---NC4E_C_EUMT_20170920000515_GTT_DEV_20170920000008_20170920000015_N_JLS_T_0001_0001.nc
- Rename for readability
mv W_XX-EUMETSAT-Darmstadt,IMG+SAT,MTI1+FCI-1C-RRAD-FDHSI-FD--CHK-BODY---NC4E_C_EUMT_20170920000515_GTT_DEV_20170920000008_20170920000015_N_JLS_T_0001_0001.nc rrad.nc
- Make sure the enum "detector_equalization_enabled" is declared only once in the netCDF with
ncdump -h rrad.nc | grep detector_equalization_enabled
- generate ncml
java -classpath /usr/share/java/netcdfAll-5.5.3.jar rrad.nc -ncml > rrad.ncml
- grep the enum declaration in the ncml:
grep "enumTypedef name=\"detector_equalization_enabled\"" ./rrad.ncml
--> There are 6 occurrences of the enum declaration.
I haven't done too much java lately, but I'm happy to give a try in solving this if PR are welcomed and you don't have time to resolve this.
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
- I agree to follow the UCAR/Unidata Code of Conduct
I've cloned the netcdf-java repository and I have been trying to reproduce this issue in an automated test.
However, I fail to reproduce it, the ncml created using:
ByteArrayOutputStream baos = new ByteArrayOutputStream();
System.setOut(new PrintStream(baos));
Ncdump.main(new String[]{TestDir.cdmLocalTestDataDir + "test_prod.nc", "-ncml"});
String attempt2 = baos.toString();
is correct, it only contains a single declaration enumTypeDef
of each enum.
What puzzles me is that I don't see any commit in NcmlWriter.java that would have fixed this...
Plus, when running from command line java -classpath /usr/share/java/netcdfAll-5.5.3.jar ucar.nc2.write.Ncdump Examples_of_aux_files/test_prod.nc -ncml > test_prod2.ncml
it still produces the issue.
Any idea what is going on ?
Do you have the same issue when you test from the command line with the latest netcdfAll-5.5.4-SNAPSHOT.jar (which you can download here)?
My speculation is that this is related to this PR: #1151. The thing you need to know is that the netcdf file (the underlying HDF5 file actually) may actually contain multiple definitions of an enum type, even though access thru the API or ncdump shows only a single type.
So Tara's question is important to determine if you are using that PR or not.
My speculation is that this is related to this PR: #1151. The thing you need to know is that the netcdf file (the underlying HDF5 file actually) may actually contain multiple definitions of an enum type, even though access thru the API or ncdump shows only a single type.
Interesting, thanks for clarifying that.
Indeed, when using the netcdfAll-5.5.4-SNAPSHOT.jar
I don't have the issue anymore.
Thus, I'm closing as fixed by #1151, thanks @tdrwenski, @DennisHeimbigner