Re: more with area_hi2lores: trouble with output

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Mon, 15 Jun 2009 08:50:38 -0600

I inadvertently did not respond to ncl-talk

> On Sat, 13 Jun 2009, Dennis Shea wrote:
>
>> Your LAT and LON on your netCDF are wrong.
>>
>> Please do a
>>
>> %> ncdump -v LAT,LON,time Test_20060901_CMORPH_3hr-050deg.nc | less
>>
>> [snip]
>> time = 2006090100, 2006090103, 2006090106, 2006090109, 2006090112,
>> 2006090115, 2006090118, 2006090121 ;
>>
>> LAT = -179.625, -179.125, -178.625, -178.125, -177.625, -177.125,
>> -176.625,
>> -176.125, -175.625, -175.125, -174.625, -174.125, -173.625, -173.125,
>> -172.625, -172.125, -171.625, -171.125, -170.625, -170.125, -169.625,
>> [snip]
>>
>>
>> LON = 0.125, 0.625, 1.125, 1.625, 2.125, 2.625, 3.125, 3.625, 4.125,
>> 4.625,
>> 5.125, 5.625, 6.125, 6.625, 7.125, 7.625, 8.125, 8.625, 9.125, 9.625,
>> [snip]
>> 352.125, 352.625, 353.125, 353.625, 354.125, 354.625, 355.125,
>> 355.625,
>> 356.125, 356.625, 357.125, 357.625, 358.125, 358.625, 359.125,
>> 359.625,
>> 0.125, 0.625, 1.125, 1.625, 2.125, 2.625, 3.125, 3.625, 4.125, 4.625,
>> 5.125, 5.625, 6.125, 6.625, 7.125, 7.625, 8.125, 8.625, 9.125, 9.625,
>> [snip]
>> ============================================================
>> The nlat and mlon you are using here are the *0.25* values
>> LAT = 59.875 - ispan(0,nlat-1,1)*0.50
>> LON = 0.125 + ispan(0,mlon-1,1)*0.50
>>
>> Change to
>> NLAT = nlat/2
>> MLON = mlon/2
>> LAT = 59.875 - ispan(0,NLAT-1,1)*0.50
>> LON = 0.125 + ispan(0,MLON-1,1)*0.50
>>
>>
>> B N wrote:
>>> Dr. Shea:
>>> Thank you. I am trying to input a Cmorph binary file and output a
>>> regridded netcdf file.
>>> Both files are in the incoming directory at ftp.cgd.ucar.edu.
>>> The cmorph binary file is 20060901_CMORPH_3hr-025deg
>>> The output version of this file is Test_20060901_CMORPH_3hr-050deg.nc
>>> Please let me know if you cannot find them. (I could not see the
>>> contents of the incoming directory so I assume it is protected.)
>>>
>>> My question is: am I making the output incorrectly (i.e. the cmorph
>>> page says that the arrays of data go from 0.125E eastward and from
>>> 59.875N southward at .25 grid increments)?
>>> Sincerely,
>>> -Bold
>>> On Fri, Jun 12, 2009 at 6:12 PM, Dennis Shea<shea_at_ucar.edu> wrote:
>>>> This is offline.
>>>>
>>>> If you send me (say) two files, I will look at this.
>>>>
>>>> ftp ftp.cgd.ucar.edu
>>>> anonymous
>>>> Use your email address for the password
>>>> cd incoming
>>>> put ...
>>>> put ...
>>>> quit
>>>>
>>>> Send an email with the following information:
>>>>
>>>> * The names of the files after you have successfully completed the
>>>> transfer.
>>>> I cannot look at the ftp/incoming directory for security reasons.
>>>> * The version of NCL you are running (ncl -V).
>>>> * The type of system you are on (uname -a).
>>>>
>>>>
>>>> B N wrote:
>>>>> Hi. Thank for all of the earlier help to help this newbie. 100
>>>>> thank you's
>>>>> :-)
>>>>>
>>>>> I am now using the area_hi2lores to regrid precipitation data (CMORPH)
>>>>> from a hi resolution grid to a lo resolution grid.
>>>>> Although I'm not getting an immediate error with my script, I am
>>>>> getting bad output. I use the script below to extract the global
>>>>> cmorph data from its original binary format, create meta data, then I
>>>>> try to use the area_hi2lores function. (po = area_hi2lores_Wrap
>>>>> (CMORPH_rate&lon,CMORPH_rate&lat, CMORPH_rate , True, 1, LON, LAT,
>>>>> False) in the script).
>>>>>
>>>>> When I look at my results only cover half of the world. Its supposed
>>>>> to be global.
>>>>> Picture is attached to show my result. My terminal log is attached
>>>>> too.
>>>>>
>>>>> Could I have a few suggestions on how to fix this?
>>>>> Sincerely,
>>>>> BOLD
>>>>>
>>>>> ; NCL script that reads in multiple NOAA CMORH precipitation where
>>>>> each file contains
>>>>> ; 16 direct access binary ("big_endian") records, which are 2
>>>>> variables at 3-hourly
>>>>> ; intervals for 1 day (8 pairs)
>>>>> ; MAKE SURE ONLY CMORPH FILES YOU WANT TO PROCESS ARE PRESENT IN
>>>>> DIRECTORY
>>>>> ;************************************************
>>>>> 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"
>>>>> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
>>>>> ;************************************************
>>>>> DATADir = "./" ; path to your data must have trailing "/"
>>>>> InFILE = "*_3hr-025deg_cpc+comb"
>>>>> FILES = systemfunc("ls " + DATADir + InFILE ) ; root of data file
>>>>> numFILES = dimsizes(FILES)
>>>>> ;=============================
>>>>> ; create lat and long coordinate variables from CMORPH
>>>>> documentation
>>>>> ;============================
>>>>> nlat = 480
>>>>> mlon = 1440
>>>>> lat = 59.875 - ispan(0,nlat-1,1)*0.25
>>>>> lon = 0.125 + ispan(0,mlon-1,1)*0.25
>>>>> lat!0 = "lat"
>>>>> lat&lat = lat
>>>>> lat_at_units = "degrees_north"
>>>>> lon!0 = "lon"
>>>>> lon&lon = lon
>>>>> lon_at_units = "degrees_east"
>>>>>
>>>>> count = 0
>>>>> do ifil = 0, numFILES-1 ; BIG FILES LOOP ; NEW file loop
>>>>> ;===================
>>>>> ; create time variable
>>>>> ;===================
>>>>> year = 2006 ; start year or make part of the loop
>>>>> month = 09 ; start month or make part of loop
>>>>> day = ifil+1
>>>>> ;print(day)
>>>>> yyyymmdd = year*10000 + month*100 + day
>>>>> ntime = 8
>>>>> time = yyyymmdd*100 + ispan(0,21,3)
>>>>> time!0 = "time"
>>>>> time_at_units = "yyyymmddhh"
>>>>> time&time = time
>>>>> ;print(time)
>>>>> ;=======================================
>>>>> ;Create Array of Variables in binary data
>>>>> ;=======================================
>>>>> ntimes = 8 ; 3hourly data in 1 day equals eight intervals
>>>>> CMORPH_rate = new ( (/ntime,nlat,mlon/), "float")
>>>>> comb_MW_global = CMORPH_rate
>>>>> ;========================================
>>>>> ;Read in Binary
>>>>> ;========================================
>>>>> fName = FILES(ifil)
>>>>> setfileoption ("bin", "ReadByteOrder", "BigEndian")
>>>>> ntim = 1
>>>>> do i = 0, 14,2 ; CMORPH binary file contains 16
>>>>> records.
>>>>> NCL
>>>>> starts at counting at 0
>>>>> print ("====== Binary Record= "+(i+1) +"/ NCL Record Counter
>>>>> "+(i)+" ======")
>>>>> comb_MW_global(i/2,:,:) =
>>>>> fbindirread(fName,i,(/ntim,nlat,mlon/),"float")
>>>>> print ("====== Binary Record= "+(i+2) +"/ NCL Record Counter
>>>>> "+(i+1)+" ======")
>>>>> CMORPH_rate(i/2,:,:) = fbindirread(fName,
>>>>> i+1,(/ntim,nlat,mlon/),"float")
>>>>> end do
>>>>> ;=============================
>>>>> ; name dimensions of variables
>>>>> ;============================
>>>>> comb_MW_global!0 = "time"
>>>>> comb_MW_global!1 = "lat"
>>>>> comb_MW_global!2 = "lon"
>>>>> comb_MW_global&time = time
>>>>> comb_MW_global&lat = lat
>>>>> comb_MW_global&lon = lon
>>>>> comb_MW_global_at_long_name = "merged microwave precipitation"
>>>>> comb_MW_global_at_units = "mm/hr"
>>>>> comb_MW_global@_FillValue = -9999
>>>>> printVarSummary(comb_MW_global)
>>>>>
>>>>> CMORPH_rate!0 = "time"
>>>>> CMORPH_rate!1 = "lat"
>>>>> CMORPH_rate!2 = "lon"
>>>>> CMORPH_rate&time = time
>>>>> CMORPH_rate&lat = lat
>>>>> CMORPH_rate&lon = lon
>>>>> CMORPH_rate_at_long_name = "CMORPH"
>>>>> CMORPH_rate_at_units = "mm/hr"
>>>>> CMORPH_rate@_FillValue =-9999
>>>>>
>>>>> ;;;;;;;;;;;;;;;;;;;;;USE NCL's lonflip command to flip the longitudes
>>>>> to go from -180 to 180 instead of 0 to 360
>>>>> CMORPH_rate = lonFlip(CMORPH_rate)
>>>>> printVarSummary(CMORPH_rate)
>>>>> ;==============================
>>>>> ;;;;;;;;;;;;;;USE NCL's area_hi2lores function for precipitation
>>>>> ;;;;;;;;;;;;;; I want to regrid from default .25x.25 grid to
>>>>> 0.5x0.5 grid
>>>>>
>>>>> LAT = 59.875 - ispan(0,nlat-1,1)*0.50
>>>>> LON = 0.125 + ispan(0,mlon-1,1)*0.50
>>>>> po = area_hi2lores_Wrap (CMORPH_rate&lon,CMORPH_rate&lat, CMORPH_rate
>>>>> , True, 1, LON, LAT, False)
>>>>>
>>>>> ;;;;DO I need to use lonFlip again?????
>>>>> po = po(:,::-1,:)
>>>>> po = lonFlip(po)
>>>>> printVarSummary(po)
>>>>> printMinMax(po,True)
>>>>> ;======================
>>>>> ; Create NetCDF Ouput File of day
>>>>> ;======================
>>>>> ncout ="Test_"+yyyymmdd+"_CMORPH_3hr-050deg.nc"
>>>>> system("/bin/rm -f "+ncout)
>>>>> a = addfile(ncout,"c") ; write netCDF file
>>>>> a_at_title = " CMORPH and Combined MW Precipitation 3-hourly data"
>>>>> a_at_source =
>>>>> "ftp://ftp.cpc.ncep.noaa.gov/precip/global_CMORPH/3-hourly_025deg"
>>>>> filedimdef(a,"time",-1,True) ; make time an UNLIMITED
>>>>> dimension, always recommended
>>>>> ;=============================
>>>>> ;Place Contents into NetCDF file
>>>>> ;=============================
>>>>> a->CMORPH_RATE = po;
>>>>> end do
>>>>>
>>>>>
>>>>> ------------------------------------------------------------------------
>>>>>
>>>>>
>>>>>
>>>>> ------------------------------------------------------------------------
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> ncl-talk mailing list
>>>>> List instructions, subscriber options, unsubscribe:
>>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Jun 15 2009 - 08:50:38 MDT

This archive was generated by hypermail 2.2.0 : Mon Jun 15 2009 - 08:53:05 MDT