;----------- begin ; f = addfile("E-OBS_1961-1990_pr.nc", "r") ; time = f->time ; pr = f->pr(:,:,:) ; time_size=dimsizes(time) f2 = addfile("E-OBS_1961-1990_pr_ys.nc", "r") ; yearly_sum precipitation: cdo yearsum E-OBS_1961-1990_pr.nc E-OBS_1961-1990_pr_ys.nc pr_year_sum = f2->pr(:,:,:) time2 = f2->time dsizes_pr = dimsizes(pr_year_sum) tim_dims = dsizes_pr(0) lon_dims = dsizes_pr(1) ; get the longitude dimension length lat_dims = dsizes_pr(2) ; get the latitude dimension length wks = gsn_open_wks("pdf","test") pr_reshape = reshape(pr_year_sum,(/tim_dims,(lon_dims*lat_dims)/)) ; reshape 3D array to 2D one (time,gridpoints) ; printVarSummary(pr_reshape) pr_aver = dim_avg(pr_reshape) ; average the yearly sum precipitation over the field ; print(pr_aver) pr_sort = dim_pqsort_n(pr_aver,1,0) ;sort the averaged precipitation to find the dry and wet season print(pr_sort) time_sort = new((/tim_dims/),"double") ; create an array for sorted time pr1 = new((/tim_dims/),"float") ; create an array for sorted precipitation values do n=0,tim_dims-1 time_sort(n) = time2(pr_sort(n)) ; gives the sorted time pr1(n) = pr_aver(pr_sort(n)) ; gives the sorted precipitation yearly sum values end do print(time_sort) print(pr1) utc_date = cd_calendar(time_sort,0) ; convert the serial date to calendar date year= tointeger(utc_date(:,0)) ; gives the year values year_dry = tointeger(utc_date(0:((tim_dims/2)-1),0)) year_wet = tointeger(utc_date((tim_dims/2):tim_dims-1,0)) ; print(year_dry) ; print(year_wet) ;--I tried to find the daily precipitation values with the following way but I am afraid of that it is not a correct way: utc_date2 = cd_calendar(time,0) ; time is daily time data year2 = tointeger(utc_date2(:,0)) ; get the years from serial date data do j=0,(tim_dims/2)-1 do n=0,time_size-1 if(year2(n).eq.year_dry(j)) then pr_dry=pr(n,:,:) else pr_wet=pr(n,:,:) end if end do end do ;printVarSummary(pr_dry) end