Due to the current gap in continued funding from the U.S. National Science Foundation (NSF), the NSF Unidata Program Center has temporarily paused most operations. See NSF Unidata Pause in Most Operations for details.
John, Thanks for the quick response. 1. Sadly, I'm just a recipient of the netCDF files created by the v4.0 API and the upstream source of this data is not planning on upgrading anytime soon. That said, I expected you guys might say that so I did verified that the code works this way in 4.3 too. 2. Understood. I've already finished the code that does the netCDF -> GRIB conversion so this was more of a "why does it work that way?" type of email. 3. Gotcha. I wasn't even thinking of it from a GIS standpoint. After spending time writing code that handles GRIB data, I'm used to the first point in a GRIB record being 0,0 and going from there. The only reason I brought it up was that it was the first indication that the projection being used to generate the x and y is not using LA1 and LO1 as the originating point. 4. I'm guessing this is where I'm getting hung up. All this time, I've been working with the assumption that LA1 and LO1 from the GDS was origin of the projection. How was it decided that LATIN1 and LOV were going to be used for the origin instead? I've talked to a two other software devs who work with GRIB (full disclosure, one is a meteorologist, the other is not), and they haven't seen it done this way either. I appreciate the input here. To be fair, now that I understand how it works, my conversion code spits out great GRIB formatted messages and, as I mentioned above, this was primarily a follow up to see why it is done this way and determine if there's a problem. Bryan From: netcdf-java-bounces@xxxxxxxxxxxxxxxx [mailto:netcdf-java-bounces@xxxxxxxxxxxxxxxx] On Behalf Of John Caron Sent: Monday, June 25, 2012 1:30 PM To: netcdf-java@xxxxxxxxxxxxxxxx Subject: Re: [netcdf-java] GRIB-2-netCDF Projection Question Hi Bryan: 1. The classes you are working with in NetCDF-Java 4.0 are no longer supported. Please look at ucar.nc2.grib.* classes in NetCDF-Java 4.3. 2. NetCDF-Java does not support writing GRIB files, only reading them. So we support GRIB -> netcdf/CF, but not the other way around. In principle, if you understand the CF conventions, you can write the correct GRIB GDS from them. 3. The convention that projection x and y values must be positive is not used. Thats more of a GIS thing and is rather artificial; one typically has to add "false_northing" and "false_easting" to make it true. 4. The "origin of the projection" may also be different than what you are used to. It is essentially the place where x=0, y=0 in the projection defined by the LambertConformal class; LA1 and LO1 is the position of one of the corners of the grid. Theres no documentation other than the code for GRIB, but you might find this helpful: http://www.unidata.ucar.edu/software/netcdf-java/reference/StandardCoordinateTransforms.html John On 6/25/2012 12:14 PM, Rockwood, Bryan wrote: Greetings, As part of the process of creating a GRIB1 file from subgridded netCDF data generated by the NetCDF-Java 4.0 API (long story), I had a difficult time figuring out how the X and Y values from the netCDF were calculated. Since there were negative X and Y values, it appeared that the projection used to calculate X and Y were not grid based. So, I obtained the Java netCDF source and proceeded to debug through the code. After some exploring, I found a class called GridHorizCoordSys in the package ucar.nc2.iosp.grid. In said class is a private method called makeLC and the first thing it does is create a projection for the GRIB record. Now here's where I'm confused. This is the code in question: proj = new LambertConformal( gds.getDouble(GridDefRecord.LATIN1), gds.getDouble(GridDefRecord.LOV), gds.getDouble(GridDefRecord.LATIN1), gds.getDouble(GridDefRecord.LATIN2)); Looking at the javadoc for the LambertConformal constructor, the first two parameters should be the latitude and longitude origin of the coordinate system. In my experience when dealing with Lambert Conformal grids, this is typically GridDefRecord.LA1 and GridDefRecord.LO1, respectively, from the GRIB GDS. The code above is using GridDefRecord.LATIN1 and GridDefRecord.LOV instead. Once I found out how the projection was being created, it was then possible to get the LA1 and LO1 from the X and Y within the netCDF to create a valid GDS for the GRIB data I'm generating. My questions are as follows: Why use the LATIN1 and LOV to set the lat and lon origin of the projection instead of LA1 and LO1? Is this documented someplace? I'm curious how someone such as myself would know to create a projection like this without debugging through the code. Bryan Rockwood _______________________________________________ netcdf-java mailing list netcdf-java@xxxxxxxxxxxxxxxx<mailto:netcdf-java@xxxxxxxxxxxxxxxx> For list information or to unsubscribe, visit: http://www.unidata.ucar.edu/mailing_lists/
netcdf-java
archives: