1 function p=sort_rsac_files(prefix)
2 % d=sort_rsac_files(file_search)
3 % example;: log_likelihood('TIFs/','w.mat')
6 % file_search directory search string
7 % d cell array of file names ordered by time
9 % insert query to use tifs of Level2 data here
10 use_tifs = 0;%input_num('Use TIF files? No = 0',0,1);
11 %obsolete, using only l2 data now
13 d=dir([prefix,'*.tif.mat']);d={d.name};
14 if(isempty(d)), error(['No files found for ',prefix]),end
16 % order the files in time
28 dhdf=dir([prefix,'*.hdf']);
29 dh5 = dir([prefix,'*.h5']);
30 dnc = dir([prefix,'*.nc']);
31 d=[{dhdf.name},{dh5.name},{dnc.name}];
32 if(isempty(d)), error(['No files found for ',prefix]),end
34 % order the files in time
45 %check to make sure geolocation and data files are both present!
47 fprintf('Mismatch, number of files is not an even number \n')
49 %check that pairs are there delete unpaired granule form list
50 match_mask = true(1,nfiles);
53 if p.time(j) == p.time(j+1)
54 fprintf('time match %s\n',p.file{j})
55 fprintf('time match %s\n',p.file{j+1})
56 fprintf('Pair %d, %d \n\n',j,j+1)
59 fprintf('***\n time mismatch %s\n***\n',p.file{j})
60 match_mask(j) = false;
64 %check for match in last file
65 if p.time(nfiles) ~= p.time(nfiles-1)
66 fprintf('***\n time mismatch %s\n***\n',p.file{nfiles})
67 match_mask(nfiles) = false;
69 %remove unpaired granules
70 p.file = p.file(match_mask);
71 p.time = p.time(match_mask);