1 function g = subset_l2_detections(prefix,p,red,time_bounds,fig)
2 %same input as load_subset_detections
3 %reads only active fire pixels, non-detections, water,,etc. are ignored
5 itime=find(p.time>=time_bounds(1) & p.time<=time_bounds(2));
6 d=p.file(itime); % files within the specified time
8 fprintf('Selected %i files in the given time bounds, from %i total.\n',...
9 length(d),length(p.time))
15 %only read fire product files
16 if strcmp(file(4:5),'14')
17 file_str = [prefix,file];
19 %fprintf('reading fire product \n')
20 if strcmp(file(1),'M')
22 fprintf('Reading MODIS FRP data \n')
24 v.power = hdfread(file_str,'/FP_power');
25 v.lon = hdfread(file_str,'/FP_longitude');
26 v.lat = hdfread(file_str,'/FP_latitude');
27 v.conf = hdfread(file_str,'/FP_confidence');
28 v.mask = hdfread(file_str,'/fire mask');
30 warning('Read error somewhere')
33 fprintf('Reading VIIRS FRP data \n')
34 %%fake for the time being
37 v.power = h5read(file_str,'/FP_power')';
38 v.lon = h5read(file_str,'/FP_longitude')';
39 v.lat = h5read(file_str,'/FP_latitude')';
40 v.conf = h5read(file_str,'/FP_confidence')';
41 v.mask = h5read(file_str,'/fire mask');
43 warning('read error somewhere')
47 xj=find(v.lon > red.min_lon & v.lon < red.max_lon);
48 xi=find(v.lat > red.min_lat & v.lat < red.max_lat);
49 idx = intersect(xi,xj);
50 ax=[red.min_lon red.max_lon red.min_lat red.max_lat];
51 if isempty(xi) | isempty(xj)
52 fprintf('outside of the domain\n');
54 fprintf('inside domain %d \n',gc)
58 v.power = v.power(idx);
62 v.axis=[red.min_lon,red.max_lon,red.min_lat,red.max_lat];
65 v.fxdata = [];% v.mask(xj,xi);
66 %also fake for time being
67 v.data = 9*ones(size(v.conf));
68 %% put variables into granule struct
77 fprintf('Detections loaded. %d granules had data inside domain \n',gc);