I wrote a little script to read the data into Matlab for further processing. Nothing particularly clever, mainly a bit of file management and string processing to extract data and convert it into arrays. Some basic visualisations can be done.
Right now it just deals with each station separately, but the next step involves merging the data in various ways.
Not sure if it works in Octave.
% Matlab code to load Land surface climate station records
% Assumes the data is unzipped into a subdirectory named Data.
% Iterates through the subfolders, loading the data station by station
%
% Anders Sandberg
subdirs=dir('Data');
files={};
llong=[];
llat=[];
hheight=[];
for i=1:length(subdirs)
if (subdirs(i).name(1)~='.')
datafiles=dir(strcat('Data/',char(subdirs(i).name)));
for j=1:length(datafiles)
if (datafiles(j).name(1)~='.')
filename = strcat('Data/',char(subdirs(i).name),'/',char(datafiles(j).name));
fid=fopen(filename,'r');
%tline = fgetl(fid);
%sscanf(tline,'%d'),
while (1)
tline = fgetl(fid);
if (strcmp(tline,'Obs:')) break; end
C=textscan(tline,'%s%s', 1,'Delimiter','=');
if (strcmp(C{1},'Number')) id=C{2}; end
if (strcmp(C{1},'Name')) name=C{2}; end
if (strcmp(C{1},'Country')) country=C{2}; end
if (strcmp(C{1},'Lat')) lat=C{2}; lat=str2num(lat{1}); end
if (strcmp(C{1},'Long')) long=C{2}; long=str2num(long{1}); end
if (strcmp(C{1},'Height')) height=C{2}; height=str2num(height{1}); end
if (strcmp(C{1},'Start year')) startyear=C{2}; end
if (strcmp(C{1},'End year')) stopyear=C{2}; end
if (strcmp(C{1},'First Good year')) goodyear=C{2}; end
if (strcmp(C{1},'Source ID')) sourceid=C{2}; end
if (strcmp(C{1},'Source file')) sourcefile=C{2}; end
if (strcmp(C{1},'Normals source')) normalsource=C{2}; end
if (strcmp(C{1},'Normals source start year')) normalstart=C{2}; end
if (strcmp(C{1},'Normals source end year')) normalend=C{2}; end
if (strcmp(C{1},'Normals')) normals=C{2}; nromals=str2num(normals{1}); end
if (strcmp(C{1},'Standard deviations source')) stdsource=C{2}; end
if (strcmp(C{1},'Standard deviations source start year')) stdstart=C{2}; end
if (strcmp(C{1},'Standard deviations source end year')) stdend=C{2}; end
if (strcmp(C{1},'Standard deviations')) stds=C{2}; stds=str2num(stds{1}); end
end
data=textscan(fid,'%d%f%f%f%f%f%f%f%f%f%f%f%f');
% Vector of years for this station
year=double(data{1});
% Matrix of temp data
bdata=[data{2} data{3} data{4} data{5} data{6} data{7} data{8} data{9} data{10} data{11} data{12} data{13}];
% Vector of temp data
sdata=bdata'; sdata=sdata(:);
% Vectors of months and years
smonth=repmat(1:12,1,length(year));
syear=[]; for k=1:length(year); syear=[syear ones(1,12)*year(k)]; end
N=length(sdata);
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%VISUALISATIONS
% Comment/uncomment as needed
% Remove nonexistent data
sdata(find(sdata<-98))=NaN;
% plot full data serially
%plot(syear+(smonth-1)/12, sdata)
% plot year cycle
%plot(sdata(1:(N-3)),sdata(4:N))
% % Plot colored year cycle
% clf
% hold on
% for ii=1:(N-4)
% co=ii*[1 1 1]/N;
% plot([sdata(ii) sdata(ii+1)],[sdata(ii+3) sdata(ii+4)],'LineWidth',2,'Color',co);
% end
% set(gca,'Color',[153 136 85]/255)
% xlabel('T(t)')
% ylabel('T(t+3)')
% V=axis;
% title(strcat(char(name),' / ',char(country)),'FontSize',20)
%
% make map
%if (height<-100) height=0; end; % remove missing heights
%plot3(long,lat,height,'.')
%text(long,lat,height,strcat(name,' ',country));
% plot monthly deviation from mean temperature
%mm=mean(sdata(find(~isnan(sdata))));
%plot(syear+(smonth-1)/12, sdata-mm);
% Plot a polar diagram of temperatures
clf
hold on
singleplot=0; % single color or multicolor
mi=-50;
ma=50;
% Draw background lines
theta=2*pi*(0:100)/100;
for r=-30:10:30
R=0.1+0.9*(r - mi)/(ma-mi);
if (R>0)
plot(R.*cos(theta),R.*sin(theta),'k','Color',[0.7 0.7 0.7])
text(R+.025,0+.025,num2str(r),'FontSize',8)
end
end
monthname=['Jan';'Feb';'Mar';'Apr';'May';'Jun';'Jul';'Aug';'Sep';'Oct';'Nov';'Dec'];
for mo=1:12
tm=-2*pi*(mo-1)/12;
plot([0 Rm*cos(tm)],[0 Rm*sin(tm)],'k','Color',[0.7 0.7 0.7]);
text(1.05*Rm*cos(tm),1.05*Rm*sin(tm),monthname(mo,:),'HorizontalAlignment','center');
end
theta=-(2*pi*(smonth-1)/12)';
R=0.1+0.9*(sdata - mi)/(ma-mi);
Rm=1;
if (singleplot==1)
plot(R.*cos(theta),R.*sin(theta))
else
for ii=1:(N-1)
co=ii*[1 1 1]/N;
plot([R(ii)*cos(theta(ii)) R(ii+1)*cos(theta(ii+1))],[R(ii)*sin(theta(ii)) R(ii+1)*sin(theta(ii+1))],'Color',co,'LineWidth',2);
end
end
axis([-1.1 1.1 -1.1 1.1])
axis square
axis off
title(strcat(char(name),' / ',char(country)),'FontSize',20)
% Make unreliable mean year plot
% bdata(find(bdata<-98))=NaN;
% plot(year, mean(bdata'))
drawnow
pause
%%%%%%%%%%%%%%%%%%%%%%%%%
% Collect data across stations
llong=[llong long];
llat=[llat lat];
hheight=[hheight height];
fclose(fid);
end
end
end
end
