function main_ecuador ()
%--------------------------------
% The main function to read
% the ecuador data from May 2010 
% and make plots
% gupchup@gmail.com
%--------------------------------

% set the environment
constants;

% get all the csv files in the directory
% given by data_dir
infile = dir(strcat(data_dir,'*.csv'));

% for each group
% plot the CO2 data
plot_var = struct('hdl',[]);
for f=1:length(group),
    for c=1:length(group(f).co2)
        co2_fname = char(strcat(data_dir, group(f).co2(c),'.csv'));
        
        % read input file
        [co2.dt co2.ch1 co2.ch2 co2.ch3 co2.ch4 co2.ch5 co2.ch6 co2.ch7 co2.ch8 co2.ch9 co2.ch10] = ...
            textread(co2_fname,fmt,'delimiter',',');
        
        % plot the co2 part and store the handles to 
        % subplot temperature and moisture
        plot_var(f).hdl(c) = plot_co2_data (co2, group(f).co2(c));
    end
end

% for each group
% plot the soil temp and soil moist
for f=1:length(group),
   for c=1:length(group(f).co2),
      % read the soil temp and moisture data
      stm1_fname = char(strcat(data_dir, group(f).moistemp(1),'.csv'));
      stm2_fname = char(strcat(data_dir, group(f).moistemp(2),'.csv'));
      
      [st1.dt st1.ch1 st1.ch2 st1.ch3 st1.ch4 st1.ch5 st1.ch6 st1.ch7 st1.ch8 st1.ch9 st1.ch10] = ...
            textread(stm1_fname,fmt,'delimiter',',');
      [st2.dt st2.ch1 st2.ch2 st2.ch3 st2.ch4 st2.ch5 st2.ch6 st2.ch7 st2.ch8 st2.ch9 st2.ch10] = ...
            textread(stm2_fname,fmt,'delimiter',',');
   
      % plot the temperature and moisture  
      plot_moistemp_data (plot_var(f).hdl(c), st1, st2);  
        
      % save figure
      figname = strcat(fig_save_loc, group(f).co2(c),fig_ext);
      save_figure(plot_var(f).hdl(c), char(figname), fig_fmt, [fig_width fig_height],'points'); 
   end
end

end

