-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGetAltimetry.m
92 lines (75 loc) · 2.84 KB
/
GetAltimetry.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
function [Altimetry,DEM,GDat,nodata] = GetAltimetry(VS,Ncyc)
%2.1) Read in height & sigma0 data
fname=[VS.ID '_' num2str(VS.Rate) 'hz'];
delimiterIn = {' ',' ',' ',' '};
fid=fopen(fname);
GDat=-1;
if fid==-1
Altimetry.c=[];
DEM=0;
else if all(fgetl(fid)~= -1)
formatSpec = '%f%f%f%f%f%f%f%f%f%f%[^\n\r]';
datah = textscan(fid,formatSpec,'headerlines',3,'CollectOutput',true,'Delimiter', '', 'WhiteSpace', '','ReturnOnError',false);
fclose(fid);
datah=datah{1};
Altimetry.c=datah(:,1);
Altimetry.h=datah(:,2);
if length(Altimetry.h)>20
GDat=VS.Id;
end
tMJD=datah(:,3);
Altimetry.sig0=datah(:,4);
Altimetry.lon=datah(:,5);
Altimetry.lat=datah(:,6);
Altimetry.PK=datah(:,7);
offdate =datenum(2000, 1, 1, 0, 0, 0) -51544; %from Chan email 3 Apr 2014
Altimetry.tAll=tMJD+offdate;
%2.2) Process heights cycle & time info
[Altimetry.ci,i]=unique(Altimetry.c);
Altimetry.t=Altimetry.tAll(i);
Altimetry.cmax = Ncyc;
Altimetry.call=1:Altimetry.cmax;
Altimetry.GDRMissing=false(size(Altimetry.call)); %initiate
for i=1:length(Altimetry.call),
if ~any(Altimetry.ci==Altimetry.call(i)),
Altimetry.GDRMissing(i)=true;
end
end
%% read DEM data
%ers DEM info is in a different format
if strcmp(VS.Satellite,'Envisat') || strcmp(VS.Satellite,'Jason2')
delimiter = {' ',' ',' ',' '};
endRow = 3;
% formatSpec='%*[#]%d%*f%*f';
formatSpec = '%*s%f%f%f%*s%*s%*s%*s%*s%*s%*s%*s%*s%[^\n\r]';
%formatSpec = '%*3s%10s%*15s%*[^\n\r]';
else
delimiter = {','};
endRow=3;
formatSpec = '%s%s%s';
end
fid=fopen(fname);
Altimetry.demDat=textscan(fid,formatSpec, endRow,...
'Delimiter',delimiter,'EmptyValue',NaN,'ReturnOnError', false);
fclose(fid);
if ~strcmp(VS.Satellite,'Envisat') && ~strcmp(VS.Satellite,'Jason2')
for k = 1:3;
for m=1:3;
delimiter = {'='};
formatSpec = '%*s%f';
Altimetry.demDat{1,k}(m)= textscan(Altimetry.demDat{1,k}{m},...
formatSpec, 'Delimiter',delimiter,...
'EmptyValue',NaN,'ReturnOnError', false);
end
Altimetry.demDat{1,k} = cell2mat(Altimetry.demDat{1,k});
end
end
DEM=Altimetry.demDat{1}';
Altimetry.AvgGradient=Altimetry.demDat{2}';
Altimetry.RMSGradient=Altimetry.demDat{3}';
else
GDat=-1;
Altimetry.c=[];
end
end
return