Changeset 330 for trunk/src/series
 Timestamp:
 Dec 10, 2011, 2:27:11 PM (12 years ago)
 Location:
 trunk/src/series
 Files:

 1 added
 1 deleted
 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/series/time_series.m
r259 r330 15 15 function GUI_input=time_series(num_i1,num_i2,num_j1,num_j2,Series) 16 16 17 % requests for the visibility of input windows in the GUI series (activated directly by the selection in the menu ACTION)17 %% requests for the visibility of input windows in the GUI series (activated directly by the selection in the menu ACTION) 18 18 if ~exist('num_i1','var') 19 19 GUI_input={'RootPath';'two';...%nbre of possible input series (options 'on'/'two'/'many', default:'one') … … 42 42 hset_object=findobj(allchild(0),'tag','set_object'); 43 43 ProjObject=read_set_object(guidata(hset_object)); 44 %answeryes=questdlg({['field series projected on ' Series.ProjObject.Style]});45 44 answeryes=msgbox_uvmat('INPUT_YN',['field series projected on ' ProjObject.Style]); 46 45 if ~isequal(answeryes,'Yes') … … 52 51 end 53 52 54 %% root names 55 if iscell(Series.RootPath) 56 RootPath=Series.RootPath; 57 RootFile=Series.RootFile; 58 SubDir=Series.SubDir; 59 FileExt=Series.FileExt; 60 NomType=Series.NomType; 61 else 62 RootPath={Series.RootPath}; 63 RootFile={Series.RootFile}; 64 SubDir={Series.SubDir}; 65 FileExt={Series.FileExt}; 66 NomType={Series.NomType}; 53 %% root names: transform input to cell in case of a single input series 54 if ischar(Series.RootPath) 55 Series.RootPath={Series.RootPath}; 56 Series.RootFile={Series.RootFile}; 57 Series.SubDir={Series.SubDir}; 58 Series.FileExt={Series.FileExt}; 59 Series.NomType={Series.NomType}; 67 60 num_i1={num_i1}; 68 61 num_i2={num_i2}; … … 70 63 num_j2={num_j2}; 71 64 end 72 ext=FileExt{1}; 73 form=imformats(ext([2:end]));%test valid Matlab image formats 74 testima=0; 75 if ~isempty(form)isequal(lower(ext),'.avi') 76 testima=1; 77 end 78 nbview=length(RootPath);%number of series (1 or 2) 65 ext=Series.FileExt{1}; 66 form=imformats(ext(2:end));%test valid Matlab image formats 79 67 nbfield=size(num_i1{1},1)*size(num_i1{1},2); %number of fields in the time series 80 68 81 %Number of input series: this function accepts only one or two input file series (sub_field is used in the latter case) 82 nbview=length(RootPath); 83 84 %determine image type 69 %% determine image type 85 70 hhh=which('mmreader'); 86 71 testnetcdf=0; 72 nbview=length(Series.RootPath);%Number of input series: this function accepts only one or two input file series (sub_field is used in the latter case) 87 73 for iview=1:nbview 88 if isequal( FileExt{iview},'.nc')isequal(FileExt{iview},'.cdf')74 if isequal(Series.FileExt{iview},'.nc')isequal(Series.FileExt{iview},'.cdf') 89 75 FileType{iview}='netcdf'; 90 76 testnetcdf=1; 91 elseif isequal(lower( FileExt{iview}),'.avi')92 if ~isequal(hhh,'') && mmreader.isPlatformSupported()93 MovieObject{iview}=mmreader(fullfile( RootPath{iview},[RootFile{iview}FileExt{iview}]));77 elseif isequal(lower(Series.FileExt{iview}),'.avi') 78 if ~isequal(hhh,'')%&& mmreader.isPlatformSupported() 79 MovieObject{iview}=mmreader(fullfile(Series.RootPath{iview},[Series.RootFile{iview} Series.FileExt{iview}])); 94 80 FileType{iview}='movie'; 95 81 else 96 82 FileType{iview}='avi'; 97 83 end 98 elseif isequal(lower( FileExt{iview}),'.vol')84 elseif isequal(lower(Series.FileExt{iview}),'.vol') 99 85 FileType{iview}='vol'; 100 86 else 101 form=imformats( FileExt{iview}(2:end));87 form=imformats(Series.FileExt{iview}(2:end)); 102 88 if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab 103 if isequal( NomType{iview},'*');89 if isequal(Series.NomType{iview},'*'); 104 90 FileType{iview}='multimage'; 105 91 else … … 109 95 end 110 96 end 111 filebase{1}=fullfile( RootPath{1},RootFile{1});112 113 % number of slices114 NbSlice=str2 num(get(hseries.NbSlice,'String'));115 if is empty(NbSlice)97 filebase{1}=fullfile(Series.RootPath{1},Series.RootFile{1}); 98 99 %% number of slices 100 NbSlice=str2double(get(hseries.NbSlice,'String')); 101 if isnan(NbSlice) 116 102 NbSlice=1; 117 103 end 118 NbSlice_name=num2str(NbSlice); 119 120 % Field and velocity type (the same for the two views) 104 105 %% Field and velocity type (the same for the two views) 121 106 if isfield(Series,'Field') 122 107 FieldName=Series.Field;%the same set of fields for all views … … 133 118 delete(hget_field(2:end)) % delete multiple occurerence of the GUI get_fioeld 134 119 elseif isempty(hget_field) 135 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});120 filename=name_generator(filebase{1},num_i1{1}(1),num_j1{1}(1),Series.FileExt{1},Series.NomType{1},1,num_i2{1}(1),num_j2{1}(1),Series.SubDir{1}); 136 121 idetect(iview)=exist(filename,'file'); 137 122 hget_field=get_field(filename); … … 141 126 if isempty(SubField) 142 127 delete(hget_field) 143 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});128 filename=name_generator(filebase{1},num_i1{1}(1),num_j1{1}(1),Series.FileExt{1},Series.NomType{1},1,num_i2{1}(1),num_j2{1}(1),Series.SubDir{1}); 144 129 hget_field=get_field(filename); 145 130 SubField=read_get_field(hget_field); %read the names of the variables to plot in the get_field GUI … … 147 132 end 148 133 149 %detect whether the two files are 'images' or 'netcdf' 150 134 %% detect whether the two files are 'images' or 'netcdf' 151 135 testcivx=0; 152 FileExt=get(hseries.FileExt,'String');136 % FileExt=get(hseries.FileExt,'String'); 153 137 if ~isequal(FieldName,{'get_field...'}) 154 138 testcivx=isequal(FileType{1},'netcdf'); 155 139 end 156 157 140 VelType_str=get(hseries.VelTypeMenu,'String'); 158 141 VelType_val=get(hseries.VelTypeMenu,'Value'); … … 165 148 166 149 %% Calibration data and timing: read the ImaDoc files 167 mode=''; %default150 % mode=''; %default 168 151 timecell={}; 169 152 XmlData={}; … … 172 155 for iview=1:nbview%Loop on views 173 156 XmlData{iview}=[];%default 174 filebase{iview}=fullfile( RootPath{iview},RootFile{iview});157 filebase{iview}=fullfile(Series.RootPath{iview},Series.RootFile{iview}); 175 158 if exist([filebase{iview} '.xml'],'file') 176 159 [XmlData{iview},error]=imadoc2struct([filebase{iview} '.xml']); … … 185 168 end 186 169 end 187 elseif exist([filebase{iview} '.civ'],'file') 170 elseif exist([filebase{iview} '.civ'],'file')%old convention .civ text file 188 171 [error,time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([filebase{iview} '.civ']); 189 172 itime=itime+1; … … 208 191 end 209 192 end 193 time=[];%default 194 if ~isempty(timecell) 195 if numel(timecell{1})<nbfield 196 msgbox_uvmat('WARNING','time array from ImaDoc to short') 197 else 198 time=timecell{1}; %time defined from ImaDoc file (image series) 199 end 200 end 210 201 211 202 %% check coincidence in time 212 multitime=0; 213 if isempty(timecell)214 time=[];215 elseif length(timecell)==1 216 time=timecell{1};217 elseif length(timecell)>1 218 multitime=1;219 for icell=1:length(timecell)220 if ~isequal(size(timecell{icell}),size(timecell{1}))203 if length(timecell)>1 204 for icell=2:length(timecell) 205 if isequal(size(timecell{icell}),size(time)) 206 diff_time=max(abs(timecell{icell}time)); 207 if diff_time>0 208 msgbox_uvmat('WARNING',['times of series differ by more than ' num2str(diff_time)]) 209 break 210 end 211 else 221 212 msgbox_uvmat('WARNING','inconsistent time array dimensions in ImaDoc fields, the time for the first series is used') 222 time=timecell{1};223 multitime=0;224 213 break 225 214 end 226 215 end 227 216 end 228 if multitime 229 for icell=1:length(timecell) 230 time(icell,:,:)=timecell{icell}; 231 end 232 diff_time=max(max(diff(time))); 233 if diff_time>0 234 msgbox_uvmat('WARNING',['times of series differ by more than ' num2str(diff_time)]) 235 end 236 end 237 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' 238 time=[]; 217 if ~isempty(time) 218 display(['time is read from ' filebase{iview} '.xml']) 239 219 end 240 220 241 221 %% Root name of output files (TO GENERALISE FOR TWO INPUT SERIES) 242 222 subdir_result='time_series'; 243 pathdir=fullfile( RootPath{1},subdir_result);223 pathdir=fullfile(Series.RootPath{1},subdir_result); 244 224 while exist(pathdir,'dir') 245 225 subdir_result=[subdir_result '.0']; 246 pathdir=fullfile( RootPath{1},subdir_result);226 pathdir=fullfile(Series.RootPath{1},subdir_result); 247 227 end 248 228 [m1,m2,m3]=mkdir(pathdir); … … 255 235 return 256 236 end 257 258 237 filebase_out=filebase{1}; 259 NomTypeOut=nomtype2pair( NomType{1},num_i2{end}(end)num_i1{1}(1),num_j2{end}(end)num_j1{1}(1));238 NomTypeOut=nomtype2pair(Series.NomType{1},num_i2{end}(end)num_i1{1}(1),num_j2{end}(end)num_j1{1}(1)); 260 239 261 240 %% coordinate transform or other user defined transform … … 276 255 277 256 %% LOOP ON SLICES 257 nbmissing=0; %number of undetected files 278 258 for i_slice=1:NbSlice 279 dt=[]; 280 nbmissing=0; %number of undetected files 281 nbfiles=0; 282 %%%%%%%%%%%%%%%%%%%%%%%%%%%%LOOP ON FIELDS IN A SLICE 283 for ifile=i_slice:NbSlice:nbfield 259 dt=[]; 260 %%%%%%%%%%%%%%%%%%%%%%%%%%%% LOOP ON FIELDS WITHIN A SLICE 261 filecounter=0; 262 for ifile=i_slice:NbSlice:nbfield 284 263 stopstate=get(hseries.RUN,'BusyAction'); 264 errormsg=''; 285 265 if isequal(stopstate,'queue')% enable STOP command 286 update_waitbar(hseries.waitbar,WaitbarPos,ifile/nbfield) 287 for iview=1:nbview 288 filename=... 289 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}); 290 idetect(iview)=exist(filename,'file'); 291 Data{iview}=[]; %default 292 if ~isequal(FileType{iview},'netcdf') 293 Data{iview}.ListVarName={'A'}; 294 Data{iview}.AName='image'; 295 switch FileType{iview} 296 case 'movie' 297 A=read(MovieObject{iview},num_i1{iview}(ifile)); 298 case 'avi' 299 mov=aviread(filename,num_i1{iview}(ifile)); 300 A=frame2im(mov(1)); 301 case 'vol' 302 A=imread(filename); 303 case 'multimage' 304 A=imread(filename,num_i1{iview}(ifile)); 305 case 'image' 306 A=imread(filename); 307 end 308 Data{iview}.ListVarName={'AY','AX','A'}; % 309 npy=size(A,1); 310 npx=size(A,2); 311 nbcolor=size(A,3); 312 if nbcolor==3 313 Data{iview}.VarDimName={'AY','AX',{'AY','AX','rgb'}}; 266 update_waitbar(hseries.waitbar,WaitbarPos,ifile/nbfield) % update the waitbar 267 % loop on views (in case of multiple input series) 268 for iview=1:nbview 269 filename=name_generator(filebase{iview},... 270 num_i1{iview}(ifile),num_j1{iview}(ifile),Series.FileExt{iview},Series.NomType{iview},1,num_i2{iview}(ifile),num_j2{iview}(ifile),Series.SubDir{iview}); 271 if exist(filename,'file') 272 try 273 Data{iview}=[]; %default 274 if ~isequal(FileType{iview},'netcdf') 275 Data{iview}.ListVarName={'A'}; 276 Data{iview}.AName='image'; 277 switch FileType{iview} 278 case 'movie' 279 A=read(MovieObject{iview},num_i1{iview}(ifile)); 280 case 'avi' 281 mov=aviread(filename,num_i1{iview}(ifile)); 282 A=frame2im(mov(1)); 283 case 'vol' 284 A=imread(filename); 285 case 'multimage' 286 A=imread(filename,num_i1{iview}(ifile)); 287 case 'image' 288 A=imread(filename); 289 end 290 Data{iview}.ListVarName={'AY','AX','A'}; % 291 npy=size(A,1); 292 npx=size(A,2); 293 nbcolor=size(A,3); 294 if nbcolor==3 295 Data{iview}.VarDimName={'AY','AX',{'AY','AX','rgb'}}; 296 else 297 Data{iview}.VarDimName={'AY','AX',{'AY','AX'}}; 298 end 299 Data{iview}.AY=[npy0.5 0.5]; 300 Data{iview}.AX=[0.5 npx0.5]; 301 Data{iview}.A=double(A); 302 Data{iview}.CoordUnit='pixel'; 303 elseif testcivx 304 [Data{iview},VelTypeOut]=read_civxdata(filename,FieldName,VelType); 305 if ~isequal(FieldName,{''}) 306 Data{iview}=calc_field(FieldName,Data{iview});%calculate field (vort..) 307 end 308 else 309 [Data{iview},var_detect]=nc2struct(filename,SubField.ListVarName); %read the corresponding input data 310 Data{iview}.VarAttribute=SubField.VarAttribute; 311 end 312 if ~isempty(NbSlice_calib) % z index 313 Data{iview}.ZIndex=mod(num_i1{iview}(ifile)1,NbSlice_calib{1})+1; 314 end 315 catch ME 316 errormsg=ME.message; 317 end 318 else 319 errormsg=[filename ' is missing']; 320 end 321 if isempty(errormsg) 322 % coordinate transform (or other user defined transform) 323 if ~isempty(transform_fct) 324 if nbview==2 325 [Data{1},Data{2}]=transform_fct(Data{1},XmlData{1},Data{2},XmlData{2}); 326 if isempty(Data{2}) 327 Data(2)=[]; 328 end 329 else 330 Data{1}=transform_fct(Data{1},XmlData{1}); 331 end 332 end 333 if length(Data)==2 334 [Field,errormsg]=sub_field(Data{1},Data{2}); %substract the two fields 314 335 else 315 Data{iview}.VarDimName={'AY','AX',{'AY','AX'}}; 316 end 317 Data{iview}.AY=[npy0.5 0.5]; 318 Data{iview}.AX=[0.5 npx0.5]; 319 Data{iview}.A=double(A); 320 Data{iview}.CoordUnit='pixel'; 321 elseif testcivx 322 [Data{iview},VelTypeOut]=read_civxdata(filename,FieldName,VelType); 323 else 324 [Data{iview},var_detect]=nc2struct(filename,SubField.ListVarName); %read the corresponding input data 325 Data{iview}.VarAttribute=SubField.VarAttribute; 336 Field=Data{1}; 337 end 338 if test_object 339 [Field,errormsg]=proj_field(Field,ProjObject); 340 end 326 341 end 327 if ~isempty(NbSlice_calib) % z index 328 Data{iview}.ZIndex=mod(num_i1{iview}(ifile)1,NbSlice_calib{1})+1; 329 end 330 end 331 332 % coordinate transform (or other user defined transform) 333 if ~isempty(transform_fct) 334 % z index 335 if ~isempty(NbSlice_calib) 336 Data{iview}.ZIndex=mod(num_i1{iview}(ifile)1,NbSlice_calib{1})+1;%Zindex for phys transform 337 end 338 if nbview==2 339 [Data{1},Data{2}]=transform_fct(Data{1},XmlData{1},Data{2},XmlData{2}); 340 if isempty(Data{2}) 341 Data(2)=[]; 342 end 343 else 344 Data{1}=transform_fct(Data{1},XmlData{1}); 345 end 346 end 347 if testcivx && ~isequal(FieldName,{''}) 348 Data{iview}=calc_field(FieldName,Data{iview});%calculate field (vort..) 349 end 350 if length(Data)==2 351 [Field,errormsg]=sub_field(Data{1},Data{2}); %substract the two fields 352 if ~isempty(errormsg) 353 msgbox_uvmat('ERROR',['error in time_series/sub_field:' errormsg]) 354 return 355 end 356 else 357 Field=Data{1}; 358 end 359 if test_object 360 [Field,errormsg]=proj_field(Field,ProjObject); 361 if ~isempty(errormsg) 362 msgbox_uvmat('ERROR',['error in time_series/proj_field:' errormsg]) 363 return 364 end 365 end 366 if min(idetect)>=1% the input file(s) have been detected 367 nbfiles=nbfiles+1; 368 if nbfiles==1 %first field: initiate the time series 342 filecounter=filecounter+1; 343 344 % initiate the time series at the first iteration 345 if filecounter==1 346 % stop program if the first field reading is in error 347 if ~isempty(errormsg) 348 msgbox_uvmat('ERROR',['error in time_series/sub_field:' errormsg]) 349 return 350 end 369 351 RecordData=Field;%default 370 RecordData.NbDim=Field.NbDim+1; %add the time dimension for plots 352 RecordData.NbDim=Field.NbDim+1; %add the time dimension for plots 371 353 nbvar=length(Field.ListVarName); 372 354 if nbvar==0 … … 375 357 end 376 358 testsum=2*ones(1,nbvar);%initiate flag for action on each variable 377 indexfalse=0; 378 CoordName={}; 379 indexremove=[]; 380 if isfield(Field,'VarAttribute') % look for coordinate and flag variables 359 if isfield(Field,'VarAttribute') % look for coordinate and flag variables 381 360 for ivar=1:nbvar 382 361 if length(Field.VarAttribute)>=ivar && isfield(Field.VarAttribute{ivar},'Role') 383 %Field.ListVarName{ivar}384 362 var_role=Field.VarAttribute{ivar}.Role;%'role' of the variable 385 363 if isequal(var_role,'errorflag') 386 364 msgbox_uvmat('ERROR','do not handle error flags in time series') 387 return 365 return 388 366 end 389 if isequal(var_role,'warnflag') 390 testsum(ivar)=0; % not recorded variable 367 if isequal(var_role,'warnflag') 368 testsum(ivar)=0; % not recorded variable 391 369 eval(['RecordData=rmfield(RecordData,''' Field.ListVarName{ivar} ''');']);%remove variable 392 end 370 end 393 371 if isequal(var_role,'coord_x') isequal(var_role,'coord_y')... 394 isequal(var_role,'coord_z')isequal(var_role,'coord')372 isequal(var_role,'coord_z')isequal(var_role,'coord') 395 373 testsum(ivar)=1; %constant coordinates, record without time evolution 396 374 end … … 402 380 end 403 381 if numel(DimCell)==1 && isequal(Field.ListVarName{ivar},DimCell{1})%detect dimension variables 404 testsum(ivar)=1;382 testsum(ivar)=1; 405 383 end 406 384 end 407 385 end 408 386 for ivar=1:nbvar 409 if testsum(ivar)==2 387 if testsum(ivar)==2 410 388 eval(['RecordData.' Field.ListVarName{ivar} '=[];']) 411 389 end … … 413 391 RecordData.ListVarName=[{'Time'} RecordData.ListVarName]; 414 392 end 393 394 % add data to the current field 415 395 for ivar=1:length(Field.ListVarName) 416 396 VarName=Field.ListVarName{ivar}; 417 eval(['VarVal=Field.' VarName ';']); 418 if testsum(ivar)==2% test for recorded variable 419 eval(['VarVal=Field.' VarName ';']); 420 if isequal(ProjObject.ProjMode,'inside')% take the average in the domain for 'inside' mode 421 if isempty(VarVal) 422 msgbox_uvmat('ERROR',['empty result at frame index ' num2str(num_i1{iview}(ifile))]) 423 return 424 end 425 VarVal=mean(VarVal,1); 426 end 427 VarVal=shiftdim(VarVal,1); %shift dimension 428 eval(['RecordData.' VarName '=cat(1,RecordData.' VarName ',VarVal);']);%concanete the current field to the time series 397 VarVal=Field.(VarName); 398 if testsum(ivar)==2% test for recorded variable 399 if isempty(errormsg) 400 if isequal(ProjObject.ProjMode,'inside')% take the average in the domain for 'inside' mode 401 if isempty(VarVal) 402 msgbox_uvmat('ERROR',['empty result at frame index ' num2str(num_i1{iview}(ifile))]) 403 return 404 end 405 VarVal=mean(VarVal,1); 406 end 407 VarVal=shiftdim(VarVal,1); %shift dimension 408 RecordData.(VarName)=cat(1,RecordData.(VarName),VarVal);%concanete the current field to the time series 409 else 410 RecordData.(VarName)=cat(1,RecordData.(VarName),0);% put each variable to 0 in case of input reading error 411 end 429 412 elseif testsum(ivar)==1% variable representing fixed coordinates 430 413 eval(['VarInit=RecordData.' VarName ';']); 431 if ~isequal(VarVal,VarInit)414 if isempty(errormsg) && ~isequal(VarVal,VarInit) 432 415 msgbox_uvmat('ERROR',['time series requires constant coordinates ' VarName]) 433 416 return 434 417 end 435 end 418 end 436 419 end 437 % time: 420 421 % record the time: 438 422 if isempty(time)% time read in ncfiles 439 if isfield(Field,'Time')440 RecordData.Time(nbfiles,1)=Field.Time;441 else442 RecordData.Time(nbfiles,1)=nbfiles;%default443 end423 if isfield(Field,'Time') 424 RecordData.Time(filecounter,1)=Field.Time; 425 else 426 RecordData.Time(filecounter,1)=ifile;%default 427 end 444 428 else % time from ImaDoc prevails 445 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;429 RecordData.Time(filecounter,1)=(time(1,num_i1{1}(ifile),num_j1{1}(ifile))+time(end,num_i2{end}(ifile),num_j2{end}(ifile)))/2; 446 430 end 447 else 448 nbmissing=nbmissing+1; 431 432 % record the number of missing input fields 433 if ~isempty(errormsg) 434 nbmissing=nbmissing+1; 435 display(['ifile=' num2str(ifile) ':' errormsg]) 436 end 449 437 end 450 438 end 451 439 end 440 %%%%%%% END OF LOOP WITHIN A SLICE 441 452 442 %remove time for global attributes if exists 453 for iattr=1:numel(RecordData.ListGlobalAttribute) 443 for iattr=1:numel(RecordData.ListGlobalAttribute) 454 444 if strcmp(RecordData.ListGlobalAttribute{iattr},'Time') 455 445 RecordData.ListGlobalAttribute(iattr)=[]; … … 461 451 eval(['RecordData.' VarName '=squeeze(RecordData.' VarName ');']) %remove singletons 462 452 end 463 % add time dimension and update VarDimIndex: 464 for ivar=1:length(Field.ListVarName) 465 DimCell=Field.VarDimName(ivar); 466 if testsum(ivar)==2%variable used as time series 467 RecordData.VarDimName{ivar}=[{'Time'} DimCell]; 468 elseif testsum(ivar)==1 469 RecordData.VarDimName{ivar}=DimCell; 470 end 471 end 453 454 % add time dimension 455 for ivar=1:length(Field.ListVarName) 456 DimCell=Field.VarDimName(ivar); 457 if testsum(ivar)==2%variable used as time series 458 RecordData.VarDimName{ivar}=[{'Time'} DimCell]; 459 elseif testsum(ivar)==1 460 RecordData.VarDimName{ivar}=DimCell; 461 end 462 end 472 463 indexremove=find(~testsum); 473 464 if ~isempty(indexremove) 474 465 RecordData.ListVarName(1+indexremove)=[]; 475 466 RecordData.VarDimName(indexremove)=[]; 476 if isfield(RecordData,'Role') &~isempty(RecordData.Role{1})%generaliser aus autres attributs467 if isfield(RecordData,'Role') && ~isempty(RecordData.Role{1})%generaliser aus autres attributs 477 468 RecordData.Role(1+indexremove)=[]; 478 469 end 479 470 end 480 471 481 472 %shift variable attributes 482 473 if isfield(RecordData,'VarAttribute') 483 474 RecordData.VarAttribute=[{[]} RecordData.VarAttribute]; 484 end 475 end 485 476 RecordData.VarDimName=[{'Time'} RecordData.VarDimName]; 486 477 RecordData.Action=Series.Action;%name of the processing programme 478 test_time=diff(RecordData.Time)>0;% test that the readed time is increasing (not constant) 479 if ~test_time 480 RecordData.Time=[1:filecounter]; 481 end 482 483 % display nbmissing 484 if ~isequal(nbmissing,0) 485 msgbox_uvmat('WARNING',[num2str(nbmissing) ' files skipped: missing files or bad input, see command window display']) 486 end 487 487 488 488 %name of result file 489 % RecordData490 % RecordData.VarDimName{1}491 % RecordData.VarDimName{2}492 % RecordData.VarDimName{3}493 % RecordData.VarDimName{4}494 % RecordData.VarDimName{5}495 % RecordData.VarDimName{6}496 489 [filemean]=... 497 490 name_generator(filebase_out,num_i1{1}(i_slice),num_j1{1}(i_slice),'.nc','_i1i2_j1j2',1,num_i2{end}(ifile),num_j2{end}(ifile),subdir_result); 498 491 errormsg=struct2nc(filemean,RecordData); %save result file 499 492 if isempty(errormsg) … … 504 497 end 505 498 499 %% plot the time series (the last one in case of multislices) 506 500 figure 507 501 haxes=axes; 508 509 502 plot_field(RecordData,haxes) 503 504 %% display the result file using the GUI get_field 510 505 hget_field=findobj(allchild(0),'name','get_field'); 511 506 if ~isempty(hget_field) 512 507 delete(hget_field) 513 508 end 514 515 509 get_field(filemean,RecordData) 516 510 517 % 511 % 518 512 %  Executes on selection change in CoordType. 519 513 function CoordType_Callback(hObject, eventdata, handles) 514 % 520 515 menu_str=get(handles.CoordType,'String'); 521 516 ind_coord=get(handles.CoordType,'Value');
Note: See TracChangeset
for help on using the changeset viewer.