Bob Simons wrote:
Thank you for your email.
John Caron wrote:
Bob Simons wrote:
Ultimately, I want to use the java netcdf 2.2 library to generate an
.nc file which, when viewed with opendap, appears to have a sequence.
My reading of the netcdf java library leads me to believe I need to
create a Structure. Does anyone have sample code showing how to
create a .nc file with a Structure using the java netcdf library?
Netcdf-3 files are limited in what they can represent; Netcdf-4, when
available will be able to represent the entire CDM.
The only possible structure in a Netcdf-3 file is by using the
unlimited dimension. See this doc for details:
There are no programming details there. That document is filled with
examples of the what the NCDUMP of the resulting file is, but there is
no Java code showing how to make the files. In other words, it says
what can be done, not how to do it. I ask again: can you point me to
sample Java code to write files with structures?
Really, netcdf-3 files dont support structures. Nj22 will recognize the "record" structure, which you get by using unlimited dimensions. The example in the nj22 manual appendix "Create a netCDF file" shows creating a file with unlimited dimension. Its a bit out of date, im afraid to say, you need to use
Dimension timeDim = ncfile.addDimension("time", -1, true, true, false);
Dimension timeDim = ncfile.addDimension("time", -1);
But this wont be useful within an arbitrary opendap server/client. So if we
rewind a few steps, I guess it would help me to know what opendap server you
want to use, and perhaps a bit more of the context.
All the variables that have the unlimited dimension get put into the
"record" structure, and if you call netcdfFile.addRecordStructure(), a
Structure is added. The TDS-OpenDAP server, for example, will serve
this as an Array of Structures. Since the length of it is known,
theres no reason to make it into a Sequence. Currently theres no way
to get nested Sequences.
So the "when viewed with opendap" part depends on what opendap server
A Sequence is special because you are promising to allow relational
constraint expressions on the fields. So your server has to deal with
that, which is non-trivial. We are still considering if its possible
to support sequences in the CDM.
I have experimented with netcdfFile.addRecordStructure(), but can't
figure out how to access the Structure in order to call
addMemberVariable in order to add the variables to it.
Note that you can create an in-memory NetcdfFile with
addMemberVariable() etc, but you cannot save this to a netcdf-3 file.
As I said, netcdf-4 will allow other things, including (I think)
variable length nested Structures, which are Sequences, but the
question of supporting relational constraint expressions remains open.
I don't think you answered my other email. Here are the questions in
Can anyone point me to a working example which uses
PointObsDataset, StationObsDataset and/or TrajectoryObsDataset?
Is there any documentation for these classes (other than
Im sorry theres not at this time. Those are experimental APIs that we are
working on currently. The ToolsUI code uses them, but in a rather complex way.
If you want, look at the ucar.nc2.ui.PointObsViewer class.
Satellite Data Product Manager
Environmental Research Division
NOAA Southwest Fisheries Science Center
1352 Lighthouse Ave
Pacific Grove, CA 93950-2079
<>< <>< <>< <>< <>< <>< <>< <>< <><