[ncl-talk] How to extract a grid value of TRMM according the certain latitude and longitude

Dennis Shea shea at ucar.edu
Tue Mar 14 11:46:46 MDT 2017


Mary was guessing that the TRMM data was curvilinear where the latitude and
longitudes are two-dimensional. RG lat2d(nlat,mlon) and lon2d(nlat,mlon)

However, *if* your data has a structure like the following. The grid is
**rectilinear**.

netcdf TRMM {
dimensions:
    time = UNLIMITED ; // (172 currently)
    longitude = 1440 ;
    latitude = 400 ;
variables:
    double time(time) ;
        time:units = "hours since 1998-1-1 0" ;
    double longitude(longitude) ;
        longitude:units = "degrees_east" ;
        longitude:long_name = "Longitude" ;
    double latitude(latitude) ;
        latitude:units = "degrees_north" ;
        latitude:long_name = "Latitude" ;
    float pcp(time, latitude, longitude) ;                  <====
        pcp:comments = "Unknown1 variable comment" ;
        pcp:long_name = "precipitation:" ;
        pcp:units = "" ;
[snip]

===
Also, the question is a bit ambiguous. Please be clear when posting
questions.

re:
" ... extract some grid values of TRMM according to a series of specified
point locations (defined by their latitudes and longitudes).

===
If you want a *region* from a *rectilinear* grid

  latS = -25
  latN =  15
  lonL = -120
  lonR = 30

   f = addfile("...", "r")
   PCP = f->pcp(:, {latS:latN},{lonL:lonR})
   printVarSummary(PCP)


Variable: PCP
Type: float
Total Size: 66048000 bytes
            16512000 values
Number of Dimensions: 3
Dimensions and sizes:    [time | 172] x [latitude | 160] x [longitude |
600]  <===
Coordinates:
            time: [   0..124896]
            latitude: [-24.875..14.875]
            longitude: [-119.875..29.875]

=================================
So if you want random *individual grid points* from a *rectilinear* grid:

   LAT = (/ -20, 0, 25/)                ; user specified grid location
   LON = (/0, 50, 100/)/)

   f = add file("...", "r")
   pcp = f->pcp(:, {LAT},{LON})   ; all timed at 3 grid locations
   printVarSummary(pcp)

===
Variable: pcp
Type: float
Total Size: 6192 bytes
            1548 values
Number of Dimensions: 3
Dimensions and sizes:    [time | 172] x [latitude | *3*] x [longitude | *3*]
Coordinates:
            time: [   0..124896]
            latitude: [-20.125..24.875]
            longitude: [-0.125..99.875]
Number Of Attributes: 9

====

If you are learning NCL, please spend the time to look at

http://www.ncl.ucar.edu/Document/Manuals/NCL_User_Guide/

This will help you learn the language

On Tue, Mar 14, 2017 at 10:09 AM, Mary Haley <haley at ucar.edu> wrote:

> ​Hi ​
> Yi Lu,
>
> We have a examples page on subsetting data based on lat/lon.  See:
>
> http://www.ncl.ucar.edu/Applications/latlon_subset.shtml
>
> I believe TRMM data is represented by two-dimensional lat/lon arrays, is
> that correct? If so, then the "latlon_subset_2.ncl" example is the one you
> want to look at. The function it uses is getind_latlon2d:
>
> http://www.ncl.ucar.edu/Document/Functions/Contributed/getind_latlon2d.
> shtml
>
> --Mary
>
>
>
> On Tue, Mar 14, 2017 at 8:26 AM, 易路 <dg1225033 at smail.nju.edu.cn> wrote:
>
>> Hi, all
>>      I planned to extract some grid values of TRMM according to a series
>> of specified point locations (defined by their latitudes and longitudes),
>> but I don't know which function I could use, are there any functions in
>> NCL like wrf_user_ll_to_ij() and wrf_user_ij_to_ll() to obtain the grid
>> numbers of TRMM according to the latitude and longitude information?
>>     Thanks very much for your attentions and precious time!
>>
>> Best wishes!
>>
>> Yi Lu
>>
>>
>>
>>
>> 易路
>>
>> 南大邮件系统/学生/博士生/12级博士生
>>
>> 南京市汉口路22号
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170314/4f1a40c5/attachment.html 


More information about the ncl-talk mailing list