how to take out extreme event annually from the data.
Ältere Kommentare anzeigen
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 Kommentar
Walter Roberson
am 11 Apr. 2014
Bearbeitet: Walter Roberson
am 11 Apr. 2014
Please do not tag individuals. Volunteers respond if and when they feel like responding, and should not be pressured into it.
Akzeptierte Antwort
Weitere Antworten (1)
Matt Tearle
am 11 Apr. 2014
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 Kommentare
Matt Tearle
am 11 Apr. 2014
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
am 11 Apr. 2014
Matt, I've gone ahead and tagged you for this :)
Image Analyst
am 11 Apr. 2014
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.
Kategorien
Mehr zu Logical finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!