1 function g = load_subset_detections(prefix,p,red,time_bounds,fig)
4 itime=find(p.time>=time_bounds(1) & p.time<=time_bounds(2));
5 d=p.file(itime); % files within the specified time
7 fprintf('Selected %i files in the given time bounds, from %i total.\n',...
8 length(d),length(p.time))
14 fprintf('%s file %s \n',stime(t(i),red),file);
15 %v=readmod14(prefix,file,'silent'); original line
17 v=readmod14(prefix,file);
19 %[v.lon,v.lat] = meshgrid(v.lon,v.lat);
21 % reading l2 data instead of tifs
23 % take only as matched pairs
27 fprintf('send to readl2data , i = %d \n',i)
28 v = readl2data(prefix,file,file2);
29 % loop over unclassified data to filter
30 % this will turn matrices to vectors
32 for uu = 1:length(unclass)
33 mask = v.data(:) ~= unclass(uu);
34 v.data = v.data(mask);
37 %check for filter fail
38 fail = sum(v.data(:)==unclass(uu));
40 fprintf('Data corruption in %, class %d',file,unclass(uu));
45 % select fire detection within the domain
46 xj=find(v.lon > red.min_lon & v.lon < red.max_lon);
47 xi=find(v.lat > red.min_lat & v.lat < red.max_lat);
48 idx = intersect(xi,xj);
49 ax=[red.min_lon red.max_lon red.min_lat red.max_lat];
50 if isempty(xi) | isempty(xj)
51 fprintf('outside of the domain\n');
55 x.data=v.data(xi,xj); % subset data
59 x.det(1)=sum(x.data(:)==3); % water
60 x.det(2)=sum(x.data(:)==5); % land
61 x.det(3)=sum((x.data(:)==7)); % low confidence fire
62 x.det(4)=sum((x.data(:)==8)); % medium confidence fire
63 x.det(5)=sum((x.data(:)==9)); % high confidence fire
65 fprintf(' no data in the domain\n')
75 fprintf('water %i land %i fire low %i med %i high %i\n',x.det)
76 x.axis=[red.min_lon,red.max_lon,red.min_lat,red.max_lat];
86 %interpolate to fire mesh, projection????
88 [x.xlon,x.xlat]=meshgrid(x.lon,x.lat);
89 %use scatter interpolation instead, seems to make no
90 %difference but need to check
91 x.fxdata=griddata(double(x.xlon(:)),double(x.xlat(:)),double(x.data(:)),red.fxlong,red.fxlat,'nearest');
92 %x.fxdata=interp2(v.lon,v.lat,v.data,red.fxlong,red.fxlat,'nearest');
94 %this next line breaks the plotting of detections
95 %downstream in fire_pixels3d.m
98 u_space = red.min_lat:du:red.max_lat;
99 v_space = red.min_lon:dv:red.max_lon;
100 [x.xlon,x.xlat]=meshgrid(v_space,u_space);
101 %[x.xlon,x.xlat]=meshgrid(x.lon,x.lat);
102 data = griddata(double(x.lon(:)),double(x.lat(:)),double(x.data(:)),x.xlon,x.xlat,'nearest');
103 x.fxdata=griddata(double(x.lon(:)),double(x.lat(:)),double(x.data(:)),red.fxlong,red.fxlat,'nearest');
108 if fig.fig_interp, % map interpolated data to reduced domain
109 figure(fig.fig_interp)
111 c=reshape(cmap(x.fxdata+1,:),[size(x.fxdata),3]);
112 surf(red.fxlong,red.fxlat,zeros(size(red.fxlat)),c,'EdgeAlpha',0.2);
113 title(['Detection interpolated to fire mesh ',stime(x.time,red)])
115 g(k)=x; % store the data structure
117 figure(fig.fig_map);clf
120 contour(red.fxlong,red.fxlat,red.tign,[v.time v.time],'-k');
121 %fprintf('image time %s\n',datestr(x.time));
123 if x.time >= ss.min_time && x.time <= ss.max_time,
124 step=interp1(ss.time,ss.num,x.time);
134 uu=w0*ss.uh(:,:,step0)+w1*ss.uh(:,:,step1);
135 vv=w0*ss.vh(:,:,step0)+w1*ss.vh(:,:,step1);
136 fprintf('wind interpolated to %s from\n',datestr(x.time))
137 fprintf('step %i %s weight %8.3f\n',step0,datestr(ss.time(step0)),w0)
138 fprintf('step %i %s weight %8.3f\n',step1,datestr(ss.time(step1)),w1)
139 fprintf('wind interpolated to %s from\n',datestr(x.time))
140 sc=0.006;quiver(w.xlong,w.xlat,sc*uu,sc*vv,0);
146 % M(k)=getframe(gcf);
147 % print(fig.fig_map,'-dpng',['fig',v.timestr]);
150 hold on; fire_pixels_3d(fig.fig_3d,x,red.base_time)
155 if ~exist('g','var'),
156 fprintf('No files found.')
159 fprintf('%i detections selected\n',length(g))