[ncl-talk] Reading 3G68 TRMM

Dennis Shea shea at ucar.edu
Mon Aug 17 16:59:00 MDT 2015


Did you read the following:
      ftp://trmmopen.gsfc.nasa.gov/pub/README.3G68

===
This is  more that taking a one-dimensional grid and reshaping it.
This is a "Universal Grid". The file contains the grid locations to
which the values are assigned.
Any grid point not explicitly indicated is set to _FillValue

You should study the README file

Further, you must convert from string to integer or float prior to use.




On Sun, Aug 16, 2015 at 10:34 AM, Ipsita Putatunda
<ipsita.putatunda at gmail.com> wrote:
> 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 --------------
;; ftp://trmmopen.gsfc.nasa.gov/pub/README.3G68
;====================================================================
; UNIVERSAL GRID
;====================================================================
;;3G68 7.1 NONE NONE NASA/JAXA/NICT 2013-12-03T18:33UTC
;;360 720 -90 -180 0.5 20131201
;;-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
;;hour minute row column TMI_total_pixels TMI_rain_pixels TMI_mean_mm/hr TMI_%convective PR_total_pixels PR_rain_pixels PR_mean_mm/hr PR_%convective TCI_total_pixels TCI_rain_pixels TCI_mean_mm/hr TCI_%convective
;;0 36 101 32 2 0 0 0 0
;;0 36 101 33 5 0 0 0 0
;;
;;1  2   3  4 5 6 7 8  9    <= field number

begin
  delim =" "
  fn  ="3G68.20131201.7.txt"
  x1  = asciiread(fn ,-1 , "string")
  row = toint( str_get_field(x1(5:), 2,delim) )   ; 0-based
  col = toint( str_get_field(x1(5:), 3,delim) ) ; 0-based
  x   = tofloat( str_get_field(x1(5:), 7,delim) )
  printVarSummary(x)
  printMinMax(x,1)
  nx  = dimsizes(x)
;====================================================================

  nlat  = 360
  mlon  = 720
  PR    = new( (/nlat,mlon/), float, 1e20)

  do n=0,nx-1
     PR(row(n),col(n)) = x(n)
  end do

  latStrt  = -89.75
  latLast = abs(latStrt)
  lonStrt = -179.75
  lonLast = abs(latStrt)

  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"
  PR!0 = "lat"
  PR!1 = "lon"
  PR&lat = lat
  PR&lon = lon
  PR at long_name = "TMI_mean"
  PR at units = "mm/hour"

    print(PR)
 end
                       


More information about the ncl-talk mailing list