Re: [netcdf-java] Can't seem to be able to create a NetCDF file with NetCDF-Java that conforms to the CF-1.6/H5.3 format

  • To: Aleksander Vines <aleksander.vines@xxxxxxxx>
  • Subject: Re: [netcdf-java] Can't seem to be able to create a NetCDF file with NetCDF-Java that conforms to the CF-1.6/H5.3 format
  • From: Roland Schweitzer - NOAA Affiliate <roland.schweitzer@xxxxxxxx>
  • Date: Mon, 27 Jan 2014 08:45:50 -0600
Yeah, sorry.  I was imprecise.  I do this:

NetcdfFileWriter ncfile =
NetcdfFileWriter.createNew(NetcdfFileWriter.Version.netcdf3,
netcdfFilename);

>From the description, FileWrite2 is about copying structures, but from the
low-level NetcdfFileWriter you can build the entire file from scratch.

Roland


On Sat, Jan 25, 2014 at 4:27 AM, Aleksander Vines <aleksander.vines@xxxxxxxx
> wrote:

> I'm not using FileWriter, I'm using NetcdfFileWriteable, which creates
> NetCDF-3. I figured I needed the "Conventions:CF-1.6" attribute, and that
> the names of the dimensions in the documentation is ambiguous (should I use
> profiles/stations or profile/station)?
>
> One note, both of these classes are deprecated, and I should apparently
> use FileWriter2(?). However then I have to work with already created
> NetCDF files, and I would like to be able to create one programmatically
> from scratch. But this is perhaps something that is not going to be
> supported by NetCDF-java in future versions since those classes are
> deprecated, and I should really create the basic structures in some files
> so that the software has something to start with?
>
> Aleksander
>
>
> Roland Schweitzer - NOAA Affiliate <roland.schweitzer@xxxxxxxx> ,
> 1/24/2014 11:47 PM:
>
> What netCDF version do you use in you FileWriter.createNew?
>
> I'm able to make CF files for point features readable by toolsUI, but I
> restrict myself to NetcdfFileWriter.Version.netcdf3?
>
> Roland
>
>
> On Fri, Jan 24, 2014 at 7:55 AM, Aleksander Vines <
> aleksander.vines@xxxxxxxx> wrote:
>
> Hi,
>
> I need some help with the creation of a NetCDF file.
>
> I'm attempting to create the NetCDF file programmatically. I have a lot of
> point data, and I want to be able to create different types of NetCDF-files
> after extracting different subsets of these points. I want the files to
> conform to CF-1.6 (as far as its possible with the input I got).
>
> I'm using NetCDF-java 4.3.
>
> I've found a "Short guide to writing files using CF-1.6 Discrete Sampling
> Features Conventions":
>
>    -
>    
> http://www.unidata.ucar.edu/software/thredds/current/netcdf-java/reference/FeatureDatasets/CFpointImplement.html
>
> From this guide, I concluded that I should support the format specified in
> CF-1.6 H5.3 (see below) in my application (I'm also writing other kind of
> formats)
>
>    -
>    
> http://cf-pcmdi.llnl.gov/documents/cf-conventions/1.6/cf-conventions.html#idp8432528
>    -  I've figured one obvious error in this example, and that is that
>    they referred to name_strlen as a dimension without specifying it in the
>    dimension list.
>
> ncdump of the file I've created:
>
>    -  http://pastebin.com/fsPGX5LD
>    -  I've changed station_info to a 2D char array (as far as I
>    understand, this is just some extra info and it shouldn't make a difference
>    that I changed it to be a char/String(2D)?)
>    -  I miss a few long_names, and a few standard names are not the
>    "correct" standard names, but I can't figure out why this is not working.
>
> All seems nice so far, but when I try to read this netCDF-file with
> ToolsUI 4.3, I get this error message: http://i.stack.imgur.com/kmAqR.png
>
>    - Can't open x.nc
>    - NestedTable: cant find variable time for coordinate type Time
>    - NestedTable: cant find variable lat for coordinate type Lat
>    - NestedTable: cant find variable lon for coordinate type Lon
>    - Table Structure(record) featureType POINT: lat/lon/time coord not
>    found
>    - Failed to find FeatureDatasetFactory for=x.nc datatype=ANY_POINT
>
> Could the problem have something to do with the following comment in
> the "Short guide to writing files using CF-1.6 Discrete Sampling Features
> Conventions", under 9.5: "CDM: A variable representing the instance id is
> required, indicated by an attribute named cf_role, which follows all the
> CF rules above."
>
> It is absolutely not a requirement that the file is read by ToolsUI 4.3,
> but the fact that it can't be read from there probably indicates that
> something is wrong with the format (ncWMS can't read the file either).
>
> I'm not sure if it makes any difference to show the code here, but here is
> the method that writes to the netCDF file: http://pastebin.com/QTHKUyw8 (and
> yes, I know NetcdfFileWriteable is deprecated, but in my opinion, your
> documentation is quite difficult to use, and the "latest" examples (
> https://www.unidata.ucar.edu/software/thredds/current/netcdf-java/tutorial/
>   http://www.unidata.ucar.edu/software/netcdf/examples/programs/ ) seems
> to be using this class)
>
> Any help with this problem would be greatly appreciated :)
>
> Many Thanks,
> Aleksander Vines
>
> _______________________________________________
> netcdf-java mailing list
> netcdf-java@xxxxxxxxxxxxxxxx
> For list information or to unsubscribe, visit:
> http://www.unidata.ucar.edu/mailing_lists/
>
>
>
  • 2014 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-java archives: