- Timestamp:
- Jun 20, 2012, 2:14:10 PM (13 years ago)
- Location:
- trunk/src/series
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/series/aver_stat.m
r457 r462 67 67 %% select different modes, RUN, parameter input, BATCH 68 68 % BATCH case: read the xml file for batch case 69 ParamOut=Param; %default output70 69 if ischar(Param) 71 if strcmp(Param,'input?')72 checkrun=1;% will inly search input parameters (preparation of BATCH mode)73 else74 70 Param=xml2struct(Param); 75 71 checkrun=0; 76 end77 72 % RUN case: parameters introduced as the input structure Param 78 73 else 79 74 hseries=guidata(Param.hseries);%handles of the GUI series 80 75 WaitbarPos=get(hseries.waitbar_frame,'Position');%position of the waitbar on the GUI series 81 checkrun=2; % indicate the RUN option is used 82 end 76 if isfield(Param,'Specific')&& strcmp(Param.Specific,'?') 77 checkrun=1;% will only search interactive input parameters (preparation of BATCH mode) 78 else 79 checkrun=2; % indicate the RUN option is used 80 end 81 end 82 ParamOut=Param; %default output 83 83 84 84 %% root input file(s) and type … … 240 240 241 241 %% Initiate output fields 242 % initiate the output structure as a copy of the first input one (reproduce fields)243 [DataOut,ParamOut,errormsg] = read_field(filecell{1,1},FileType{1},InputFields{1},1);244 if ~isempty(errormsg)245 msgbox_uvmat('ERROR',['error reading ' filecell{1,1} ': ' errormsg])246 return247 end248 time_1=[];249 if isfield(DataOut,'Time')250 time_1=DataOut.Time(1);251 end252 if CheckNc{iview}253 if isempty(strcmp('Conventions',DataOut.ListGlobalAttribute))254 DataOut.ListGlobalAttribute=['Conventions' DataOut.ListGlobalAttribute];255 end256 DataOut.Conventions='uvmat';257 DataOut.ListGlobalAttribute=[DataOut.ListGlobalAttribute {Param.Action}];258 ActionKey='Action';259 while isfield(DataOut,ActionKey)260 ActionKey=[ActionKey '_1'];261 end262 DataOut.(ActionKey)=Param.Action;263 DataOut.ListGlobalAttribute=[DataOut.ListGlobalAttribute {ActionKey}];264 if isfield(DataOut,'Time')265 DataOut.ListGlobalAttribute=[DataOut.ListGlobalAttribute {'Time','Time_end'}];266 end267 end242 % %initiate the output structure as a copy of the first input one (reproduce fields) 243 % [DataOut,ParamOut,errormsg] = read_field(filecell{1,1},FileType{1},InputFields{1},1); 244 % if ~isempty(errormsg) 245 % msgbox_uvmat('ERROR',['error reading ' filecell{1,1} ': ' errormsg]) 246 % return 247 % end 248 % time_1=[]; 249 % if isfield(DataOut,'Time') 250 % time_1=DataOut.Time(1); 251 % end 252 % if CheckNc{iview} 253 % if isempty(strcmp('Conventions',DataOut.ListGlobalAttribute)) 254 % DataOut.ListGlobalAttribute=['Conventions' DataOut.ListGlobalAttribute]; 255 % end 256 % DataOut.Conventions='uvmat'; 257 % DataOut.ListGlobalAttribute=[DataOut.ListGlobalAttribute {Param.Action}]; 258 % ActionKey='Action'; 259 % while isfield(DataOut,ActionKey) 260 % ActionKey=[ActionKey '_1']; 261 % end 262 % DataOut.(ActionKey)=Param.Action; 263 % DataOut.ListGlobalAttribute=[DataOut.ListGlobalAttribute {ActionKey}]; 264 % if isfield(DataOut,'Time') 265 % DataOut.ListGlobalAttribute=[DataOut.ListGlobalAttribute {'Time','Time_end'}]; 266 % end 267 % end 268 268 269 269 %% MAIN LOOP ON SLICES … … 274 274 nbmissing=0; 275 275 276 %initiate result fields277 for ivar=1:length(DataOut.ListVarName)278 DataOut.(DataOut.ListVarName{ivar})=0; % initialise all fields to zero279 end280 276 %initiate result fields 277 % for ivar=1:length(DataOut.ListVarName) 278 % DataOut.(DataOut.ListVarName{ivar})=0; % initialise all fields to zero 279 % end 280 281 281 %%%%%%%%%%%%%%%% loop on field indices %%%%%%%%%%%%%%%% 282 282 for index=index_slice … … 304 304 %%%%%%%%%%%% END STANDARD PART %%%%%%%%%%%% 305 305 % EDIT FROM HERE 306 307 if isempty(errormsg) 306 307 if isempty(errormsg) 308 308 % coordinate transform (or other user defined transform) 309 309 if ~isempty(transform_fct) … … 339 339 %field projection on an object 340 340 if Param.CheckObject 341 [Field,errormsg]=proj_field(Field,P rojObject);341 [Field,errormsg]=proj_field(Field,Param.ProjObject); 342 342 if ~isempty(errormsg) 343 343 msgbox_uvmat('ERROR',['error in aver_stat/proj_field:' errormsg]) … … 349 349 %%%%%%%%%%%% MAIN RUNNING OPERATIONS %%%%%%%%%%%% 350 350 %update sum 351 for ivar=1:length(Field.ListVarName) 352 VarName=Field.ListVarName{ivar}; 353 sizmean=size(DataOut.(VarName)); 354 siz=size(Field.(VarName)); 355 if ~isequal(DataOut.(VarName),0)&& ~isequal(siz,sizmean) 356 msgbox_uvmat('ERROR',['unequal size of input field ' VarName ', need to project on a grid']) 357 return 358 else 359 DataOut.(VarName)=DataOut.(VarName)+ double(Field.(VarName)); % update the sum 351 if nbfiles==1 %first field 352 time_1=[]; 353 if isfield(Field,'Time') 354 time_1=Field.Time(1); 355 end 356 DataOut=Field;%default 357 for ivar=1:length(Field.ListVarName) 358 VarName=Field.ListVarName{ivar}; 359 DataOut.(VarName)=double(DataOut.(VarName)); 360 end 361 else %current field 362 for ivar=1:length(Field.ListVarName) 363 VarName=Field.ListVarName{ivar}; 364 sizmean=size(DataOut.(VarName)); 365 siz=size(Field.(VarName)); 366 if ~isequal(DataOut.(VarName),0)&& ~isequal(siz,sizmean) 367 msgbox_uvmat('ERROR',['unequal size of input field ' VarName ', need to project on a grid']) 368 return 369 else 370 DataOut.(VarName)=DataOut.(VarName)+ double(Field.(VarName)); % update the sum 371 end 360 372 end 361 373 end 362 374 %%%%%%%%%%%% END MAIN RUNNING OPERATIONS %%%%%%%%%%%% 363 375 else 364 display(errormsg) 376 display(errormsg) 365 377 end 366 378 end … … 374 386 msgbox_uvmat('WARNING',[num2str(nbmissing) ' input files are missing or skipted']) 375 387 end 376 if isempty(time) % time is read from files 388 if isempty(time) % time is read from files 377 389 if isfield(Field,'Time') 378 390 time_end=Field.Time(1);%last time read -
trunk/src/series/merge_proj.m
r457 r462 47 47 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 48 48 49 function GUI_input=merge_proj(Param)49 function ParamOut=merge_proj(Param) 50 50 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 GUI_input={'NbViewMax';2;...% max nbre of input file series (default='' , no limitation)53 ParamOut={'NbViewMax';'';...% max nbre of input file series (default='' , no limitation) 54 54 'AllowInputSort';'off';...% allow alphabetic sorting of the list of input files (options 'off'/'on', 'off' by default) 55 'WholeIndexRange';'off';...% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default) 55 56 'NbSlice';'on'; ...%nbre of slices ('off' by default) 56 'VelType';' two';...% menu for selecting the velocity type (options 'off'/'one'/'two', 'off' by default)57 'FieldName';' two';...% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)57 'VelType';'one';...% menu for selecting the velocity type (options 'off'/'one'/'two', 'off' by default) 58 'FieldName';'one';...% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default) 58 59 'FieldTransform'; 'on';...%can use a transform function 59 60 'ProjObject';'on';...%can use projection object(option 'off'/'on', 60 'Mask';'o n';...%can use mask option (option 'off'/'on', 'off' by default)61 'OutputDirExt';'. proj';...%set the output dir extension61 'Mask';'off';...%can use mask option (option 'off'/'on', 'off' by default) 62 'OutputDirExt';'.mproj';...%set the output dir extension 62 63 ''}; 63 64 return … … 68 69 % BATCH case: read the xml file for batch case 69 70 if ischar(Param) 70 if strcmp(Param,'input?')71 checkrun=1;% will inly search input parameters (preparation of BATCH mode)72 else73 71 Param=xml2struct(Param); 74 72 checkrun=0; 75 end76 73 % RUN case: parameters introduced as the input structure Param 77 74 else 78 75 hseries=guidata(Param.hseries);%handles of the GUI series 79 76 WaitbarPos=get(hseries.waitbar_frame,'Position');%position of the waitbar on the GUI series 80 checkrun=2; % indicate the RUN option is used 81 end 77 if isfield(Param,'Specific')&& strcmp(Param.Specific,'?') 78 checkrun=1;% will only search interactive input parameters (preparation of BATCH mode) 79 else 80 checkrun=2; % indicate the RUN option is used 81 end 82 end 83 ParamOut=Param; %default output 82 84 83 85 %% root input file(s) and type … … 100 102 101 103 NbSlice=1;%default 102 if isfield(Param.IndexRange,'NbSlice') 104 if isfield(Param.IndexRange,'NbSlice')&&~isempty(Param.IndexRange.NbSlice) 103 105 NbSlice=Param.IndexRange.NbSlice; 104 106 end … … 111 113 112 114 %determine the file type on each line from the first input file 113 ImageTypeOptions={'image','multimage','mmreader','video'};%allowed input file types(images) 114 115 [FileType{1},FileInfo{1},MovieObject{1}]=get_file_type(filecell{1,1}); 116 CheckImage{1}=~isempty(find(strcmp(FileType,ImageTypeOptions)));% =1 for images 117 if ~isempty(j1_series{1}) 118 frame_index{1}=j1_series{1}; 119 else 120 frame_index{1}=i1_series{1}; 115 ImageTypeOptions={'image','multimage','mmreader','video'}; 116 NcTypeOptions={'netcdf','civx','civdata'}; 117 for iview=1:nbview 118 if ~exist(filecell{iview,1}','file') 119 msgbox_uvmat('ERROR',['the first input file ' filecell{iview,1} ' does not exist']) 120 return 121 end 122 [FileType{iview},FileInfo{iview},MovieObject{iview}]=get_file_type(filecell{iview,1}); 123 CheckImage{iview}=~isempty(find(strcmp(FileType{iview},ImageTypeOptions)));% =1 for images 124 CheckNc{iview}=~isempty(find(strcmp(FileType{iview},NcTypeOptions)));% =1 for netcdf files 125 if ~isempty(j1_series{iview}) 126 frame_index{iview}=j1_series{iview}; 127 else 128 frame_index{iview}=i1_series{iview}; 129 end 121 130 end 122 131 … … 126 135 itime=0; 127 136 NbSlice_calib={}; 137 XmlData=cell(1,nbview);%initiate the structures containing the data from the xml file (calibration and timing) 128 138 for iview=1:nbview%Loop on views 129 XmlData{iview}=[];%default 130 filebase{iview}=fullfile(RootPath{iview},RootFile{iview}); 131 if exist([filebase{iview} '.xml'],'file') 132 [XmlData{iview},error]=imadoc2struct([filebase{iview} '.xml']); 133 if isfield(XmlData{iview},'Time') 134 itime=itime+1; 135 timecell{itime}=XmlData{iview}.Time; 136 end 137 if isfield(XmlData{iview},'GeometryCalib') && isfield(XmlData{iview}.GeometryCalib,'SliceCoord') 138 NbSlice_calib{iview}=size(XmlData{iview}.GeometryCalib.SliceCoord,1);%nbre of slices for Zindex in phys transform 139 if ~isequal(NbSlice_calib{iview},NbSlice_calib{1}) 140 msgbox_uvmat('WARNING','inconsistent number of Z indices for the two field series'); 141 end 142 end 143 elseif exist([filebase{iview} '.civ'],'file') 144 [error,time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([filebase{iview} '.civ']); 139 SubDirBase=regexprep(SubDir{iview},'\..*','');%take the root part of SubDir, before the first dot '.' 140 filexml=[fullfile(RootPath{iview},SubDirBase) '.xml'];%new convention: xml at the level of the image folder 141 if ~exist(filexml,'file') 142 filexml=[fullfile(RootPath{iview},SubDir{iview},RootFile{iview}) '.xml']; % old convention: xml inside the image folder 143 if ~exist(filexml,'file') 144 filexml=[fullfile(RootPath{iview},SubDir{iview},RootFile{iview}) '.civ']; % very old convention: .civ file 145 if ~exist(filexml,'file') 146 filexml=''; 147 end 148 end 149 end 150 if ~isempty(filexml) 151 [XmlData{iview},error]=imadoc2struct(filexml); 152 end 153 if isfield(XmlData{iview},'Time') 145 154 itime=itime+1; 146 timecell{itime}=time; 147 XmlData{iview}.Time=time; 148 GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0]; 149 GeometryCalib.Tx=0; 150 GeometryCalib.Ty=0; 151 GeometryCalib.Tz=1; 152 GeometryCalib.dpx=1; 153 GeometryCalib.dpy=1; 154 GeometryCalib.sx=1; 155 GeometryCalib.Cx=0; 156 GeometryCalib.Cy=0; 157 GeometryCalib.f=1; 158 GeometryCalib.kappa1=0; 159 GeometryCalib.CoordUnit='cm'; 160 XmlData{iview}.GeometryCalib=GeometryCalib; 161 if error==1 162 msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file'); 155 timecell{itime}=XmlData{iview}.Time; 156 end 157 if isfield(XmlData{iview},'GeometryCalib') && isfield(XmlData{iview}.GeometryCalib,'SliceCoord') 158 NbSlice_calib{iview}=size(XmlData{iview}.GeometryCalib.SliceCoord,1);%nbre of slices for Zindex in phys transform 159 if ~isequal(NbSlice_calib{iview},NbSlice_calib{1}) 160 msgbox_uvmat('WARNING','inconsistent number of Z indices for the two field series'); 163 161 end 164 162 end … … 191 189 end 192 190 end 193 if size(time,2) < i2_series{1}(end) || size(time,3) < j2_series{1}(end)% time array absent or too short in ImaDoc xml file'191 if size(time,2) < i2_series{1}(end) ||( ~isempty(j2_series{1}) && size(time,3) < j2_series{1}(end))% time array absent or too short in ImaDoc xml file' 194 192 time=[]; 195 193 end … … 212 210 return 213 211 end 214 if nbview==2 && ~isequal(CheckImage{1},CheckImage{2}) 215 msgbox_uvmat('ERROR','input must be two image series or two netcdf file series') 212 for iview=1:nbview 213 if ~isequal(CheckImage{iview},CheckImage{1})||~isequal(CheckNc{iview},CheckNc{1}) 214 msgbox_uvmat('ERROR','input set of input series: need either netcdf either image series') 216 215 return 217 216 end 218 NomTypeOut='_1-2_1';% output file index will indicate the first and last ref index in the series 219 if NbSlice~=nbfield_j 220 answer=msgbox_uvmat('INPUT_Y-N',['will not average slice by slice: for so cancel and set NbSlice= ' num2str(nbfield_j)]); 221 if ~strcmp(answer,'Yes') 222 return 223 end 224 end 217 NomTypeOut=NomType;% output file index will indicate the first and last ref index in the series 225 218 226 219 %% Set field names and velocity types 227 InputFields{1}=[];%default (case of images) 228 if isfield(Param,'InputFields') 229 InputFields{1}=Param.InputFields; 230 end 231 if nbview==2 232 InputFields{2}=[];%default (case of images) 233 if isfield(Param,'InputFields') 234 InputFields{2}=Param.InputFields{1};%default 235 if isfield(Param.InputFields,'FieldName_1') 236 InputFields{2}.FieldName=Param.InputFields.FieldName_1; 237 if isfield(Param.InputFields,'VelType_1') 238 InputFields{2}.VelType=Param.InputFields.VelType_1; 239 end 240 end 241 end 242 end 220 %use Param.InputFields for all views 243 221 244 222 %% Initiate output fields 245 223 %initiate the output structure as a copy of the first input one (reproduce fields) 246 [DataOut,ParamOut,errormsg] = read_field(filecell{1,1},FileType{1}, InputFields{1},1);224 [DataOut,ParamOut,errormsg] = read_field(filecell{1,1},FileType{1},Param.InputFields,1); 247 225 if ~isempty(errormsg) 248 226 msgbox_uvmat('ERROR',['error reading ' filecell{1,1} ': ' errormsg]) … … 278 256 279 257 %initiate result fields 258 280 259 for ivar=1:length(DataOut.ListVarName) 281 260 DataOut.(DataOut.ListVarName{ivar})=0; % initialise all fields to zero … … 290 269 stopstate='queue'; 291 270 end 292 %OUTPUT 293 % GUI_input=list of options in the GUI series.fig needed for the function 294 % 295 %INPUT: 296 % Param: structure containing all the parameters read on the GUI series 297 % or name of the xml file containing these parameters (BATCH case) 298 % 299 300 301 %% projection object 302 test_object=get(hseries.GetObject,'Value'); 303 if test_object 304 hset_object=findobj(allchild(0),'tag','set_object'); 305 %ProjObject=read_set_object(guidata(hset_object)); 306 ProjObject=read_GUI(hset_object); 307 if ~isfield(ProjObject,'Type') 308 msgbox_uvmat('ERROR','Undefined projection object type') 309 return 310 end 311 if ~isequal(ProjObject.Type,'plane')|| isequal(ProjObject.ProjMode,'projection') 312 msgbox_uvmat('ERROR','The projection object must be a plane with projection mode interp or filter') 313 return 314 end 315 answeryes=msgbox_uvmat('INPUT_Y-N',['field series projected on ' ProjObject.Type]); 316 if ~isequal(answeryes,'Yes') 317 return 318 end 319 end 320 321 %% features of the input fields 322 RootPath=Param.InputTable(:,1); 323 RootFile=Param.InputTable(:,3); 324 SubDir=Param.InputTable(:,2); 325 NomType=Param.InputTable(:,4); 326 FileExt=Param.InputTable(:,5); 327 328 nbview=length(RootFile);%number of views (file series to merge) 329 nbfield=size(i1_series{1},1)*size(i1_series{1},2);%number of fields in the time series 330 hhh=which('mmreader'); 331 for iview=1:nbview 332 test_movie(iview)=0; 333 if ~isempty(hhh) 334 if isequal(lower(FileExt{iview}),'.avi') 335 MovieObject{iview}=mmreader(fullfile(RootPath{iview},[RootFile{iview} FileExt{iview}])); 336 test_movie(iview)=1; 337 end 338 end 339 end 340 341 %% Calibration data and timing: read the ImaDoc files 342 timecell={}; 343 itime=0; 344 NbSlice_calib={}; %test for z index 345 for iview=1:nbview%Loop on views 346 XmlData{iview}=[];%default 347 filebase{iview}=fullfile(RootPath{iview},RootFile{iview}); 348 if exist([filebase{iview} '.xml'],'file') 349 [XmlData{iview},error]=imadoc2struct([filebase{iview} '.xml']); 350 if isfield(XmlData{iview},'Time') 351 itime=itime+1; 352 timecell{itime}=XmlData{iview}.Time; 353 end 354 if isfield(XmlData{iview},'GeometryCalib') && isfield(XmlData{iview}.GeometryCalib,'SliceCoord') 355 NbSlice_calib{iview}=size(XmlData{iview}.GeometryCalib.SliceCoord,1); 356 if ~isequal(NbSlice_calib{iview},NbSlice_calib{1}) 357 msgbox_uvmat('WARNING','inconsistent number of Z indices for the two field series'); 358 end 359 end 360 elseif exist([filebase{iview} '.civ'],'file') 361 [error,time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([filebase{iview} '.civ']); 362 itime=itime+1; 363 timecell{itime}=time; 364 XmlData{iview}.Time=time; 365 GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0]; 366 GeometryCalib.Tx=0; 367 GeometryCalib.Ty=0; 368 GeometryCalib.Tz=1; 369 GeometryCalib.dpx=1; 370 GeometryCalib.dpy=1; 371 GeometryCalib.sx=1; 372 GeometryCalib.Cx=0; 373 GeometryCalib.Cy=0; 374 GeometryCalib.f=1; 375 GeometryCalib.kappa1=0; 376 GeometryCalib.CoordUnit='cm'; 377 XmlData{iview}.GeometryCalib=GeometryCalib; 378 if error==1 379 msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file'); 380 end 381 end 382 end 383 384 %% check coincidence in time 385 multitime=0; 386 if isempty(timecell) 387 time=[]; 388 elseif length(timecell)==1 389 time=timecell{1}; 390 elseif length(timecell)>1 391 multitime=1; 392 for icell=1:length(timecell) 393 if ~isequal(size(timecell{icell}),size(timecell{1})) 394 msgbox_uvmat('WARNING','inconsistent time array dimensions in ImaDoc fields, the time for the first series is used') 395 time=timecell{1}; 396 multitime=0; 397 break 398 end 399 end 400 end 401 if multitime 402 for icell=1:length(timecell) 403 time(icell,:,:)=timecell{icell}; 404 end 405 diff_time=max(max(diff(time))); 406 if diff_time>0 407 msgbox_uvmat('WARNING',['times of series differ by more than ' num2str(diff_time)]) 408 end 409 time=sqeeze(mean(time,1)); 410 end 411 % if size(time,2) < i2_series{1}(end) || size(time,3) < j2_series{1}(end)% ime array absent or too short in ImaDoc xml file' 412 % time=[]; 413 % end 414 415 %% Field and velocity type (the same for all views) 416 FieldName=''; 417 if isfield(Param,'InputFields')&&isfield(Param.InputFields,'FieldMenu') 418 FieldName=Param.InputFields.FieldMenu;%the same set of fields for all views 419 VelType=Param.InputFields.VelTypeMenu; 420 end 421 % if strcmp(get(hseries.FieldMenu,'Visible'),'on') 422 % Field_str=get(hseries.FieldMenu,'String'); 423 % val=get(hseries.FieldMenu,'Value'); 424 % FieldName=Field_str(val);%the same set of fields for all views 425 % VelType_str=get(hseries.VelTypeMenu,'String'); 426 % VelType_val=get(hseries.VelTypeMenu,'Value'); 427 % VelType=VelType_str{VelType_val}; %the same for all views 428 if strcmp(FieldName,'') 429 msgbox_uvmat('ERROR','no input field defined in FieldMenu') 430 elseif strcmp(FieldName,'get_field...') 431 hget_field=findobj(allchild(0),'Name','get_field');%find the get_field... GUI 432 SubField=get_field('read_get_field',hObject,eventdata,hget_field); %read the names of the variables to plot in the get_field GUI 433 end 434 % end 435 %detect whether all the files are 'images' or 'netcdf' 436 testima=0; 437 testvol=0; 438 testcivx=0; 439 testnc=0; 440 for iview=1:nbview 441 ext=FileExt{iview}; 442 form=imformats(ext(2:end)); 443 if isequal(lower(ext),'.vol') 444 testvol=testvol+1; 445 elseif ~isempty(form)||isequal(lower(ext),'.avi')% if the extension corresponds to an image format recognized by Matlab 446 testima=testima+1; 447 elseif isequal(ext,'.nc') 448 testnc=testnc+1; 449 end 450 end 451 if testvol 452 msgbox_uvmat('ERROR','volume images not implemented yet') 453 return 454 end 455 if testnc~=nbview && testima~=nbview && testvol~=nbview 456 msgbox_uvmat('ERROR','need a set of images or a set of netcdf files with the same fields as input') 457 return 458 end 459 if ~isequal(FieldName,'get_field...') 460 testcivx=testnc; 461 end 462 463 %% name of output files and directory: 464 ProjectDir=fileparts(fileparts(RootPath{1}));% preoject directory (GERK) 465 prompt={['result directory (in' ProjectDir ')']}; 466 % RootPath=get(hseries.RootPath,'String'); 467 % SubDir=get(hseries.SubDir,'String'); 468 if isequal(length(RootPath),1) 469 fulldir=RootPath{1}; 470 subdir='merge_proj'; 471 res_subdir=fullfile(fulldir,subdir); 472 else 473 def={fullfile(ProjectDir,'0_RESULTS')}; 474 dlgTitle='result directory'; 475 lineNo=1; 476 answer=msgbox_uvmat('INPUT_TXT',dlgTitle,def); 477 fulldir=answer{1}; 478 subdir=[]; 479 dirlist=sort(RootFile); 480 for iview=1:nbview 481 if ~isempty(subdir) 482 subdir=[subdir '-']; 483 end 484 subdir=[subdir dirlist{iview}]; 485 end 486 res_subdir=fullfile(fulldir,subdir); 487 end 488 ext=FileExt{1}; 489 if ~exist(fulldir,'dir') 490 msgbox_uvmat('ERROR',['directory ' fulldir ' needs to be created']) 491 return 492 end 493 if ~exist(res_subdir,'dir') 494 dircur=pwd; 495 cd(fulldir); 496 succeed=mkdir(subdir); 497 if succeed 498 [xx,msg2] = fileattrib(res_subdir,'+w','g'); %yield writing access (+w) to user group (g) 499 if ~strcmp(msg2,'') 500 msgbox_uvmat('ERROR',['pb of permission for ' res_subdir ': ' msg2])%error message for directory creation 501 cd(dircur) 502 return 503 end 504 cd(dircur); 505 else 506 msgbox_uvmat('ERROR',['Cannot create directory ' fulldir]) 507 return 508 end 509 end 510 filebasesub=fullfile(res_subdir,RootFile{1}); 511 %filebase_merge=fullfile(res_subdir,'merged');%root name for the merged files 512 513 %% MAIN LOOP 514 for ifile=1:nbfield 515 stopstate=get(hseries.RUN,'BusyAction'); 516 if isequal(stopstate,'queue')% enable STOP command from the 'series' interface 517 update_waitbar(hseries.waitbar,WaitbarPos,ifile/nbfield) 518 519 %% ----------LOOP ON VIEWS---------------------- 520 nbtime=0; 271 272 %%%%%%%%%%%%%%%% loop on views (input lines) %%%%%%%%%%%%%%%% 273 Data=cell(1,nbview);%initiate the set Data 521 274 for iview=1:nbview 522 %name of the current file 523 filename=filecell{iview,ifile}; 524 % filename=name_generator(filebase{iview},i1_series{iview}(ifile),j1_series{iview}(ifile),FileExt{iview},NomType{iview},1,i2_series{iview}(ifile),j2_series{iview}(ifile),SubDir{iview}); 525 if ~exist(filename,'file') 526 msgbox_uvmat('ERROR',['missing input file' filename]) 275 % reading input file(s) 276 [Data{iview},ParamOut,errormsg] = read_field(filecell{iview,index},FileType{iview},Param.InputFields,frame_index{iview}(index)); 277 if ~isempty(errormsg) 278 errormsg=['error of input reading: ' errormsg]; 527 279 break 528 280 end 529 timeread(iview)=0;530 %reading the current file531 if testima532 if test_movie(iview)533 Field{iview}.A=read(MovieObject{iview},i1_series{iview}(ifile));534 else535 Field{iview}.A=imread(filename);536 end % TODO: introduce ListVarName537 npxy=size(Field{iview}.A);538 Field{iview}.ListVarName={'AX','AY','A'};539 Field{iview}.VarDimName={'AX','AY',{'AY','AX'}};540 Field{iview}.AX=[0.5 npxy(2)-0.5]; % coordinates of the first and last pixel centers541 Field{iview}.AY=[npxy(1)-0.5 0.5];542 Field{iview}.CoordUnit='pixel';543 Field{iview}.AName='image';544 else545 if testcivx546 [Field{iview},VelTypeOut]=read_civxdata(filename,FieldName,VelType);547 else548 [Field{iview},var_detect]=nc2struct(filename,SubField.ListVarName); %read the corresponding input data549 Field{iview}.VarAttribute=SubField.VarAttribute;550 end551 if isfield(Field{iview},'Txt')552 msgbox_uvmat('ERROR',Field{iview}.Txt)553 return554 end555 if isfield(Field{iview},'Time')556 timeread(iview)=Field{iview}.Time;557 nbtime=nbtime+1;558 end559 end560 281 if ~isempty(NbSlice_calib) 561 Field{iview}.ZIndex=mod(i1_series{iview}(ifile)-1,NbSlice_calib{1})+1;282 Data{iview}.ZIndex=mod(i1_series{iview}(index)-1,NbSlice_calib{iview})+1;%Zindex for phys transform 562 283 end 563 284 %transform the input field (e.g; phys) if requested 564 285 if ~isempty(transform_fct) 565 Field{iview}=transform_fct(Field{iview},XmlData{iview}); %transform to phys if requested 566 end 567 if testcivx 568 Field{iview}=calc_field(FieldName,Field{iview}); 569 end 286 Data{iview}=transform_fct(Data{iview},XmlData{iview}); %transform to phys if requested 287 end 288 % field calculation (vort, div...) 289 if strcmp(FileType{1},'civx')||strcmp(FileType{1},'civ') 290 Data{iview}=calc_field(Param.InputFields.FieldName,Data{iview});%calculate field (vort..) 291 end 292 570 293 %projection on object (gridded plane) 571 294 if test_object 572 [ Field{iview},errormsg]=proj_field(Field{iview},ProjObject);295 [Data{iview},errormsg]=proj_field(Data{iview},ProjObject); 573 296 if ~isempty(errormsg) 574 297 msgbox_uvmat('ERROR',['error in merge_proge/proj_field: ' errormsg]) … … 580 303 581 304 %% merge the nbview fields 582 MergeData=merge_field( Field);305 MergeData=merge_field(Data); 583 306 if isfield(MergeData,'Txt') 584 307 msgbox_uvmat('ERROR',MergeData.Txt) … … 586 309 end 587 310 % generating the name of the merged field 588 if testima 589 ResultExt='.png'; 590 else 591 ResultExt=FileExt{iview}; 592 end 593 i1=i1_series{iview}(ifile); 311 i1=i1_series{iview}(index); 594 312 if ~isempty(i2_series{iview}) 595 i2=i2_series{iview}(i file);313 i2=i2_series{iview}(index); 596 314 else 597 315 i2=i1; … … 600 318 j2=1; 601 319 if ~isempty(j1_series{iview}) 602 j1=j1_series{iview}(i file);320 j1=j1_series{iview}(index); 603 321 if ~isempty(j2_series{iview}) 604 j2=j2_series{iview}(i file);322 j2=j2_series{iview}(index); 605 323 else 606 324 j2=j1; 607 325 end 608 326 end 609 mergename=fullfile_uvmat(res_subdir,'','merged',ResultExt,NomType{iview},i1,i2,j1,j2); 610 % mergename=name_generator(filebase_merge,i1,j1_series{iview}(ifile),ResultExt,NomType{iview},1,i2_series{iview}(ifile),j2_series{iview}(ifile)); 611 327 OutputFile=fullfile_uvmat(RootPath{1},Param.OutputSubDir,RootFile{1},FileExtOut,NomType{1},i1,i2,j1,j2); 328 612 329 % time of the merged field: 613 330 time_i=0;%default … … 626 343 bitdepth=16; 627 344 end 628 imwrite(MergeData.A, mergename,'BitDepth',bitdepth);345 imwrite(MergeData.A,OutputFile,'BitDepth',bitdepth); 629 346 %write xml calibration file 630 347 siz=size(MergeData.A); … … 659 376 MergeData.nb_dim=2; 660 377 dt=[]; 661 if isfield( Field{1},'dt')&& isnumeric(Field{1}.dt)662 dt= Field{1}.dt;663 end 664 for iview =2:numel( Field)665 if ~(isfield( Field{iview},'dt')&& isequal(Field{iview}.dt,dt))378 if isfield(Data{1},'dt')&& isnumeric(Data{1}.dt) 379 dt=Data{1}.dt; 380 end 381 for iview =2:numel(Data) 382 if ~(isfield(Data{iview},'dt')&& isequal(Data{iview}.dt,dt)) 666 383 dt=[];%dt not the same for all fields 667 384 end … … 673 390 end 674 391 MergeData.Time=time_i; 675 error=struct2nc( mergename,MergeData);%save result file392 error=struct2nc(OutputFile,MergeData);%save result file 676 393 if isempty(error) 677 display(['output file ' mergename ' written'])394 display(['output file ' OutputFile ' written']) 678 395 else 679 396 display(error) -
trunk/src/series/relabel_i_j.m
r457 r462 67 67 %% select different modes, RUN, parameter input, BATCH 68 68 % BATCH case: read the xml file for batch case 69 GUI_config=Param;%reproduce the input parameters, no interactive input70 69 if ischar(Param) 71 if strcmp(Param,'input?')72 checkrun=1;% will inly search input parameters (preparation of BATCH mode)73 else74 70 Param=xml2struct(Param); 75 71 checkrun=0; 76 end77 72 % RUN case: parameters introduced as the input structure Param 78 73 else 79 74 hseries=guidata(Param.hseries);%handles of the GUI series 80 75 WaitbarPos=get(hseries.waitbar_frame,'Position');%position of the waitbar on the GUI series 81 checkrun=2; % indicate the RUN option is used 82 end 76 if isfield(Param,'Specific')&& strcmp(Param.Specific,'?') 77 checkrun=1;% will only search interactive input parameters (preparation of BATCH mode) 78 else 79 checkrun=2; % indicate the RUN option is used 80 end 81 end 82 ParamOut=Param; %default output 83 83 84 84 %% root input file(s) and type -
trunk/src/series/sub_background.m
r459 r462 75 75 %% select different modes, RUN, parameter input, BATCH 76 76 % BATCH case: read the xml file for batch case 77 ParamOut=Param; %default output78 77 if ischar(Param) 79 if strcmp(Param,'input?')80 checkrun=1;% will search input parameters (preparation of BATCH mode)81 else82 78 Param=xml2struct(Param); 83 79 checkrun=0; 84 end85 80 % RUN case: parameters introduced as the input structure Param 86 81 else 87 82 hseries=guidata(Param.hseries);%handles of the GUI series 88 83 WaitbarPos=get(hseries.waitbar_frame,'Position');%position of the waitbar on the GUI series 89 checkrun=2; % indicate the RUN option is used 90 end 84 if isfield(Param,'Specific')&& strcmp(Param.Specific,'?') 85 checkrun=1;% will search input parameters (preparation of BATCH mode) 86 else 87 checkrun=2; % indicate the RUN option is used 88 end 89 end 90 ParamOut=Param; %default output 91 91 92 92 %% root input file(s) and type … … 147 147 if strcmp(lower(NomType{1}(end)),'a') 148 148 NomTypeOut=NomType{1};%case of letter appendix 149 elseif isempty(j1_series) 150 NomTypeOut='_1'; 149 151 else 150 152 NomTypeOut='_1_1';% caseof purely numerical indexing -
trunk/src/series/time_series.m
r459 r462 67 67 %% select different modes, RUN, parameter input, BATCH 68 68 % BATCH case: read the xml file for batch case 69 ParamOut=Param; %default output70 69 if ischar(Param) 71 if strcmp(Param,'input?')72 checkrun=1;% will inly search input parameters (preparation of BATCH mode)73 else74 70 Param=xml2struct(Param); 75 71 checkrun=0; 76 end77 72 % RUN case: parameters introduced as the input structure Param 78 73 else 79 74 hseries=guidata(Param.hseries);%handles of the GUI series 80 75 WaitbarPos=get(hseries.waitbar_frame,'Position');%position of the waitbar on the GUI series 81 checkrun=2; % indicate the RUN option is used 82 end 76 if isfield(Param,'Specific')&& strcmp(Param.Specific,'?') 77 checkrun=1;% will only search interactive input parameters (preparation of BATCH mode) 78 else 79 checkrun=2; % indicate the RUN option is used 80 end 81 end 82 ParamOut=Param; %default output 83 83 84 84 %% root input file(s) and type
Note: See TracChangeset
for help on using the changeset viewer.