[ncl-talk] Reading 3G68 TRMM

Ipsita Putatunda ipsita.putatunda at gmail.com
Sun Aug 16 10:34:19 MDT 2015


Thank you for your help. I got the 2D variable as per your suggestions. But
it is giving one warning message as mentioned below, as the size of x and
PR differs. Is their any way to make it correct. Why is it coming like
that? There are also some grids for the variable where there is no data,
and may be that is why converting PR from string to float is preventing.
How can I convert the data from string to float? Any help will be
appreciated.
My script is attached here with.

Variable: x
Type: string
Total Size: 802264 bytes
            200566 values
Number of Dimensions: 1
Dimensions and sizes:   [200566]
Coordinates:
warning:onedtond : output dimension sizes not even multiples of input,
check output


Variable: PR
Type: string
Total Size: 1036800 bytes
            259200 values
Number of Dimensions: 2
Dimensions and sizes:   [lat | 360] x [lon | 720]
Coordinates:
            lat: [-89.75..89.75]
            lon: [-179.75..89.75]
Number Of Attributes: 2
  long_name :   PR_rain
  units :       mm/hour
(0,0)
(0,1)
(0,2)
(0,3)
(0,4)
(0,5)
(0,6)
(0,7)
(0,8)
(0,9)
(0,10)
(0,11)


Thanks,
Ipsita

On Sun, Aug 16, 2015 at 7:05 PM, Dennis Shea <shea at ucar.edu> wrote:

> Please read:
>   https://www.ncl.ucar.edu/Document/Functions/Built-in/onedtond.shtml
>
> =================
> You must look at your data.  There are different resolutions (0.25,
> 0.50, ..). A 0.5 light have
>
> 3G68 7.1 NONE NONE NASA/JAXA/NICT 2011-08-14T21:16UTC
> 360 720 -90 -180 0.5 20100901
> -40 40 -180 180
> Grid_First_Row=0 Grid_Center_Latitude=-89.75 Grid_First_Column=0
> Grid_Center_Longitude=-179.75 Grid_Cell_Resolution=0.5 Duration=Day
>
> So, in the function below,
>    latStrt  = -89.75
>    latLast = abs(latStrt)
>    lonStrt = -179.75
>    lonLast = abs(latStrt)
>    nlat  = 360
>    mlon = 729
>
> =====
>
>
> undef("3G68_txt2latlon")
> function 3G68_txt2latlon(x[*], nlat[1]:integer, mlon[1]:integer \
>                                        ,latStrt[1]:numeric, latLast[1]
>      \
>
>  ,lonStrt[1]:numeric,lonLast[1]:numeric)
> begin
>     data = onedtooned(x, (/nlat,mlon/) )
>
>     lat     = fspan(latStrt,latLast,nlat)
>     lat!0  = "lat"
>     lat at units = "degrees_north"
>     lon    = fspan(lonStrt,latLast,mlon)
>     lon!0 ="lon"
>     lon at units = "degrees_east"
>
>     data!0 = "lat"
>     data!1 = "lon"
>     data&lat = lat
>     data&lon = lon
>     data at long_name = "..."
>     data at units = "..."
>
>     return(data)
> end
>
>
>
> On Sun, Aug 16, 2015 at 12:15 AM, Ipsita Putatunda
> <ipsita.putatunda at gmail.com> wrote:
> > Dear all,
> >    I need to get a two dimensional variable Var(lat,lon) from TRMM 3G68
> > dataset which is in ascii form. I am able to read the data using
> asciiread,
> > and then by using str_get_field function, but how to convert it into a 2
> > dimensional variable whose coordinate will be lat and lon. Any help in
> this
> > issue will be appreciated.
> >
> > Thanks in advance,
> > Ipsita
> >
> > _______________________________________________
> > 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/20150816/302dc9a6/attachment.html 
-------------- next part --------------
;====================================================================
 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
 ;load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
;====================================================================
 ;begin
  netCDF=True
  fn="3G68.20131201.7.txt"
  x1 = asciiread(fn ,-1 , "string")
  delim=" "
;====================================================================
  x= str_get_field(x1(5:),11,delim)
  printVarSummary(x)
;====================================================================
  latStrt  = -89.75
  latLast = abs(latStrt)
  lonStrt = -179.75
  lonLast = abs(latStrt)
  nlat  = 360
  mlon = 720
;=====================================================
   undef("txt2latlon")
function txt2latlon(x[*], nlat[1]:integer, mlon[1]:integer \
                                       ,latStrt[1]:numeric, latLast[1]         \
                                       ,lonStrt[1]:numeric,lonLast[1]:numeric)
;=====================================================
  local data
  begin
    data = onedtond(x, (/nlat,mlon/) )
    lat     = fspan(latStrt,latLast,nlat)
    lat!0  = "lat"
    lat at units = "degrees_north"
    lon    = fspan(lonStrt,latLast,mlon)
    lon!0 ="lon"
    lon at units = "degrees_east"
    data!0 = "lat"
    data!1 = "lon"
    data&lat = lat
    data&lon = lon
    data at long_name = "PR_rain"
    data at units = "mm/hour"

    return(data)
   end
   begin
    PR=txt2latlon(x, nlat, mlon \
                                       ,latStrt,latLast\
                                       ,lonStrt,lonLast)
    print(PR)
   end
                       


More information about the ncl-talk mailing list