Changeset 459
- Timestamp:
- Jun 18, 2012, 9:23:41 AM (12 years ago)
- Location:
- trunk/src/series
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/series/sub_background.m
r457 r459 54 54 55 55 56 function GUI_config=sub_background (Param)56 function ParamOut=sub_background (Param) 57 57 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 GUI_config={'NbViewMax';1;...% max nbre of input file series (default='' , no limitation)60 ParamOut={'NbViewMax';1;...% max nbre of input file series (default='' , no limitation) 61 61 'AllowInputSort';'off';...% allow alphabetic sorting of the list of input files (options 'off'/'on', 'off' by default) 62 62 'WholeIndexRange';'on';...% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default) … … 75 75 %% select different modes, RUN, parameter input, BATCH 76 76 % BATCH case: read the xml file for batch case 77 ParamOut=Param; %default output 77 78 if ischar(Param) 78 79 if strcmp(Param,'input?') 79 checkrun=1;% will inlysearch input parameters (preparation of BATCH mode)80 checkrun=1;% will search input parameters (preparation of BATCH mode) 80 81 else 81 82 Param=xml2struct(Param); … … 206 207 return 207 208 end 208 GUI_config.CheckVolume=strcmp(answer{1},'Yes');209 GUI_config.SlidingSequenceSize=nbaver_ima;210 GUI_config.BrightnessRankThreshold=str2num(answer{3});209 ParamOut.Specific.CheckVolume=strcmp(answer{1},'Yes'); 210 ParamOut.Specific.SlidingSequenceSize=nbaver_ima; 211 ParamOut.Specific.BrightnessRankThreshold=str2num(answer{3}); 211 212 212 213 % apply the image rescaling function 'level' (avoid the blinking effects of bright particles) 213 214 answer=msgbox_uvmat('INPUT_Y-N','apply image rescaling function levels.m after sub_background'); 214 GUI_config.CheckLevelTransform=strcmp(answer,'Yes');215 if checkrun== 2215 ParamOut.Specific.CheckLevelTransform=strcmp(answer,'Yes'); 216 if checkrun==1 216 217 return 217 218 end 218 219 %%%%%%%%%%%%%%%%%%%%%% STOP HERE FOR PAMETER INPUT MODE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 219 220 else 220 GUI_config=Param.Specific; 221 if isequal(GUI_config.CheckVolume,1) 221 if isequal(Param.Specific.CheckVolume,1) 222 222 step=1; 223 223 else 224 224 step=nbfield_j;%case of bursts: the sliding background is shifted by the length of one burst 225 225 end 226 nbaver_ima= GUI_config.SlidingSequenceSize;%number of images for the sliding background226 nbaver_ima=Param.Specific.SlidingSequenceSize;%number of images for the sliding background 227 227 nbaver=ceil(nbaver_ima/step);%number of bursts for the sliding background 228 228 if isequal(floor(nbaver/2),nbaver) … … 237 237 238 238 % calculate absolute brightness rank 239 rank=floor( GUI_config.BrightnessRankThreshold*nbaver_ima);239 rank=floor(ParamOut.Specific.BrightnessRankThreshold*nbaver_ima); 240 240 if rank==0 241 241 rank=1;%rank selected in the sorted image series … … 341 341 342 342 %write result file 343 if GUI_config.CheckLevelTransform343 if ParamOut.Specific.CheckLevelTransform 344 344 C=levels(Acor); 345 345 imwrite(C,newname,'BitDepth',8); % save the new image … … 390 390 newname=fullfile_uvmat(RootPath{1},Param.OutputSubDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(ifile),[],j1); 391 391 %write result file 392 if GUI_config.CheckLevelTransform392 if ParamOut.Specific.CheckLevelTransform 393 393 C=levels(Acor); 394 394 imwrite(C,newname,'BitDepth',8); % save the new image … … 425 425 426 426 %write result file 427 if GUI_config.CheckLevelTransform427 if ParamOut.Specific.CheckLevelTransform 428 428 C=levels(Acor); 429 429 imwrite(C,newname,'BitDepth',8); % save the new image -
trunk/src/series/time_series.m
r457 r459 48 48 function ParamOut=time_series(Param) 49 49 50 %% requests for the visibility of input windows in the GUI series (activated directly by the selection in the menu ACTION) 51 if ~exist('Param','var') 52 ParamOut={'RootPath';'two';...%nbre of possible input series (options 'on'/'two'/'many', default:'one') 53 'SubDir';'on';... % subdirectory of derived files (PIV fields), ('on' by default) 54 'RootFile';'on';... %root input file name ('on' by default) 55 'FileExt';'on';... %input file extension ('on' by default) 56 'NomType';'on';...%type of file indexing ('on' by default) 50 %% set the input elements needed on the GUI series when the action is selected in the menu ActionName 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) 54 'WholeIndexRange';'off';...% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default) 57 55 'NbSlice';'on'; ...%nbre of slices ('off' by default) 58 'VelTypeMenu';'two';...% menu for selecting the velocity type (civ1,..) options 'off'/'one'/'two', 'off' by default) 59 'FieldMenu';'two';...% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default) 60 'CoordType';'on';...%can use a transform function 'off' by default 61 'GetObject';'on';...%can use projection object ,'off' by default 62 'OutputDirExt';'.series'... 63 %'GetMask';'on'...%can use mask option ,'off' by default 64 %'PARAMETER'; options: name of the user defined parameter',repeat a line for each parameter 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) 58 'FieldTransform'; 'on';...%can use a transform function 59 'ProjObject';'on';...%can use projection object(option 'off'/'on', 60 'Mask';'off';...%can use mask option (option 'off'/'on', 'off' by default) 61 'OutputDirExt';'.tseries';...%set the output dir extension 65 62 ''}; 66 return %exit the function63 return 67 64 end 68 65 … … 242 239 end 243 240 %%% TO UPDATE 244 if isequal( FieldName,'get_field...')241 if isequal(InputFields{1},'get_field...') 245 242 hget_field=findobj(allchild(0),'name','get_field');%find the get_field... GUI 246 243 if numel(hget_field)>1 … … 291 288 end 292 289 end 293 294 295 296 297 %% detect whether the two files are 'images' or 'netcdf'298 testcivx=0;299 % FileExt=get(hseries.FileExt,'String');300 if ~isequal(FieldName,{'get_field...'})301 testcivx=isequal(FileType{1},'netcdf');302 end303 % VelType_str=get(hseries.VelTypeMenu,'String');304 % VelType_val=get(hseries.VelTypeMenu,'Value');305 % VelType{1}=VelType_str{VelType_val};306 % if nbview==2307 % VelType_str=get(hseries.VelTypeMenu_1,'String');308 % VelType_val=get(hseries.VelTypeMenu_1,'Value');309 % VelType{2}=VelType_str{VelType_val};310 % end311 290 312 291 %% LOOP ON SLICES … … 397 376 Field=Data{1}; 398 377 end 399 if test_object400 [Field,errormsg]=proj_field(Field,P rojObject);378 if Param.CheckObject 379 [Field,errormsg]=proj_field(Field,Param.ProjObject); 401 380 end 402 381 end … … 410 389 return 411 390 end 412 RecordData=Field;%default413 RecordData.NbDim=Field.NbDim+1; %add the time dimension for plots391 DataOut=Field;%default 392 DataOut.NbDim=Field.NbDim+1; %add the time dimension for plots 414 393 nbvar=length(Field.ListVarName); 415 394 if nbvar==0 … … 428 407 if isequal(var_role,'warnflag') 429 408 testsum(ivar)=0; % not recorded variable 430 eval([' RecordData=rmfield(RecordData,''' Field.ListVarName{ivar} ''');']);%remove variable409 eval(['DataOut=rmfield(DataOut,''' Field.ListVarName{ivar} ''');']);%remove variable 431 410 end 432 411 if isequal(var_role,'coord_x')| isequal(var_role,'coord_y')|... … … 447 426 for ivar=1:nbvar 448 427 if testsum(ivar)==2 449 eval([' RecordData.' Field.ListVarName{ivar} '=[];'])450 end 451 end 452 RecordData.ListVarName=[{'Time'} RecordData.ListVarName];428 eval(['DataOut.' Field.ListVarName{ivar} '=[];']) 429 end 430 end 431 DataOut.ListVarName=[{'Time'} DataOut.ListVarName]; 453 432 end 454 433 … … 459 438 if testsum(ivar)==2% test for recorded variable 460 439 if isempty(errormsg) 461 if isequal(P rojObject.ProjMode,'inside')% take the average in the domain for 'inside' mode440 if isequal(Param.ProjObject.ProjMode,'inside')% take the average in the domain for 'inside' mode 462 441 if isempty(VarVal) 463 442 msgbox_uvmat('ERROR',['empty result at frame index ' num2str(i1_series{iview}(ifile))]) … … 467 446 end 468 447 VarVal=shiftdim(VarVal,-1); %shift dimension 469 RecordData.(VarName)=cat(1,RecordData.(VarName),VarVal);%concanete the current field to the time series448 DataOut.(VarName)=cat(1,DataOut.(VarName),VarVal);%concanete the current field to the time series 470 449 else 471 RecordData.(VarName)=cat(1,RecordData.(VarName),0);% put each variable to 0 in case of input reading error450 DataOut.(VarName)=cat(1,DataOut.(VarName),0);% put each variable to 0 in case of input reading error 472 451 end 473 452 elseif testsum(ivar)==1% variable representing fixed coordinates 474 eval(['VarInit= RecordData.' VarName ';']);453 eval(['VarInit=DataOut.' VarName ';']); 475 454 if isempty(errormsg) && ~isequal(VarVal,VarInit) 476 455 msgbox_uvmat('ERROR',['time series requires constant coordinates ' VarName]) … … 483 462 if isempty(time)% time read in ncfiles 484 463 if isfield(Field,'Time') 485 RecordData.Time(filecounter,1)=Field.Time;464 DataOut.Time(filecounter,1)=Field.Time; 486 465 else 487 RecordData.Time(filecounter,1)=ifile;%default466 DataOut.Time(filecounter,1)=ifile;%default 488 467 end 489 468 else % time from ImaDoc prevails TODO: correct 490 % RecordData.Time(filecounter,1)=time{1}(i1_series{1})(ifile),j1_series{1}(ifile))+time(end,i2_series{end}(ifile),j2_series{end}(ifile)))/2;491 RecordData.Time(filecounter,1)=i1_series{1}(ifile);% TODO : generalise469 % 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; 470 DataOut.Time(filecounter,1)=i1_series{1}(ifile);% TODO : generalise 492 471 end 493 472 … … 503 482 504 483 %remove time for global attributes if exists 505 Time_index=find(strcmp('Time', RecordData.ListGlobalAttribute));484 Time_index=find(strcmp('Time',DataOut.ListGlobalAttribute)); 506 485 if ~isempty(Time_index) 507 RecordData.ListGlobalAttribute(Time_index)=[];508 end 509 RecordData.Conventions='uvmat';510 for ivar=1:numel( RecordData.ListVarName)511 VarName= RecordData.ListVarName{ivar};512 eval([' RecordData.' VarName '=squeeze(RecordData.' VarName ');']) %remove singletons486 DataOut.ListGlobalAttribute(Time_index)=[]; 487 end 488 DataOut.Conventions='uvmat'; 489 for ivar=1:numel(DataOut.ListVarName) 490 VarName=DataOut.ListVarName{ivar}; 491 eval(['DataOut.' VarName '=squeeze(DataOut.' VarName ');']) %remove singletons 513 492 end 514 493 … … 517 496 DimCell=Field.VarDimName(ivar); 518 497 if testsum(ivar)==2%variable used as time series 519 RecordData.VarDimName{ivar}=[{'Time'} DimCell];498 DataOut.VarDimName{ivar}=[{'Time'} DimCell]; 520 499 elseif testsum(ivar)==1 521 RecordData.VarDimName{ivar}=DimCell;500 DataOut.VarDimName{ivar}=DimCell; 522 501 end 523 502 end 524 503 indexremove=find(~testsum); 525 504 if ~isempty(indexremove) 526 RecordData.ListVarName(1+indexremove)=[];527 RecordData.VarDimName(indexremove)=[];528 if isfield( RecordData,'Role') && ~isempty(RecordData.Role{1})%generaliser aus autres attributs529 RecordData.Role(1+indexremove)=[];505 DataOut.ListVarName(1+indexremove)=[]; 506 DataOut.VarDimName(indexremove)=[]; 507 if isfield(DataOut,'Role') && ~isempty(DataOut.Role{1})%generaliser aus autres attributs 508 DataOut.Role(1+indexremove)=[]; 530 509 end 531 510 end 532 511 533 512 %shift variable attributes 534 if isfield( RecordData,'VarAttribute')535 RecordData.VarAttribute=[{[]} RecordData.VarAttribute];536 end 537 RecordData.VarDimName=[{'Time'} RecordData.VarDimName];538 RecordData.Action=Param.Action;%name of the processing programme539 test_time=diff( RecordData.Time)>0;% test that the readed time is increasing (not constant)513 if isfield(DataOut,'VarAttribute') 514 DataOut.VarAttribute=[{[]} DataOut.VarAttribute]; 515 end 516 DataOut.VarDimName=[{'Time'} DataOut.VarDimName]; 517 DataOut.Action=Param.Action;%name of the processing programme 518 test_time=diff(DataOut.Time)>0;% test that the readed time is increasing (not constant) 540 519 if ~test_time 541 RecordData.Time=[1:filecounter];520 DataOut.Time=[1:filecounter]; 542 521 end 543 522 … … 548 527 549 528 %name of result file 550 % [filemean]=... 551 % name_generator(filebase_out,i1_series{1}(i_slice),j1_series{1}(i_slice),'.nc','_i1-i2_j1-j2',1,i2_series{end}(ifile),j2_series{end}(ifile),subdir_result); 552 filemean=fullfile_uvmat(RootPath{1},subdir_result,RootFile{1},'.nc','_1',i1_series{1}(i_slice)); 553 errormsg=struct2nc(filemean,RecordData); %save result file 529 % filemean=fullfile_uvmat(RootPath{1},subdir_result,RootFile{1},'.nc','_1',i1_series{1}(i_slice)); 530 OutputFile=fullfile_uvmat(RootPath{1},Param.OutputSubDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(1),i1_series{1}(end),i_slice,[]); 531 errormsg=struct2nc(OutputFile,DataOut); %save result file 554 532 if isempty(errormsg) 555 display([ filemean' written'])533 display([OutputFile ' written']) 556 534 else 557 535 msgbox_uvmat('ERROR',['error in Series/struct2nc: ' errormsg]) … … 562 540 figure 563 541 haxes=axes; 564 plot_field( RecordData,haxes)542 plot_field(DataOut,haxes) 565 543 566 544 %% display the result file using the GUI get_field … … 569 547 delete(hget_field) 570 548 end 571 get_field( filemean,RecordData)549 get_field(OutputFile,DataOut) 572 550 573 %------------------------------------------------------------------------ 574 % --- Executes on selection change in CoordType. 575 function CoordType_Callback(hObject, eventdata, handles) 576 %------------------------------------------------------------------------ 577 menu_str=get(handles.CoordType,'String'); 578 ind_coord=get(handles.CoordType,'Value'); 579 coord_option=menu_str{ind_coord}; 580 if isequal(coord_option,'more...'); 581 fct_name=''; 582 if exist('./TMP/current_usr_fct.mat','file')% if a file is found 583 h=load('./TMP/current_usr_fct.mat'); 584 if isfield(h,'fct_name'); 585 fct_name=h.fct_name; 586 end 587 end 588 prompt = {'Enter the name of the transform function'}; 589 dlg_title = 'user defined transform'; 590 num_lines= 1; 591 [FileName, PathName, filterindex] = uigetfile( ... 592 {'*.m', ' (*.m)'; 593 '*.m', '.m files '; ... 594 '*.*', 'All Files (*.*)'}, ... 595 'Pick a file', fct_name); 596 fct_name=fullfile(PathName,FileName); 597 addpath(PathName);%add the path to the selected fct 598 [errormsg,date_str]=check_functions;%check whether new functions can oversed the uvmat package A UTILISER 599 if ~exist(fct_name,'file') 600 warndlg(['image procesing fct ' fct_name ' not found']) 601 else 602 transform=FileName(1:end-2);% 603 update_menu(handles.CoordType,transform)%add the selected fct to the menu 604 % set(handles.mouse_coord,'String',menu([1:end-1])')%update the mouse coord menu 605 %save ('./TMP/current_usr_fct.mat','fct_name'); 606 end 607 end 608 ind_coord=get(handles.CoordType,'Value'); 609 610 %--------------------------------------------------------------------- 611 % % --- Executes on selection change in ProjObject. 612 % function ProjObject_Callback(hObject, eventdata, handles) 613 % 614 % list_object=get(handles.ProjObject,'String'); 615 % index=get(handles.ProjObject,'Value'); 616 % hseries=get(handles.ProjObject,'Parent'); 617 % SeriesData=get(hseries,'UserData'); 618 % Obj=SeriesData.ProjObject{index}; 619 % [SeriesData.hset_object,SeriesData.sethandles]=set_object(SeriesData.ProjObject{index}); 620 % set(hseries,'UserData',SeriesData); 621 551 552
Note: See TracChangeset
for help on using the changeset viewer.