Changeset 867


Ignore:
Timestamp:
Feb 12, 2015, 9:31:47 PM (10 years ago)
Author:
sommeria
Message:

python option added in series and bug corrections

Location:
trunk/src
Files:
1 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/calc_field_tps.m

    r866 r867  
    105105    VarAttribute=[VarAttribute VarAttributeNew];
    106106end
    107 Attr_FF.Role='errorflag';
    108 VarAttribute=[VarAttribute {Attr_FF}];
     107%Attr_FF.Role='errorflag';
     108%VarAttribute=[VarAttribute {Attr_FF}];
    109109FieldName(check_remove)=[];
    110110
     
    160160    end
    161161end
    162 DataOut.FF=nbval==0; %put errorflag to 1 for points outside the interpolation rang
    163 nbval(nbval==0)=1;% to avoid division by zero for averaging
     162%DataOut.FF=nbval==0; %put errorflag to 1 for points outside the interpolation rang
     163nbval(nbval==0)=NaN;% to avoid division by zero for averaging
    164164ListFieldOut=fieldnames(DataOut);
    165165for ifield=1:numel(ListFieldOut)
  • trunk/src/find_field_bounds.m

    r809 r867  
    4141NbDim=max(NbDimArray);% spatial dimension of the input field
    4242imax=find(NbDimArray==NbDim);% indices of field cells to consider
    43 if isfield(Field,'NbDim')
    44     NbDim=double(Field.NbDim);% deal with plane fields containing z coordinates
    45 end
     43% if isfield(Field,'NbDim')
     44%     NbDim=double(Field.NbDim);% deal with plane fields containing z coordinates
     45% end
    4646FieldOut.NbDim=NbDim;
    4747if  NbDim<=1; return; end% stop here for 1D fields
  • trunk/src/find_file_series.m

    r809 r867  
    6868    i1_series=[];i2_series=[];j1_series=[];j2_series=[];
    6969    i1_input=1;i2_input=[];j1_input=[];j2_input=[];
     70    if ~exist(fullfileinput,'file')
     71        RootFile='';
     72        return
     73    end
    7074end
    7175if ~exist(FilePath,'dir')
     
    7478if checkfileindexing
    7579NomTypePref='';
    76 if isempty(NomType)
     80if isempty(NomType)||strcmp(NomType,'*')
    7781    if exist(fullfileinput,'file')
    7882        [tild,RootFile]=fileparts(fileinput);% case of constant name (no indexing), get the filename without its extension
  • trunk/src/proj_field.m

    r866 r867  
    666666   
    667667    %% identify vector components
    668     testU=isfield(CellInfo{icell},'VarIndex_vector_x') &&isfield(CellInfo{icell},'VarIndex_vector_y') ;% test for vectors
     668    %testU=isfield(CellInfo{icell},'VarIndex_vector_x') &&isfield(CellInfo{icell},'VarIndex_vector_y') ;% test for vectors
    669669    %     if testU
    670670    %         UName=FieldData.ListVarName{CellInfo{icell}.VarIndex_vector_x};
     
    700700                    return
    701701                end
    702                 ProjData.ListVarName=[ProjData.ListVarName {FieldData.ListVarName{CellInfo{icell}.CoordIndex(end)}}];
    703                 ProjData.VarDimName=[ProjData.VarDimName {FieldData.ListVarName{CellInfo{icell}.CoordIndex(end-1)}}];
     702                ProjData.ListVarName=[ProjData.ListVarName FieldData.ListVarName(CellInfo{icell}.CoordIndex(end))];
     703                ProjData.VarDimName=[ProjData.VarDimName FieldData.ListVarName(CellInfo{icell}.CoordIndex(end))];
    704704                nbvar=numel(ProjData.ListVarName);
    705705                ProjData.VarAttribute{nbvar}.long_name='abscissa along line';
     
    717717                ProjData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(end)})=Xproj;
    718718                for ivar=1:numel(VarIndex)
    719                     ProjData.(VarName{ivar})=FieldData.(VarName{ivar})(flagsel);% restrict vrtibles to the projection band
     719                    ProjData.(VarName{ivar})=FieldData.(VarName{ivar})(flagsel);% restrict variables to the projection band
    720720                    ProjData.(VarName{ivar})=ProjData.(VarName{ivar})(indsort);% sort by absissa
    721721                    ProjData.ListVarName=[ProjData.ListVarName VarName{ivar}];
    722                     ProjData.VarDimName=[ProjData.VarDimName {FieldData.ListVarName{CellInfo{icell}.CoordIndex(end)}}];
     722                    ProjData.VarDimName=[ProjData.VarDimName FieldData.ListVarName(CellInfo{icell}.CoordIndex(end))];
    723723                    ProjData.VarAttribute{nbvar+ivar}=FieldData.VarAttribute{VarIndex(ivar)};%reproduce var attribute
    724724                    if isfield(ProjData.VarAttribute{nbvar+ivar},'Role')
    725725                        if  strcmp(ProjData.VarAttribute{nbvar+ivar}.Role,'vector_x');
    726                             ivar_U=ivar;
     726                            ivar_U=nbvar+ivar;
    727727                        elseif strcmp(ProjData.VarAttribute{nbvar+ivar}.Role,'vector_y');
    728                             ivar_V=ivar;
     728                            ivar_V=nbvar+ivar;
    729729                        end
    730730                    end
     
    777777                end
    778778                [DataOut,VarAttribute,errormsg]=calc_field_tps(Coord,NbCentres,SubRange,FieldVar,CellInfo{icell}.FieldName,cat(3,XI,YI));
     779                ProjData.ListVarName=[ProjData.ListVarName {'X'}];
     780                ProjData.VarDimName=[ProjData.VarDimName {'X'}];
    779781                ProjData.X=Xproj;
    780782                nbvar=numel(ProjData.ListVarName);
     
    784786                ProjData.VarAttribute=[ProjData.VarAttribute VarAttribute];
    785787                for ivar=1:numel(VarAttribute)
    786                     ProjData.VarDimName=[ProjData.VarDimName {XName}];
     788                    ProjData.VarDimName=[ProjData.VarDimName {'X'}];
    787789                    if isfield(VarAttribute{ivar},'Role')
    788790                        if  strcmp(VarAttribute{ivar}.Role,'vector_x');
  • trunk/src/read_field.m

    r822 r867  
    136136                    Role=[Role {'vector_y'}];
    137137                    ProjModeRequest=[ProjModeRequest {ProjModeRequestVar}];
    138                     ListInputField=[ListInputField {''}];
    139                     %ListOperator=[ListOperator {[r.Operator '_V']}];
     138                    ListInputField=[ListInputField InputField(ilist)];
     139                    %ListInputField=[ListInputField {''}];
    140140                else
    141141                    checkV=1;
  • trunk/src/series.m

    r863 r867  
    135135[path_series,name,ext]=fileparts(which('series'));% path to the GUI series
    136136path_series_fct=fullfile(path_series,'series');%path of the functions in subdirectroy 'series'
    137 ActionExtList={'.m';'.sh'};% default choice of extensions (Matlab fct .m or compiled version .sh
     137ActionExtList={'.m';'.sh';'.py (in dev.)'};% default choice of extensions (Matlab fct .m or compiled version .sh
    138138ActionPathList=cell(NbBuiltinAction,1);%initiate the cell matrix of Action fct paths
    139139ActionPathList(:)={path_series_fct}; %set the default path to series fcts to all list members
     
    620620    if ~exist(RootPath,'dir')
    621621        i1_series=[];
    622         RootPath=fileparts(RootPath); %will try the upper folder
     622        %RootPath=fileparts(RootPath); %will try the upper folder
     623        RootFile='';
    623624    else %scan the input folder
    624625        [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileInfo,MovieObject]=...
     
    626627    end
    627628    % if no file is found, open a browser
    628     if isempty(i1_series)
     629    if isempty(RootFile)&& isempty(i1_series)
    629630        fileinput=uigetfile_uvmat(['wrong input at line ' num2str(iview) ':pick a new input file'],RootPath);
    630631        if isempty(fileinput)
     
    722723if strcmp(iview,'append') % display the input data as a new line in the table
    723724    iview=size(InputTable,1)+1;% the next line in InputTable becomes the current line
    724     InputTable(iview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}];
     725%     InputTable(iview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}];
    725726elseif strcmp(iview,'one') % refresh the list of  input  file series
    726727    iview=1; %the first line in InputTable becomes the current line
    727728    InputTable={'','','','',''};
    728     InputTable(iview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}];
     729%     InputTable(iview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}];
    729730    set(handles.TimeTable,'Data',[{''},{[]},{[]},{[]},{[]}])
    730731    set(handles.MinIndex_i,'Data',[])
     
    742743    SeriesData.Time={};
    743744end
     745   SeriesData.i1_series(iview+1:end)=[];
     746    SeriesData.i2_series(iview+1:end)=[];
     747    SeriesData.j1_series(iview+1:end)=[];
     748    SeriesData.j2_series(iview+1:end)=[];
     749    SeriesData.FileType(iview+1:end)=[];
     750    SeriesData.FileInfo(iview+1:end)=[];
     751    SeriesData.Time(iview+1:end)=[];
     752 InputTable(iview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}];
    744753if iview >1
    745754    set(handles.InputLine,'String',num2str(iview))
     
    13961405ActionExt='.m';%default
    13971406if isfield(Param.Action,'ActionExt')
    1398     ActionExt=Param.Action.ActionExt;% '.m' or '.sh' (compiled)
     1407    ActionExt=Param.Action.ActionExt;% '.m', '.sh' (compiled)  or '.py' (Python)
    13991408    Param.Action=rmfield(Param.Action,'ActionExt');%remove from the recorded xml file to avoid interference during ImportConfig
    14001409end
     
    16471656set(handles.status,'UserData',StatusData)
    16481657
     1658
     1659if strcmp(ActionExt, '.py (in dev.)')
     1660    fprintf([
     1661        '\n' ...
     1662        '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n' ...
     1663        'The option .py is used. It is still in development.\n' ...
     1664        'Do not use it unless you really know what you do!\n' ...
     1665        'To try it, first install Pyp and the most recent version of FluidDyn.\n' ...
     1666        '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n'])
     1667    RunMode = 'python';
     1668    t = struct2xml(Param);
     1669    t = set(t, 1, 'name', 'Series');
     1670    filexml = fullfile_uvmat(DirXml, '', Param.InputTable{1,3}, '.xml', OutputNomType,...
     1671         Param.IndexRange.first_i, Param.IndexRange.last_i, first_j, last_j);
     1672    save(t, filexml);
     1673end
     1674
     1675
    16491676%% direct processing on the current Matlab session
    16501677if strcmp (RunMode,'local')
     
    16821709        end
    16831710    end
    1684 else
     1711elseif ~strcmp(RunMode,'python')
    16851712    %% processing on a different session of the same computer (background) or cluster, create executable files
    16861713    batch_file_list=cell(NbProcess,1);% initiate the list of executable files
     
    18371864        system(oar_command); 
    18381865        msgbox_uvmat('CONFIRMATION',[ActionName ' launched in cluster: press STATUS to see results'])
     1866    case 'python'
     1867        command = [
     1868            'LD_LIBRARY_PATH=$(echo $LD_LIBRARY_PATH | pyp "p.split('':'') | [s for s in p if ''matlab'' not in s] | '':''.join(p)") ' ...
     1869            'python -m fluiddyn.postproc.uvmat ' filexml];
     1870        % fprintf(['command:\n' command '\n\n'])
     1871        system(command, '-echo');
    18391872end
    18401873
     
    18591892if isfield(Param,'Pairs')
    18601893    Param=rmfield(Param,'Pairs'); %info Pairs not needed for output
     1894end
     1895if isfield(Param,'InputLine')
     1896    Param=rmfield(Param,'InputLine');
     1897end
     1898if isfield(Param,'EditObject')
     1899    Param=rmfield(Param,'EditObject');
    18611900end
    18621901Param.IndexRange.TimeSource=Param.IndexRange.TimeTable{end,1};
     
    23282367    SeriesData=get(handles.series,'UserData');
    23292368    % input line for which the field choice is relevant
    2330     iview=find(strcmp('netcdf',SeriesData.FileType)|strcmp('civx',SeriesData.FileType)|strcmp('civdata',SeriesData.FileType));% all nc files, icluding civ
     2369    iview=find(ismember(SeriesData.FileType,{'netcdf','civx','civdata'}));% all nc files, icluding civ
    23312370    hget_field=findobj(allchild(0),'name','get_field');
    23322371    if ~isempty(hget_field)
     
    23372376    % check the existence of the first file in the series
    23382377    first_j=[];last_j=[];MinIndex_j=1;MaxIndex_j=1;%default setting for index j
    2339     if isfield(Param.IndexRange,'first_j');% if index j is used
     2378    if isfield(Param.IndexRange,'first_j');% if index j is used     
    23402379        first_j=Param.IndexRange.first_j;
    23412380        last_j=Param.IndexRange.last_j;
     
    23462385    if isfield(Param.IndexRange,'PairString'); PairString=Param.IndexRange.PairString{iview}; end
    23472386    [i1,i2,j1,j2] = get_file_index(Param.IndexRange.first_i,first_j,PairString);
    2348     FirstFileName=fullfile_uvmat(InputTable{1},InputTable{2},InputTable{3},...
    2349         InputTable{5},InputTable{4},i1,i2,j1,j2);
     2387    LineIndex=iview(1);
     2388    if numel(iview)>1     
     2389        answer=msgbox_uvmat('INPUT_TXT',['select the line of the input table:' num2str(iview)] ,num2str(iview(1)));
     2390        LineIndex=str2num(answer);
     2391%         InputLine=str2num(get(handles.InputLine,'String'));
     2392%         if ismember(InputLine,iview)
     2393%             LineIndex=InputLine;
     2394%         end
     2395    end
     2396    FirstFileName=fullfile_uvmat(InputTable{LineIndex,1},InputTable{LineIndex,2},InputTable{LineIndex,3},...
     2397        InputTable{LineIndex,5},InputTable{LineIndex,4},i1,i2,j1,j2);
    23502398    if exist(FirstFileName,'file')
    23512399        ParamIn.Title='get_field: pick input variables and coordinates for series processing';
     
    23722420                XName='X';
    23732421                YName='y';
    2374                 set(handles.VelType,'visible','on')
    2375                 set(handles.VelType_title,'visible','on')
    23762422        end
    23772423        set(handles.FieldName,'Value',1)
    23782424        set(handles.FieldName,'String',[FieldList; {'get_field...'}]);
    23792425        if ~strcmp(GetFieldData.FieldOption,'civdata...')
    2380             set(handles.FieldName,'Value',1:numel(FieldList))%select all input fields by default
    2381             set(handles.VelType,'visible','off')
    2382             set(handles.VelType_title,'visible','off')
     2426           if ~isempty(regexp(FieldList{1},'^vec'))
     2427                set(handles.FieldName,'Value',1)
     2428           else
     2429                set(handles.FieldName,'Value',1:numel(FieldList))%select all input fields by default
     2430           end
    23832431            XName=GetFieldData.Coordinates.Coord_x;
    23842432            YName=GetFieldData.Coordinates.Coord_y;
     
    23922440                    TimeName=['att:' GetFieldData.Time.TimeName];
    23932441                    % update the time table
    2394                     TimeTable{iview,2}=get_time(Param.IndexRange.MinIndex_i(iview),MinIndex_j,PairString,InputTable,SeriesData.FileInfo{iview},GetFieldData.Time.TimeName);  % Min time     
    2395                     TimeTable{iview,3}=get_time(Param.IndexRange.first_i,first_j,PairString,InputTable,SeriesData.FileInfo{iview},GetFieldData.Time.TimeName);  % first time             
    2396                     TimeTable{iview,4}=get_time(Param.IndexRange.last_i,last_j,PairString,InputTable,SeriesData.FileInfo{iview},GetFieldData.Time.TimeName);  % last time                     
    2397                     TimeTable{iview,5}=get_time(Param.IndexRange.MaxIndex_i(iview),MaxIndex_j,PairString,InputTable,SeriesData.FileInfo{iview},GetFieldData.Time.TimeName);  % Max time
     2442                    TimeTable{LineIndex,2}=get_time(Param.IndexRange.MinIndex_i(LineIndex),MinIndex_j,PairString,InputTable,SeriesData.FileInfo{LineIndex},GetFieldData.Time.TimeName);  % Min time     
     2443                    TimeTable{LineIndex,3}=get_time(Param.IndexRange.first_i,first_j,PairString,InputTable,SeriesData.FileInfo{LineIndex},GetFieldData.Time.TimeName);  % first time             
     2444                    TimeTable{LineIndex,4}=get_time(Param.IndexRange.last_i,last_j,PairString,InputTable,SeriesData.FileInfo{LineIndex},GetFieldData.Time.TimeName);  % last time                     
     2445                    TimeTable{LineIndex,5}=get_time(Param.IndexRange.MaxIndex_i(LineIndex),MaxIndex_j,PairString,InputTable,SeriesData.FileInfo{LineIndex},GetFieldData.Time.TimeName);  % Max time
    23982446                case 'variable'
    23992447                    set(handles.TimeName,'String',['var:' GetFieldData.Time.TimeName])
     
    24092457                    ParamIn.TimeDimName=GetFieldData.Time.TimeName;
    24102458            end
    2411             TimeTable{iview,1}=TimeName;
     2459            TimeTable{LineIndex,1}=TimeName;
    24122460            set(handles.TimeTable,'Data',TimeTable);
    24132461        end
    24142462        set(handles.Coord_x,'String',XName)
    24152463        set(handles.Coord_y,'String',YName)
     2464        set(handles.Coord_x,'Visible','on')
     2465        set(handles.Coord_y,'Visible','on')
    24162466    else
    24172467        msgbox_uvmat('ERROR',[FirstFileName ' does not exist'])
     
    31063156ActionExtList=get(handles.ActionExt,'String');
    31073157ActionExt=ActionExtList{get(handles.ActionExt,'Value')};
    3108 ActionList=get(handles.ActionName,'String');
    3109 ActionName=ActionList{get(handles.ActionName,'Value')};
     3158if strcmp(ActionExt,'.py (in dev.)')
     3159    set(handles.RunMode,'Value',2)
     3160end
     3161% ActionList=get(handles.ActionName,'String');
     3162% ActionName=ActionList{get(handles.ActionName,'Value')};
    31103163
    31113164function num_NbProcess_Callback(hObject, eventdata, handles)
  • trunk/src/series/aver_stat.m

    r810 r867  
    136136for iview=1:NbView
    137137    if ~exist(filecell{iview,1}','file')
    138         msgbox_uvmat('ERROR',['the first input file ' filecell{iview,1} ' does not exist'])
     138        disp_uvmat('ERROR',['the first input file ' filecell{iview,1} ' does not exist'],checkrun)
    139139        return
    140140    end
     
    155155    diff_time=max(max(diff(time)));
    156156    if diff_time>0
    157         msgbox_uvmat('WARNING',['times of series differ by (max) ' num2str(diff_time)])
     157        disp_uvmat('WARNING',['times of series differ by (max) ' num2str(diff_time)],checkrun)
    158158    end   
    159159end
     
    176176    FileExtOut='.nc';% write result as .nc files for netcdf inputs
    177177else
    178     msgbox_uvmat('ERROR',['invalid file type input ' FileType{1}])
     178    disp_uvmat('ERROR',['invalid file type input ' FileType{1}],checkrun)
    179179    return
    180180end
    181181if NbView==2 && ~isequal(CheckImage{1},CheckImage{2})
    182     msgbox_uvmat('ERROR','input must be two image series or two netcdf file series')
     182    disp_uvmat('ERROR','input must be two image series or two netcdf file series',checkrun)
    183183    return
    184184end
     
    216216% index_slice=i_slice:NbSlice:nbfield;% select file indices of the slice
    217217nbfiles=0;
    218 nbmissing=0;
     218% nbmissing=0;
    219219
    220220%%%%%%%%%%%%%%%% loop on field indices %%%%%%%%%%%%%%%%
     
    275275            [Field,errormsg]=proj_field(Field,Param.ProjObject);
    276276            if ~isempty(errormsg)
    277                 msgbox_uvmat('ERROR',['error in aver_stat/proj_field:' errormsg])
     277                disp_uvmat('ERROR',['error in aver_stat/proj_field:' errormsg],checkrun)
    278278                return
    279279            end
     
    289289            DataOut=Field;%default
    290290            DataOut.Conventions='uvmat'; %suppress Conventions='uvmat/civdata' for civ input files
    291             for ivar=1:length(Field.ListVarName)
     291            errorvar=zeros(numel(Field.ListVarName));%index of errorflag associated to each variable
     292            for ivar=1:numel(Field.ListVarName)
    292293                VarName=Field.ListVarName{ivar};
    293                 DataOut.(VarName)=double(DataOut.(VarName));
    294             end
    295         else   %current field
    296             for ivar=1:length(Field.ListVarName)
    297                 VarName=Field.ListVarName{ivar};
    298                 sizmean=size(DataOut.(VarName));
    299                 siz=size(Field.(VarName));
    300                 if ~isequal(DataOut.(VarName),0)&& ~isequal(siz,sizmean)
    301                     disp_uvmat('ERROR',['unequal size of input field ' VarName ', need to project  on a grid'],checkrun)
    302                     return
     294                DataOut.(VarName)=zeros(size(DataOut.(VarName)));% initiate each field to zero
     295                NbData.(VarName)=zeros(size(DataOut.(VarName)));% initiate the nbre of good data to zero
     296                for iivar=1:length(Field.VarAttribute)
     297                    if isequal(Field.VarDimName{iivar},Field.VarDimName{ivar})&& isfield(Field.VarAttribute{iivar},'Role')...
     298                            && strcmp(Field.VarAttribute{iivar}.Role,'errorflag')
     299                        errorvar(ivar)=iivar; % index of the errorflag variable corresponding to ivar
     300                    end
     301                end
     302            end
     303            DataOut.ListVarName(errorvar(errorvar~=0))=[]; %remove errorflag from result
     304            DataOut.VarDimName(errorvar(errorvar~=0))=[]; %remove errorflag from result
     305            DataOut.VarAttribute(errorvar(errorvar~=0))=[]; %remove errorflag from result
     306        end   %current field
     307        for ivar=1:length(DataOut.ListVarName)
     308            VarName=Field.ListVarName{ivar};
     309            sizmean=size(DataOut.(VarName));
     310            siz=size(Field.(VarName));
     311            if ~isequal(DataOut.(VarName),0)&& ~isequal(siz,sizmean)
     312                disp_uvmat('ERROR',['unequal size of input field ' VarName ', need to project  on a grid'],checkrun)
     313                return
     314            else
     315                if errorvar(ivar)==0
     316                    check_bad=isnan(Field.(VarName));%=0 for NaN data values, 1 else
    303317                else
    304                     DataOut.(VarName)=DataOut.(VarName)+ double(Field.(VarName)); % update the sum
     318                    check_bad=isnan(Field.(VarName)) | Field.(Field.ListVarName{errorvar(ivar)})~=0;%=0 for NaN or error flagged data values, 1 else
    305319                end
     320                Field.(VarName)(check_bad)=0; %set to zero NaN or data marked by error flag
     321                DataOut.(VarName)=DataOut.(VarName)+ double(Field.(VarName)); % update the sum
     322                NbData.(VarName)=NbData.(VarName)+ ~check_bad;% records the number of data for each point
    306323            end
    307324        end
     
    315332for ivar=1:length(Field.ListVarName)
    316333    VarName=Field.ListVarName{ivar};
    317     DataOut.(VarName)=DataOut.(VarName)/nbfiles; % normalize the mean
    318 end
     334    DataOut.(VarName)=DataOut.(VarName)./NbData.(VarName); % normalize the mean
     335end
     336nbmissing=NbField-nbfiles;
    319337if nbmissing~=0
    320     msgbox_uvmat('WARNING',[num2str(nbmissing) ' input files are missing or skipted'])
     338    disp_uvmat('WARNING',[num2str(nbmissing) ' input files are missing or skipted'],checkrun)
    321339end
    322340if isempty(time) % time is read from files
  • trunk/src/series/merge_proj.m

    r857 r867  
    196196    FileExtOut='.nc'; %netcdf output
    197197end
    198 NomTypeOut=NomType;% output file index will indicate the first and last ref index in the series
     198%NomTypeOut=NomType;% output file index will indicate the first and last ref index in the series
    199199RootFileOut=RootFile{1};
    200200for iview=2:NbView
     
    403403end
    404404errormsg='';
    405 MergeData=Data{1};% merged field= first field by default, reproduces the glabal attributes of the first field
     405MergeData=Data{1};% merged field= first field by default, reproduces the global attributes of the first field
    406406NbView=length(Data);
    407 if NbView==1
    408     return
     407if NbView==1% if there is only one field, just reproduce it in MergeData
     408    return 
    409409end
    410410
     
    419419    if NbDim(icell)~=1 % skip field cells which are of dim 1
    420420        switch CellInfo{icell}.CoordType
    421             case 'scattered'  %case of input fields with unstructured coordinates: just concacene data
     421            case 'scattered'  %case of input fields with unstructured coordinates: just concatene data
    422422                for ivar=CellInfo{icell}.VarIndex %  indices of the selected variables in the list FieldData.ListVarName
    423423                    VarName=Data{1}.ListVarName{ivar};
    424                     %MergeData=Data{1};% merged field= first field by default, reproduces the glabal attributes of the first field
    425424                    for iview=2:NbView
    426425                        MergeData.(VarName)=[MergeData.(VarName); Data{iview}.(VarName)];
     
    431430                if isfield(CellInfo{icell},'VarIndex_errorflag') && ~isempty(CellInfo{icell}.VarIndex_errorflag)
    432431                    FFName=Data{1}.ListVarName{CellInfo{icell}.VarIndex_errorflag};% name of errorflag variable
     432                    MergeData.ListVarName(CellInfo{icell}.VarIndex_errorflag)=[];%remove error flag variable in MergeData (will use NaN instead)
     433                    MergeData.VarDimName(CellInfo{icell}.VarIndex_errorflag)=[];
     434                    MergeData.VarAttribute(CellInfo{icell}.VarIndex_errorflag)=[];
    433435                end
    434436                % select good data on each view
     
    441443                            check_bad=isnan(Data{iview}.(VarName)) | Data{iview}.(FFName)~=0;%=0 for NaN or error flagged data values, 1 else
    442444                        end
    443                         Data{iview}.(VarName)(check_bad)=0; %set to zero NaN or masked data
     445                        Data{iview}.(VarName)(check_bad)=0; %set to zero NaN or data marked by error flag
    444446                        if iview==1
    445                             MergeData.(VarName)=Data{1}.(VarName);% correct the field of MergeData
     447                            %MergeData.(VarName)=Data{1}.(VarName);% initiate MergeData with the first field
    446448                            NbAver=~check_bad;% initiate NbAver: the nbre of good data for each point
    447449                        elseif size(Data{iview}.(VarName))~=size(MergeData.(VarName))
    448450                            errormsg='sizes of the input matrices do not agree, need to interpolate on a common grid using a projection object';
    449451                            return
    450                         else     
    451                          
    452                             MergeData.(VarName)=MergeData.(VarName) + Data{iview}.(VarName);%add data
     452                        else                             
     453                            MergeData.(VarName)=MergeData.(VarName) +double(Data{iview}.(VarName));%add data
    453454                            NbAver=NbAver + ~check_bad;% add 1 for good data, 0 else
    454455                        end
    455456                    end
    456457                    MergeData.(VarName)(NbAver~=0)=MergeData.(VarName)(NbAver~=0)./NbAver(NbAver~=0);% take average of defined data at each point
     458                    MergeData.(VarName)(NbAver==0)=NaN;% set to NaN the points with no good data
    457459                end
    458460        end
    459         if isempty(FFName)
    460             FFName='FF';
    461         end
    462         MergeData.(FFName)(NbAver~=0)=0;% flag to 1 undefined summed data
    463         MergeData.(FFName)(NbAver==0)=1;% flag to 1 undefined summed data
     461%         if isempty(FFName)
     462%             FFName='FF';
     463%         end
     464%         MergeData.(FFName)(NbAver~=0)=0;% flag to 1 undefined summed data
     465%         MergeData.(FFName)(NbAver==0)=1;% flag to 1 undefined summed data
    464466    end
    465467end
  • trunk/src/series/time_series.m

    r810 r867  
    207207%% Set field names and velocity types
    208208InputFields{1}=[];%default (case of images)
     209if nbview==2
     210    InputFields{2}=[];%default (case of images)
     211end
    209212if isfield(Param,'InputFields')
    210213    InputFields{1}=Param.InputFields;
    211 end
    212 if nbview==2
    213     InputFields{2}=[];%default (case of images)
    214     if isfield(Param,'InputFields')
    215         InputFields{2}=Param.InputFields{1};%default
     214    if nbview==2
     215        InputFields{2}=Param.InputFields;%default
    216216        if isfield(Param.InputFields,'FieldName_1')
    217217            InputFields{2}.FieldName=Param.InputFields.FieldName_1;
  • trunk/src/uvmat.m

    r866 r867  
    28182818        elseif ref_j_1<0
    28192819            errormsg='minimum j index reached';
    2820         elseif ref_i_1+1>size(UvData.i1_series{2},3)
     2820        elseif ref_i_1+1>size(UvData.i1_series{2},3)&&~isempty(InputFile.NomType_1)
    28212821            errormsg='maximum i index reached for the second series (reload the input file to update the index bound)';
    2822         elseif ref_j_1+1>size(UvData.i1_series{2},2)
     2822        elseif ref_j_1+1>size(UvData.i1_series{2},2)&&~isempty(InputFile.NomType_1)
    28232823            errormsg='maximum j index reached for the second series(reload the input file to update the index bound)';
    28242824        end
     
    28262826        siz=size(UvData.i1_series{2});
    28272827        ref_indices=ref_i_1*siz(1)*siz(2)+ref_j_1*siz(1)+1:ref_i_1*siz(1)*siz(2)+(ref_j_1+1)*siz(1);
    2828         i1_subseries=UvData.i1_series{2}(ref_indices);
    2829         ref_indices=ref_indices(i1_subseries>0);
    2830         if isempty(ref_indices)% case of pairs (free index i)
    2831             ref_indices=ref_i_1*siz(1)*siz(2)+1:(ref_i_1+1)*siz(1)*siz(2);
     2828        if ~isempty(InputFile.NomType_1)
    28322829            i1_subseries=UvData.i1_series{2}(ref_indices);
    28332830            ref_indices=ref_indices(i1_subseries>0);
    2834         end
    2835         i1_1=UvData.i1_series{2}(ref_indices(end));
    2836         if ~isempty(UvData.i2_series{2})
    2837             i2_1=UvData.i2_series{2}(ref_indices(end));
    2838         end
    2839         if ~isempty(UvData.j1_series{2})
    2840             j1_1=UvData.j1_series{2}(ref_indices(end));
    2841         end
    2842         if ~isempty(UvData.j2_series{2})
    2843             j2_1=UvData.j2_series{1}(ref_indices(end));
     2831            if isempty(ref_indices)% case of pairs (free index i)
     2832                ref_indices=ref_i_1*siz(1)*siz(2)+1:(ref_i_1+1)*siz(1)*siz(2);
     2833                i1_subseries=UvData.i1_series{2}(ref_indices);
     2834                ref_indices=ref_indices(i1_subseries>0);
     2835            end
     2836            i1_1=UvData.i1_series{2}(ref_indices(end));
     2837            if ~isempty(UvData.i2_series{2})
     2838                i2_1=UvData.i2_series{2}(ref_indices(end));
     2839            end
     2840            if ~isempty(UvData.j1_series{2})
     2841                j1_1=UvData.j1_series{2}(ref_indices(end));
     2842            end
     2843            if ~isempty(UvData.j2_series{2})
     2844                j2_1=UvData.j2_series{1}(ref_indices(end));
     2845            end
    28442846        end
    28452847    else% the second series (if needed) is the same file as the first
     
    36003602%% get bounds and dimensions of the input field
    36013603UvData.Field=find_field_bounds(UvData.Field);
    3602 
    36033604testnewseries=UvData.NewSeries;
    36043605UvData.NewSeries=0;% put to 0 the test for a new field series (set by RootPath_callback)
Note: See TracChangeset for help on using the changeset viewer.