1 | function GUI_input=time_series(num_i1,num_i2,num_j1,num_j2,Series) |
---|
2 | %---------------------------------------------------------------------- |
---|
3 | % --- make a time series analysis |
---|
4 | %---------------------------------------------------------------------- |
---|
5 | %INPUT: |
---|
6 | %num_i1: series of first indices i (given from the series interface as first_i:incr_i:last_i, mode and list_pair_civ) |
---|
7 | %num_i2: series of second indices i (given from the series interface as first_i:incr_i:last_i, mode and list_pair_civ) |
---|
8 | %num_j1: series of first indices j (given from the series interface as first_j:incr_j:last_j, mode and list_pair_civ ) |
---|
9 | %num_j2: series of second indices j (given from the series interface as first_j:incr_j:last_j, mode and list_pair_civ) |
---|
10 | %OTHER INPUTS given by the structure Series |
---|
11 | |
---|
12 | %requests for the visibility of input windows in the GUI series (activated directly by the selection in the menu ACTION) |
---|
13 | if ~exist('num_i1','var') |
---|
14 | GUI_input={'RootPath';'two';...%nbre of possible input series (options 'on'/'two'/'many', default:'one') |
---|
15 | 'SubDir';'on';... % subdirectory of derived files (PIV fields), ('on' by default) |
---|
16 | 'RootFile';'on';... %root input file name ('on' by default) |
---|
17 | 'FileExt';'on';... %input file extension ('on' by default) |
---|
18 | 'NomType';'on';...%type of file indexing ('on' by default) |
---|
19 | 'NbSlice';'on'; ...%nbre of slices ('off' by default) |
---|
20 | 'VelTypeMenu';'two';...% menu for selecting the velocity type (civ1,..) options 'off'/'one'/'two', 'off' by default) |
---|
21 | 'FieldMenu';'two';...% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default) |
---|
22 | 'CoordType';'on';...%can use a transform function 'off' by default |
---|
23 | 'GetObject';'on';...%can use projection object ,'off' by default |
---|
24 | %'GetMask';'on'...%can use mask option ,'off' by default |
---|
25 | %'PARAMETER'; options: name of the user defined parameter',repeat a line for each parameter |
---|
26 | ''}; |
---|
27 | return %exit the function |
---|
28 | end |
---|
29 | |
---|
30 | %------------------------------------------------------ |
---|
31 | hseries=guidata(Series.hseries);%handles in the GUI series |
---|
32 | WaitbarPos=get(hseries.waitbar_frame,'Position'); %position of the waitbar frame |
---|
33 | |
---|
34 | %projection object |
---|
35 | test_object=get(hseries.GetObject,'Value'); |
---|
36 | if test_object |
---|
37 | hset_object=findobj(allchild(0),'tag','set_object'); |
---|
38 | ProjObject=read_set_object(guidata(hset_object)); |
---|
39 | %answeryes=questdlg({['field series projected on ' Series.ProjObject.Style]}); |
---|
40 | answeryes=msgbox_uvmat('INPUT_Y-N',['field series projected on ' ProjObject.Style]); |
---|
41 | if ~isequal(answeryes,'Yes') |
---|
42 | return |
---|
43 | end |
---|
44 | else |
---|
45 | msgbox_uvmat('ERROR','a projection object is needed'); |
---|
46 | return |
---|
47 | end |
---|
48 | |
---|
49 | % root names |
---|
50 | if iscell(Series.RootPath) |
---|
51 | RootPath=Series.RootPath; |
---|
52 | RootFile=Series.RootFile; |
---|
53 | SubDir=Series.SubDir; |
---|
54 | FileExt=Series.FileExt; |
---|
55 | NomType=Series.NomType; |
---|
56 | else |
---|
57 | RootPath={Series.RootPath}; |
---|
58 | RootFile={Series.RootFile}; |
---|
59 | SubDir={Series.SubDir}; |
---|
60 | FileExt={Series.FileExt}; |
---|
61 | NomType={Series.NomType}; |
---|
62 | num_i1={num_i1}; |
---|
63 | num_i2={num_i2}; |
---|
64 | num_j1={num_j1}; |
---|
65 | num_j2={num_j2}; |
---|
66 | end |
---|
67 | ext=FileExt{1}; |
---|
68 | form=imformats(ext([2:end]));%test valid Matlab image formats |
---|
69 | testima=0; |
---|
70 | if ~isempty(form)||isequal(lower(ext),'.avi') |
---|
71 | testima=1; |
---|
72 | end |
---|
73 | nbview=length(RootPath);%number of series (1 or 2) |
---|
74 | nbfield=size(num_i1{1},1)*size(num_i1{1},2); %number of fields in the time series |
---|
75 | |
---|
76 | %Number of input series: this function accepts only a single input file series |
---|
77 | nbview=length(RootPath); |
---|
78 | if nbview==2 |
---|
79 | %TODO: choose between difference and two series |
---|
80 | elseif nbview>2 % TODO: make multiple series |
---|
81 | % RootPath=RootPath(1:2); |
---|
82 | % set(hseries.RootPath,'String',RootPath) |
---|
83 | % SubDir=SubDir(1:2); |
---|
84 | % set(hseries.SubDir,'String',SubDir) |
---|
85 | % RootFile=RootFile(1:2); |
---|
86 | % set(hseries.RootFile,'String',RootFile) |
---|
87 | % NomType=NomType(1:2); |
---|
88 | % %set(hseries.NomType,'String',NomType) |
---|
89 | % FileExt=FileExt(1:2); |
---|
90 | % set(hseries.FileExt,'String',FileExt) |
---|
91 | % nbview=2; |
---|
92 | end |
---|
93 | |
---|
94 | %determine image type |
---|
95 | hhh=which('mmreader'); |
---|
96 | for iview=1:nbview |
---|
97 | if isequal(FileExt{iview},'.nc')||isequal(FileExt{iview},'.cdf') |
---|
98 | FileType{iview}='netcdf'; |
---|
99 | elseif isequal(lower(FileExt{iview}),'.avi') |
---|
100 | if ~isequal(hhh,'')&& mmreader.isPlatformSupported() |
---|
101 | MovieObject{iview}=mmreader(fullfile(RootPath{iview},[RootFile{iview} FileExt{iview}])); |
---|
102 | FileType{iview}='movie'; |
---|
103 | else |
---|
104 | FileType{iview}='avi'; |
---|
105 | end |
---|
106 | elseif isequal(lower(FileExt{iview}),'.vol') |
---|
107 | FileType{iview}='vol'; |
---|
108 | else |
---|
109 | form=imformats(FileExt{iview}(2:end)); |
---|
110 | if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab |
---|
111 | if isequal(NomType{iview},'*'); |
---|
112 | FileType{iview}='multimage'; |
---|
113 | else |
---|
114 | FileType{iview}='image'; |
---|
115 | end |
---|
116 | end |
---|
117 | end |
---|
118 | end |
---|
119 | filebase{1}=fullfile(RootPath{1},RootFile{1}); |
---|
120 | |
---|
121 | % number of slices |
---|
122 | NbSlice=str2num(get(hseries.NbSlice,'String')); |
---|
123 | if isempty(NbSlice) |
---|
124 | NbSlice=1; |
---|
125 | end |
---|
126 | NbSlice_name=num2str(NbSlice); |
---|
127 | |
---|
128 | % Field and velocity type (the same for the two views) |
---|
129 | if isfield(Series,'Field') |
---|
130 | FieldName=Series.Field;%the same set of fields for all views |
---|
131 | else |
---|
132 | FieldName={''}; |
---|
133 | end |
---|
134 | if isequal(FieldName,{'get_field...'}) |
---|
135 | hget_field=findobj(allchild(0),'name','get_field');%find the get_field... GUI |
---|
136 | if numel(hget_field)>1 |
---|
137 | delete(hget_field(2:end)) % delete multiple occurerence of the GUI get_fioeld |
---|
138 | elseif isempty(hget_field) |
---|
139 | filename=name_generator(filebase{1},num_i1{1}(1),num_j1{1}(1),FileExt{1},NomType{1},1,num_i2{1}(1),num_j2{1}(1),SubDir{1}); |
---|
140 | idetect(iview)=exist(filename,'file'); |
---|
141 | hget_field=get_field(filename); |
---|
142 | return |
---|
143 | end |
---|
144 | %hhget_field=guidata(hget_field);%handles of GUI elements in get_field |
---|
145 | SubField=read_get_field(hget_field); %read the names of the variables to plot in the get_field GUI |
---|
146 | if isempty(SubField) |
---|
147 | delete(hget_field) |
---|
148 | filename=name_generator(filebase{1},num_i1{1}(1),num_j1{1}(1),FileExt{1},NomType{1},1,num_i2{1}(1),num_j2{1}(1),SubDir{1}); |
---|
149 | hget_field=get_field(filename); |
---|
150 | SubField=read_get_field(hget_field); %read the names of the variables to plot in the get_field GUI |
---|
151 | end |
---|
152 | % if isequal(get(hhget_field.menu_coord,'Visible'),'on') |
---|
153 | % list_transform=get(hhget_field.menu_coord,'String'); |
---|
154 | % val_list=get(hhget_field.menu_coord,'Value'); |
---|
155 | % transform=list_transform{val_list}; |
---|
156 | % end |
---|
157 | end |
---|
158 | |
---|
159 | %detect whether the two files are 'images' or 'netcdf' |
---|
160 | % testima=0; |
---|
161 | % testvol=0; |
---|
162 | testcivx=0; |
---|
163 | % testnc=0; |
---|
164 | FileExt=get(hseries.FileExt,'String'); |
---|
165 | % for iview=1:nbview |
---|
166 | % ext=FileExt{iview}; |
---|
167 | % form=imformats(ext([2:end])); |
---|
168 | % if isequal(lower(ext),'.vol') |
---|
169 | % testvol=testvol+1; |
---|
170 | % elseif ~isempty(form)||isequal(lower(ext),'.avi')% if the extension corresponds to an image format recognized by Matlab |
---|
171 | % testima=testima+1; |
---|
172 | % elseif isequal(ext,'.nc') |
---|
173 | % testnc=testnc+1; |
---|
174 | % end |
---|
175 | % end |
---|
176 | % if testvol |
---|
177 | % msgbox_uvmat('ERROR','volume images not implemented yet') |
---|
178 | % return |
---|
179 | % end |
---|
180 | % if testnc~=nbview && testima~=nbview && testvol~=nbview |
---|
181 | % msgbox_uvmat('need a set of images or a set of netcdf files with the same fields as input','ERROR') |
---|
182 | % return |
---|
183 | % end |
---|
184 | if ~isequal(FieldName,{'get_field...'}) |
---|
185 | testcivx=isequal(FileType{1},'netcdf'); |
---|
186 | end |
---|
187 | |
---|
188 | VelType_str=get(hseries.VelTypeMenu,'String'); |
---|
189 | VelType_val=get(hseries.VelTypeMenu,'Value'); |
---|
190 | VelType{1}=VelType_str{VelType_val}; |
---|
191 | if nbview==2 |
---|
192 | VelType_str=get(hseries.VelTypeMenu_1,'String'); |
---|
193 | VelType_val=get(hseries.VelTypeMenu_1,'Value'); |
---|
194 | VelType{2}=VelType_str{VelType_val}; |
---|
195 | end |
---|
196 | |
---|
197 | %Calibration data and timing: read the ImaDoc files |
---|
198 | mode=''; %default |
---|
199 | timecell={}; |
---|
200 | XmlData={}; |
---|
201 | itime=0; |
---|
202 | NbSlice_calib={}; |
---|
203 | for iview=1:nbview%Loop on views |
---|
204 | XmlData{iview}=[];%default |
---|
205 | filebase{iview}=fullfile(RootPath{iview},RootFile{iview}); |
---|
206 | if exist([filebase{iview} '.xml'],'file') |
---|
207 | [XmlData{iview},error]=imadoc2struct([filebase{iview} '.xml']); |
---|
208 | if isfield(XmlData{iview},'Time') |
---|
209 | itime=itime+1; |
---|
210 | timecell{itime}=XmlData{iview}.Time; |
---|
211 | end |
---|
212 | if isfield(XmlData{iview},'GeometryCalib') && isfield(XmlData{iview}.GeometryCalib,'SliceCoord') |
---|
213 | NbSlice_calib{iview}=size(XmlData{iview}.GeometryCalib.SliceCoord,1);%nbre of slices for Zindex in phys transform |
---|
214 | if ~isequal(NbSlice_calib{iview},NbSlice_calib{1}) |
---|
215 | msgbox_uvmat('WARNING','inconsistent number of Z indices for the field series'); |
---|
216 | end |
---|
217 | end |
---|
218 | elseif exist([filebase{iview} '.civ'],'file') |
---|
219 | [error,time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([filebase{iview} '.civ']); |
---|
220 | itime=itime+1; |
---|
221 | timecell{itime}=time; |
---|
222 | XmlData{iview}.Time=time; |
---|
223 | GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0]; |
---|
224 | GeometryCalib.Tx=0; |
---|
225 | GeometryCalib.Ty=0; |
---|
226 | GeometryCalib.Tz=1; |
---|
227 | GeometryCalib.dpx=1; |
---|
228 | GeometryCalib.dpy=1; |
---|
229 | GeometryCalib.sx=1; |
---|
230 | GeometryCalib.Cx=0; |
---|
231 | GeometryCalib.Cy=0; |
---|
232 | GeometryCalib.f=1; |
---|
233 | GeometryCalib.kappa1=0; |
---|
234 | GeometryCalib.CoordUnit='cm'; |
---|
235 | XmlData{iview}.GeometryCalib=GeometryCalib; |
---|
236 | if error==1 |
---|
237 | msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file'); |
---|
238 | end |
---|
239 | end |
---|
240 | end |
---|
241 | |
---|
242 | %check coincidence in time |
---|
243 | multitime=0; |
---|
244 | if length(timecell)==0 |
---|
245 | time=[]; |
---|
246 | elseif length(timecell)==1 |
---|
247 | time=timecell{1}; |
---|
248 | elseif length(timecell)>1 |
---|
249 | multitime=1; |
---|
250 | for icell=1:length(timecell) |
---|
251 | if ~isequal(size(timecell{icell}),size(timecell{1})) |
---|
252 | msgbox_uvmat('WARNING','inconsistent time array dimensions in ImaDoc fields, the time for the first series is used') |
---|
253 | time=timecell{1}; |
---|
254 | multitime=0; |
---|
255 | break |
---|
256 | end |
---|
257 | end |
---|
258 | end |
---|
259 | if multitime |
---|
260 | for icell=1:length(timecell) |
---|
261 | time(icell,:,:)=timecell{icell}; |
---|
262 | end |
---|
263 | diff_time=max(max(diff(time))); |
---|
264 | if diff_time>0 |
---|
265 | msgbox_uvmat('WARNING',['times of series differ by more than ' num2str(diff_time)]) |
---|
266 | end |
---|
267 | end |
---|
268 | if size(time,2) < num_i2{1}(end) || size(time,3) < num_j2{1}(end)% ime array absent or too short in ImaDoc xml file' |
---|
269 | time=[]; |
---|
270 | end |
---|
271 | |
---|
272 | % Root name of output files (TO GENERALISE FOR TWO INPUT SERIES) |
---|
273 | subdir_result='time_series'; |
---|
274 | if ~exist(fullfile(RootPath{1},subdir_result),'dir') |
---|
275 | dircur=pwd; %record current working directory |
---|
276 | cd(RootPath{1})% goes to the iamge directory |
---|
277 | [m1,m2,m3]=mkdir(subdir_result); |
---|
278 | if ~isequal(m2,'') |
---|
279 | msgbox_uvmat('CONFIRMATION',m2);%error message for directory creation |
---|
280 | end |
---|
281 | [xx,msg2] = fileattrib(subdir_result,'+w','g'); %yield writing access (+w) to user group (g) |
---|
282 | if ~strcmp(msg2,'') |
---|
283 | msgbox_uvmat('ERROR',['pb of permission for ' subdir_result ': ' msg2])%error message for directory creation |
---|
284 | cd(dircur) |
---|
285 | return |
---|
286 | end |
---|
287 | cd(dircur) %back to the initial working directory |
---|
288 | end |
---|
289 | filebase_out=filebase{1}; |
---|
290 | NomTypeOut=nomtype2pair(NomType{1},num_i2{end}(end)-num_i1{1}(1),num_j2{end}(end)-num_j1{1}(1)); |
---|
291 | |
---|
292 | % coordinate transform or other user defined transform |
---|
293 | transform_fct=[];%default |
---|
294 | if isfield(Series,'transform_fct') |
---|
295 | transform_fct=Series.transform_fct; |
---|
296 | end |
---|
297 | |
---|
298 | % to update: |
---|
299 | VelType_str=get(hseries.VelTypeMenu,'String'); |
---|
300 | VelType_val=get(hseries.VelTypeMenu,'Value'); |
---|
301 | VelType{1}=VelType_str{VelType_val}; |
---|
302 | if nbview==2 |
---|
303 | VelType_str=get(hseries.VelTypeMenu_1,'String'); |
---|
304 | VelType_val=get(hseries.VelTypeMenu_1,'Value'); |
---|
305 | VelType{2}=VelType_str{VelType_val}; |
---|
306 | end |
---|
307 | |
---|
308 | %LOOP ON SLICES |
---|
309 | for i_slice=1:NbSlice |
---|
310 | dt=[]; |
---|
311 | nbmissing=0; %number of undetected files |
---|
312 | nbfiles=0; |
---|
313 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%LOOP ON FIELDS IN A SLICE |
---|
314 | for ifile=i_slice:NbSlice:nbfield |
---|
315 | stopstate=get(hseries.RUN,'BusyAction'); |
---|
316 | if isequal(stopstate,'queue')% enable STOP command |
---|
317 | update_waitbar(hseries.waitbar,WaitbarPos,ifile/nbfield) |
---|
318 | for iview=1:nbview |
---|
319 | filename=... |
---|
320 | name_generator(filebase{iview},num_i1{iview}(ifile),num_j1{iview}(ifile),FileExt{iview},NomType{iview},1,num_i2{iview}(ifile),num_j2{iview}(ifile),SubDir{iview}); |
---|
321 | idetect(iview)=exist(filename,'file'); |
---|
322 | Data{iview}=[]; %default |
---|
323 | if ~isequal(FileType{iview},'netcdf') |
---|
324 | Data{iview}.ListVarName={'A'}; |
---|
325 | Data{iview}.AName='image'; |
---|
326 | switch FileType{iview} |
---|
327 | case 'movie' |
---|
328 | A=read(MovieObject{iview},num_i1{iview}(ifile)); |
---|
329 | case 'avi' |
---|
330 | mov=aviread(filename,num_i1{iview}(ifile)); |
---|
331 | A=frame2im(mov(1)); |
---|
332 | case 'vol' |
---|
333 | A=imread(filename); |
---|
334 | case 'multimage' |
---|
335 | A=imread(filename,num_i1{iview}(ifile)); |
---|
336 | case 'image' |
---|
337 | A=imread(filename); |
---|
338 | end |
---|
339 | Data{iview}.ListVarName={'AY','AX','A'}; % |
---|
340 | npy=size(A,1); |
---|
341 | npx=size(A,2); |
---|
342 | nbcolor=size(A,3); |
---|
343 | if nbcolor==3 |
---|
344 | Data{iview}.VarDimName={'AY','AX',{'AY','AX','rgb'}}; |
---|
345 | else |
---|
346 | Data{iview}.VarDimName={'AY','AX',{'AY','AX'}}; |
---|
347 | end |
---|
348 | Data{iview}.AY=[npy-0.5 0.5]; |
---|
349 | Data{iview}.AX=[0.5 npx-0.5]; |
---|
350 | Data{iview}.A=double(A); |
---|
351 | Data{iview}.CoordType='px'; |
---|
352 | elseif testcivx |
---|
353 | [Data{iview},VelTypeOut]=read_civxdata(filename,FieldName,VelType); |
---|
354 | else |
---|
355 | [Data{iview},var_detect]=nc2struct(filename,SubField.ListVarName); %read the corresponding input data |
---|
356 | Data{iview}.VarAttribute=SubField.VarAttribute; |
---|
357 | end |
---|
358 | if ~isempty(NbSlice_calib) % z index |
---|
359 | Data{iview}.ZIndex=mod(num_i1{iview}(ifile)-1,NbSlice_calib{1})+1; |
---|
360 | end |
---|
361 | end |
---|
362 | |
---|
363 | % coordinate transform (or other user defined transform) |
---|
364 | if ~isempty(transform_fct) |
---|
365 | % z index |
---|
366 | if ~isempty(NbSlice_calib) |
---|
367 | Data{iview}.ZIndex=mod(num_i1{iview}(ifile)-1,NbSlice_calib{1})+1;%Zindex for phys transform |
---|
368 | end |
---|
369 | if nbview==2 |
---|
370 | [Data{1},Data{2}]=transform_fct(Data{1},XmlData{1},Data{2},XmlData{2}); |
---|
371 | if isempty(Data{2}) |
---|
372 | Data(2)=[]; |
---|
373 | end |
---|
374 | else |
---|
375 | Data{1}=transform_fct(Data{1},XmlData{1}); |
---|
376 | end |
---|
377 | end |
---|
378 | if testcivx |
---|
379 | Data{iview}=calc_field(FieldName,Data{iview});%calculate field (vort..) |
---|
380 | end |
---|
381 | if length(Data)==2 |
---|
382 | [Field,errormsg]=sub_field(Data{1},Data{2}); %substract the two fields |
---|
383 | if ~isempty(errormsg) |
---|
384 | msgbox_uvmat('ERROR',['error in time_series/sub_field:' errormsg]) |
---|
385 | return |
---|
386 | end |
---|
387 | else |
---|
388 | Field=Data{1}; |
---|
389 | end |
---|
390 | if test_object |
---|
391 | [Field,errormsg]=proj_field(Field,ProjObject); |
---|
392 | if ~isempty(errormsg) |
---|
393 | msgbox_uvmat('ERROR',['error in time_series/proj_field:' errormsg]) |
---|
394 | return |
---|
395 | end |
---|
396 | end |
---|
397 | if min(idetect)>=1% the input file(s) have been detected |
---|
398 | nbfiles=nbfiles+1; |
---|
399 | if nbfiles==1 %first field: initiate the time series |
---|
400 | RecordData=Field;%default |
---|
401 | RecordData.NbDim=Field.NbDim+1; %add the time dimension for plots |
---|
402 | nbvar=length(Field.ListVarName); |
---|
403 | if nbvar==0 |
---|
404 | msgbox_uvmat('ERROR','no input variable selected in get_field') |
---|
405 | return |
---|
406 | end |
---|
407 | testsum=2*ones(1,nbvar);%initiate flag for action on each variable |
---|
408 | indexfalse=0; |
---|
409 | CoordName={}; |
---|
410 | indexremove=[]; |
---|
411 | if isfield(Field,'VarAttribute') % look for coordinate and flag variables |
---|
412 | for ivar=1:nbvar |
---|
413 | if length(Field.VarAttribute)>=ivar && isfield(Field.VarAttribute{ivar},'Role') |
---|
414 | %Field.ListVarName{ivar} |
---|
415 | var_role=Field.VarAttribute{ivar}.Role;%'role' of the variable |
---|
416 | if isequal(var_role,'errorflag') |
---|
417 | msgbox_uvmat('ERROR','do not handle error flags in time series') |
---|
418 | return |
---|
419 | end |
---|
420 | if isequal(var_role,'warnflag') |
---|
421 | testsum(ivar)=0; % not recorded variable |
---|
422 | eval(['RecordData=rmfield(RecordData,''' Field.ListVarName{ivar} ''');']);%remove variable |
---|
423 | end |
---|
424 | if isequal(var_role,'coord_x')| isequal(var_role,'coord_y')|... |
---|
425 | isequal(var_role,'coord_z')|isequal(var_role,'coord') |
---|
426 | testsum(ivar)=1; %constant coordinates, record without time evolution |
---|
427 | end |
---|
428 | end |
---|
429 | % check whether the variable ivar is a dimension variable |
---|
430 | DimCell=Field.VarDimName{ivar}; |
---|
431 | if ischar(DimCell) |
---|
432 | DimCell={DimCell}; |
---|
433 | end |
---|
434 | if numel(DimCell)==1 && isequal(Field.ListVarName{ivar},DimCell{1})%detect dimension variables |
---|
435 | testsum(ivar)=1; |
---|
436 | end |
---|
437 | end |
---|
438 | end |
---|
439 | for ivar=1:nbvar |
---|
440 | if testsum(ivar)==2 |
---|
441 | eval(['RecordData.' Field.ListVarName{ivar} '=[];']) |
---|
442 | end |
---|
443 | end |
---|
444 | RecordData.ListVarName=[{'Time'} RecordData.ListVarName]; |
---|
445 | end |
---|
446 | for ivar=1:length(Field.ListVarName) |
---|
447 | VarName=Field.ListVarName{ivar}; |
---|
448 | eval(['VarVal=Field.' VarName ';']); |
---|
449 | if testsum(ivar)==2% test for recorded variable |
---|
450 | eval(['VarVal=Field.' VarName ';']); |
---|
451 | if isequal(ProjObject.ProjMode,'inside')% take the average in the domain for 'inside' mode |
---|
452 | if isempty(VarVal) |
---|
453 | msgbox_uvmat('ERROR',['empty result at frame index ' num2str(num_i1{iview}(ifile))]) |
---|
454 | return |
---|
455 | end |
---|
456 | VarVal=mean(VarVal,1); |
---|
457 | end |
---|
458 | VarVal=shiftdim(VarVal,-1); %shift dimension |
---|
459 | eval(['RecordData.' VarName '=cat(1,RecordData.' VarName ',VarVal);']);%concanete the current field to the time series |
---|
460 | elseif testsum(ivar)==1% variable representing fixed coordinates |
---|
461 | eval(['VarInit=RecordData.' VarName ';']); |
---|
462 | if ~isequal(VarVal,VarInit) |
---|
463 | msgbox_uvmat('ERROR',['time series requires constant coordinates ' VarName]) |
---|
464 | return |
---|
465 | end |
---|
466 | end |
---|
467 | end |
---|
468 | % time: |
---|
469 | if isempty(time)% time read in ncfiles |
---|
470 | if isfield(Field,'Time') |
---|
471 | RecordData.Time(nbfiles,1)=Field.Time; |
---|
472 | else |
---|
473 | RecordData.Time(nbfiles,1)=nbfiles;%default |
---|
474 | end |
---|
475 | else % time from ImaDoc prevails |
---|
476 | RecordData.Time(nbfiles,1)=(time(1,num_i1{1}(ifile),num_j1{1}(ifile))+time(end,num_i2{end}(ifile),num_j2{end}(ifile)))/2; |
---|
477 | end |
---|
478 | else |
---|
479 | nbmissing=nbmissing+1; |
---|
480 | end |
---|
481 | end |
---|
482 | end |
---|
483 | %remove time for global attributes if exists |
---|
484 | for iattr=1:numel(RecordData.ListGlobalAttribute) |
---|
485 | if strcmp(RecordData.ListGlobalAttribute{iattr},'Time') |
---|
486 | RecordData.ListGlobalAttribute(iattr)=[]; |
---|
487 | break |
---|
488 | end |
---|
489 | end |
---|
490 | for ivar=1:numel(RecordData.ListVarName) |
---|
491 | VarName=RecordData.ListVarName{ivar}; |
---|
492 | eval(['RecordData.' VarName '=squeeze(RecordData.' VarName ');']) %remove singletons |
---|
493 | end |
---|
494 | % add time dimension and update VarDimIndex: |
---|
495 | for ivar=1:length(Field.ListVarName) |
---|
496 | DimCell=Field.VarDimName(ivar); |
---|
497 | if testsum(ivar)==2%variable used as time series |
---|
498 | RecordData.VarDimName{ivar}=[{'Time'} DimCell]; |
---|
499 | elseif testsum(ivar)==1 |
---|
500 | RecordData.VarDimName{ivar}=DimCell; |
---|
501 | end |
---|
502 | end |
---|
503 | indexremove=find(~testsum); |
---|
504 | if ~isempty(indexremove) |
---|
505 | RecordData.ListVarName(1+indexremove)=[]; |
---|
506 | RecordData.VarDimName(indexremove)=[]; |
---|
507 | if isfield(RecordData,'Role')&~isempty(RecordData.Role{1})%generaliser aus autres attributs |
---|
508 | RecordData.Role(1+indexremove)=[]; |
---|
509 | end |
---|
510 | end |
---|
511 | |
---|
512 | %shift variable attributes |
---|
513 | if isfield(RecordData,'VarAttribute') |
---|
514 | RecordData.VarAttribute=[{[]} RecordData.VarAttribute]; |
---|
515 | end |
---|
516 | RecordData.VarDimName=[{'Time'} RecordData.VarDimName]; |
---|
517 | RecordData.Action=Series.Action;%name of the processing programme |
---|
518 | |
---|
519 | %name of result file |
---|
520 | [filemean]=... |
---|
521 | name_generator(filebase_out,num_i1{1}(i_slice),num_j1{1}(i_slice),'.nc','_i1-i2_j1-j2',1,num_i2{end}(ifile),num_j2{end}(ifile),subdir_result); |
---|
522 | errormsg=struct2nc(filemean,RecordData); %save result file |
---|
523 | if isempty(errormsg) |
---|
524 | display([filemean ' written']) |
---|
525 | else |
---|
526 | msgbox_uvmat('ERROR',['error in Series/struct2nc' errormsg]) |
---|
527 | end |
---|
528 | end |
---|
529 | |
---|
530 | figure |
---|
531 | haxes=axes; |
---|
532 | |
---|
533 | plot_field(RecordData,haxes) |
---|
534 | hget_field=findobj(allchild(0),'name','get_field'); |
---|
535 | if ~isempty(hget_field) |
---|
536 | delete(hget_field) |
---|
537 | end |
---|
538 | |
---|
539 | get_field(filemean,RecordData) |
---|
540 | |
---|
541 | %----------------------------------------------------------------------- |
---|
542 | % --- Executes on selection change in CoordType. |
---|
543 | function CoordType_Callback(hObject, eventdata, handles) |
---|
544 | menu_str=get(handles.CoordType,'String'); |
---|
545 | ind_coord=get(handles.CoordType,'Value'); |
---|
546 | coord_option=menu_str{ind_coord}; |
---|
547 | if isequal(coord_option,'more...'); |
---|
548 | fct_name=''; |
---|
549 | if exist('./TMP/current_usr_fct.mat','file')% if a file is found |
---|
550 | h=load('./TMP/current_usr_fct.mat'); |
---|
551 | if isfield(h,'fct_name'); |
---|
552 | fct_name=h.fct_name; |
---|
553 | end |
---|
554 | end |
---|
555 | prompt = {'Enter the name of the transform function'}; |
---|
556 | dlg_title = 'user defined transform'; |
---|
557 | num_lines= 1; |
---|
558 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
559 | {'*.m', ' (*.m)'; |
---|
560 | '*.m', '.m files '; ... |
---|
561 | '*.*', 'All Files (*.*)'}, ... |
---|
562 | 'Pick a file', fct_name); |
---|
563 | fct_name=fullfile(PathName,FileName); |
---|
564 | addpath(PathName);%add the path to the selected fct |
---|
565 | [errormsg,date_str]=check_functions;%check whether new functions can oversed the uvmat package A UTILISER |
---|
566 | if ~exist(fct_name,'file') |
---|
567 | warndlg(['image procesing fct ' fct_name ' not found']) |
---|
568 | else |
---|
569 | transform=FileName(1:end-2);% |
---|
570 | update_menu(handles.CoordType,transform)%add the selected fct to the menu |
---|
571 | % set(handles.mouse_coord,'String',menu([1:end-1])')%update the mouse coord menu |
---|
572 | %save ('./TMP/current_usr_fct.mat','fct_name'); |
---|
573 | end |
---|
574 | end |
---|
575 | ind_coord=get(handles.CoordType,'Value'); |
---|
576 | |
---|
577 | %--------------------------------------------------------------------- |
---|
578 | % % --- Executes on selection change in ProjObject. |
---|
579 | % function ProjObject_Callback(hObject, eventdata, handles) |
---|
580 | % |
---|
581 | % list_object=get(handles.ProjObject,'String'); |
---|
582 | % index=get(handles.ProjObject,'Value'); |
---|
583 | % hseries=get(handles.ProjObject,'Parent'); |
---|
584 | % SeriesData=get(hseries,'UserData'); |
---|
585 | % Obj=SeriesData.ProjObject{index}; |
---|
586 | % [SeriesData.hset_object,SeriesData.sethandles]=set_object(SeriesData.ProjObject{index}); |
---|
587 | % set(hseries,'UserData',SeriesData); |
---|
588 | |
---|