Changeset 474 for trunk/src/series
- Timestamp:
- Jun 25, 2012, 12:14:16 AM (13 years ago)
- Location:
- trunk/src/series
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/series/aver_stat.m
r470 r474 31 31 % each line decomposed as {RootPath,SubDir,Rootfile,NomType,Extension} 32 32 % .OutputSubDir: name of the subdirectory for data outputs 33 % .OutputDir : directory for data outputs, including path33 % .OutputDirExt: directory extension for data outputs 34 34 % .Action: .ActionName: name of the current activated function 35 35 % .ActionPath: path of the current activated function … … 50 50 %% set the input elements needed on the GUI series when the action is selected in the menu ActionName 51 51 if ~exist('Param','var') % case with no input parameter 52 ParamOut={'NbViewMax';2;...% max nbre of input file series (default='' , no limitation) 53 'AllowInputSort';'off';...% allow alphabetic sorting of the list of input files (options 'off'/'on', 'off' by default) 52 ParamOut={'AllowInputSort';'off';...% allow alphabetic sorting of the list of input files (options 'off'/'on', 'off' by default) 54 53 'WholeIndexRange';'off';...% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default) 55 54 'NbSlice';'on'; ...%nbre of slices ('off' by default) … … 64 63 end 65 64 66 %%%%%%%%%%%% STANDARD PART (DO NOT EDIT)%%%%%%%%%%%%65 %%%%%%%%%%%% STANDARD PART %%%%%%%%%%%% 67 66 %% select different modes, RUN, parameter input, BATCH 68 67 % BATCH case: read the xml file for batch case … … 81 80 end 82 81 ParamOut=Param; %default output 83 82 OutputDir=[Param.OutputSubDir Param.OutputDirExt]; 83 84 84 %% root input file(s) and type 85 85 RootPath=Param.InputTable(:,1); … … 88 88 NomType=Param.InputTable(:,4); 89 89 FileExt=Param.InputTable(:,5); 90 91 % get the set of input file names (cell array filecell), and the lists of92 % input file or frame indices i1_series,i2_series,j1_series,j2_series93 90 [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param); 94 % filecell{iview,fileindex}: cell array representing the list of file names 91 %%%%%%%%%%%% 92 % The cell array filecell is the list of input file names, while 93 % filecell{iview,fileindex}: 95 94 % iview: line in the table corresponding to a given file series 96 95 % fileindex: file index within the file series, 97 96 % i1_series(iview,ref_j,ref_i)... are the corresponding arrays of indices i1,i2,j1,j2, depending on the input line iview and the two reference indices ref_i,ref_j 98 97 % i1_series(iview,fileindex) expresses the same indices as a 1D array in file indices 99 % set of frame indices used for movie or multimage input 100 % numbers of slices and file indices 101 98 %%%%%%%%%%%% 102 99 NbSlice=1;%default 103 100 if isfield(Param.IndexRange,'NbSlice')&&~isempty(Param.IndexRange.NbSlice) … … 140 137 %% coordinate transform or other user defined transform 141 138 transform_fct='';%default 142 if isfield(Param,'FieldTransform')&&isfield(Param.FieldTransform,'TransformHandle') 143 transform_fct=Param.FieldTransform.TransformHandle; 144 end 139 if isfield(Param,'FieldTransform') 140 addpath(Param.FieldTransform.TransformPath) 141 transform_fct=str2func(Param.FieldTransform.TransformName); 142 rmpath(Param.FieldTransform.TransformPath) 143 end 144 145 145 %%%%%%%%%%%% END STANDARD PART %%%%%%%%%%%% 146 146 % EDIT FROM HERE … … 160 160 end 161 161 NomTypeOut='_1-2_1';% output file index will indicate the first and last ref index in the series 162 if NbSlice~=nbfield_j 163 answer=msgbox_uvmat('INPUT_Y-N',['will not average slice by slice: for so cancel and set NbSlice= ' num2str(nbfield_j)]); 164 if ~strcmp(answer,'Yes') 165 return 166 end 162 if checkrun==1 163 return % stop here for input checks 167 164 end 168 165 … … 185 182 end 186 183 187 %% Initiate output fields188 % %initiate the output structure as a copy of the first input one (reproduce fields)189 % [DataOut,ParamOut,errormsg] = read_field(filecell{1,1},FileType{1},InputFields{1},1);190 % if ~isempty(errormsg)191 % msgbox_uvmat('ERROR',['error reading ' filecell{1,1} ': ' errormsg])192 % return193 % end194 % time_1=[];195 % if isfield(DataOut,'Time')196 % time_1=DataOut.Time(1);197 % end198 % if CheckNc{iview}199 % if isempty(strcmp('Conventions',DataOut.ListGlobalAttribute))200 % DataOut.ListGlobalAttribute=['Conventions' DataOut.ListGlobalAttribute];201 % end202 % DataOut.Conventions='uvmat';203 % DataOut.ListGlobalAttribute=[DataOut.ListGlobalAttribute {Param.Action}];204 % ActionKey='Action';205 % while isfield(DataOut,ActionKey)206 % ActionKey=[ActionKey '_1'];207 % end208 % DataOut.(ActionKey)=Param.Action;209 % DataOut.ListGlobalAttribute=[DataOut.ListGlobalAttribute {ActionKey}];210 % if isfield(DataOut,'Time')211 % DataOut.ListGlobalAttribute=[DataOut.ListGlobalAttribute {'Time','Time_end'}];212 % end213 % end214 215 184 %% MAIN LOOP ON SLICES 216 185 %%%%%%%%%%%%% STANDARD PART (DO NOT EDIT) %%%%%%%%%%%% … … 219 188 nbfiles=0; 220 189 nbmissing=0; 221 222 %initiate result fields 223 % for ivar=1:length(DataOut.ListVarName) 224 % DataOut.(DataOut.ListVarName{ivar})=0; % initialise all fields to zero 225 % end 226 190 227 191 %%%%%%%%%%%%%%%% loop on field indices %%%%%%%%%%%%%%%% 228 192 for index=index_slice … … 350 314 351 315 %writing the result file 352 OutputFile=fullfile_uvmat(RootPath{1}, Param.OutputSubDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(1),i1_series{1}(end),i_slice,[]);316 OutputFile=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(1),i1_series{1}(end),i_slice,[]); 353 317 if CheckImage{1} %case of images 354 318 if isequal(FileInfo{1}.BitDepth,16)||(numel(FileInfo)==2 &&isequal(FileInfo{2}.BitDepth,16)) -
trunk/src/series/merge_proj.m
r470 r474 1 %'merge_proj': project and concatene fields merge_proj2 % can be used as a template for applying an operation (here projection and concate antion) on each field of an input series1 %'merge_proj': project and concatene fields 2 % can be used as a template for applying an operation (here projection and concatenation) on each field of an input series 3 3 %------------------------------------------------------------------------ 4 4 % function ParamOut=merge_proj(Param) … … 32 32 % each line decomposed as {RootPath,SubDir,Rootfile,NomType,Extension} 33 33 % .OutputSubDir: name of the subdirectory for data outputs 34 % .OutputDir : directory for data outputs, including path34 % .OutputDirExt: directory extension for data outputs 35 35 % .Action: .ActionName: name of the current activated function 36 36 % .ActionPath: path of the current activated function … … 51 51 %% set the input elements needed on the GUI series when the action is selected in the menu ActionName 52 52 if ~exist('Param','var') % case with no input parameter 53 ParamOut={'NbViewMax';'';...% max nbre of input file series (default='' , no limitation) 54 'AllowInputSort';'off';...% allow alphabetic sorting of the list of input files (options 'off'/'on', 'off' by default) 53 ParamOut={'AllowInputSort';'off';...% allow alphabetic sorting of the list of input files (options 'off'/'on', 'off' by default) 55 54 'WholeIndexRange';'off';...% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default) 56 55 'NbSlice';'on'; ...%nbre of slices ('off' by default) … … 82 81 end 83 82 ParamOut=Param; %default output 83 OutputSubDir=[Param.OutputSubDir Param.OutputDirExt]; 84 84 85 85 %% root input file(s) and type … … 89 89 NomType=Param.InputTable(:,4); 90 90 FileExt=Param.InputTable(:,5); 91 92 % get the set of input file names (cell array filecell), and the lists of93 % input file or frame indices i1_series,i2_series,j1_series,j2_series94 91 [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param); 95 % filecell{iview,fileindex}: cell array representing the list of file names 92 %%%%%%%%%%%% 93 % The cell array filecell is the list of input file names, while 94 % filecell{iview,fileindex}: 96 95 % iview: line in the table corresponding to a given file series 97 96 % fileindex: file index within the file series, 98 97 % i1_series(iview,ref_j,ref_i)... are the corresponding arrays of indices i1,i2,j1,j2, depending on the input line iview and the two reference indices ref_i,ref_j 99 98 % i1_series(iview,fileindex) expresses the same indices as a 1D array in file indices 100 % set of frame indices used for movie or multimage input 101 % numbers of slices and file indices 102 99 %%%%%%%%%%%% 103 100 NbSlice=1;%default 104 101 if isfield(Param.IndexRange,'NbSlice')&&~isempty(Param.IndexRange.NbSlice) … … 117 114 for iview=1:nbview 118 115 if ~exist(filecell{iview,1}','file') 119 msgbox_uvmat('ERROR',['the first input file ' filecell{iview,1} ' does not exist'])116 displ_uvmat('ERROR',['the first input file ' filecell{iview,1} ' does not exist'],checkrun) 120 117 return 121 118 end … … 135 132 if size(time,1)>1 136 133 diff_time=max(max(diff(time))); 137 if diff_time>0 138 msgbox_uvmat('WARNING',['times of series differ by (max) ' num2str(diff_time)])134 if diff_time>0 135 displ_uvmat('WARNING',['times of series differ by (max) ' num2str(diff_time)],checkrun) 139 136 end 140 137 end 141 142 138 143 139 %% coordinate transform or other user defined transform 144 140 transform_fct='';%default 145 if isfield(Param,'FieldTransform')&&isfield(Param.FieldTransform,'TransformHandle') 146 transform_fct=Param.FieldTransform.TransformHandle; 147 end 141 if isfield(Param,'FieldTransform') 142 addpath(Param.FieldTransform.TransformPath) 143 transform_fct=str2func(Param.FieldTransform.TransformName); 144 rmpath(Param.FieldTransform.TransformPath) 145 end 146 148 147 %%%%%%%%%%%% END STANDARD PART %%%%%%%%%%%% 149 148 % EDIT FROM HERE … … 154 153 elseif CheckNc{1} 155 154 FileExtOut='.nc';% write result as .nc files for netcdf inputs 156 else 157 msgbox_uvmat('ERROR',['invalid file type input ' FileType{1}])155 else 156 displ_uvmat('ERROR',['invalid file type input ' FileType{1}],checkrun) 158 157 return 159 158 end 160 159 for iview=1:nbview 161 160 if ~isequal(CheckImage{iview},CheckImage{1})||~isequal(CheckNc{iview},CheckNc{1}) 162 msgbox_uvmat('ERROR','input set of input series: need either netcdf either image series')161 displ_uvmat('ERROR','input set of input series: need either netcdf either image series',checkrun) 163 162 return 164 163 end 165 164 end 166 165 NomTypeOut=NomType;% output file index will indicate the first and last ref index in the series 166 if checkrun==1 167 ParamOut.Specific=[];%no specific parameter 168 return %stop here for interactive input (option Param.Specific='?') 169 end 167 170 168 171 %% Set field names and velocity types 169 172 %use Param.InputFields for all views 170 171 %% Initiate output fields172 %initiate the output structure as a copy of the first input one (reproduce fields)173 [DataOut,tild,errormsg] = read_field(filecell{1,1},FileType{1},Param.InputFields,1);174 if ~isempty(errormsg)175 msgbox_uvmat('ERROR',['error reading ' filecell{1,1} ': ' errormsg])176 return177 end178 time_1=[];179 if isfield(DataOut,'Time')180 time_1=DataOut.Time(1);181 end182 if CheckNc{iview}183 if isempty(strcmp('Conventions',DataOut.ListGlobalAttribute))184 DataOut.ListGlobalAttribute=['Conventions' DataOut.ListGlobalAttribute];185 end186 DataOut.Conventions='uvmat';187 DataOut.ListGlobalAttribute=[DataOut.ListGlobalAttribute {Param.Action}];188 ActionKey='Action';189 while isfield(DataOut,ActionKey)190 ActionKey=[ActionKey '_1'];191 end192 DataOut.(ActionKey)=Param.Action;193 DataOut.ListGlobalAttribute=[DataOut.ListGlobalAttribute {ActionKey}];194 if isfield(DataOut,'Time')195 DataOut.ListGlobalAttribute=[DataOut.ListGlobalAttribute {'Time','Time_end'}];196 end197 end198 173 199 174 %% MAIN LOOP ON SLICES … … 203 178 nbfiles=0; 204 179 nbmissing=0; 205 206 %initiate result fields 207 208 for ivar=1:length(DataOut.ListVarName) 209 DataOut.(DataOut.ListVarName{ivar})=0; % initialise all fields to zero 210 end 211 180 212 181 %%%%%%%%%%%%%%%% loop on field indices %%%%%%%%%%%%%%%% 213 182 for index=index_slice … … 227 196 [Data{iview},tild,errormsg] = read_field(filecell{iview,index},FileType{iview},Param.InputFields,frame_index{iview}(index)); 228 197 if ~isempty(errormsg) 229 errormsg=['error of input reading: ' errormsg]; 198 errormsg=['merge_proj/read_field/' errormsg]; 199 display(errormsg) 230 200 break 231 201 end … … 251 221 [Data{iview},errormsg]=proj_field(Data{iview},Param.ProjObject); 252 222 if ~isempty(errormsg) 253 msgbox_uvmat('ERROR',['error in merge_proge/proj_field: ' errormsg])223 displ_uvmat('ERROR',['error in merge_proge/proj_field: ' errormsg],checkrun) 254 224 return 255 225 end … … 261 231 MergeData=merge_field(Data); 262 232 if isfield(MergeData,'Txt') 263 msgbox_uvmat('ERROR',MergeData.Txt)233 displ_uvmat('ERROR',MergeData.Txt,checkrun) 264 234 return 265 235 end … … 288 258 end 289 259 end 290 OutputFile=fullfile_uvmat(RootPath{1}, Param.OutputSubDir,RootFile{1},FileExtOut,NomType{1},i1,i2,j1,j2);260 OutputFile=fullfile_uvmat(RootPath{1},OutputSubDir,RootFile{1},FileExtOut,NomType{1},i1,i2,j1,j2); 291 261 292 262 % recording the merged field … … 387 357 else 388 358 if length(ivar_Y)~=1 389 msgbox_uvmat('ERROR','y coordinate missing in proj_field.m')359 displ_uvmat('ERROR','y coordinate missing in proj_field.m',checkrun) 390 360 return 391 361 end -
trunk/src/series/sub_background.m
r462 r474 38 38 % each line decomposed as {RootPath,SubDir,Rootfile,NomType,Extension} 39 39 % .OutputSubDir: name of the subdirectory for data outputs 40 % .OutputDir : directory for data outputs, including path40 % .OutputDirExt: extension for the directory for data outputs 41 41 % .Action: .ActionName: name of the current activated function 42 42 % .ActionPath: path of the current activated function … … 58 58 %% set the input elements needed on the GUI series when the action is selected in the menu ActionName 59 59 if ~exist('Param','var') % case with no input parameter 60 ParamOut={'NbViewMax';1;...% max nbre of input file series (default='' , no limitation) 61 'AllowInputSort';'off';...% allow alphabetic sorting of the list of input files (options 'off'/'on', 'off' by default) 60 ParamOut={'AllowInputSort';'off';...% allow alphabetic sorting of the list of input files (options 'off'/'on', 'off' by default) 62 61 'WholeIndexRange';'on';...% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default) 63 62 'NbSlice';'on'; ...%nbre of slices ('off' by default) … … 89 88 end 90 89 ParamOut=Param; %default output 90 OutputDir=[Param.OutputSubDir Param.OutputDirExt]; 91 91 92 92 %% root input file(s) and type … … 96 96 NomType=Param.InputTable(:,4); 97 97 FileExt=Param.InputTable(:,5); 98 99 % get the set of input file names (cell array filecell), and the lists of100 % input file or frame indices i1_series,i2_series,j1_series,j2_series101 98 [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param); 102 % filecell{iview,fileindex}: cell array representing the list of file names 99 %%%%%%%%%%%% 100 % The cell array filecell is the list of input file names, while 101 % filecell{iview,fileindex}: 103 102 % iview: line in the table corresponding to a given file series 104 103 % fileindex: file index within the file series, 105 104 % i1_series(iview,ref_j,ref_i)... are the corresponding arrays of indices i1,i2,j1,j2, depending on the input line iview and the two reference indices ref_i,ref_j 106 105 % i1_series(iview,fileindex) expresses the same indices as a 1D array in file indices 107 % set of frame indices used for movie or multimage input 108 % numbers of slices and file indices 109 106 %%%%%%%%%%%% 110 107 NbSlice=1;%default 111 108 if isfield(Param.IndexRange,'NbSlice')&&~isempty(Param.IndexRange.NbSlice) … … 340 337 j1=j1_series{1}(ifile); 341 338 end 342 newname=fullfile_uvmat(RootPath{1}, Param.OutputSubDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(ifile),[],j1);339 newname=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(ifile),[],j1); 343 340 344 341 %write result file … … 390 387 j1=j1_series{1}(ifile); 391 388 end 392 newname=fullfile_uvmat(RootPath{1}, Param.OutputSubDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(ifile),[],j1);389 newname=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(ifile),[],j1); 393 390 %write result file 394 391 if ParamOut.Specific.CheckLevelTransform … … 424 421 j1=j1_series{1}(ifile); 425 422 end 426 newname=fullfile_uvmat(RootPath{1}, Param.OutputSubDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(ifile),[],j1);423 newname=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(ifile),[],j1); 427 424 428 425 %write result file -
trunk/src/series/time_series.m
r470 r474 31 31 % each line decomposed as {RootPath,SubDir,Rootfile,NomType,Extension} 32 32 % .OutputSubDir: name of the subdirectory for data outputs 33 % .OutputDir : directory for data outputs, including path33 % .OutputDirExt: directory extension for data outputs 34 34 % .Action: .ActionName: name of the current activated function 35 35 % .ActionPath: path of the current activated function … … 50 50 %% set the input elements needed on the GUI series when the action is selected in the menu ActionName 51 51 if ~exist('Param','var') % case with no input parameter 52 ParamOut={'NbViewMax';2;...% max nbre of input file series (default='' , no limitation) 53 'AllowInputSort';'off';...% allow alphabetic sorting of the list of input files (options 'off'/'on', 'off' by default) 52 ParamOut={'AllowInputSort';'off';...% allow alphabetic sorting of the list of input files (options 'off'/'on', 'off' by default) 54 53 'WholeIndexRange';'off';...% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default) 55 54 'NbSlice';'on'; ...%nbre of slices ('off' by default) … … 81 80 end 82 81 ParamOut=Param; %default output 82 OutputDir=[Param.OutputSubDir Param.OutputDirExt]; 83 83 84 84 %% root input file(s) and type … … 116 116 for iview=1:nbview 117 117 if ~exist(filecell{iview,1}','file') 118 msgbox_uvmat('ERROR',['the first input file ' filecell{iview,1} ' does not exist'])118 displ_uvmat('ERROR',['the first input file ' filecell{iview,1} ' does not exist'],checkrun) 119 119 return 120 120 end … … 134 134 diff_time=max(max(diff(time))); 135 135 if diff_time>0 136 msgbox_uvmat('WARNING',['times of series differ by (max) ' num2str(diff_time)])136 displ_uvmat('WARNING',['times of series differ by (max) ' num2str(diff_time)],checkrun) 137 137 end 138 138 end … … 140 140 %% coordinate transform or other user defined transform 141 141 transform_fct='';%default 142 if isfield(Param,'FieldTransform')&&isfield(Param.FieldTransform,'TransformHandle') 143 transform_fct=Param.FieldTransform.TransformHandle; 144 end 142 if isfield(Param,'FieldTransform') 143 addpath(Param.FieldTransform.TransformPath) 144 transform_fct=str2func(Param.FieldTransform.TransformName); 145 rmpath(Param.FieldTransform.TransformPath) 146 end 147 145 148 %%%%%%%%%%%% END STANDARD PART %%%%%%%%%%%% 146 149 % EDIT FROM HERE … … 152 155 FileExtOut='.nc';% write result as .nc files for netcdf inputs 153 156 else 154 msgbox_uvmat('ERROR',['invalid file type input ' FileType{1}])157 displ_uvmat('ERROR',['invalid file type input ' FileType{1}],checkrun) 155 158 return 156 159 end 157 160 if nbview==2 && ~isequal(CheckImage{1},CheckImage{2}) 158 msgbox_uvmat('ERROR','input must be two image series or two netcdf file series')161 displ_uvmat('ERROR','input must be two image series or two netcdf file series',checkrun) 159 162 return 160 163 end 161 164 NomTypeOut='_1-2_1';% output file index will indicate the first and last ref index in the series 162 if NbSlice~=nbfield_j163 answer=msgbox_uvmat('INPUT_Y-N',['will not average slice by slice: for so cancel and set NbSlice= ' num2str(nbfield_j)]);164 if ~strcmp(answer,'Yes')165 return166 end167 end165 % if NbSlice~=nbfield_j 166 % answer=_uvmat('INPUT_Y-N',['will not average slice by slice: for so cancel and set NbSlice= ' num2str(nbfield_j)]); 167 % if ~strcmp(answer,'Yes') 168 % return 169 % end 170 % end 168 171 169 172 %% Set field names and velocity types … … 211 214 [DataOut,tild,errormsg] = read_field(filecell{1,1},FileType{1},InputFields{1},1); 212 215 if ~isempty(errormsg) 213 msgbox_uvmat('ERROR',['error reading ' filecell{1,1} ': ' errormsg])216 displ_uvmat('ERROR',['error reading ' filecell{1,1} ': ' errormsg],checkrun) 214 217 return 215 218 end … … 238 241 nbmissing=0; %number of undetected files 239 242 for i_slice=1:NbSlice 240 dt=[]; 241 %%%%%%%%%%%%%%%%%%%%%%%%%%%% LOOP ON FIELDS WITHIN A SLICE 242 filecounter=0; 243 for ifile=i_slice:NbSlice:nbfield 243 index_slice=i_slice:NbSlice:nbfield;% select file indices of the slice 244 nbfiles=0; 245 nbmissing=0; 246 247 %%%%%%%%%%%%%%%% loop on field indices %%%%%%%%%%%%%%%% 248 for index=index_slice 244 249 if checkrun 245 update_waitbar(hseries.waitbar_frame,WaitbarPos,i file/nbfield)250 update_waitbar(hseries.waitbar_frame,WaitbarPos,index/(nbfield)) 246 251 stopstate=get(hseries.RUN,'BusyAction'); 247 252 else 248 253 stopstate='queue'; 249 254 end 250 errormsg=''; 255 256 %%%%%%%%%%%%%%%% loop on views (input lines) %%%%%%%%%%%%%%%% 257 Data=cell(1,nbview);%initiate the set Data 258 nbtime=0; 259 dt=[]; 251 260 if isequal(stopstate,'queue')% enable STOP command 252 261 % loop on views (in case of multiple input series) 253 262 for iview=1:nbview 254 filename=filecell{iview,ifile}; 255 % filename=name_generator(filebase{iview},... 256 % i1_series{iview}(ifile),j1_series{iview}(ifile),FileExt{iview},NomType{iview},1,i2_series{iview}(ifile),j2_series{iview}(ifile),SubDir{iview}); 257 if exist(filename,'file') 258 try 259 Data{iview}=[]; %default 260 if ~isequal(FileType{iview},'netcdf') 261 Data{iview}.ListVarName={'A'}; 262 Data{iview}.AName='image'; 263 switch FileType{iview} 264 case 'movie' 265 A=read(MovieObject{iview},i1_series{iview}(ifile)); 266 case 'avi' 267 mov=aviread(filename,i1_series{iview}(ifile)); 268 A=frame2im(mov(1)); 269 case 'vol' 270 A=imread(filename); 271 case 'multimage' 272 A=imread(filename,i1_series{iview}(ifile)); 273 case 'image' 274 A=imread(filename); 275 end 276 Data{iview}.ListVarName={'AY','AX','A'}; % 277 npy=size(A,1); 278 npx=size(A,2); 279 nbcolor=size(A,3); 280 if nbcolor==3 281 Data{iview}.VarDimName={'AY','AX',{'AY','AX','rgb'}}; 282 else 283 Data{iview}.VarDimName={'AY','AX',{'AY','AX'}}; 284 end 285 Data{iview}.AY=[npy-0.5 0.5]; 286 Data{iview}.AX=[0.5 npx-0.5]; 287 Data{iview}.A=double(A); 288 Data{iview}.CoordUnit='pixel'; 289 elseif testcivx 290 [Data{iview},VelTypeOut]=read_civxdata(filename,FieldName,VelType); 291 if ~isequal(FieldName,{''}) 292 Data{iview}=calc_field(FieldName,Data{iview});%calculate field (vort..) 293 end 294 else 295 [Data{iview},var_detect]=nc2struct(filename,SubField.ListVarName); %read the corresponding input data 296 Data{iview}.VarAttribute=SubField.VarAttribute; 297 end 298 if ~isempty(NbSlice_calib) % z index 299 Data{iview}.ZIndex=mod(i1_series{iview}(ifile)-1,NbSlice_calib{1})+1; 300 end 301 catch ME 302 errormsg=ME.message; 263 % reading input file(s) 264 [Data{iview},tild,errormsg] = read_field(filecell{iview,index},FileType{iview},Param.InputFields,frame_index{iview}(index)); 265 if ~isempty(errormsg) 266 errormsg=['time_series/read_field/' errormsg]; 267 display(errormsg) 268 break 269 end 270 timeread(iview)=0; 271 if isfield(Data{iview},'Time') 272 timeread(iview)=Data{iview}.Time; 273 nbtime=nbtime+1; 274 end 275 if ~isempty(NbSlice_calib) 276 Data{iview}.ZIndex=mod(i1_series{iview}(index)-1,NbSlice_calib{iview})+1;%Zindex for phys transform 277 end 278 end 279 % coordinate transform (or other user defined transform) 280 if ~isempty(transform_fct) 281 if nbview==2 282 [Data{1},Data{2}]=transform_fct(Data{1},XmlData{1},Data{2},XmlData{2}); 283 if isempty(Data{2}) 284 Data(2)=[]; 303 285 end 304 286 else 305 errormsg=[filename ' is missing']; 306 end 307 if isempty(errormsg) 308 % coordinate transform (or other user defined transform) 309 if ~isempty(transform_fct) 310 if nbview==2 311 [Data{1},Data{2}]=transform_fct(Data{1},XmlData{1},Data{2},XmlData{2}); 312 if isempty(Data{2}) 313 Data(2)=[]; 287 Data{1}=transform_fct(Data{1},XmlData{1}); 288 end 289 end 290 if length(Data)==2 291 [Field,errormsg]=sub_field(Data{1},Data{2}); %substract the two fields 292 else 293 Field=Data{1}; 294 end 295 if Param.CheckObject 296 [Field,errormsg]=proj_field(Field,Param.ProjObject); 297 end 298 nbtime=nbtime+1; 299 300 % initiate the time series at the first iteration 301 if nbtime==1 302 % stop program if the first field reading is in error 303 if ~isempty(errormsg) 304 displ_uvmat('ERROR',['error in time_series/sub_field:' errormsg],checkrun) 305 return 306 end 307 DataOut=Field;%default 308 DataOut.NbDim=Field.NbDim+1; %add the time dimension for plots 309 nbvar=length(Field.ListVarName); 310 if nbvar==0 311 displ_uvmat('ERROR','no input variable selected in get_field',checkrun) 312 return 313 end 314 testsum=2*ones(1,nbvar);%initiate flag for action on each variable 315 if isfield(Field,'VarAttribute') % look for coordinate and flag variables 316 for ivar=1:nbvar 317 if length(Field.VarAttribute)>=ivar && isfield(Field.VarAttribute{ivar},'Role') 318 var_role=Field.VarAttribute{ivar}.Role;%'role' of the variable 319 if isequal(var_role,'errorflag') 320 displ_uvmat('ERROR','do not handle error flags in time series',checkrun) 321 return 314 322 end 315 else 316 Data{1}=transform_fct(Data{1},XmlData{1}); 323 if isequal(var_role,'warnflag') 324 testsum(ivar)=0; % not recorded variable 325 eval(['DataOut=rmfield(DataOut,''' Field.ListVarName{ivar} ''');']);%remove variable 326 end 327 if isequal(var_role,'coord_x')| isequal(var_role,'coord_y')|... 328 isequal(var_role,'coord_z')|isequal(var_role,'coord') 329 testsum(ivar)=1; %constant coordinates, record without time evolution 330 end 331 end 332 % check whether the variable ivar is a dimension variable 333 DimCell=Field.VarDimName{ivar}; 334 if ischar(DimCell) 335 DimCell={DimCell}; 336 end 337 if numel(DimCell)==1 && isequal(Field.ListVarName{ivar},DimCell{1})%detect dimension variables 338 testsum(ivar)=1; 317 339 end 318 340 end 319 if length(Data)==2 320 [Field,errormsg]=sub_field(Data{1},Data{2}); %substract the two fields 341 end 342 for ivar=1:nbvar 343 if testsum(ivar)==2 344 eval(['DataOut.' Field.ListVarName{ivar} '=[];']) 345 end 346 end 347 DataOut.ListVarName=[{'Time'} DataOut.ListVarName]; 348 end 349 350 % add data to the current field 351 for ivar=1:length(Field.ListVarName) 352 VarName=Field.ListVarName{ivar}; 353 VarVal=Field.(VarName); 354 if testsum(ivar)==2% test for recorded variable 355 if isempty(errormsg) 356 if isequal(Param.ProjObject.ProjMode,'inside')% take the average in the domain for 'inside' mode 357 if isempty(VarVal) 358 displ_uvmat('ERROR',['empty result at frame index ' num2str(i1_series{iview}(ifile))],checkrun) 359 return 360 end 361 VarVal=mean(VarVal,1); 362 end 363 VarVal=shiftdim(VarVal,-1); %shift dimension 364 DataOut.(VarName)=cat(1,DataOut.(VarName),VarVal);%concanete the current field to the time series 321 365 else 322 Field=Data{1};366 DataOut.(VarName)=cat(1,DataOut.(VarName),0);% put each variable to 0 in case of input reading error 323 367 end 324 if Param.CheckObject 325 [Field,errormsg]=proj_field(Field,Param.ProjObject); 326 end 327 end 328 filecounter=filecounter+1; 329 330 % initiate the time series at the first iteration 331 if filecounter==1 332 % stop program if the first field reading is in error 333 if ~isempty(errormsg) 334 msgbox_uvmat('ERROR',['error in time_series/sub_field:' errormsg]) 368 elseif testsum(ivar)==1% variable representing fixed coordinates 369 eval(['VarInit=DataOut.' VarName ';']); 370 if isempty(errormsg) && ~isequal(VarVal,VarInit) 371 displ_uvmat('ERROR',['time series requires constant coordinates ' VarName],checkrun) 335 372 return 336 373 end 337 DataOut=Field;%default 338 DataOut.NbDim=Field.NbDim+1; %add the time dimension for plots 339 nbvar=length(Field.ListVarName); 340 if nbvar==0 341 msgbox_uvmat('ERROR','no input variable selected in get_field') 342 return 343 end 344 testsum=2*ones(1,nbvar);%initiate flag for action on each variable 345 if isfield(Field,'VarAttribute') % look for coordinate and flag variables 346 for ivar=1:nbvar 347 if length(Field.VarAttribute)>=ivar && isfield(Field.VarAttribute{ivar},'Role') 348 var_role=Field.VarAttribute{ivar}.Role;%'role' of the variable 349 if isequal(var_role,'errorflag') 350 msgbox_uvmat('ERROR','do not handle error flags in time series') 351 return 352 end 353 if isequal(var_role,'warnflag') 354 testsum(ivar)=0; % not recorded variable 355 eval(['DataOut=rmfield(DataOut,''' Field.ListVarName{ivar} ''');']);%remove variable 356 end 357 if isequal(var_role,'coord_x')| isequal(var_role,'coord_y')|... 358 isequal(var_role,'coord_z')|isequal(var_role,'coord') 359 testsum(ivar)=1; %constant coordinates, record without time evolution 360 end 361 end 362 % check whether the variable ivar is a dimension variable 363 DimCell=Field.VarDimName{ivar}; 364 if ischar(DimCell) 365 DimCell={DimCell}; 366 end 367 if numel(DimCell)==1 && isequal(Field.ListVarName{ivar},DimCell{1})%detect dimension variables 368 testsum(ivar)=1; 369 end 370 end 371 end 372 for ivar=1:nbvar 373 if testsum(ivar)==2 374 eval(['DataOut.' Field.ListVarName{ivar} '=[];']) 375 end 376 end 377 DataOut.ListVarName=[{'Time'} DataOut.ListVarName]; 378 end 379 380 % add data to the current field 381 for ivar=1:length(Field.ListVarName) 382 VarName=Field.ListVarName{ivar}; 383 VarVal=Field.(VarName); 384 if testsum(ivar)==2% test for recorded variable 385 if isempty(errormsg) 386 if isequal(Param.ProjObject.ProjMode,'inside')% take the average in the domain for 'inside' mode 387 if isempty(VarVal) 388 msgbox_uvmat('ERROR',['empty result at frame index ' num2str(i1_series{iview}(ifile))]) 389 return 390 end 391 VarVal=mean(VarVal,1); 392 end 393 VarVal=shiftdim(VarVal,-1); %shift dimension 394 DataOut.(VarName)=cat(1,DataOut.(VarName),VarVal);%concanete the current field to the time series 395 else 396 DataOut.(VarName)=cat(1,DataOut.(VarName),0);% put each variable to 0 in case of input reading error 397 end 398 elseif testsum(ivar)==1% variable representing fixed coordinates 399 eval(['VarInit=DataOut.' VarName ';']); 400 if isempty(errormsg) && ~isequal(VarVal,VarInit) 401 msgbox_uvmat('ERROR',['time series requires constant coordinates ' VarName]) 402 return 403 end 404 end 405 end 406 407 % record the time: 408 if isempty(time)% time read in ncfiles 409 if isfield(Field,'Time') 410 DataOut.Time(filecounter,1)=Field.Time; 411 else 412 DataOut.Time(filecounter,1)=ifile;%default 413 end 414 else % time from ImaDoc prevails TODO: correct 415 % DataOut.Time(filecounter,1)=time{1}(i1_series{1})(ifile),j1_series{1}(ifile))+time(end,i2_series{end}(ifile),j2_series{end}(ifile)))/2; 416 DataOut.Time(filecounter,1)=i1_series{1}(ifile);% TODO : generalise 417 end 418 419 % record the number of missing input fields 420 if ~isempty(errormsg) 421 nbmissing=nbmissing+1; 422 display(['ifile=' num2str(ifile) ':' errormsg]) 423 end 374 end 375 end 376 377 % record the time: 378 if isempty(time)% time read in ncfiles 379 if isfield(Field,'Time') 380 DataOut.Time(filecounter,1)=Field.Time; 381 else 382 DataOut.Time(filecounter,1)=ifile;%default 383 end 384 else % time from ImaDoc prevails TODO: correct 385 % DataOut.Time(filecounter,1)=time{1}(i1_series{1})(ifile),j1_series{1}(ifile))+time(end,i2_series{end}(ifile),j2_series{end}(ifile)))/2; 386 DataOut.Time(filecounter,1)=i1_series{1}(ifile);% TODO : generalise 387 end 388 389 % record the number of missing input fields 390 if ~isempty(errormsg) 391 nbmissing=nbmissing+1; 392 display(['ifile=' num2str(ifile) ':' errormsg]) 424 393 end 425 394 end 426 395 end 427 396 %%%%%%% END OF LOOP WITHIN A SLICE 428 397 429 398 %remove time for global attributes if exists 430 399 Time_index=find(strcmp('Time',DataOut.ListGlobalAttribute)); … … 438 407 end 439 408 440 % add time dimension 409 % add time dimension 441 410 for ivar=1:length(Field.ListVarName) 442 411 DimCell=Field.VarDimName(ivar); … … 469 438 % display nbmissing 470 439 if ~isequal(nbmissing,0) 471 msgbox_uvmat('WARNING',[num2str(nbmissing) ' files skipped: missing files or bad input, see command window display'])440 displ_uvmat('WARNING',[num2str(nbmissing) ' files skipped: missing files or bad input, see command window display'],checkrun) 472 441 end 473 442 474 443 %name of result file 475 % filemean=fullfile_uvmat(RootPath{1},subdir_result,RootFile{1},'.nc','_1',i1_series{1}(i_slice)); 476 OutputFile=fullfile_uvmat(RootPath{1},Param.OutputSubDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(1),i1_series{1}(end),i_slice,[]); 444 OutputFile=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(1),i1_series{1}(end),i_slice,[]); 477 445 errormsg=struct2nc(OutputFile,DataOut); %save result file 478 446 if isempty(errormsg) 479 447 display([OutputFile ' written']) 480 448 else 481 msgbox_uvmat('ERROR',['error in Series/struct2nc: ' errormsg])449 displ_uvmat('ERROR',['error in Series/struct2nc: ' errormsg],checkrun) 482 450 end 483 451 end … … 486 454 figure 487 455 haxes=axes; 456 if checkrun 488 457 plot_field(DataOut,haxes) 458 end 489 459 490 460 %% display the result file using the GUI get_field
Note: See TracChangeset
for help on using the changeset viewer.