function [Lat,Lon,time,date]=readhdr_bcd(cast,letter)
% readhdr.m -  to read header file for SeaBird CTD files

path = '/mnt/oc415-2a/oc415_2/ctd/';


if strcmp(letter,' ')
  fid = fopen([path,'oc4152',int2str(cast),'.HDR'],'r');
else
  fid = fopen([path,'oc4152',int2str(cast),letter,'.HDR'],'r');
end
string = fread(fid);

aa = find(string == 42); % these are the '*' at the beginning of
                         % each line
	
% 9th line has date
date = setstr(string(aa(9)+23:aa(9)+33))';

% Lat on 10th line
Lat = setstr(string(aa(10)+18:aa(10)+27))';

% Lon on 11th line
Lon = setstr(string(aa(11)+19:aa(11)+29))';

% 12th line has time			 
time = setstr(string(aa(12)+20:aa(12)+27))';

% now get numbers from strings
[A,count]= sscanf(Lat,'%d %f',2);
lat = A(1) + A(2)/60;

[A,count]= sscanf(Lon,'%d %f',2);
lon = A(1) + A(2)/60;

fclose(fid);
