-
Notifications
You must be signed in to change notification settings - Fork 1
/
whp_ctd.m
60 lines (52 loc) · 1.24 KB
/
whp_ctd.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
function [p,t,s,o2] = whp_ctd(flname);
% WHP_CTD Reads in standard WOCE ctd ascii file specified by flname
% Checks the header record and if the temperature is in ITS-90,
% if is converted to IPTS-68 before being returned
%
% Usage: [p,t,s,o2] = whp_ctd(flname);
%
% Output : (column vectors)
% p : pressure
% t : (in situ) temperature
% s : salinity
% ox: oxygen
%
%
% Paul E. Robbins copyright 1995
fid = fopen(flname,'r');
if fid == -1
%try to find file in matlab_data directory
fid = fopen([getenv('MATLAB_DATA'),flname],'r');
if fid == -1
fid = fopen([getenv('MATLAB_DATA'),'ctd/woce/',flname],'r');
if fid == -1;
disp(['File ',flname,' not found'])
break
end
end
end
% read in 6 lines of header data
for l = 1:2
line = fgetl(fid); disp(line);
end
for l = 3:5
line = fgetl(fid);
end
if any(findstr(line,'ITS-90'))
dotemp = 1;
disp([' Converting temperature from ITS-90 to IPTS-68'])
else
dotemp = 0;
end
line = fgetl(fid);
% read in data block
dat = fscanf(fid,'%f',[6 inf]);
p = dat(1,:);
t = dat(2,:);
s = dat(3,:);
o2 = dat(4,:);
fclose(fid);
if dotemp
t = 1.00024*t;
end
p = p(:); t = t(:); s = s(:); o2 = o2(:);