[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Fwd: RE: [netcdf-java] FW: Adding a new projection to GRIB netcdf decoder] (fwd)



i forgot to mention the uk table ukmet_2_v175, it has the wrong version number but it's the latest uk table I have.

Robb...


===============================================================================
Robb Kambic                                Unidata Program Center
Software Engineer III                      Univ. Corp for Atmospheric Research
address@hidden             WWW: http://www.unidata.ucar.edu/
===============================================================================

---------- Forwarded message ----------
Date: Mon, 10 Nov 2008 19:17:54 -0700
From: John Caron <address@hidden>
To: Robb Kambic <address@hidden>
Subject: Re: [Fwd: RE: [netcdf-java] FW: Adding a new projection to GRIB netcdf
    decoder]

should they agree with NCEP? given thats its a UK file ?

is this the same issue as BUFR of using master ids when they are really local ?

Robb Kambic wrote:

These are the values from the file, they don't agree with the NCEP
values for grid 10 parameters Ni,Nj, La1, La2, Di and Dj that are
included later
I wonder if the NCEP values are after the rotation is done. But Ni and Nj
 should agree.

Also, gribtonc decoding got the same values, so maybe the file is
corrupt or the NCEP values are wrong.



                        Header : GRIB1
                    Discipline : 0 Meteorological Products
                  GRIB Edition : 1
                   GRIB length : 28014
            Originating Center : 74 UK Meteorological Office Bracknell
(RSMC)
        Originating Sub-Center : 2 Melbourne
            Product Definition : 0 Forecast/Uninitialized Analysis/Image
Product
            Parameter Category : -1 Meteorological Parameters
                Parameter Name : 201 VAR201 N1 5m temperature - maximum
over last 24 hours
               Parameter Units : K
                Reference Time : 2005-03-14T00:00:00Z
                    Time Units : hour
          Time Range Indicator : product valid at RT + P1
                   Time 1 (P1) : 45
                   Time 2 (P2) : 0
       Generating Process Type : 1 Unknown
                    Level Type : 1 surface
                 Level Value 1 : 0.0
                 Level Value 2 : 0.0
                    GDS Exists : true
                    BMS Exists : false
         Number of data points : 9216
                     Grid Name : Rotated latitude/longitude grid
                     Grid Shape: 0 spherical
         Spherical earth radius: 6367.47
                            Nx : 96
                            Ny : 96
                           La1 : -0.635
                           Lo1 : 359.015
  Resolution & Component flags : 128
                         Winds : True
                           La2 : 0.22
                           Lo2 : 359.87
                            Dx : 0.0090
                            Dy : 0.0090
                 Scanning mode : 64
     Latitude of southern pole : -19.03
    Longitude of southern pole : 25.44
             Angle of Rotation : 2.0

GDS length =122
GDS  NV = 20
vertical coordinate values  seem inconsistent****
vertical coordinate =0 =9.0
vertical coordinate =1 =2.0
vertical coordinate =2 =2.0
vertical coordinate =3 =2.0
vertical coordinate =4 =2.0
vertical coordinate =5 =2.0
vertical coordinate =6 =-134.1875
vertical coordinate =7 =2.0
vertical coordinate =8 =2.0
vertical coordinate =9 =2.0
vertical coordinate =10 =2.0
vertical coordinate =11 =36.7575
vertical coordinate =12 =140.84
vertical coordinate =13 =2.0
vertical coordinate =14 =-8.644
vertical coordinate =15 =0.644
vertical coordinate =16 =150.43788
vertical coordinate =17 =0.644
vertical coordinate =18 =-196608.0
vertical coordinate =19 =9.0


NCEP values from:
http://www.nco.ncep.noaa.gov/pmb/docs/on388/tableb.html#GRID10

VALUE      GRID DESCRIPTIONS
10     Latitude/Longitude Ocean grid
with (1,1) at (1E,64E) and (180,139) at (1W,74S)
I increasing Eastward, Equator at J=65



Ni     180
Nj     139
La1     64.000N
Lo1     1.0E
Res. & Comp. Flag     1 0 0 0 0 0 0 0
La2     74.000S
Lo2     359.000E = 1.000W
Di     2.000 degrees
Dj     1.000 degrees
Scanning Mode     0 0 0(NB: matrix style)














On Thu, 30 Oct 2008, John Caron wrote:

this file is not reading in, can you look:

R:/testdata/grid/transforms/rotlatlon.grb


-------- Original Message --------
Subject: RE: [netcdf-java] FW: Adding a new projection to GRIB netcdf
decoder
Date: Thu, 30 Oct 2008 16:55:19 +0100
From: Tor Christian Bekkvik <address@hidden>
To: caron <address@hidden>
CC: Kjell Røang <address@hidden>

Hi,
Here you have an example GRIB file with rotated LatLon projection..
(stored at our ftp for limited time)

ftp://ftp.cmr.no/pub/incoming/rotlatlon.grb

