-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathextr_prof.m
More file actions
44 lines (40 loc) · 1.33 KB
/
extr_prof.m
File metadata and controls
44 lines (40 loc) · 1.33 KB
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
function data=extr_prof(filein,ind)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Extracts the profiles with the indices (IND) present in the file
% (FILEIN). Output is a structure (DATA)
%
% Author: Ingrid M. Angel-Benavides
% BSH - MOCCA/EA-Rise (Euro-Argo)
% (ingrid.angel@bsh.de)
% Last update: 08.2021
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
var_list=whos('-file',filein);
nvar=numel(var_list);
% get list of variables
var_list=whos('-file',filein);
strv=[];
for i=1:nvar
strv=[strv var_list(i).name ' '];
end
nvar=numel(var_list);
% get data
if isempty(ind)==0
for i=1:nvar
eval(['load ' filein ' ' var_list(i).name])
if var_list(i).size(1) ==1 && strcmp(var_list(i).class,'char')==0
eval(['tmp=' var_list(i).name '(ind);' ])
eval(['data.' var_list(i).name '=tmp;']);
elseif strcmp(var_list(i).class,'char')
else
eval(['tmp=' var_list(i).name '(:,ind);' ])
eval(['data.' var_list(i).name '=tmp;']);
end
end
end
% removes lines filled only with nans if they exist
if isfield(data,'pres')
f=find(sum(isnan(data.pres),2)==size(data.pres,2)); %#ok<*NODEF>
if isempty(f)==0
data.pres(f,:)=[];data.temp(f,:)=[];data.ptmp(f,:)=[];data.sal(f,:)=[];
end
end