Changeset 1194 for trunk


Ignore:
Timestamp:
Feb 23, 2026, 3:58:54 PM (8 days ago)
Author:
sommeria
Message:

several bugs repaired

Location:
trunk/src
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/fill_GUI.m

    r1127 r1194  
    3333errormsg='';
    3434if ~isstruct(Param)
    35     errormsg='first input parmaeter of fill_GUI must be a structure';
     35    errormsg='first input parameter of fill_GUI must be a structure';
    3636    return
    3737end
     
    9191        end
    9292        for ibox=1:numel(hh)
    93         % finalise the update of GUI uicontrol filled by the input element
     93            % finalise the update of GUI uicontrol filled by the input element
    9494            if ~isempty(hh(ibox))&& ~check_done
    9595                set(hh(ibox),'Visible','on')% make the filled GUI element visible
     
    104104                            if isnumeric(input_data)
    105105                                if numel(input_data)>0
    106                                     input_string=num2str(input_data(ibox),4);
     106                                    if floor(input_data(ibox))==input_data(ibox)
     107                                        input_string=num2str(input_data(ibox)); % case of integers, write in full
     108                                    else
     109                                        input_string=num2str(input_data(ibox),4);%case of floating point:nbre_digit=4;
     110                                    end
    107111                                end
    108112                            elseif ischar(input_data)
  • trunk/src/find_file_series.m

    r1181 r1194  
    11%'find_file_series': check the content of an input file and find the corresponding file series
    22%--------------------------------------------------------------------------
    3 % function [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileInfo,Object,i1_input,i2_input,j1_input,j2_input]=find_file_series(FilePath,fileinput,checkxml)
     3% function [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileInfo,Object,i1_input,i2_input,j1_input,j2_input]=find_file_series(FilePath,fileinput)
    44%
    55% OUTPUT:
     
    77% SubDir: data dir containing the input file series
    88% RootFile: root file detected in fileinput, possibly modified for movies (indexing is then done on image view, not file)
    9 % i1_series(pair,ref_j+1, ref_i+1),i2_series,j1_series,j2_series: set of indices (i1,i2,j1,j2) sorted by ref index ref_i, ref_j, and pairindex in case of multiple pairs with the same ref
    10 %  (ref_i+1 is used to deal with the image index zero sometimes used)
     9% i1_series(pair,ref_j+1, ref_i+1): set of indices i1 sorted by ref index ref_i, ref_j, and pair index in case of multiple pairs with the same ref.
     10%     (ref_i+1 is used to deal with the image index zero sometimes used)
     11% i2_series,j1_series,j2_series: same as i1_series but for the indices i2,j1,j2.
     12
    1113% NomType: nomenclature type corrected after checking the first file (problem of 0 before the number string)
    1214% FileInfo: structure containing info on the input files (assumed identical on the whole series)
     
    2426% FilePath: path to the directory to be scanned
    2527% fileinput: name (without path) of the input file sample
    26 % checkxml: =1(default) take into account xml file existence to possibly include indexes in RootFile
    27 %           =0: do not take into account xml file existence
    2828
    2929%=======================================================================
     
    4545%=======================================================================
    4646
    47 function [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileInfo,MovieObject,i1_input,i2_input,j1_input,j2_input]=find_file_series(FilePath,fileinput,checkxml)
     47function [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileInfo,MovieObject,i1_input,i2_input,j1_input,j2_input]=find_file_series(FilePath,fileinput)
    4848%------------------------------------------------------------------------
    4949
     
    7575        end
    7676    else
    77         %% if checkxml=1, possibly include the first index in the root name, if there exists a corresponding xml file
    78         if ~exist('checkxml','var')||checkxml
    79             r=regexp(NomType,'^(?<tiretnum>_|\d+)','names');%look for a number or _1 at the beginning of NomType
    80             if ~isempty(r) %if NomType begins by a number or _1
    81                 fileinput_end=regexprep(fileinput,['^' RootFile],'');%remove RootFile at the beginning of fileinput
    82                 if isempty(regexp(r.tiretnum,'^_','once'))% if a separator '_' is not  detected
    83                     rr=regexp(fileinput_end,'^(?<i1>\d+)','names');
    84                 else% if a separator '_' is  detected
    85                     rr=regexp(fileinput_end,'^(?<i1>_\d+)','names');
    86                 end
    87                 if ~isempty(rr)
    88                     RootFile_i=[RootFile rr.i1];% new root file
    89                     %look for an xml file correspoonding to the new root name
    90                     if exist(fullfile(RootPath,SubDir,[RootFile_i '.xml']),'file') || (strcmp(FileExt,'.nc') && exist(fullfile(RootPath,[RootFile_i '.xml']),'file'))
    91                         RootFile=RootFile_i;
    92                         NomTypePref=r.tiretnum;
    93                         NomType=regexprep(NomType,['^'  NomTypePref],'');
    94                         i1_input=j1_input;
    95                         i2_input=j2_input;
    96                         j1_input=[];
    97                         j2_input=[];
    98                     end
    99                 end
    100             end
    101         end
     77     
    10278       
    10379        %% analyse the list of existing files when relevant
  • trunk/src/get_field.m

    r1162 r1194  
    428428        pos(2)=pos_coord(2)-pos(4)-2;
    429429        set(handles.PanelScalar,'Position',pos)
     430        set(handles.Coord_x,'Visible','on')
    430431        set(handles.Coord_y,'Visible','on')
    431432        set(handles.Y_title,'Visible','on')     
     
    507508%------------------------------------------------------------------------
    508509Field=get(handles.get_field,'UserData');
    509 VarIndex=find(strcmp(VarName,Field.Display.ListVarName),1);
    510 DimCell=Field.Display.VarDimName{VarIndex};
     510VarIndex=find(strcmp(VarName,Field.Display.ListVarName),1);% find the index of the input coord variable
     511DimCell=Field.Display.VarDimName{VarIndex};% dimension(s) of the input coord variable
    511512
    512513
    513514%% set list of possible coordinates
    514 
    515 test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordiante
    516 
    517 for ilist=1:numel(Field.Display.VarDimName)
    518     %dimnames=Field.Display.VarDimName{ilist}; %list of dimensions for variable #ilist
    519     % if isequal(dimnames,DimCell)||isequal(dimnames(1:end-1),DimCell)||isequal(dimnames(2:end),DimCell)
    520     % if numel(dimnames)==1 ||
    521     %     test_coord(ilist)=1;
    522     % end
    523 end
    524 ListCoord=Field.Display.ListVarName;%(find(test_coord));
     515if isequal(get(handles.FieldOption,'Value'),1)% case of 1D plot
     516    test_coord=false(size(Field.Display.VarDimName)); %=true when variable #ilist is eligible as ordinate
     517    for ilist=1:numel(Field.Display.VarDimName)
     518        dimnames=Field.Display.VarDimName{ilist}; %list of dimensions for variable #ilist
     519        if isequal(dimnames,DimCell)&& ~strcmp(Field.Display.ListVarName{ilist},VarName) %exclude the the same variable as coord_y
     520            test_coord(ilist)=true;
     521        elseif numel(dimnames)==2 && (isequal(dimnames(1),DimCell)||isequal(dimnames(2),DimCell))
     522            test_coord(ilist)=true;
     523        end
     524    end
     525    ListCoord=Field.Display.ListVarName(test_coord);
     526else
     527    ListCoord=Field.Display.ListVarName;
     528end
    525529set(handles.Coord_y,'String',ListCoord)
    526530val_y=1;
     
    605609
    606610%% set list of possible coordinates
    607 test_component=zeros(size(Field.Display.VarDimName));%=1 when variable #ilist is eligible as unstructured coordinate
    608 test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordiante
     611test_component=false(size(Field.Display.VarDimName));%=1 when variable #ilist is eligible as unstructured coordinate
     612test_coord=false(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordiante
    609613dim_var=Field.Display.VarDimName{scalar_index};%list of dimensions of the selected variable
    610 %if ~get(handles.CheckDimensionX,'Value')
     614
    611615%look for coordinate variables among the other variables
    612616for ilist=1:numel(Field.Display.VarDimName)
    613617    dimnames=Field.Display.VarDimName{ilist}; %list of dimensions for variable #ilist
    614618    if isequal(dimnames,dim_var)
    615         test_component(ilist)=1;% the listed variable has the same dimension as the selected scalar-> possibly chosen as unstructured coordinate
     619        test_component(ilist)=true;% the listed variable has the same dimension as the selected scalar-> possibly chosen as unstructured coordinate
    616620    elseif numel(dimnames)==1 && ~isempty(find(strcmp(dimnames{1},dim_var), 1))%variable ilist is a 1D array which can be coordinate variable
    617         test_coord(ilist)=1;
    618     end
    619 end
    620 %end
     621        test_coord(ilist)=true;
     622%         if strcmp(dimnames{1},Field.Display.ListVarName{ilist})% case of diemnsion with same name as the variable
     623%             test_select(ilist)=true
     624    end
     625end
     626
    621627var_component=find(test_component);% list of variable indices elligible as unstructured coordinates
    622628var_coord=find(test_coord);% % list of variable indices elligible as gridded coordinates
    623 index_coord=[];
    624 index_component=[];
    625 for iscalar=1:numel(scalar_index)
    626     index_component=[index_component find(var_component==scalar_index(iscalar),1)];
    627     index_coord=[index_coord find(var_coord==scalar_index(iscalar),1)];
    628 end
    629 var_component(index_component)=[];
    630 var_coord(index_coord)=[];
     629% index_coord=[];
     630% index_component=[];
     631% for iscalar=1:numel(scalar_index)
     632%     index_component=[index_component find(var_component==scalar_index(iscalar),1)];
     633%     index_coord=[index_coord find(var_coord==scalar_index(iscalar),1)];
     634% end
     635% var_component(index_component)=[];
     636% var_coord(index_coord)=[];
    631637ListCoord=Field.Display.ListVarName([var_coord var_component]);
    632 coord_val=zeros(size(ListCoord));
     638%coord_val=zeros(size(ListCoord));
    633639
    634640%% set default selection for grid coordinates
    635 if numel(var_coord)>=2
    636     coord_val(1)=var_coord(end);
    637     coord_val(2)=var_coord(end-1);
    638     if numel(var_coord)>=3
    639         coord_val(3)=var_coord(end-2);
    640     end
    641 end
     641% if numel(var_coord)>=2
     642%     coord_val(1)=var_coord(end);
     643%     coord_val(2)=var_coord(end-1);
     644%     if numel(var_coord)>=3
     645%         coord_val(3)=var_coord(end-2);
     646%     end
     647% end
    642648% if numel(find(test_coord))>3
    643649%     SwitchVarIndexTime=get(handles.SwitchVarIndexTime,'String');
     
    649655%     SwitchVarIndexTime_Callback([], [], handles)
    650656% end
     657coord_val=[];
    651658
    652659%% default selection for labelled unstructured coordinates
     
    664671    end
    665672end
    666 if numel(find(coord_val))<2 % no predefiend components
    667     if numel(var_coord)>=3
    668         coord_val(3)=3;
    669     end
    670     coord_val([1 2])=[1 2];
     673% if numel(find(coord_val))<2 % no predefined components
     674%     if numel(var_coord)>=3
     675%         coord_val(3)=3;
     676%     end
     677%     coord_val([1 2])=[1 2];
     678% end
     679%% structured coordinates
     680if isempty(coord_val)% structured coordinates
     681    if numel(dim_var)>=3
     682        ind_select3=find(strcmp(dim_var{3},ListCoord), 1);
     683        if ~isempty(ind_select3)
     684            coord_val(3)=ind_select3;
     685        end
     686    end
     687    ind_select1=find(strcmp(dim_var{2},ListCoord));
     688    if ~isempty(ind_select1)
     689        coord_val(1)=ind_select1;
     690    end
     691    ind_select2=find(strcmp(dim_var{1},ListCoord));
     692    if ~isempty(ind_select2)
     693        coord_val(2)=ind_select2;
     694    end
    671695end
    672696
     
    676700set(handles.Coord_y,'Value',coord_val(2))
    677701set(handles.Coord_y,'String',ListCoord)
    678 if numel(find(coord_val))>=3
     702if numel(dim_var)>=3
    679703    set(handles.Coord_z,'Value',coord_val(3))
    680704    set(handles.Coord_z,'String',ListCoord)
     
    882906string=get(handles.Coord_x,'String');
    883907VarName=string{index};
    884 if ~ischar(DimCell)
    885     update_field(handles,VarName)
     908if ~ischar(DimCell)% no dimension as input
     909    update_field(handles,VarName)% update the display of the variable 'VarName' and its dimensions in the general list of variables
    886910end
    887911if isequal(get(handles.FieldOption,'Value'),1)
    888 set_coord_y_options(handles,VarName)
     912    set_coord_y_options(handles,VarName)
    889913end
    890914
     
    899923
    900924if ~ischar(DimCell)
    901 update_field(handles,VarName)
     925    update_field(handles,VarName)
    902926end
    903927
     
    911935VarName=string{index};
    912936if ~ischar(DimCell)
    913 update_field(handles,VarName)
     937    update_field(handles,VarName)
    914938end
    915939
     
    10031027end
    10041028
    1005 
    1006 
    1007 % % --- Executes on button press in CheckDimensionY.
    1008 % function CheckDimensionY_Callback(hObject, eventdata, handles)
    1009 % FieldList=get(handles.FieldOption,'String');
    1010 % FieldOption=FieldList{get(handles.FieldOption,'Value')};
    1011 % switch FieldOption
    1012 %     case '1D plot'
    1013 %         
    1014 %     case {'scalar','pick variables'}
    1015 %        scalar_Callback(hObject, eventdata, handles)
    1016 %     case 'vectors'
    1017 % end
    1018 %
    1019 %
    1020 % % --- Executes on button press in CheckDimensionZ.
    1021 % function CheckDimensionZ_Callback(hObject, eventdata, handles)
    1022 % FieldList=get(handles.FieldOption,'String');
    1023 % FieldOption=FieldList{get(handles.FieldOption,'Value')};
    1024 % switch FieldOption
    1025 %     case '1D plot'
    1026 %         
    1027 %     case 'scalar'
    1028 %        scalar_Callback(hObject, eventdata, handles)
    1029 %     case 'vectors'
    1030 % end
    1031 
     1029%------------------------------------------------------------------------
    10321030% --- Executes on selection change in TimeName.
     1031%------------------------------------------------------------------------
    10331032function TimeName_Callback(hObject, eventdata, handles)
    10341033
  • trunk/src/nc2struct.m

    r1181 r1194  
    284284                    return
    285285                end
    286                 ind_vec(index_time)=TimeIndex-1;% selected index(or indices) to read
     286                ind_vec(index_time)=TimeIndex(1)-1;% selected index(or indices) to read
    287287                ind_size(index_time)=numel(TimeIndex);%length of the selected set of time indices
    288288                if numel(TimeIndex)==1 && ~strcmp(VarName,TimeVarName)
  • trunk/src/num2stra.m

    r1127 r1194  
    88% INPUT:
    99% num: input number (file index)
    10 % nom_type: nomencalture type (see fct name_generator)
    11 % index: 1 or 2 (first or secodn index in file naming)
     10% nom_type: nomenclature type (see fct name_generator)
     11% index: 1 or 2 (first or second index in file naming)
    1212% see also: stra2num, name_generator, name2display
    1313
     
    3737switch index
    3838    case 1
    39 %         if length(nom_type)>=4 && isequal(nom_type(1:2),'%0') && isequal(nom_type(4),'d')
    40 %            str=num2str(num,nom_type(1:4));
    41 %         else
    4239           str=num2str(num);
    43 %         end
    4440    case 2
    4541        if ~isempty(nom_type) && (isequal(nom_type(end),'a')||isequal(nom_type(end),'b'))
  • trunk/src/read_multimadoc.m

    r1184 r1194  
    7979function time=get_time(timeimadoc,i1_series,i2_series,j1_series,j2_series)
    8080 time=[];
    81  if ~ (isempty(i2_series)||size(timeimadoc,1) < i2_series(end) ||( ~isempty(j2_series) && size(timeimadoc,2) < j2_series(end)))% time array absent or too short in ImaDoc xml file'
     81 if ~ (isempty(i2_series)||size(timeimadoc,1) < i2_series(end)+1 ||( ~isempty(j2_series) && size(timeimadoc,2) < j2_series(end)+1))% time array absent or too short in ImaDoc xml file'
    8282     if isempty(j1_series)
    8383         j1_series=1;
  • trunk/src/series.m

    r1193 r1194  
    650650        j1=str2double(get(handles.num_first_j,'String'));
    651651        j2=[];%default
    652         PairString=get(handles.PairString,'Data');
    653         if numel(PairString)>=iview
    654             r=regexp(PairString{iview},'(?<num1>\d+)-(?<num2>\d+)' ,'names');
    655             if ~isempty(r)
    656                 j1=str2double(r.num1);
    657                 j2=str2double(r.num2);
    658             end
    659         end
    660         InputFile=fullfile_uvmat('','',InputTable{iview,3},InputTable{iview,5},InputTable{iview,4},i1,[],j1,j2);
     652%         PairString=get(handles.PairString,'Data');
     653%         if numel(PairString)>=iview
     654%             r=regexp(PairString{iview},'(?<num1>\d+)-(?<num2>\d+)' ,'names');
     655%             if ~isempty(r)
     656%                 j1=str2double(r.num1);
     657%                 j2=str2double(r.num2);
     658%             end
     659%         end
     660 InputFile=[InputTable{iview,3} InputTable{iview,4} InputTable{iview,5}];
     661        %InputFile=fullfile_uvmat('','',InputTable{iview,3},InputTable{iview,5},InputTable{iview,4},i1,[],j1,j2);
    661662        [RootPath,~,RootFile,Param.i1_series,Param.i2_series,Param.j1_series,Param.j2_series,~,Param.FileInfo,MovieObject]=...
    662663            find_file_series(fullfile(InputTable{iview,1},InputTable{iview,2}),InputFile);
     
    814815    SeriesData.j1_series={};
    815816    SeriesData.j2_series={};
    816     SeriesData.FileType={};
     817 %   SeriesData.FileType={};
    817818    SeriesData.FileInfo={};
    818819    SeriesData.Time={};
     
    10671068
    10681069    %% get index range in case of relabeling
    1069     if ~isempty(Param.XmlData.Time)
     1070    if isfield(Param,'XmlData') && ~isempty(Param.XmlData.Time)
    10701071        Time=Param.XmlData.Time;
    10711072        MinIndex_i=1;
     
    10751076        TimeName='xml';
    10761077    else
    1077         [nbfield,nbfield_j]=size(XmlData.Time);
     1078        InputTable=get(handles.InputTable,'Data');
     1079        [XmlFileName,Rank]=find_imadoc(InputTable{iview,1},InputTable{iview,2});
     1080        if isempty(XmlFileName)
     1081            return
     1082        else
     1083            Param.XmlData=read_imadoc(XmlFileName);
     1084        end
     1085        [nbfield,nbfield_j]=size(Param.XmlData.Time);
    10781086        nbfield=nbfield-1; %remove the possible index 0
    10791087        nbfield_j=nbfield_j-1; %remove the possible index 0
     
    10891097        %i1=(first_i-SeriesData.FileSeries{1}.FirstFileIndex)*SeriesData.FileSeries{1}.NbFramePerFile+1;%frame index deduced from input file index
    10901098        i1=1;
    1091         if strcmp(SeriesData.TimeName,'xml')% indices i and j
     1099        if isfield(SeriesData,'TimeName') && strcmp(SeriesData.TimeName,'xml')% indices i and j
    10921100            j1=mod(i1-1,nbfield_j)+first_j;
    10931101            i1=floor((i1-1)/nbfield_j)+1;
     
    10961104    end
    10971105end
    1098 %     set(handles.num_first_i,'String',num2str(i1))
    1099 %     %         last_i=str2double(get(handles.num_last_i,'String'));
    1100 %     %         last_j=str2double(get(handles.num_last_j,'String'));
    1101 %     %         i1=(last_i-SeriesData.FileSeries{1}.FirstFileIndex)*SeriesData.FileSeries{1}.NbFramePerFile+1;%frame index deduced from input file index
    1102 %     %         if strcmp(SeriesData.TimeName,'xml')% indices i and j
    1103 %     %             j1=mod(i1-1,nbfield_j)+1;
    1104 %     %             i1=floor((i1-1)/nbfield_j)+1;
    1105 %     %         end
    1106 %     set(handles.num_last_i,'String',num2str(nbfield))
    1107 %     set(handles.num_last_j,'String',num2str(nbfield_j))
    1108 % % else
    1109 
    1110 
    1111 
    1112 
    1113 %     %% case of possible index relabeling from xml info
    1114 %     if isfield(XmlData,'FileSeries')&& strcmp(FileInfo.FileType,'multimage')
    1115 %         answer=msgbox_uvmat('INPUT_Y-N','relabel the frame  indices according to the xml info?');
    1116 %         if strcmp(answer,'Yes')
    1117 %             set(handles.Relabel,'Visible','on')
    1118 %             set(handles.Relabel,'Value',1)
    1119 %             SeriesData.FileSeries{iview}=XmlData.FileSeries;
    1120 %             TimeMin=Time(2,2);
    1121 %             TimeMax=Time(end,end);
    1122 %             TimeFirst=TimeMin;
    1123 %             TimeLast=TimeMax;
    1124 %         end
    1125 %     elseif iview==1
    1126 %         set(handles.Relabel,'Visible','off')
    1127 %     end
    11281106
    11291107if isfield(Param,'FileInfo') && ~isempty(Param.FileInfo) && strcmp(Param.FileInfo.FileType,'rdvision')
     
    11371115    end
    11381116    TimeMin=Time(MinIndex_i+1,MinIndex_j+1);
    1139 %     if size(Time)>=[first_i+1 first_j+1]
    1140 %         TimeFirst=Time(first_i+1,first_j+1);
    1141 %     end
    1142 %     if size(Time)>=[last_i+1 last_j+1]
    1143 %         TimeLast=Time(last_i+1,last_j+1);
    1144 %     end
    11451117    if size(Time)>=[MaxIndex_i+1 MaxIndex_j+1]
    11461118        TimeMax=Time(MaxIndex_i+1,MaxIndex_j+1);
     
    12611233CheckPair= ~isempty(i2_series)||~isempty(j2_series); % check whether index pairs need to be defined
    12621234PairString=get(handles.PairString,'Data');
     1235PairString{iview,1}=''; % no pair for #iview by default
    12631236if CheckPair% if pairs need to be display for line iview
    12641237    [ModeMenu,ModeValue]=update_mode(i1_series,i2_series,j2_series);
    12651238    Menu=update_listpair(i1_series,i2_series,j1_series,j2_series,ModeMenu{ModeValue},Time,TimeUnit,ref_i,ref_j,TimeName,InputTable(iview,:),Param.FileInfo);
    1266     PairString{iview,1}=Menu{1};
    1267 else
    1268     PairString{iview,1}=''; % no pair for #iview
     1239    if numel(Menu)>=1
     1240        PairString{iview,1}=Menu{1};
     1241    end
    12691242end
    12701243set(handles.PairString,'Data',PairString)
     
    12821255Position=get(handles.FileStatus,'Position');
    12831256set(handles.FileStatus,'Units','normalized')
    1284 %xI=0.5:Position(3)-0.5;
    12851257nbview=numel(SeriesData.i1_series);
    1286 j_max=cell(1,nbview);
     1258i_max=cell(1,nbview);
    12871259MaxIndex_i=ones(1,nbview); % default
    12881260MinIndex_i=ones(1,nbview); % default
     1261missing_indices=cell(1,nbview);
    12891262for iline=1:nbview
    1290     pair_max=squeeze(max(SeriesData.i1_series{iline},[],1)); % max on pair index
    1291     j_max{iline}=max(pair_max,[],1); % max on j index
    1292     if ~isempty(j_max{iline})
    1293         MaxIndex_i(iline)=find(j_max{iline}, 1, 'last' )-1; % max ref index i
    1294         MinIndex_i(iline)=find(j_max{iline}, 1 )-1; % min ref index i
     1263    pair_max=squeeze(max(SeriesData.i1_series{iline},[],1)); % max i1 indices from i1_series (as obtained by fct uvmat/find_file_series.m)
     1264                                                            % needed in the case of mutiple pairs for the same index ref_i)
     1265    i_max{iline}=max(pair_max,[],1); % max on j index
     1266    if ~isempty(i_max{iline})&& ~isequal(pair_max,0)
     1267        MaxIndex_i(iline)=find(i_max{iline}, 1, 'last' )-1; % max ref index i
     1268        MinIndex_i(iline)=find(i_max{iline}, 1 )-1; % min ref index i
     1269         missing_indices{iline}= find(i_max{iline}(2:end)==0);         
    12951270    end
    12961271end
     
    12991274range_index=MaxIndex_i-MinIndex_i+1;
    13001275range_y=max(1,floor(Position(4)/nbview));
    1301 npx=floor(Position(3));
    1302 file_indices=MinIndex_i+floor(((0.5:npx-0.5)/npx)*range_index)+1;
    1303 CData=zeros(nbview*range_y,npx); % initiate the image representing the existing files
     1276npx=floor(Position(3));%length of the bar image FileStatus in pixels
     1277
     1278%file_indices=MinIndex_i+floor(((0.5:npx-0.5)/npx)*range_index)+1;
     1279CData=ones(nbview*range_y,npx); % initiate the image representing the existing files
     1280LineData=ones(1,npx);
    13041281for iline=1:nbview
    13051282    ind_y=1+(iline-1)*range_y:iline*range_y;
    1306     LineData=zeros(size(file_indices));
    1307     file_select=file_indices(file_indices<=numel(j_max{iline}));
    1308     ind_select=file_indices<=numel(j_max{iline});
    1309     LineData(ind_select)=j_max{iline}(file_select)~=0;
    1310     CData(ind_y,:)=ones(size(ind_y'))*LineData;
     1283    missing_pixels=floor((missing_indices{iline}-MinIndex_i+1)*npx/range_index)+1;
     1284    LineData(missing_pixels)=0;
     1285%     LineData=zeros(size(file_indices));
     1286%     file_select=file_indices(file_indices<=numel(i_max{iline}));
     1287%     ind_select=file_indices<=numel(i_max{iline});
     1288%     LineData(ind_select)=i_max{iline}(file_select)~=0;
     1289    CData(ind_y,:)=ones(numel(ind_y),1)*LineData;%create an image band with width numel(ind_y)
    13111290end
    13121291CData=cat(3,zeros(size(CData)),CData,zeros(size(CData))); % make color images r=0,g,b=0
     
    15201499if isempty(pos_last), pos_last=1; end
    15211500Position=get(handles.Waitbar,'Position'); % position of the waitbar:= [ x,y, width, height]
    1522 Position_status=get(handles.FileStatus,'Position');
     1501Position_status=get(handles.FileStatus,'Position');% position of the FileStatus bar:= [ x,y, width, height]
    15231502Position(1)=Position_status(1)+Position_status(3)*pos_first;
    15241503Position(3)=max(Position_status(3)*(pos_last-pos_first),0.001); % width must remain positive
     
    26422621    end
    26432622    if  VelTypeRequest_1 && numel(iview_civ)>=2
    2644         menu=set_veltype_display(SeriesData.FileInfo{iview_civ(2)}.CivStage,SeriesData.FileType{iview_civ(2)});
     2623        menu=set_veltype_display(SeriesData.FileInfo{iview_civ(2)}.CivStage,SeriesData.FileInfo{iview_civ(2)}.FileType);
    26452624        set(handles.VelType_1,'Value',1)% set first choice by default
    26462625        set(handles.VelType_1,'String',[{'*'};menu])
     
    29962975    FieldListInit(field_index(1))=[];
    29972976    SeriesData=get(handles.series,'UserData');
     2977    for iview=1:numel(SeriesData.FileInfo)
     2978    FileType{iview}=SeriesData.FileInfo{iview}.FileType;
     2979    end
    29982980    % input line for which the field choice is relevant
    2999     iview=find(ismember(SeriesData.FileType,{'netcdf','civx','civdata'})); % all nc files, icluding civ
     2981    iview=find(ismember(FileType,{'netcdf','civx','civdata'})); % all nc files, icluding civ
    30002982    hget_field=findobj(allchild(0),'name','get_field');
    30012983    if ~isempty(hget_field)
     
    31523134    end
    31533135    Param=read_GUI(handles.series);
    3154     InputTable=Param.InputTable(2,:);
     3136    %InputTable=Param.InputTable(2,:);
    31553137    % check the existence of the first file in the series
    31563138    first_j=[];
     
    41944176check_input_file_series(handles,CheckRelabel)
    41954177ActionInput_Callback([],[], handles)
    4196 % if get(handles.Relabel,'Value')
    4197 %             NomType='*';
    4198 %             i1=1;i2=[];j1=1;j2=[];
    4199 %             i1_series=1:size(XmlData.Time,1)-1;   
    4200 %             i2_series=[];
    4201 %             j1_series=1:size(XmlData.Time,2)-1;
    4202 %             j2_series=[];
    4203 %
    4204 %
    4205 %
    4206 %     SeriesData=get(handles.series,'UserData');
    4207 %     if isfield(SeriesData,'FileSeries')&& ~isempty(SeriesData.FileSeries{1})
    4208 %         [nbfield,nbfield_j]=size(SeriesData.Time{1});
    4209 %         nbfield=nbfield-1; %remove the possible index 0
    4210 %         nbfield_j=nbfield_j-1; %remove the possible index 0
    4211 %         MaxIndex_i=get(handles.MaxIndex_i,'Data');
    4212 %         MaxIndex_j=get(handles.MaxIndex_j,'Data');
    4213 %         MaxIndex_i(1,:)=nbfield;
    4214 %         MaxIndex_j(1,:)=nbfield_j;
    4215 %                 MinIndex_i(1,:)=1;
    4216 %         MinIndex_j(1,:)=1;
    4217 %         set(handles.MaxIndex_i,'Data',MaxIndex_i)
    4218 %         set(handles.MaxIndex_j,'Data',MaxIndex_j)
    4219 %          set(handles.MinIndex_i,'Data',MinIndex_i)
    4220 %         set(handles.MinIndex_j,'Data',MinIndex_j)
    4221 %         first_i=str2double(get(handles.num_first_i,'String'));
    4222 %         first_j=str2double(get(handles.num_first_j,'String'));
    4223 %         %i1=(first_i-SeriesData.FileSeries{1}.FirstFileIndex)*SeriesData.FileSeries{1}.NbFramePerFile+1;%frame index deduced from input file index
    4224 %         i1=1;
    4225 %         if strcmp(SeriesData.TimeName,'xml')% indices i and j
    4226 %             j1=mod(i1-1,nbfield_j)+first_j;
    4227 %             i1=floor((i1-1)/nbfield_j)+1;
    4228 %             set(handles.num_first_j,'String',num2str(j1))
    4229 %         end
    4230 %         set(handles.num_first_i,'String',num2str(i1))
    4231 % %         last_i=str2double(get(handles.num_last_i,'String'));
    4232 % %         last_j=str2double(get(handles.num_last_j,'String'));
    4233 % %         i1=(last_i-SeriesData.FileSeries{1}.FirstFileIndex)*SeriesData.FileSeries{1}.NbFramePerFile+1;%frame index deduced from input file index
    4234 % %         if strcmp(SeriesData.TimeName,'xml')% indices i and j
    4235 % %             j1=mod(i1-1,nbfield_j)+1;
    4236 % %             i1=floor((i1-1)/nbfield_j)+1;
    4237 % %         end
    4238 %         set(handles.num_last_i,'String',num2str(nbfield))
    4239 %          set(handles.num_last_j,'String',num2str(nbfield_j))
    4240 %     end
    4241 % else
    4242 %     check_input_file_series(handles)
    4243 %     ActionInput_Callback([],[], handles)
    4244 % end
    4245 
     4178
     4179
  • trunk/src/series/filter_time_singlefile.m

    r1181 r1194  
    119119% filecell{iview,fileindex}:
    120120%        iview: line in the table corresponding to a given file series
    121 %        fileindex: file index within  the file series, 
    122 % 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 
     121%        fileindex: file index within  the file series,
     122% 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
    123123% i1_series(iview,fileindex) expresses the same indices as a 1D array in file indices
    124124%%%%%%%%%%%% NbView=1 : a single input series
     
    141141[i1,~,j1,~] = get_file_index(Param.IndexRange.first_i,first_j,PairString);
    142142[i2,~,j2,~] = get_file_index(Param.IndexRange.last_i,last_j,PairString);
    143 ncfile_out=fullfile_uvmat(OutputPath,OutputDir,Param.InputTable{1,3},'.nc',NomTypeNc,i1,i2,j1,j2);
    144 
    145 % OutputPath=fullfile(Param.OutputPath,num2str(Param.Experiment),num2str(Param.Device));
    146 % RootFileOut=RootFile{1};
    147 % NomTypeOut='_1';
     143ncfile_out=fullfile_uvmat(OutputPath,OutputDir,Param.InputTable{1,3},'*.nc',NomTypeNc,i1,i2,j1,j2);
    148144
    149145%%%%%%%%%%%%%%%% loop on field indices %%%%%%%%%%%%%%%%
    150 disp('loop for filtering started') 
    151  ncid=[];
     146disp('loop for filtering started')
     147ncid=[];
    152148for index=1:NbField
    153149    index
    154    
    155150    [Field,~,errormsg]= read_field(filecell{1,index},'netcdf',Param.InputFields);
    156151    if ~isempty(errormsg)
    157152        disp(errormsg)
    158153        if ~isempty(ncid)
    159         netcdf.close(ncid)
     154            netcdf.close(ncid)
    160155        end
    161156        return
     
    179174            VarDimIndex{ifield+3}=[2 3 1];
    180175        end
    181 
    182 %         VarDimIndex={1,2,3,[1 2 3],[1 2 3]};
    183 
    184176        DataOut.coord_x=Field.coord_x;
    185177        DataOut.coord_y=Field.coord_y;
     
    192184        netcdf.putVar(ncid,1,0,npy,Field.coord_y)
    193185        netcdf.putVar(ncid,2,0,npx,Field.coord_x)
    194 %         Uvarid=3;
    195 %         Vvarid=4;
    196186        TimeBlock=zeros(Param.ActionInput.WindowLength,1);
    197187        Fieldblock=zeros(numel(ListFields),Param.ActionInput.WindowLength,npy,npx);
    198         %Vblock=zeros(Param.ActionInput.WindowLength,npy,npx);
    199     end
    200 
     188    end
     189   
    201190    TimeBlock=circshift(TimeBlock,[-1 0 ]);
    202191    TimeBlock(end)=Field.Time;
     
    204193    Timefilter=mean(TimeBlock(end-sumindex:end,:,:));%mid time
    205194    Fieldblock=circshift(Fieldblock,[0 -1 0 0]); %shift U by ishift along the first index
    206    % Vblock=circshift(Vblock,[-1 0 0]); %shift U by ishift along the first index
    207195    for ifield=1:numel(ListFields)
    208     Fieldblock(ifield,end,:,:)=Field.(ListFields{ifield});
    209     end
    210     %Vblock(end,:,:)=Field.V;
     196        Fieldblock(ifield,end,:,:)=Field.(ListFields{ifield});
     197    end
    211198    Fieldfilter=squeeze(mean(Fieldblock(:,end-sumindex:end,:,:),2,'omitnan'));
    212 %     Ufilter=squeeze(mean(Ublock(end-sumindex:end,:,:),1,'omitnan'));
    213 %     Vfilter=squeeze(mean(Vblock(end-sumindex:end,:,:),1,'omitnan'));
    214 %     Uerror=Ufilter-Ublock(end-floor(sumindex/2),:,:);
    215 %     Verror=Ufilter-Vblock(end-floor(sumindex/2),:,:);
    216     %updating output the netcdf file
    217      tstart = tic;
    218     netcdf.putVar(ncid,0,(index-1),Timefilter)
     199    netcdf.putVar(ncid,0,(index-1),Timefilter)    % update the field in the nc file
    219200    for ifield=1:numel(ListFields)
    220201        netcdf.putVar(ncid,Field_varid(ifield),[ 0 0 (index-1)],[npy npx 1],squeeze(Fieldfilter(ifield,:,:)))
    221202    end
    222 %     netcdf.putVar(ncid,Uvarid,[ 0 0 (index-1)],[npy npx 1],Ufilter)
    223 %      netcdf.putVar(ncid,Vvarid,[0 0 (index-1)],[npy npx 1],Vfilter)
    224 
    225  telapsed = toc(tstart)% time for writting the field
    226     % writing the result file as netcdf file
    227     %     i1=i1_series{1}(index)-ceil(NpTime/2);
    228     %     OutputFile=fullfile_uvmat(OutputPath,OutputDir,RootFileOut,'.nc',NomTypeOut,i1);
    229     %     errormsg=struct2nc(OutputFile, DataOut);
    230     %     if isempty(errormsg)
    231     %         disp([OutputFile ' written'])
    232     %     else
    233     %         disp(errormsg)
    234     %     end
    235 end
    236 netcdf.close(ncid)
    237 figure
    238 plot(telapsed)
    239 ylabel('time lapsed computation')
     203end
     204
    240205'END'
  • trunk/src/series/merge_proj.m

    r1152 r1194  
    223223    NomTypeOut='_1_1';
    224224end
    225 %NomTypeOut=NomType;% output file index will indicate the first and last ref index in the series
    226225RootFileOut=RootFile{1};
    227226for iview=2:NbView
     
    265264    if ~isempty(j1_series{1})
    266265        j1=j1_series{1}(index);
    267         if ~isempty(j2_series{end})
    268             j2=j2_series{end}(index);
    269         else
    270             j2=j1;
    271         end
    272     end
    273     OutputFile=fullfile_uvmat(OutputPath,OutputDir,RootFileOut,FileExtOut,NomTypeOut,i1,i2,j1,j2);
     266    end
     267    i_out=floor((i1+i2)/2);
     268    OutputFile=fullfile_uvmat(OutputPath,OutputDir,RootFileOut,FileExtOut,NomTypeOut,i_out,[],j1);
    274269    if ~CheckOverwrite && exist(OutputFile,'file')
    275270            disp(['existing output file ' OutputFile ' already exists, skip to next field'])
  • trunk/src/struct2nc.m

    r1157 r1194  
    6868cmode = bitor(cmode, netcdf.getConstant('CLOBBER'));
    6969nc = netcdf.create(flname, cmode);
     70netcdf.setFill(nc,'NOFILL')
    7071
    7172%% write global constants
Note: See TracChangeset for help on using the changeset viewer.