%  It looks like the lats and lons may not be consistent in all of
%  Gabriel's files....  This file reads in the Monthly ET files and..

%  The result is that they changed the analysis in 2015-- but this only
%  affected the bounding box, not the location of the grid squares
%  themselves. 
%
% this  compiles lat/lon grid information from all the files.  You7 can
% later analyze these for consistency.  

for yydir=2000:2017;
    yystr=int2str(yydir);
    disp(yystr)
    
    dirname=['/Projects/CMIP5C/OBS_DATA/SSEBOP/MonthlyET/' yystr '/'];  % input file directory

    a=dir([dirname 'm*.tif']);   % list all the months in that year-directory.  This can handle partial years.
    %

    
    for k = 1:length(a);   % loop over all files in year "yydir"
        fname=a(k).name;
        [Z,R]=geotiffread([dirname fname]);   % read geotiff
        [mm,nn]=size(Z);
        rs(yydir-1999,k,:)=R.RasterSize;      %  compile information from the "geographic reference object" read in with the geotiff. 
        rlatlims(yydir-1999,k,:)=R.LatitudeLimits;
        rlonlimits(yydir-1999,k,:)=R.LongitudeLimits;
        
        rlatextent(yydir-1999,k)=R.RasterExtentInLatitude;
        rlonextent(yydir-1999,k)=R.RasterExtentInLongitude;
        rxlimits(yydir-1999,k,:)=R.XIntrinsicLimits;
        rylimits(yydir-1999,k,:)=R.YIntrinsicLimits;
        yr(k) = str2num(fname(2:5));
        mon(k) = str2num(fname(6:7));
    end
    
end
    
