[ncl-talk] How to correctly read in the merged CMORPH data usig NCL

Dennis Shea shea at ucar.edu
Wed May 3 08:01:41 MDT 2017


Barry makes a good point about the using the "Little Endian" byte-order.
Another issue is the 'type'  ,,, In my opinion, using "double" is likely
not correct. Having precipitation at (say) 12+ digits of precision is
rather silly.

I suggest that you do some very basic 'data exploration'.
For example: Look at min/max
You should do this type of thing on a regular basis.


You have:
setfileoption("bin","ReadByteOrder","LittleEndian")
rain = fbindirread(tim,0,(/nlat,nlon/),"double")
print("min="+min(rain)+"  max="+max(rain))

Try:
setfileoption("bin","ReadByteOrder","BigEndian")
rain = fbindirread(tim,0,(/nlat,nlon/),"float")
print("min="+min(rain)+"  max="+max(rain))


----
https://www.ncl.ucar.edu/Applications/
Under "Datasets", Click "High Res Precipitation"

There are several CMORPH examples.

The source of the files USA NCEP/CPC has documentation (
ftp://ftp.cpc.ncep.noaa.gov/precip/global_CMORPH/README.
cmorph.025deg_3-hourly) that states:

Each file is composed of 16 direct access binary
("big_endian")

Maybe CMA has a different data set. I do not know.

========================
cmorph_1.ncl

demonstrates how to

[1] Read the CMORPH binary files
[2] Create meta data
[3] Plot  on global projection

--
For the China region

[1]
   latS = 15.0
   latN = 58.9
   lonL = 70.0
   lonR = 140.0

Two approaches to plot the China region:

  res at mpMinLatF            = latS     ; range to zoom in on
  res at mpMaxLatF            = latN
  res at mpMinLonF            =  lonL
  res at mpMaxLonF            = lonR

[2]
  plot = gsn_csm_contour_map(wks, rain, res)

[3]

  rain_china= rain({latS:latN},{lonL:lonr})  ; coordinate subscripting

  res at gsnAddCyclic = False
  plot = gsn_csm_contour_map(wks, rain_china, res)

=============================

If you are new to NCL, please read the excellent tutorial created by DKRZ
at:
   https://www.ncl.ucar.edu/Document/Manuals/NCL_User_Guide/


Good Luck

On Tue, May 2, 2017 at 11:59 PM, wen <wenguanhuan at 163.com> wrote:

> Hi Barry,
>  ny = 440,nx=700, which are "nlat" and "nlon" in the script of Yi Lu.
>
>
>
>
> --
> Best regards,
> Guanhuan Wen
>
> At 2017-05-03 13:17:32, "Barry Lynn" <barry.h.lynn at gmail.com> wrote:
>
> Hi Wen:
>
> What are nx,ny?  Are they suppose to be the same values in the data read
> in and the data plotted?
>
> Are you sure about the little_endian definition?
>
> On Wed, May 3, 2017 at 6:16 AM, wen <wenguanhuan at 163.com> wrote:
>
>> Hi. The following script is able to read the data. I hope it work for
>> you.
>>
>>
>>  setfileoption("bin","ReadByteOrder","littleEndian")
>>  mfile = "1.grd"
>>   rec = 0
>>   crain = fbindirread(mfile,rec,(/ny,nx/),"float")
>>   rec = 1
>>   gsamp = fbindirread(mfile,rec,(/ny,nx/),"float")
>>
>>
>>
>> --
>> Best regards,
>> Guanhuan Wen
>>
>> 在 2017-04-30 12:07:44,"易路" <dg1225033 at smail.nju.edu.cn> 写道:
>>
>> Hi all,
>> I downloaed the merged CMORPH data from China Meteorological
>> Administration to get the hourly precipitation imformation, the suffix of
>> the data file is grd which is a standard format of the tool GrADS.
>> According to the associated ctl file of the grd file,  I tried to write the
>> NCL script to read it but can't get the right data, and I couldn't find out
>> the prolbems...
>>
>> So would you please help me to find out the problems ? Thanks very mcuh
>> for your precious time and kindness!
>>
>> Sincerely
>> Yi Lu
>>
>> ;;;;;;;;;;; the part of NCL script to read in the
>> precipitation ;;;;;;;;;;
>> tim = "1.grd"
>> setfileoption("bin","ReadByteOrder","LittleEndian")
>> rain = fbindirread(tim,0,(/nlat,nlon/),"double")
>>
>> nlat = 440
>> nlon = 700
>> r=new((/nlat,nlon/),"double")
>> k=0
>> do i  = 0, nlat-1
>>   do j = 0, nlon-1
>>    r(i,j) = rain(nlat-1-i,j)
>>         k = k+1
>>   end do
>> end do
>>
>> lon = fspan(70.05,139.95,nlon)
>> lon!0 = "lon"
>> lon at units = "degrees_east"
>> lon at long_name = "longitude"
>>
>> lat = fspan(15.05,58.95,nlat)
>> lat!0 = "lat"
>> lat at long_name = "latitude"
>> lat at units = "degrees_north"
>>
>> r!0 = "lat"
>> r!1 = "lon"
>> r&lat = lat
>> r&lon = lon
>> r at units = "mm/hour"
>> r at long_name = "merged CMORPH data "
>> r at _FillValue = -999.00
>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>>
>>
>>
>>
>>
>>
>> 易路
>>
>> 南大邮件系统/学生/博士生/12级博士生
>>
>> 南京市汉口路22号
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>
>
> --
> Barry H. Lynn, Ph.D
> Senior Lecturer,
> The Institute of the Earth Science,
> The Hebrew University of Jerusalem,
> Givat Ram, Jerusalem 91904, Israel
> Tel: 972 547 231 170
> Fax: (972)-25662581
>
> C.E.O, Weather It Is, LTD
> Weather and Climate Focus
> http://weather-it-is.com
> Jerusalem, Israel
> Local: 02 930 9525
> Cell: 054 7 231 170
> Int-IS: x972 2 930 9525
> US 914 432 3108 <(914)%20432-3108>
>
>
>
>
>
> _______________________________________________
> 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/20170503/4b244eee/attachment.html 


More information about the ncl-talk mailing list