-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patha_preparaMedicionesLC.m
111 lines (80 loc) · 2.3 KB
/
a_preparaMedicionesLC.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Prepara Perfiles
clear *; close all; clc;
try init; catch me; cd ..; init; end
%% ------------------------ CARGANDO LOS DATOS ------------------------
LC=readtable('D:\COASTSAT\Tarea_2\M_8\transect_time_series_filtered.csv');
Profiles=readtable('Perfiles_general.csv');
%% ------------------------- SEPARANDO PERFILES -------------------------
perf = 4413:4414; %cambiar
% exclude satelites?
% k=1;
% for i=1:numel(LC.satname)
% if LC.satname{i}=='L7' % | LC.satname{i}=='L7'
%
% else
% idx(k)=i;
% k=k+1;
% end
%
% end
%
% LC=LC(idx,:);
% LC=LC(1:end-7,:);
% k=1;
Fecha=zeros(size(LC,1),1);
for i=1:size(LC,1)
Fecha(i)=datenum(LC.dates{i},'yyyy-mm-dd HH:MM:SS');
end
TimeTOT=[];
k=1;
for i=1:numel(perf)
try
col = ['Transect' num2str(perf(i))];
ii = ~isnan(LC.(col));
ENS(k).time = Fecha(ii);
ENS(k).Yobs = LC.(col)(ii);
ENS(k).Sat = LC.satname(ii);
ENS(k).trs = perf(i);
ENS(k).xon = Profiles.xon(perf(i));
ENS(k).yon = Profiles.yon(perf(i));
ENS(k).xof = Profiles.xof(perf(i));
ENS(k).yof = Profiles.yof(perf(i));
ENS(k).phi = -pi/2.-atan((ENS(k).xof-ENS(k).xon)/(ENS(k).yof-ENS(k).yon));
TimeTOT=[TimeTOT;ENS(i).time];
[ENS(k).absX,ENS(k).absY]=abs_pos(ENS(k).xon,ENS(k).yon,ENS(k).phi,ENS(k).Yobs);
k=k+1;
catch
% do nothing
end
end
%% -------------------- SEPARANDO FECHAS CON MEDICION --------------------
TimeTOT=sort(TimeTOT,'ascend');
TimeTOT=TimeTOT(diff(TimeTOT) > 15);
for i=1:numel(TimeTOT)
for j=1:numel(ENS)
ii=abs(TimeTOT(i)-ENS(j).time)<1;
try
Yobs(i,j)=ENS(j).Yobs(ii);
catch
Yobs(i,j)=NaN;
end
end
end
Yobs=fillmissing(Yobs,'linear');
for i=1:numel(ENS)
[X(:,i),Y(:,i)]=abs_pos(ENS(i).xon,ENS(i).yon,ENS(i).phi,Yobs(:,i));
end
k=1;
for i=1:numel(TimeTOT)
if sum(~isnan(Yobs(i,:)))==size(Yobs,2)
Yobs2(k,:)=Yobs(i,:);
TimeTOT2(k)=TimeTOT(i);
k=k+1;
end
end
clear ENS;
ENS.Yobs=Yobs;ENS.X=X; ENS.Y=Y;ENS.time=TimeTOT;
%% --- GUARDA DATOS ---
save([pathRes 'EnsamblesProfiles.mat'],'ENS')
%% --------------------------END--------------------------