1 function outs = l2_detect(red)
4 [fire_name,save_name,prefix] = fire_choice()
5 %Longitude = hdfread('/home/jhaley/JPSSdata/MOD03.A2013222.0545.006.2013222112442.hdf', 'MODIS_Swath_Type_GEO', 'Fields', 'Longitude');
6 %Latitude = hdfread('/home/jhaley/JPSSdata/MOD03.A2013222.0545.006.2013222112442.hdf', 'MODIS_Swath_Type_GEO', 'Fields', 'Latitude');
7 %fire_mask = hdfread('/home/jhaley/JPSSdata/MOD14.A2013222.0545.006.2015263221706.hdf', '/fire mask', 'Index', {[1 1],[1 1],[2030 1354]});
9 dhdf=dir([prefix,'*.hdf']);
10 dh5 = dir([prefix,'*.h5']);
11 dnc = dir([prefix,'*.nc']);
12 d=[{dhdf.name},{dh5.name},{dnc.name}];
15 if(isempty(d)), error(['No files found for ',prefix]),end
17 % order the files in time
35 v = readl2data(prefix,file,file2);
36 % select fire detection within the domain
37 lon_bot = v.lon<red.max_lon;
38 lon_top = v.lon>red.min_lon;
39 lat_bot = v.lat<red.max_lat;
40 lat_top = v.lat>red.min_lat;
41 lon_msk = logical(lon_top.*lon_bot);
42 lat_msk = logical(lat_top.*lat_bot);
43 msk = logical(lat_msk.*lon_msk);
44 xj=find(v.lon > red.min_lon & v.lon < red.max_lon);
45 xi=find(v.lat > red.min_lat & v.lat < red.max_lat);
46 idx = (intersect(xi,xj));
47 ax=[red.min_lon red.max_lon red.min_lat red.max_lat];
48 if isempty(xi) | isempty(xj)
49 fprintf('outside of the domain\n');
59 fires = [fires; v.lon(dets) v.lat(dets)];
60 %fires = [fires; v.lons(dets) v.lats(dets)];
62 gran_count = gran_count + 1;
67 fires = fires(2:end,:);
68 fprintf('%d fires in %d granules \n',length(fires), length(d))
69 figure,scatter(fires(:,1),fires(:,2))