Ignore:
Timestamp:
Jun 25, 2012, 12:14:16 AM (12 years ago)
Author:
sommeria
Message:

functions adpated to mode background

File:
1 edited

Legend:

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

    r470 r474  
    1 %'merge_proj': project and concatene fieldsmerge_proj
    2 % can be used as a template for applying an operation (here projection and concateantion) on each field of an input series
     1%'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
    33%------------------------------------------------------------------------
    44% function ParamOut=merge_proj(Param)
     
    3232%                      each line decomposed as {RootPath,SubDir,Rootfile,NomType,Extension}
    3333%    .OutputSubDir: name of the subdirectory for data outputs
    34 %    .OutputDir: directory for data outputs, including path
     34%    .OutputDirExt: directory extension for data outputs
    3535%    .Action: .ActionName: name of the current activated function
    3636%             .ActionPath:   path of the current activated function
     
    5151%% set the input elements needed on the GUI series when the action is selected in the menu ActionName
    5252if ~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)
    5554        'WholeIndexRange';'off';...% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default)
    5655        'NbSlice';'on'; ...%nbre of slices ('off' by default)
     
    8281end
    8382ParamOut=Param; %default output
     83OutputSubDir=[Param.OutputSubDir Param.OutputDirExt];
    8484
    8585%% root input file(s) and type
     
    8989NomType=Param.InputTable(:,4);
    9090FileExt=Param.InputTable(:,5);
    91 
    92 % get the set of input file names (cell array filecell), and the lists of
    93 % input file or frame indices i1_series,i2_series,j1_series,j2_series
    9491[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}:
    9695%        iview: line in the table corresponding to a given file series
    9796%        fileindex: file index within  the file series,
    9897% 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
    9998% 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%%%%%%%%%%%%
    103100NbSlice=1;%default
    104101if isfield(Param.IndexRange,'NbSlice')&&~isempty(Param.IndexRange.NbSlice)
     
    117114for iview=1:nbview
    118115    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)
    120117        return
    121118    end
     
    135132if size(time,1)>1
    136133    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)
    139136    end   
    140137end
    141 
    142138
    143139%% coordinate transform or other user defined transform
    144140transform_fct='';%default
    145 if isfield(Param,'FieldTransform')&&isfield(Param.FieldTransform,'TransformHandle')
    146     transform_fct=Param.FieldTransform.TransformHandle;
    147 end
     141if isfield(Param,'FieldTransform')
     142    addpath(Param.FieldTransform.TransformPath)
     143    transform_fct=str2func(Param.FieldTransform.TransformName);
     144    rmpath(Param.FieldTransform.TransformPath)
     145end
     146
    148147%%%%%%%%%%%% END STANDARD PART  %%%%%%%%%%%%
    149148 % EDIT FROM HERE
     
    154153elseif CheckNc{1}
    155154    FileExtOut='.nc';% write result as .nc files for netcdf inputs
    156 else 
    157     msgbox_uvmat('ERROR',['invalid file type input ' FileType{1}])
     155else
     156    displ_uvmat('ERROR',['invalid file type input ' FileType{1}],checkrun)
    158157    return
    159158end
    160159for iview=1:nbview
    161160        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)
    163162    return
    164163    end
    165164end
    166165NomTypeOut=NomType;% output file index will indicate the first and last ref index in the series
     166if checkrun==1
     167    ParamOut.Specific=[];%no specific parameter
     168    return %stop here for interactive input (option Param.Specific='?')
     169end
    167170
    168171%% Set field names and velocity types
    169172%use Param.InputFields for all views
    170 
    171 %% Initiate output fields
    172 %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     return
    177 end
    178 time_1=[];
    179 if isfield(DataOut,'Time')
    180     time_1=DataOut.Time(1);
    181 end
    182 if CheckNc{iview}
    183     if isempty(strcmp('Conventions',DataOut.ListGlobalAttribute))
    184         DataOut.ListGlobalAttribute=['Conventions' DataOut.ListGlobalAttribute];
    185     end
    186     DataOut.Conventions='uvmat';
    187     DataOut.ListGlobalAttribute=[DataOut.ListGlobalAttribute {Param.Action}];
    188     ActionKey='Action';
    189     while isfield(DataOut,ActionKey)
    190         ActionKey=[ActionKey '_1'];
    191     end
    192     DataOut.(ActionKey)=Param.Action;
    193     DataOut.ListGlobalAttribute=[DataOut.ListGlobalAttribute {ActionKey}];
    194     if isfield(DataOut,'Time')
    195         DataOut.ListGlobalAttribute=[DataOut.ListGlobalAttribute {'Time','Time_end'}];
    196     end
    197 end
    198173
    199174%% MAIN LOOP ON SLICES
     
    203178    nbfiles=0;
    204179    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
    212181    %%%%%%%%%%%%%%%% loop on field indices %%%%%%%%%%%%%%%%
    213182    for index=index_slice
     
    227196            [Data{iview},tild,errormsg] = read_field(filecell{iview,index},FileType{iview},Param.InputFields,frame_index{iview}(index));
    228197            if ~isempty(errormsg)
    229                 errormsg=['error of input reading: ' errormsg];
     198                errormsg=['merge_proj/read_field/' errormsg];
     199                display(errormsg)
    230200                break
    231201            end
     
    251221                [Data{iview},errormsg]=proj_field(Data{iview},Param.ProjObject);
    252222                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)
    254224                    return
    255225                end
     
    261231        MergeData=merge_field(Data);
    262232        if isfield(MergeData,'Txt')
    263             msgbox_uvmat('ERROR',MergeData.Txt)
     233            displ_uvmat('ERROR',MergeData.Txt,checkrun)
    264234            return
    265235        end
     
    288258            end
    289259        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);
    291261       
    292262        % recording the merged field
     
    387357    else
    388358        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)
    390360                return
    391361        end
Note: See TracChangeset for help on using the changeset viewer.