FpOutput: Main_FLEXPART_Processing - Sample.m

File Main_FLEXPART_Processing - Sample.m, 2.4 KB (added by sureshraja1, 3 years ago)

Main File

Line 
1
2[header,y]=flex_header('C:\Users\Output\',0,0,0); %Change File Location%
3
4[a,b,c,d]=flex_read_V7(header,1,1,1,1,0);
5
6[ar,vo]=calculate_grid_area_eff(header);
7 
8[name,loc,conc]=flex_read_recepconc(header,1,6);
9
10[xgrid,ygrid,zgrid,xdum,ydum,zdum,numT]=size(a);
11
12sample_avg=header.loutaver/60;  %average time in minutes%
13
14%need 1 hour averages%
15num1hr=numT*sample_avg/60; %number of 1hour average samples%
16
17[dum,latgrid]=size(header.latp);
18[dum,longrid]=size(header.latp);
19avg1hr=repmat(0,[latgrid,longrid]);
20hr_cnt=0;
21num_dig=4; %number of digits the average 1hour matrix will be rounded to%
22
23
24for i=1:num1hr
25    for j=1:round(60/sample_avg);
26       avg1hr=avg1hr+a(:,:,1,1,1,1,j+hr_cnt);
27    end
28   
29    avg1hr=((avg1hr*((0.001*24.5)/(64.1*1000)))/(round(60/sample_avg))); %convert nearest integer in ppm%
30    avg1hr = round(avg1hr*(10^num_dig))/(10^num_dig); %rounding to four digits only%
31   
32    %max_element=max(max(avg1hr));
33    %copyt=avg1hr;
34    %copyt(copyt==0)=Inf;
35    %min_element=min(min(copyt));
36    %v=linspace(min_element,max_element,15);
37    %which_elem=[];
38   
39    %for ielem=1:2:size(v,2)-1;
40    %    cnt_elem(ielem)=numel(avg1hr(avg1hr(:)>v(ielem) & avg1hr(:)<v(ielem+1)));
41    %    if cnt_elem(ielem)< 2;
42    %       which_elem=[which_elem;ielem];
43    %       which_elem=[which_elem;ielem+1];
44    %    end
45    %end
46   
47    %which_elem=[which_elem;(max(which_elem)+1)];
48         
49    %if max(which_elem) == size(linspace(min_element,max_element,10),2)-1;
50    %   which_elem=[which_elem;max(which_elem)+1];
51    %end
52   
53    %v(:,which_elem)=[];
54   
55    %[val,index]=max(cnt_elem);
56   
57    %v=linspace(min_element,v(index+1),10);
58   
59    %run_kml=1;
60    %if max(cnt_elem)==5;
61    %   run_kml=0;
62    %end
63   
64    %if max_element>0 & run_kml==1
65     try
66       filenam=sprintf('my_kml_%i',i)
67       k=kml(filenam);
68       [xm,ym]=meshgrid(header.latp,header.lonp);
69       [min_element,max_element,v]=get_ContourRange(avg1hr)
70       my_levels=v
71       %my_levels=[0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.5 2 3 4 5]
72       k.contour(ym,xm,avg1hr,'numberOfLevels',my_levels);
73       k.save(filenam);     
74       avg1hr=repmat(0,[latgrid,longrid]);
75     catch exception
76       %[min_element, max_element,v]=get_ContourRangeAgain(v,avg1hr)
77       disp(sprintf('zero concentrations detected in the %ith 1-hour sample', hr_cnt));
78    end
79    hr_cnt=hr_cnt+1;
80end
hosted by ZAMG