Changeset 474 for trunk/src/series/merge_proj.m
- Timestamp:
- Jun 25, 2012, 12:14:16 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.