% Extracts binary inundated area information from all time steps of loaded
% map files - specifically for unsteady flow events, the model runs
% specified output time steps

clear

% Specify the set of files to look for inundation

% Root folder
folder_root = ['/Users/Colin/Documents/MATLAB/DFlow/abq_models/'...
    'abq2010add2012_histextent/'];

% 250 meter cross-sectional areas for analysis
polygon250m = load(['/Users/Colin/Documents/MATLAB/DFlow/'...
    'attenuation_chap1/abq_valley_250m_polygons_0_25km']);

% Define folder with *map.nc files for inundation analysis
% folder_list = {'run9005_s180p/';'run9006_s300p/';...
%     'run9007_m180p/';'run9008_m300p/';...
%     'run9009_l180p/';'run9010_l300p/'}; % file path
folder_list = {'run7016_1942dailyarea/map_files/'}; % file path

% Define models runs are 32 or 64 partitions
partitions = 32;

[num_runs,~] = size(folder_list);
area_return_cell = cell(num_runs,1);

for i = 1:num_runs
    
    folder_path = strcat(folder_root,folder_list{i,:});
    area_return_cell(i,1) = {map_binary_wet(folder_path,polygon250m,...
        partitions)};
    
end