clear all
%close all

if (0)
    data=dlmread('formatted/embrapa_Davis.all','\t',2,0);

    temp=data(:,6);
    rh=data(:,9);
    wind_speed=data(:,11);
    wind_dir=data(:,12);
    pres=data(:,19);
    rain=data(:,20);
    rain_rate=data(:,21);
    
    time=data(:,1:5);
    time(:,6)=0;
    jd=datenum(time);
    
    % problemas na temperatura
    mask=(temp<0) | ...
         (jd>datenum(2012,8,19,13,0,0) & jd<datenum(2012,8,19,15,0,0)) | ...
         

    jd5=squeeze(ncread('~/era5_t2m.nc','time'))/24. + datenum(1900,1,1);
    t5=squeeze(ncread('~/era5_t2m.nc','t2m')) - 273.15;
    td5=squeeze(ncread('~/era5_td2m.nc','d2m')) - 273.15;
    sw5=squeeze(ncread('~/era5_swdown.nc','ssrd'));
    ps5=squeeze(ncread('~/era5_ps.nc','sp'))/100.;
    prec5=squeeze(ncread('~/era5_prec.nc','tp'))*1000.;
    u5=squeeze(ncread('~/era5_u10m.nc','u10'));
    v5=squeeze(ncread('~/era5_v10m.nc','v10'));
    
    clear data
    save('formatted/embrapa_Davis.all.mat');
else
    load('formatted/embrapa_Davis.all.mat')
end


% fim