[ncl-talk] Extract point value + WRF model output
Dennis Shea
shea at ucar.edu
Sun Oct 24 22:18:21 MDT 2021
Barry illustrated how to get some answers via wrf_ functions
====
In your screen shot you are using NCL's "*coordinate variable*" syntax:
{...}
By netCDF definition, a "*coordinate variable*" is a *one* dimensional
variable.
Some examples include: time(time), level(level), lat(lat), lon(lon).
WRF geographical coordinates are *multi-dimensional*. Hence, they are not
"coordinate variables".
For eample:
float XLAT(Time, south_north, west_east)
float XLONG(Time, south_north, west_east)
They are variables that contain coordinates.
By rule, NCL's coordinate variable notation [ {...} ] can not be used on
multi-dimensional arrays that contain coordinates..
--------------
You can interpolate to a specific locations using: *rcm2points
<http://www.ncl.ucar.edu/Document/Functions/Built-in/rcm2points.shtml> *or
*rcm2points_Wrap*
<http://www.ncl.ucar.edu/Document/Functions/Contributed/rcm2points_Wrap.shtml>
(Possibly, these could be slow.)
lon_pts = (/-104.867, -102.0/)
lat_pts = (/ 39.75, 38.0/)
f = addfile ("some_WRF_file.nc", "r")
lat2d = f->XLAT(0,:,:) ; size = (nlat,nlon)
lon2d = f->XLONG(0,:,:) ; size = (nlat,nlon)
x = f->X
x_pts = *rcm2points_Wrap *(lat2d, lon2d, x, lat_pts, lon_pts, 0)
print(x_pts)
---------------
The following will return the indices (subscripts) of the spatial
coordinates closest to a location.
*getind_latlon2d*
<http://www.ncl.ucar.edu/Document/Functions/Contributed/getind_latlon2d.shtml>
lon_pts = (/-104.867, -102.0/)
lat_pts = (/ 39.75, 38.0/)
f = addfile ("some_WRF_file.nc", "r")
lat2d = f->XLAT(0,:,:) ; size = (nlat,nlon)
lon2d = f->XLONG(0,:,:) ; size = (nlat,nlon)
x = f->X
nm = *getind_latlon2d* (lat2d,lon2d, lat_pts, lon_pts)
*print* <http://www.ncl.ucar.edu/Document/Functions/Built-in/print.shtml>(nm)
do k=0,*dimsizes*
<http://www.ncl.ucar.edu/Document/Functions/Built-in/dimsizes.shtml>(lat_pts)-1
; loop over locations
n = nm(k,0)
m = nm(k,1)
x_nm = x(:,n,m) ; x(:,:,n,m)
print("---")
*print* <http://www.ncl.ucar.edu/Document/Functions/Built-in/print.shtml>(lat2d(n,m)+"
"+lon2d(n,m))
print(x_nm)
end do
On Sun, Oct 24, 2021 at 2:15 PM Setareh Rahimi via ncl-talk <
ncl-talk at mailman.ucar.edu> wrote:
> Dear all,
> Regarding my question, I tried below codes to extract point values.But I
> noticed there is no associated coordinate variable for latitude( have look
> at the attached image).
>
> begin
> a = addfile("wrfout_d03_2021-01-27_00:00:00","r")
> lat = a->XLAT
> printVarSummary(lat)
> t = a->T2(:,{35.6},{51}) ;T2 refers to temperature at 2m
> printVarSummary(t)
> asciiwrite("outfile.txt",t)
> end
>
> Therefore I can not choose my desire lat/lon to extract point value for a
> specific variable.
> May I ask you please to advise me on how to sort this issue out?
> Many thanks in advance,
> Best wishes
>
> On Sat, Oct 23, 2021 at 8:20 PM Setareh Rahimi <setareh.rahimi at gmail.com>
> wrote:
>
>> Dear NCL users,
>> I have a WRF output file in nc format. I need to have point values of
>> wind, temperature,and humidity at specific lat/lon and specific times. I
>> do not need a map plot or time series. I just want point values for each
>> variable at specific times ( 00,03,06,09,12,15,18,21 UTC) in ascii format
>> .For example, for wind variable at lat:y and lon:x
>> Time: 00 , 03 , 06 , 09 ,12
>> wind value : x1 , x2 , x3 , x4 , x5,
>> Would you please kindly help me in this regard?
>> Best wishes,
>>
>> --
>> S.Rahimi
>>
>>
>
> --
> S.Rahimi
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at mailman.ucar.edu
> List instructions, subscriber options, unsubscribe:
> https://mailman.ucar.edu/mailman/listinfo/ncl-talk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20211024/fcd490f8/attachment.html>
More information about the ncl-talk
mailing list