[ncl-talk] Daily to weekly Rainfall data conversion

Ipshita Majhi ipmajhi at alaska.edu
Sat Jan 23 17:06:49 MST 2016


Hi

Here is the input file. I will follow the advice you gave, thanks so much
for the help. I will update once I am able to able to make it work

On Sat, Jan 23, 2016 at 2:30 PM, Adv <advita6 at gmail.com> wrote:

> Hi ,
> Can you please attach a input file? Is that three dimensional array. If so
>
> a(time:,lat:,lon:)
> a(0:end:7,:,:) This would give you a weekly data from daily and then
> calculate average to get a weekly average.
>
> Cheers..
>
>
> On Sat, Jan 23, 2016 at 5:01 PM, Ipshita Majhi <ipmajhi at alaska.edu> wrote:
>
>> Dear NCL,
>>
>> I have written a code to convert daily to weekly data and it does not
>> match the data set I have, the code I have written works. I was wondering
>> where I went wrong. If you could guide me on that it would be very helpful.
>>
>> Here is the code
>> ***********************************************************************
>> ;This is to convert daily to weekly for precipitation data
>>
>> ;*******************************************
>> 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"
>> ;*******************************************
>>
>> a= addfile("~/Documents/Snow_cover_IMS/NCL_codes/precp_daily_krishna.nc
>> ","r")
>> precp=a->p
>> t=a->time
>>
>>
>> time_cd=cd_calendar(t,0)
>>
>> ;Since we are reading data from 1967-2013, we have 46 years
>> year_52=ispan(1901,2010,1)
>>
>>
>> ;Writing a loop to process the xday information
>>
>> xday=new((/110,365/),"float")
>> time_year=time_cd(:,0)
>>
>> do i=0,109
>>
>> matching=ind(year_52(i).eq.time_year)
>>
>>
>>
>> day_size=(dimsizes(matching))
>>
>> if (day_size.gt.365) then
>>
>> d=matching(1:365)
>>
>> else
>> d=matching
>> end if
>> precp_daily=precp(d)
>> xday(i,:)= precp_daily
>>
>> delete(matching)
>> delete(precp_daily)
>>
>> end do
>> print(xday)
>>
>>
>> ; Now converting daily to weekly
>>
>> ;Now we want to convert the 365 days to weekly for each year
>>
>> ;Now just doing it for one year and checking the result
>>
>> ;pweek=new((/110,52/),"float")
>> x364=xday(:,0:363); This is to get 52 weeks
>> ;print(x364)
>>
>> printVarSummary(x364)
>> pweek=new((/110,52/),"float")
>>
>>
>> do i=0,109
>> do j=0,357,7
>> pweek(i,j/7)=avg(x364(i,j:j+6))
>> if(any(ismissing(pweek))) then
>> pweek at _FillValue =-9999.0  ; sets _FillValue to -9999.0
>>   end if
>> end do
>> end do
>>
>>
>> pweek = where(pweek.gt. 1e25, pweek at _FillValue, pweek)
>>
>> printMinMax(pweek, 0)
>>
>> opt = True
>> opt at fout = "weekly_mean_AIR_precp.txt"
>> write_matrix(pweek, "52f9.1", opt)
>>
>>
>> ******************************************************************************
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>


-- 
Ipshita Majhi
PhD Candidate
University of Alaska , Fairbanks
Atmospheric Science Department
(907)978-4220 ipmajhi at alaska.edu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160123/25f5a7d6/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: precp_daily_monthly_krishna.nc
Type: application/x-netcdf
Size: 16452 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160123/25f5a7d6/attachment.nc 


More information about the ncl-talk mailing list