How to write data of a variable in a sub group with netcdfAll 5.5.2 #1306
-
I want to create a netcdf file with variable in several groups In my code after
I have now the write data to the nested group variables Using the following method source code here throw an exception. public void write(String varName, Array values) throws IOException, InvalidRangeException The variable cannot be found
Does anyone could help me to find out the right way to set data in a sub group with netcdfall version >= 5.5.2 ? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
What variable are you trying to write that is throwing the exception? Can you share a code snippet? |
Beta Was this translation helpful? Give feedback.
-
For the structure has shown above, I try to write data like that. try (NetcdfFormatWriter writer = builder.build()) {
writer.write("R1", values.get("R1"));
writer.write("R2", values.get("R2"));
writer.write("time", values.get("time"));
writer.flush();
writer.close();
} catch (Exception e) {
log.error("Cannot create NetCDF file", e);
} The first write throw an exception because the variable is not found by the lib. I guess it looks for variable in the RootGroup but i don't know how to specify that this variable is in the subgroup R1_group. A colleague gave me a netcdf file with a similar structure so it must be possible but I'm not able to do it in Java so far. I'll try to do a code snippet. |
Beta Was this translation helpful? Give feedback.
Cool, I think all you need to change is to give the "full" name of the variable you're writing to, which is written "{subgroup}/{variable}", e.g. "R1_group/time" and "R1_group/R1"