Re: [netcdf-java] WRFConvention.java problem.

Todd Plessel wrote:
Hi John,

On Jul 10, 2010, at 11:59 AM, John Caron wrote:

Todd Plessel wrote:
Hi John,
We are displaying WRF polar stereographic gridded files
in VERDI - a Java application that uses
netcdf-4.1 Java which contains WRFConvention.java.
http://www.unidata.ucar.edu/software/netcdf-java/v4.1/javadocAll/index.html
Apparently the map is not being projected correctly.
The attached zip file contains a sample WRF NetCDF
data file wrfinput_d01 and screen.gif which shows
correct CMAQ (M3IO NetCDF) data and map on the left and
WRF land-use data and mis-matched map on the right.
The grids are almost identical and so should display
almost the same. Note that South America and
Africa are clearly mis-registered with respect to the
land-use data where (most/all) red is ocean.
Some relevant attributes are:
west_east = 199 ;
south_north = 199 ;
float LU_INDEX(Time, south_north, west_east) ;
:DX = 108000.f ;
:DY = 108000.f ;
:GRIDTYPE = "C" ;
:MAP_PROJ = 2 ;
:CEN_LAT = 90.f ;
:CEN_LON = -8.f ;
:TRUELAT1 = 45.f ;
:TRUELAT2 = 45.f ;
:MOAD_CEN_LAT = 90.f ;
:STAND_LON = -98.f ;
CEN_LON looks suspect. Perhaps it should be -98?
In any case, which attributes are actually used by
WRFConventions?
I don't see any information about the ellipsoid in the file.
CMAQ usually uses a sphere of radius 6,370,000 meters.
Perhaps WRF does too.
It would seem that the constructors for all projectors should
have ellipsoid input parameters e.g.,
double major_semiaxis,  double minor_semiaxis.
Is there a fix available?
Thanks,
Todd
1-919-541-5500
Hi Todd:

This is what we are using:

Stereographic type=Projection
  grid_mapping_name = stereographic
  longitude_of_projection_origin = -98.0
  latitude_of_projection_origin = 45.0
  scale_factor_at_projection_origin = 0.8535533905932737
  impl.class= ucar.unidata.geoloc.projection.Stereographic

Do you know what version of WRF generated this?

Version 3.1.

                :TITLE = " OUTPUT FROM REAL_EM V3.1 PREPROCESSOR" ;


I have a note that says

* Note: Apparently WRF netcdf files before version 2 didnt output the 
projection origin, so
* we cant properly georeference them.

I read that too. But these are newer format files with GRIDTYPE = "C".

Can you send me the M3IO file? If its the same projection, that might give us a 
clue.

I've attached CMAQ_polar.nc which is also polar-stereographic
on a 187 x 187 grid which is close to the WRF 199 x 199 grid.
It is a northern polar stereographic with the tangent cut at latitude = 45,
center of projection is (-98, 90) and uses a sphere of radius 6,370,000 m.

Thanks,

Todd
1-919-541-5500

I have CMAQ_polar.nc having:

Coordinate Transforms
 PolarStereographic type=Projection
   grid_mapping_name = polar_stereographic
   longitude_of_projection_origin = -98.0
   latitude_of_projection_origin = 90.0
   scale_factor_at_projection_origin = 0.8537995936163079
   impl.class= ucar.unidata.geoloc.projection.Stereographic

Im not sure what you mean by "tangent cut at latitude = 45".

Anyway, this implies that the WRF file which is now:

Coordinate Transforms
 Stereographic type=Projection
   grid_mapping_name = stereographic
   longitude_of_projection_origin = -98.0
   latitude_of_projection_origin = 45.0
   scale_factor_at_projection_origin = 0.8535533905932737
   impl.class= ucar.unidata.geoloc.projection.Stereographic

should be:

Coordinate Transforms
 Stereographic type=Projection
   grid_mapping_name = stereographic
   longitude_of_projection_origin = -98.0
   latitude_of_projection_origin = 90.0
   scale_factor_at_projection_origin = 0.8535533905932737
   impl.class= ucar.unidata.geoloc.projection.Stereographic

and that change seems to fix the misalignment.

I will have to run my unit tests to see if anything breaks. WRF parameters have 
been unreliable, I think because most people use the rewritten GRIB files, so 
dont see the problem.

Heiko, im cc'ing you because you had originally sent me some code on this. The change is 
in ucar.nc2.dataset.conv.WRFConvention, to use centralLat ("CEN_LAT") when 
available:

       case 2:
         // Thanks to Heiko Klein for figuring out WRF Stereographic
         double lon0 = (Double.isNaN(standardLon)) ? centralLon : standardLon;
         double lat0 = (Double.isNaN(centralLat)) ? lat2 : centralLat;  // ?? 
7/20/2010
         double scaleFactor = (1 + Math.abs(Math.sin(Math.toRadians(lat1)))) / 
2.;  // R Schmunk 9/10/07
         // proj = new Stereographic(lat2, lon0, scaleFactor);
         proj = new Stereographic(lat0, lon0, scaleFactor);





  • 2010 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-java archives: