Changeset 222 for trunk/src


Ignore:
Timestamp:
Mar 14, 2011, 4:50:31 PM (14 years ago)
Author:
sommeria
Message:

cleaning of merge_proj

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/series/merge_proj.m

    r169 r222  
     1
    12%'merge_proj': project and concatene fields, used with series.fig
    23%------------------------------------------------------------------------
     
    3940
    4041
    41 
    42 %projection object
     42%% projection object
    4343test_object=get(hseries.GetObject,'Value');
    4444if test_object
     
    4949            return
    5050    end
    51     if ~isequal(ProjObject.Style,'plane')
    52             msgbox_uvmat('ERROR','The projection object must be a plane')
     51    if ~isequal(ProjObject.Style,'plane')|| isequal(ProjObject.ProjMode,'projection')
     52            msgbox_uvmat('ERROR','The projection object must be a plane with projection mode interp or filter')
    5353            return
    5454    end
    55     %answeryes=questdlg({['field series projected on ' Series.ProjObject.Style]});
    5655    answeryes=msgbox_uvmat('INPUT_Y-N',['field series projected on ' ProjObject.Style]);
    5756    if ~isequal(answeryes,'Yes')
     
    6059end
    6160
    62 %numbers of view fields (nbre of inputs in RootPath)
     61%% numbers of view fields (nbre of inputs in RootPath)
    6362testcell=iscell(Series.RootFile);
    6463if ~testcell
     
    7574nbview=length(Series.RootFile);%number of views (file series to merge)
    7675nbfield=size(num_i1{1},1)*size(num_i1{1},2);%number of fields in the time series
    77 % transform=Series.CoordType; %  field transform function
    7876hhh=which('mmreader');
    7977for iview=1:nbview
     
    8785end
    8886
    89 %Calibration data and timing: read the ImaDoc files
    90 % mode=''; %default
     87%% Calibration data and timing: read the ImaDoc files
    9188timecell={};
    9289itime=0;
     
    131128end
    132129
    133 %check coincidence in time
     130%% check coincidence in time
    134131multitime=0;
    135132if isempty(timecell)
     
    161158end
    162159
    163 % coordinate transform or other user defined transform
     160%% coordinate transform or other user defined transform
    164161transform_fct=[];%default
    165162if isfield(Series,'transform_fct')
     
    167164end
    168165
    169 % Field and velocity type (the same for all views)
     166%% Field and velocity type (the same for all views)
    170167FieldName='';
    171168if strcmp(get(hseries.FieldMenu,'Visible'),'on')
     
    212209end
    213210
    214 %name of output files and directory:
    215 % res_subdir=fullfile(Series.RootPath{1},[Series.SubDir{1} '_STAT']);
     211%% name of output files and directory:
    216212ProjectDir=fileparts(fileparts(Series.RootPath{1}));% preoject directory (GERK)
    217213prompt={['result directory (in' ProjectDir ')']};
     
    263259filebase_merge=fullfile(res_subdir,'merged');%root name for the merged files
    264260
    265     %MAIN LOOP
     261%% MAIN LOOP
    266262for ifile=1:nbfield               
    267263    stopstate=get(hseries.RUN,'BusyAction');
    268264    if isequal(stopstate,'queue')% enable STOP command from the 'series' interface
    269265         update_waitbar(hseries.waitbar,WaitbarPos,ifile/nbfield)
    270 %          Amerge=0;
    271266         
    272          %----------LOOP ON VIEWS----------------------
     267        %% ----------LOOP ON VIEWS----------------------
    273268        nbtime=0;
    274269        for iview=1:nbview
    275             %name of the current file
     270         %name of the current file
    276271            filename=name_generator(filebase{iview},num_i1{iview}(ifile),num_j1{iview}(ifile),Series.FileExt{iview},Series.NomType{iview},1,num_i2{iview}(ifile),num_j2{iview}(ifile),SubDir{iview});
    277272            if ~exist(filename,'file')
     
    279274                break
    280275            end
    281 
    282             %reading the current file
     276         %reading the current file
    283277            if testima
    284278                if test_movie(iview)
     
    311305                end
    312306            end
    313             % coord transform
    314             % z index
    315      
    316307            if ~isempty(NbSlice_calib)
    317308                Field{iview}.ZIndex=mod(num_i1{iview}(ifile)-1,NbSlice_calib{1})+1;
    318309            end
    319 %              Field{iview}.ZIndex=1;
     310         %transform the input field (e.g; phys) if requested
    320311            if ~isempty(transform_fct)
    321312                Field{iview}=transform_fct(Field{iview},XmlData{iview});  %transform to phys if requested
     
    324315                Field{iview}=calc_field(FieldName,Field{iview});
    325316            end
    326 
    327             %projection on object (gridded plane)
     317         %projection on object (gridded plane)
    328318            if test_object
    329319                Field{iview}=proj_field(Field{iview},ProjObject);
    330320            end
    331321        end   
    332          %----------END LOOP ON VIEWS----------------------
     322        %----------END LOOP ON VIEWS----------------------
    333323         
    334         %merge the nbview fields
     324        %% merge the nbview fields
    335325        MergeData=merge_field(Field);
    336326        if isfield(MergeData,'Txt')
    337327            msgbox_uvmat('ERROR',MergeData.Txt)
    338328            return
    339         end
    340        
    341         % generating the name of the merged field
     329        end       
     330     % generating the name of the merged field
    342331        mergename=name_generator(filebase_merge,num_i1{iview}(ifile),num_j1{iview}(ifile),Series.FileExt{iview},Series.NomType{iview},1,num_i2{iview}(ifile),num_j2{iview}(ifile));
    343332       
    344         % time:
     333     % time of the merged field:
    345334        time_i=0;%default
    346335        if isempty(time)% time from ImaDoc prevails
     
    350339        end
    351340       
    352         % recording the merged field
     341     % recording the merged field
    353342        if testima    %in case of input images an image is produced   
    354343            if isa(MergeData.A,'uint8')
     
    402391               MergeData.dt=dt;
    403392            end
    404             %MergeData.dt=1;
    405393            MergeData.Time=time_i;
    406394            error=struct2nc(mergename,MergeData);%save result file
     
    414402end
    415403
    416 %--------------------------------------------------------------------------   
     404%'merge_field': concatene fields
     405%------------------------------------------------------------------------
    417406function MergeData=merge_field(Data)
    418 % initiate Matlab  structure for physical field
     407%% default output
    419408if isempty(Data)||~iscell(Data)
    420409    MergeData=[];
     
    427416    return
    428417end
    429 % for iview=1:nbview
    430 %     if ~isequal(MergeData.ListDimName,Data{iview}.ListDimName)
    431 %         error=1;
    432 %     end
    433 %     if ~isequal(MergeData.ListVarName,Data{iview}.ListVarName)
    434 %         error=1;
    435 %     end
    436 % end
    437 % if error
    438 %     MergeData.Txt='ERROR: attempt at merging fields of incompatible type';
    439 %     return
    440 % end
    441 %
    442 %group the variables (fields of 'FieldData') in cells of variables with the same dimensions
     418
     419%% group the variables (fields of 'FieldData') in cells of variables with the same dimensions
    443420[CellVarIndex,NbDim,VarTypeCell]=find_field_indices(Data{1});
    444421%LOOP ON GROUPS OF VARIABLES SHARING THE SAME DIMENSIONS
     
    500477    end
    501478end
     479
    502480   
Note: See TracChangeset for help on using the changeset viewer.