how to take out extreme event annually from the data.
이전 댓글 표시
sir i have program who calculate extreme event for whole 95 years but i want to calculate extreme event annually (it mean 365 then 365 ....each separate years) then what will be change in this program for doing this? my data size is (prec_all_years) 20x22x34675(lon,lat,time).this is daily data.
prec_all_years = prec_all_years*86400; % rainfall in mm/day
xx = []
for ii= 1:95;
for i = 1:length(X1);
for j = 1:length(Y1);
xx = [xx (i-1)*[1:365]];
prec1 = prec_all_years(i,j,xx);
inds1 = find(prec1 >=64.5 & prec1 <= 124.5); inds2 = find(prec1 > 124.5 & prec1 <=244.5); inds3 = find(prec1 > 244.5);
hr(i,j) = length(inds1); vhr(i,j)= length(inds2); ehr(i,j)= length(inds3);
end end end % now find frequency of rainfall in different regions
% western region
xe = [13:20]; ye = [11:16]; xw = [1:8]; yw = [11:16]; xn = [5:9]; yn = [15:20]; xs = [5:9]; ys = [3:7];
% eastern region
freq_east_hr = hr(xe,ye);
count_hr_east = sum(freq_east_hr(:))
freq_east_vhr = vhr(xe,ye);
count_vhr_east = sum(freq_east_vhr(:))
freq_east_ehr = ehr(xe,ye);
count_ehr_east = sum(freq_east_ehr(:))
댓글 수: 1
Walter Roberson
2014년 4월 11일
편집: Walter Roberson
2014년 4월 11일
Please do not tag individuals. Volunteers respond if and when they feel like responding, and should not be pressured into it.
채택된 답변
추가 답변 (1개)
Matt Tearle
2014년 4월 11일
The reshape function is going to be your friend here. I think I've interpreted your intention correctly, in which case, your code can be simplified to:
% Change to lon/lat/day/year
prec_all_years = reshape(prec_all_years,20,22,365,95);
prec_all_years = prec_all_years*86400; % rainfall in mm/day
bins = [64.5 124.5 244.5 Inf];
% Extract a region
xe = 13:20; ye = 11:16;% xe is x for east,ye is y for east
% Reshape into matrix of observations-by-year and bin into ranges
counts = histc(reshape(prec_all_years(xe,ye,:,:),[],95),bins);
% Extract counts for each category
count_hr_east = counts(1,:);
count_vhr_east = counts(2,:);
count_ehr_east = counts(3,:);
The result is three vectors, one for each category, each with 95 elements (one per year). Repeat for the different regions.
댓글 수: 4
Matt Tearle
2014년 4월 11일
The code you posted didn't show any use for hr, vhr, and ehr beyond using them to calculate count_X_east. That's why I went straight to calculating count_hr_east without saving the counts for each lat/lon individually. But if you really need those... see my new answer.
Sean de Wolski
2014년 4월 11일
Matt, I've gone ahead and tagged you for this :)
Image Analyst
2014년 4월 11일
Hey can I get in on the party? I commented to him here and I didn't win fame, admiration, and glory there, so I'm taking another shot at it here.
카테고리
도움말 센터 및 File Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!