function inmet=load_inmet(year)
% function inmet=load_inmet(year)
%
% Load processed montly inmet data files 

% Data fields:
dfds = {'T','Tmax','Tmin','H','Hmax','Hmin','D','Dmax','Dmin','P','Pmax','Pmin','Wspd','Wdir','Wmax','Rad','Prec'};
unit = {'°C','°C','°C','%','%','%','°C','°C','°C','mbar','mbar','mbar','m/s','m/s','m/s','KJ/m²','mm'};

ik=0;
data = struct();
for mm=1:12
  fn=['/gea/data/towers/inmet-belem/belem_' num2str(year) '_' num2str(mm,'%02d') '.csv'];
  tmp=importdata(fn);

  % make mdate and convert to local time 
  [ty, tm, td, ~,~,~]=datevec(tmp.textdata(2:end,2),'dd/mm/yyyy'); 
  mdates=datenum(ty,tm,td,tmp.data(1:end,1)-3,0,0);

  ik=ik+1;
  data(ik).mtime = mdates; 
  for ii=1:17 
    data(ik).(dfds{ii}) = tmp.data(:,ii+1); 
  end

end

% Join all

fnms = fields(data);
for ii=1:numel(fnms)
  inmet.(fnms{ii}) = cat(1,data(:).(fnms{ii}))
end


