forked from tduriez/LFD_MPIV_toolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLFD_MPIV_CommandLine.m
More file actions
executable file
·170 lines (131 loc) · 6.03 KB
/
LFD_MPIV_CommandLine.m
File metadata and controls
executable file
·170 lines (131 loc) · 6.03 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
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
function data_PIV=LFD_MPIV_CommandLine(the_input,varargin)
%LFD_MPIV_COMMANDLINE computes PIV fields from CXD file(s).
%
% DATA=LFD_MPIV_COMMANDLINE(CXD_FILENAME) returns the DATA structure
% containing the result of the PIV computation using default <a href="matlab:help LFD_MPIV_parameters">parameters</a>
% for the PIV computations of images included in CXD_FILENAME archive.
%
% DATA=LFD_MPIV_COMMANDLINE(CXD_FILENAME,'arg1',value1,...) allows the use
% of custom parameters. A full list of parameters is available <a href="matlab:help LFD_MPIV_parameters">here</a>.
%
% DATA=LFD_MPIV_COMMANDLINE(LM_PARAMS) computes PIV according
% to the array LM_PARAMS of <a href="matlab:help LFD_MPIV_parameters">LFD_MPIV_parameters</a> objects provided. You
% can generate such an array using <a href="matlab:help LFD_MPIV_Interface">LFD_MPIV_Interface</a>
%
% By default, single frame time series will be converted in double frame
% time series (1-2 2-3 3-4 ...) and cumulative cross-correlation will be
% performed. Three passes (64x64 32x32 and 16x16) are performed.
%
% Quick option guide:
%
% Parameter name | Parameter values
% ------------------|-----------------
% IntWin | [64 32 16] array of interrogation window size.
% cumulcross | 1 switch to 0 to deactive cumulative
% | cross-correlation
% image_indices | [] indices of images to include. Empty
% | means all images are used.
%
% See <a href="matlab:help LFD_MPIV_parameters">here</a> for a full option list and description.
%
% See also LFD_MPIV_INTERFACE, LFD_MPIV_READ_CXD
% Copyright (c) 2017, Thomas Duriez (Distributed under GPLv3)
%% Copyright
% Copyright (c) 2017, Thomas Duriez
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <http://www.gnu.org/licenses/>.
%% three cases for THE_INPUT: structure, structure+options, file+options
GetFrames=0;
if nargin>1
if any(strcmpi(varargin,'GetFrames'));
GetFrames=1;
idx=find(strcmpi(varargin,'GetFrames'));
varargin=varargin(setdiff(1:length(varargin),idx));
end
end
if ischar(the_input) % if THE_INPUT is a CXD file route
parameters=LFD_MPIV_parameters;
parameters.cxd_file=the_input;
parameters.update(varargin{:});
if GetFrames
images=LFD_MPIV_read_images(the_input,parameters.image_indices,0);
images=prepare_frames(images,parameters);
data_PIV.images=images;
data_PIV.parameters=parameters;
return
end
elseif isa(the_input,'LFD_MPIV_parameters') % THE_INPUT is an array of LFD_MPIV objects
for i=1:numel(the_input)
% THE_INPUT is used as default so it can be overridden by specified
% parameters in varargin
parameters(i)=the_input(i).copy;
parameters(i).update(varargin{:});
end
end
%% Check if new version is available
msg=check_last_version(parameters(1));
if parameters(1).Verbose
fprintf('%s',msg)
end
%% Start of tomography
if ~isempty(parameters)
case_name_collection={};
for i=1:length(parameters);
if ~any(strcmp(case_name_collection,parameters(i).export_filename))
case_name_collection{numel(case_name_collection)+1}=parameters(i).export_filename;
end
end
for i_case=1:length(case_name_collection)
this_parameters_idx=zeros(1,length(parameters));
this_z=zeros(1,length(parameters));
for i=1:length(parameters);
if strcmp(case_name_collection{i_case},parameters(i).export_filename)
this_parameters_idx(i)=1;
this_z(i)=parameters(i).height;
end
end
this_case_parameters=parameters(this_parameters_idx>0);
[this_z,sort_idx]=sort(this_z(this_parameters_idx>0));
this_case_parameters=this_case_parameters(sort_idx);
if length(unique(this_z))~=length(this_z);
error(['At least two parametersriment have same ''case_name'''...
'and ''height''. This would result in overridden '...
'data. Please modify it'])
end
for i_height = 1:numel(this_z)
setappdata(0,'LFD_MPIV_gui',gcf);
data=raw_to_vectors(this_case_parameters(i_height));
if i_height==1
try
clear data_PIV
catch
end
data_PIV.x=repmat(data.x,[1 1 length(this_z)]);
data_PIV.y=repmat(data.y,[1 1 length(this_z)]);
data_PIV.z=repmat(permute(this_z,[1 3 2]),...
[size(data_PIV.x,1) size(data_PIV.x,2)]);
data_PIV.u=repmat(data_PIV.y*0,[1 1 1 size(data.u,3)]);
data_PIV.v=repmat(data_PIV.y*0,[1 1 1 size(data.u,3)]);
data_PIV.w=repmat(data_PIV.y*0,[1 1 1 size(data.u,3)]);
data_PIV.s2n=repmat(data_PIV.y*0,[1 1 1 size(data.u,3)]);
end
data_PIV.u(:,:,i_height,:)=permute(data.u,[1 2 4 3]);
data_PIV.v(:,:,i_height,:)=permute(data.v,[1 2 4 3]);
data_PIV.s2n(:,:,i_height,:)=permute(data.s2n,[1 2 4 3]);
data_PIV.parameters(i_height)=this_case_parameters(i_height);
end
save(sprintf('%s.mat',case_name_collection{i_case}),'data_PIV');
end
end
end