Re: right lat/lon attributes?

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Tue, 25 Mar 2008 14:35:22 -0600

Wolfgang Langhans wrote:
> Hi,
> I am trying to interpolate WRF output to another grid (gridded observational
> rain data). The interpolation works. But which lat/lon attributes do I have to
> pass to the interpolated field in order to map it? The new lat/lon are one
> dimensional arrays. Here is part of my script:
>

the reason your plot did not work is that you did not assign
units attributes for lat2dobs and lon2dobs

    lat2dobs_at_units = "degrees_north"
    lon2dobs_at_units = "degrees_east"

*All* plot map functions want units.

>
>
> -----------------------------------------------------------------------------
> a = addfile("wrfout_d04_2005-08-20_12_mp6.nc","r")
> rain_exp = wrf_user_getvar(a,"RAINNC",it2)-wrf_user_getvar(a,"RAINNC",it1)
>
> XLAT = wrf_user_getvar(a,"XLAT",it1)
> XLONG= wrf_user_getvar(a,"XLONG",it1)
>
> fil="2005.nc"
> f=addfile(fil,"read")
> RR=new((/103,241/),"float")
> RR(:,:)=f->RainRate_mmh(5591,0,:,:)
>
Don't do this

 RR=new((/103,241/),"float")
 RR(:,:)=f->RainRate_mmh(5591,0,:,:)

NCL will aoutomatically create the correct sized array.

  RR = f->RainRate_mmh

> do k=1,24
> RR(:,:)=RR(:,:) + f->RainRate_mmh(5567+k,0,:,:)
> end do
>
Don't do this

 do k=1,24
 RR(:,:)=RR(:,:) + f->RainRate_mmh(5567+k,0,:,:)
 end do

Rather

  do k=1,24
       RR = RR +f->RainRate_mmh(5567+k,0,:,:)
  end do

> lat2dobs=new((/103,241/),"float")
> lon2dobs=new((/103,241/),"float")
> do k=0,102
> lat2dobs(k,:)= 45.75 + (47.875-45.75)/102. * k
> end do
> do l=0,240
> lon2dobs(:,l)=5.75 + (10.75-5.75)/240. * l
> end do
>
These can be better replaced by one dimensional arrrays:

    lat = 45.75 + (47.875-45.75)/102. * ispan(0,102,1)
    lon = 5.75 + (10.75-5.75)/240. * ispan(0,240,1)

or, even better

    lat = fspan(45.75, 47.875, 103)
    lon = fspan( 5.75, 10.75, 241)

    lat_at_units = "degrees_north"
    lon_at_units = "degrees_east"

> RR_at_lat2d=lat2dobs
> RR_at_lon2d=lon2dobs
>
> lat1dobs = lat2dobs(:,0)
> lon1dobs = lon2dobs(0,:)
> rain_int = rcm2rgrid(XLONG,XLAT,rain_exp(:,:),lon1dobs,lat1dobs,1)
>
> rain_int_at_lat2d=lat2dobs ?????
> rain_int_at_lon2d=lon2dobs ????? Does not work!
>
      rain_int!0 = "lat" ; name dimensions
      rain_int!1 = "lon"
      rain&lat = lat ; assign coordinate variables
      rain&lon = lon

Since you are interpolating to a rectilinear grid, you only need
simple one dimensional coordinate arrays which are created/accessed
vi the & syntax.

> -------------------------------------------------------------------------------
> Thanks!
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>

-- 
======================================================
Dennis J. Shea                  tel: 303-497-1361    |
P.O. Box 3000                   fax: 303-497-1333    |
Climate Analysis Section                             |
Climate & Global Dynamics Div.                       |
National Center for Atmospheric Research             |
Boulder, CO  80307                                   |
USA                        email: shea 'at' ucar.edu |
======================================================
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Mar 25 2008 - 14:35:22 MDT

This archive was generated by hypermail 2.2.0 : Mon Mar 31 2008 - 09:11:46 MDT