Re: NAM 6KM Alaska nest - rotation of wind components

From: David Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Wed Sep 05 2012 - 14:53:13 MDT

It doesn't look like the gnum variable is used for anything other the print statement following its initialization. In GRIB2 there are officially no pre-defined grids with id numbers like 198. Grid 198 would be defined using the Polar Stereographic projection template.

Also the code is not taking advantage of the pre-computed rotation variable. Here is the original code with the changes I would make to compute the rotated u and v values.

; New way to rotate wind directions
  ut = netcdf_out->sugrd ; 3D
  vt = netcdf_out->svgrd
  un = ut ; array same size with mnam data
  vn = vt

; the only difference is that you read the rotation variable from the file rather than computing it. (the computation would be different for a Polar Stereographic grid like 198 than it would be for
; a Lambert Conformal plot. So it is much easier to read the pre-computed rotation value.)
; the rotation variable has radians for units, so you can apply the sine and cosine functions directly.
; Note that the formulas that generate un and vn are exactly the same as given by the formula_u and formula_v attributes of the rotation variable.
; This should work for any GRIB grid that has a rotation variable and grid relative vector components.
 
; read the rotation variable
  vrot = "gridrot_0"
  rotation = grib_in->\$vrot\$;

  ca = conform(ut, cos(rotation), (/1,2/) ) ; 3D (time,lon,lat)
  sa = conform(ut, sin(rotation), (/1,2/) ) ; 3D (time,lon,lat)
        
  un = ca*ut + sa*vt ; array operation [all arrays conform]
  vn = -sa*ut + ca*vt

  netcdf_out->sugrd= un
  netcdf_out->svgrd= vn

Let me know if this does not give you what you need. In that case I would need to be able to get a sample file that employs the Alaska grid in order to troubleshoot further.
 -dave

; Sp

On Sep 5, 2012, at 8:02 AM, John Kelley wrote:

> David,
>
> Thanks for responding.
>
> I am trying to figure out what I need to change in an existing code that
> we use for reading output on NAM 12km Lambert Conformal grid and
> rotating wind components in order to use it for reading output from the
> NAM 06km Alaska Nest Polar Stereographic grid and rotating the wind
> components.
> (My NAM12km script with embedded NCL code is attached.)
>
> It can't be as simple as changing GRIB2 grid number from 'gnum=218'
> to 'gnum=198' ?
>
> John
>
>
> On 9/4/2012 4:37 PM, David Brown wrote:
>> Hi John,
>> If you read the data as GRIB2, then NCL provides a pseudo-varlable in the file that contains the rotation angles associated with each grid. I don't have a suitable Polar Stereographic example at hand, but here is what a file dump looks like for a GRIB 2 lambert conformal grid:
>>
>> float gridrot_0 ( ygrid_0, xgrid_0 )
>> long_name : vector rotation angle
>> GridType : Lambert Conformal (secant, tangent, conical or bipolar)
>> units : radians
>> formula_u : Uearth = sin(rot)*Vgrid + cos(rot)*Ugrid
>> formula_v : Vearth = cos(rot)*Vgrid - sin(rot)*Ugrid
>> note1 : u and v components of vector quantities are resolved relative to grid
>> note2 : apply formulas to derive u and v components relative to earth
>>
>> float gridlat_0 ( ygrid_0, xgrid_0 )
>> corners : ( 16.281, 17.34023, 55.48131, 54.17241 )
>> long_name : latitude
>> grid_type : Lambert Conformal (secant, tangent, conical or bipolar)
>> units : degrees_north
>> Latin2 : 25
>> Latin1 : 25
>> Dy : 13.545
>> Dx : 13.545
>> Lov : 265
>> Lo1 : 233.862
>> La1 : 16.281
>>
>> float gridlon_0 ( ygrid_0, xgrid_0 )
>> corners : ( -126.138, -69.03799, -57.38108, -139.8561 )
>> long_name : longitude
>> grid_type : Lambert Conformal (secant, tangent, conical or bipolar)
>> units : degrees_east
>> Latin2 : 25
>> Latin1 : 25
>> Dy : 13.545
>> Dx : 13.545
>> Lov : 265
>> Lo1 : 233.862
>> La1 : 16.281
>>
>> Hopefully the rotation angle attributes are self-explanatory. The underlying code that computes the rotation angle (as well as the lat and lon coordinates) is from NCEP. We do not currently have a direct interface to those routines.
>> -dave
>>
>>
>> On Sep 4, 2012, at 11:48 AM, John Kelley wrote:
>>
>>> I plan to use GRIB2 output from NCEP's NAM 6km Alaska NEST domain.
>>> The Alaska NAM Nest output is on Grid #198, a 6km polar stereographic projection grid
>>> (http://www.nco.ncep.noaa.gov/pmb/docs/on388/tableb.html#GRID198)
>>>
>>> I need to convert the u and v wind components from grid relative to Earth relative.
>>>
>>> Does anyone have NCL code for converting the u and v wind components from grid relative on the NAM 6km Alaska nest to Earth relative?
>>>
>>>
>>> Sincerely,
>>> John Kelley
>>> NOAA/NOS
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
> <NCLnamgrib2tonetcdf.txt><NCLnamgrib2tonetcdf.docx>

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Sep 5 14:53:23 2012

This archive was generated by hypermail 2.1.8 : Tue Sep 11 2012 - 15:30:42 MDT