Re: Lambert Conformal GRIB to NetCDF

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Tue, 28 Oct 2008 06:20:12 -0600

Hi Hauss

ncl_convert2nc should work just fine.
The appropriate two-dimensional latitude and longitude arrays
are created by NCL and are included on the file as 'value-added'
variables.

I think the issue with panoply is that it requires data
to be fully described by "coordinate variables" (CVs).
CV are one-dimensional monotonically [in/de]creasing arrays
whose dimension name is the same as the variable name.
eg: lat(lat)

I think the issue below is that there is a variable [lat]
which is 2D and has two named dimensions (lon,lat)

     nlat = dimsizes(lat)
     nlon = dimsizes(lon)
Hence, nlat and mlon will be 1d arrays of size 2

printVarSummary(nlat)

Then the array constructors (/ ... /) do not allow
arrays as elements

dimSizes = (/-1,nlat,nlon,nlev/)

HTH
D

Hauss Reinbold wrote:
> Hi all,
>
> I am attempting to convert a GRIB file with weather data that is on a
> lambert conformal grid into a netcdf file using NCL. I initially tried
> ncl_convert2nc and it runs without error, but when I use a netcdf viewer
> like panoply to view the file, the grid does not display correctly
> because the grid points are not matched to the correct lat/lon points.
>
> Now I'm using the efficient output example in the GRIB to netCDF section
> and I'm coming across a problem. The latitude and longitude coordinate
> grids are 2-dimensional, each containing the lat and lon points
> respectively of each point on the grid, since the lambert conformal grid
> is not monotonically increasing in lat and lon.
>
> Because of this, when I have the following code (snipped for relevance):
>
> lat = grib_in->g3_lat_0
> lon = grib_in->g3_lon_1
>
> lat!0 = "lon"
> lat!1 = "lat"
>
> lon!0 = "lon"
> lon!1 = "lat"
>
> printVarSummary(lat)
>
>
>
> nlev = dimsizes(lev)
> nlat = dimsizes(lat)
> nlon = dimsizes(lon)
>
> setfileoption(netcdf_out,"DefineMode", True)
>
> dimNames = (/"time","lat","lon","lev"/)
> dimSizes = (/-1,nlat,nlon,nlev/)
> dimUnlim = (/True,False,False,False/)
> filedimdef(netcdf_out,dimNames,dimSizes,dimUnlim)
>
>
> I get an error at the dimSizes line (with print out of lat variable
> included):
>
> Variable: lat
> Type: float
> Total Size: 97696 bytes
> 24424 values
> Number of Dimensions: 2
> Dimensions and sizes: [lon | 142] x [lat | 172]
> Coordinates:
> Number Of Attributes: 11
> corners : ( -40.16801, -40.21574, -32.46025, -32.4188 )
> long_name : latitude
> GridType : Lambert Conformal Secant or Tangent, Conical or bipolar
> units : degrees_north
> Latin2 : -30
> Latin1 : -60
> Dy : 6000
> Dx : 6000
> Lov : 145
> Lo1 : 138.367
> La1 : -40.168
> fatal:_NclBuildArray: each element of a literal array must have the same
> dimension sizes, at least one item doesn't
> fatal:Execute: Error occurred at or near line 47 in file convert2ncl-2.ncl
>
>
>
> The examples I'm seeing look like they are for simple monotonically
> increasing grids. Is it possible to do this for lambert conformal and
> if so, what should I change? Thanks for any help.
>
>
>
>
> ***************************
> Hauss Reinbold
> Assitant Research Scientist/Programmer
> Hauss.Reinbold_at_dri.edu
> 775-673-7386
> *****************************
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Oct 28 2008 - 06:20:12 MDT

This archive was generated by hypermail 2.2.0 : Tue Oct 28 2008 - 09:54:43 MDT