.. And here is the projection code, in case you would like to compare
with yours :
(fwd() & inv() are inverse functions)


  public RotLatLon(double aLonsp,
                   double aLatsp,
                   double aRotsp)
  {
     lonsp = aLonsp;
     latsp = aLatsp;
     rotsp = aRotsp;
     double dlat_rad = (latsp - (-90)) * DEG2RAD; //delta latitude
     sinDlat = Math.sin(dlat_rad);
     cosDlat = Math.cos(dlat_rad);
  }

  private double[] transform(double [] lonlat, double rot1, double
rot2, double s)
  {
     double e = DEG2RAD * (lonlat[0] - rot1); //east
     double n = DEG2RAD * lonlat[1]; //north
     double cn = Math.cos(n);
     double x = cn * Math.cos(e);
     double y = cn * Math.sin(e);
     double z = Math.sin(n);
     double x2 = cosDlat * x + s * z;
     double z2 = -s * x + cosDlat * z;
     double R = Math.sqrt(x2 * x2 + y * y);
     double e2 = Math.atan2(y, x2);
     double n2 = Math.atan2(z2, R);
     double rlon = RAD2DEG * e2 - rot2;
     double rlat = RAD2DEG * n2;
     return new double[]{rlon, rlat};
  }

  public double[] fwd(double[] lonlat)
  {
     return transform(lonlat, lonsp, rotsp, sinDlat);
  }

  public double[] inv(double[] lonlat)
  {
     return transform(lonlat, -rotsp, -lonsp, -sinDlat);
  }


Thanks,
Tor C



-----Original Message-----
From: John Caron [mailto:address@hidden]
Sent: 30. oktober 2008 16:30
To: Tor Christian Bekkvik
Cc: netcdf-java
Subject: Re: [netcdf-java] FW: Adding a new projection to
GRIB netcdf decoder

Hi Tor:

1. We do have ucar.unidata.geoloc.projection.RotatedPole in
4.0. Is that the same projection?

Possibly, but I dont have the source..


2. If so, we can add to the GRIB IOSP. All we need is an
example GRIB file that uses this, so we can test.

See ftp link above...


thanks,
John

Tor Christian Bekkvik wrote:


-----Original Message-----
From: Tor Christian Bekkvik
Sent: 27. oktober 2008 14:48
To: 'address@hidden'
Cc: Kjell Røang
Subject: Adding a new projection to GRIB netcdf decoder

Hi,
We would like to add support for Rotated LatLon projection when
reading GRIB files. (using netcdf decoders)


To open the gribfile, we have used class  NetcdfDataset:
NetcdfDataset.openDataset(gribFile,...)
But this fails for with rotated latlong projection, as it
is not supported:
  ucar.grib.NoValidGribException: GDS: Unknown Grid Type :
10) is not supported.
    at
ucar.grib.grib1.Grib1GridDefinitionSection.<init>(Grib1GridDef
initionSection.java:401)
    at ucar.grib.grib1.Grib1Input.scan(Grib1Input.java:155)
    at
ucar.grib.grib1.Grib1Indexer.writeFileIndex(Grib1Indexer.java:90)
    at
ucar.nc2.iosp.grib.GribServiceProvider.writeIndex(GribServiceP
rovider.java:163)
    at
ucar.nc2.iosp.grib.GribServiceProvider.getIndex(GribServicePro
vider.java:139)
    at
ucar.nc2.iosp.grib.GribServiceProvider.open(GribServiceProvide
r.java:75)
    at ucar.nc2.NetcdfFile.<init>(NetcdfFile.java:1092)
    at ucar.nc2.NetcdfFile.open(NetcdfFile.java:485)
    at ucar.nc2.NetcdfFile.open(NetcdfFile.java:278)
    at
ucar.nc2.dataset.NetcdfDataset.openFile(NetcdfDataset.java:341)
    at
ucar.nc2.dataset.NetcdfDataset.openDataset(NetcdfDataset.java:175)
    at
ucar.nc2.dataset.NetcdfDataset.openDataset(NetcdfDataset.java:161)



To add this new projection, it seems that at least the
following code needs update:
1) ProjectionImpl  (I can implement RotLatLonProjection extends
ProjectionImpl)
2) Grib1GridDefinitionSection  (to fix
NoValidGribException, listed above)
3) GribHorizCoordSys.makeProjection   (read necessary
parameters from Grib GDS section and return RotLatLonProjection):
  private void makeProjection(NetcdfFile ncfile) {
    switch (lookup.getProjectionType(gdsIndex)) {
      case TableLookup.PolarStereographic:
        makePS();
        break;
      case TableLookup.LambertConformal:
        makeLC();
        break;
      case TableLookup.Mercator:
        makeMercator();
        break;
      case TableLookup.Orthographic:
        makeSpaceViewOrOthographic();
        break;
      default:
        throw new UnsupportedOperationException("unknown
projection = " + gdsIndex.grid_type);
    }





Currently, I don't have sufficient GRIB/NetCDF knowledge
(or source code) to do this.
But I have already added Rotated LatLon projection for the
JGRIB project (http://jgrib.sourceforge.net/), and we would
like to do the same with NetCDF/GRIB.




- Any comments how to best do this ?



Thanks,
Tor Chr Bekkvik


_______________________________________________
netcdf-java mailing list
address@hidden
For list information or to unsubscribe, visit:
http://www.unidata.ucar.edu/mailing_lists/




===============================================================================

Robb Kambic                       Unidata Program Center
Software Engineer III               Univ. Corp for Atmospheric Research
address@hidden           WWW: http://www.unidata.ucar.edu/
===============================================================================