Changeset 464


Ignore:
Timestamp:
Jun 21, 2012, 11:39:00 AM (12 years ago)
Author:
sommeria
Message:

a few bug repairs and update in the series fcts

Location:
trunk/src/series
Files:
3 edited

Legend:

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

    r462 r464  
    291291        for iview=1:nbview
    292292            % reading input file(s)
    293             [Data{iview},ParamOut,errormsg] = read_field(filecell{iview,index},FileType{iview},InputFields{iview},frame_index{iview}(index));
     293            [Data{iview},tild,errormsg] = read_field(filecell{iview,index},FileType{iview},InputFields{iview},frame_index{iview}(index));
    294294            if ~isempty(errormsg)
    295295                errormsg=['error of input reading: ' errormsg];
  • trunk/src/series/merge_proj.m

    r462 r464  
    22% can be used as a template for applying an operation (here projection and concateantion) on each field of an input series
    33%------------------------------------------------------------------------
    4 % function GUI_config=merge_proj(Param)
     4% function ParamOut=merge_proj(Param)
    55%------------------------------------------------------------------------
    66
     
    136136NbSlice_calib={};
    137137XmlData=cell(1,nbview);%initiate the structures containing the data from the xml file (calibration and timing)
     138
    138139for iview=1:nbview%Loop on views
    139140    SubDirBase=regexprep(SubDir{iview},'\..*','');%take the root part of SubDir, before the first dot '.'
     
    162163    end
    163164end
     165
    164166
    165167%% check coincidence in time for several input file series
     
    214216        msgbox_uvmat('ERROR','input set of input series: need  either netcdf either image series')
    215217    return
     218    end
    216219end
    217220NomTypeOut=NomType;% output file index will indicate the first and last ref index in the series
     
    222225%% Initiate output fields
    223226%initiate the output structure as a copy of the first input one (reproduce fields)
    224 [DataOut,ParamOut,errormsg] = read_field(filecell{1,1},FileType{1},Param.InputFields,1);
     227[DataOut,tild,errormsg] = read_field(filecell{1,1},FileType{1},Param.InputFields,1);
    225228if ~isempty(errormsg)
    226229    msgbox_uvmat('ERROR',['error reading ' filecell{1,1} ': ' errormsg])
     
    255258    nbmissing=0;
    256259   
    257    %initiate result fields
    258    
    259    for ivar=1:length(DataOut.ListVarName)
    260        DataOut.(DataOut.ListVarName{ivar})=0; % initialise all fields to zero
    261    end
    262 
     260    %initiate result fields
     261    
     262    for ivar=1:length(DataOut.ListVarName)
     263        DataOut.(DataOut.ListVarName{ivar})=0; % initialise all fields to zero
     264    end
     265   
    263266    %%%%%%%%%%%%%%%% loop on field indices %%%%%%%%%%%%%%%%
    264267    for index=index_slice
     
    272275        %%%%%%%%%%%%%%%% loop on views (input lines) %%%%%%%%%%%%%%%%
    273276        Data=cell(1,nbview);%initiate the set Data
     277        nbtime=0;
    274278        for iview=1:nbview
    275279            % reading input file(s)
    276             [Data{iview},ParamOut,errormsg] = read_field(filecell{iview,index},FileType{iview},Param.InputFields,frame_index{iview}(index));
     280            [Data{iview},tild,errormsg] = read_field(filecell{iview,index},FileType{iview},Param.InputFields,frame_index{iview}(index));
    277281            if ~isempty(errormsg)
    278282                errormsg=['error of input reading: ' errormsg];
    279283                break
    280284            end
     285            timeread(iview)=0;
     286            if isfield(Data{iview},'Time')
     287                    timeread(iview)=Field{iview}.Time;
     288                    nbtime=nbtime+1;
     289                end
    281290            if ~isempty(NbSlice_calib)
    282291                Data{iview}.ZIndex=mod(i1_series{iview}(index)-1,NbSlice_calib{iview})+1;%Zindex for phys transform
    283292            end
    284          %transform the input field (e.g; phys) if requested
     293            %transform the input field (e.g; phys) if requested
    285294            if ~isempty(transform_fct)
    286295                Data{iview}=transform_fct(Data{iview},XmlData{iview});  %transform to phys if requested
    287296            end
    288                         % field calculation (vort, div...)
    289             if strcmp(FileType{1},'civx')||strcmp(FileType{1},'civ')
     297            % field calculation (vort, div...)
     298            if strcmp(FileType{iview},'civx')||strcmp(FileType{iview},'civ')
    290299                Data{iview}=calc_field(Param.InputFields.FieldName,Data{iview});%calculate field (vort..)
    291300            end
    292            
    293          %projection on object (gridded plane)
    294             if test_object
    295                 [Data{iview},errormsg]=proj_field(Data{iview},ProjObject);
     301            
     302            %projection on object (gridded plane)
     303            if Param.CheckObject
     304                [Data{iview},errormsg]=proj_field(Data{iview},Param.ProjObject);
    296305                if ~isempty(errormsg)
    297306                    msgbox_uvmat('ERROR',['error in merge_proge/proj_field: ' errormsg])
     
    299308                end
    300309            end
    301         end   
     310        end
    302311        %----------END LOOP ON VIEWS----------------------
    303          
     312       
    304313        %% merge the nbview fields
    305314        MergeData=merge_field(Data);
     
    307316            msgbox_uvmat('ERROR',MergeData.Txt)
    308317            return
    309         end       
    310      % generating the name of the merged field
    311      i1=i1_series{iview}(index);
    312      if ~isempty(i2_series{iview})
    313          i2=i2_series{iview}(index);
    314      else
    315          i2=i1;
    316      end
    317      j1=1;
    318      j2=1;
    319      if ~isempty(j1_series{iview})
    320          j1=j1_series{iview}(index);
    321           if ~isempty(j2_series{iview})
    322               j2=j2_series{iview}(index);
    323           else
    324               j2=j1;
    325           end
    326      end
    327      OutputFile=fullfile_uvmat(RootPath{1},Param.OutputSubDir,RootFile{1},FileExtOut,NomType{1},i1,i2,j1,j2);
    328            
    329      % time of the merged field:
     318        end
     319             % time of the merged field:
    330320        time_i=0;%default
    331321        if isempty(time)% time from ImaDoc prevails
    332322            time_i=sum(timeread)/nbtime;
    333323        else
    334            % time_i=i1;
    335324            time_i=(time(i1,j1)+time(i2,j2))/2; %TODO: upgrade
    336325        end
     326        % generating the name of the merged field
     327        i1=i1_series{iview}(index);
     328        if ~isempty(i2_series{iview})
     329            i2=i2_series{iview}(index);
     330        else
     331            i2=i1;
     332        end
     333        j1=1;
     334        j2=1;
     335        if ~isempty(j1_series{iview})
     336            j1=j1_series{iview}(index);
     337            if ~isempty(j2_series{iview})
     338                j2=j2_series{iview}(index);
     339            else
     340                j2=j1;
     341            end
     342        end
     343        OutputFile=fullfile_uvmat(RootPath{1},Param.OutputSubDir,RootFile{1},FileExtOut,NomType{1},i1,i2,j1,j2);
    337344       
    338      % recording the merged field
    339         if testima    %in case of input images an image is produced   
     345        % time of the merged field:
     346        time_i=0;%default
     347        if isempty(time)% time from ImaDoc prevails
     348            time_i=sum(timeread)/nbtime;
     349        else
     350            % time_i=i1;
     351            time_i=(time(i1,j1)+time(i2,j2))/2; %TODO: upgrade
     352        end
     353       
     354        % recording the merged field
     355        if CheckImage{1}    %in case of input images an image is produced
    340356            if isa(MergeData.A,'uint8')
    341357                bitdepth=8;
     
    343359                bitdepth=16;
    344360            end
    345             imwrite(MergeData.A,OutputFile,'BitDepth',bitdepth); 
     361            imwrite(MergeData.A,OutputFile,'BitDepth',bitdepth);
    346362            %write xml calibration file
    347363            siz=size(MergeData.A);
     
    368384            t=struct2xml(ImaDoc);
    369385            t=set(t,1,'name','ImaDoc');
    370             save(t,[filebase_merge '.xml'])     
     386            save(t,[filebase_merge '.xml'])
    371387            display([filebase_merge '.xml saved'])
    372388        else
    373             MergeData.ListGlobalAttribute={'Conventions','Project','InputFile_1','InputFile_end','nb_coord','nb_dim','dt','Time','civ'};       
     389            MergeData.ListGlobalAttribute={'Conventions','Project','InputFile_1','InputFile_end','nb_coord','nb_dim','dt','Time','civ'};
    374390            MergeData.Conventions='uvmat';
    375391            MergeData.nb_coord=2;
     
    387403                MergeData.ListGlobalAttribute(6)=[];
    388404            else
    389                MergeData.dt=dt;
     405                MergeData.dt=dt;
    390406            end
    391407            MergeData.Time=time_i;
  • trunk/src/series/time_series.m

    r462 r464  
    263263%% Initiate output fields
    264264%initiate the output structure as a copy of the first input one (reproduce fields)
    265 [DataOut,ParamOut,errormsg] = read_field(filecell{1,1},FileType{1},InputFields{1},1);
     265[DataOut,tild,errormsg] = read_field(filecell{1,1},FileType{1},InputFields{1},1);
    266266if ~isempty(errormsg)
    267267    msgbox_uvmat('ERROR',['error reading ' filecell{1,1} ': ' errormsg])
Note: See TracChangeset for help on using the changeset viewer.