forked from ilkkavir/BAFIM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bafim_select.m
49 lines (39 loc) · 1.18 KB
/
bafim_select.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
function bafim_select( datadir , restype )
%
% bafim_select( datadir , restype )
%
% Switch between filtering and smoothing results in r_param and r_error variables in GUISDAP output files
%
% INPUT:
% datadir a directory containing bafim_smoother outputs
%
% UTPUT:
% restype 'filter', 'smooth', or 'rcorr'. 'rcorr' are the parameter profiles smoothed in range,
% before adding the boundary conditions and process noise.
%
%
% IV 2020
%
df = dir(fullfile(datadir,'*.mat'));
nf = length(df);
for k=1:nf
% read the data
dfpath = fullfile(datadir,df(k).name);
dd = load(dfpath);
switch lower(restype(1:5))
case 'filte'
r_param = dd.r_param_filter;
r_error = dd.r_error_filter;
case 'smoot'
r_param = dd.r_param_smooth;
r_error = dd.r_error_smooth;
case 'rcorr'
r_param = dd.r_param_rcorr;
r_error = dd.r_error_rcorr;
otherwise
error("unknown restype, must be either 'filter' or 'smooth'")
end
save(dfpath,'r_param','r_error','-append');
fprintf("\r %s",dfpath)
end
end