Changeset 362


Ignore:
Timestamp:
Jan 9, 2012, 5:21:57 PM (9 years ago)
Author:
sommeria
Message:

various bugs corrected

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r360 r362  
    423423set(handles.RootName,'String',RootName)
    424424browse=get(handles.RootName,'UserData');
    425 browse.nom_type_nc=NomTypeNc;
     425% browse.nom_type_nc=NomTypeNc;
    426426browse.incr_pair=[0 0];%default
    427427
     
    433433num_ref_j=j1;
    434434if ~isempty(j2)
    435     num_ref_i=floor((num_ref_j+j2)/2);
     435    num_ref_j=floor((num_ref_j+j2)/2);
    436436end
    437437
     
    581581
    582582%%  set the menus of image pairs and default selection for civ   %%%%%%%%%%%%%%%%%%%
    583 check_letter=~isempty(regexp(NomTypeIma,'[ab|AB]$'));%detect pair label by letter
    584 if ~check_letter|| isequal(NomTypeNc,'_1-2')|| (MaxIndex_j==1)
     583%check_letter=~isempty(regexp(NomTypeIma,'[ab|AB]$'));%detect pair label by letter
     584if isequal(NomTypeNc,'_1-2')|| (MaxIndex_j==1)
    585585    set(handles.ListPairMode,'Value',1)
    586586    set(handles.ListPairMode,'String',{'series(Di)'})   
     
    679679    set(handles.ListSubdirCiv2,'Value',ilist)
    680680else % if Civ1 data already exist
    681     find_netcpair_civ(handles,1); %update the list of available pairs from netcdf files in the new directory
     681    errormsg=find_netcpair_civ(handles,1); %update the list of available pairs from netcdf files in the new directory
     682    if ~isempty(errormsg)
     683    msgbox_uvmat('ERROR',errormsg)
     684    end
    682685end
    683686
     
    697700%update the list of available pairs from netcdf files in the new directory
    698701if ~get(handles.CheckCiv2,'Value') && ~get(handles.CheckCiv1,'Value') && ~get(handles.CheckFix1,'Value') && ~get(handles.CheckPatch1,'Value')
    699     find_netcpair_civ(handles,2);
     702    errormsg=find_netcpair_civ(handles,2);
     703        if ~isempty(errormsg)
     704    msgbox_uvmat('ERROR',errormsg)
     705    end
    700706end
    701707
     
    749755ind_selected=find(checkbox,1);
    750756if ~isempty(ind_selected)
    751   RootName=get(handles.RootName,'String');
     757    RootName=get(handles.RootName,'String');
    752758    if isempty(RootName)
    753          msgbox_uvmat('ERROR','Please open an image or PIV .nc file with the upper bar menu Open/Browse...')
    754         returnopening
     759        msgbox_uvmat('ERROR','Please open an image or PIV .nc file with the upper bar menu Open/Browse...')
     760        return
    755761    end
    756762end
     
    759765set(handles.ListSubdirCiv1,'Visible','on')
    760766if ~opening
    761 find_netcpair_civ(handles,1) % select the available netcdf files
     767    errormsg=find_netcpair_civ(handles,1); % select the available netcdf files
     768    if ~isempty(errormsg)
     769        msgbox_uvmat('ERROR',errormsg)
     770    end
    762771end
    763772if max(checkbox(4:6))% case of civ2 pair choice needed
     
    768777    set(handles.ListPairCiv2,'Visible','on')
    769778    if ~opening
    770     find_netcpair_civ(handles,2) % select the available netcdf files
     779        errormsg=find_netcpair_civ(handles,2); % select the available netcdf files
     780        if ~isempty(errormsg)
     781            msgbox_uvmat('ERROR',errormsg)
     782        end
    771783    end
    772784else
     
    27712783end
    27722784set(handles.ListPairCiv1,'UserData',displ_num);
    2773 find_netcpair_civ( handles,1)
     2785errormsg=find_netcpair_civ( handles,1);
     2786    if ~isempty(errormsg)
     2787    msgbox_uvmat('ERROR',errormsg)
     2788    end
    27742789% find_netcpair_civ2(handles)
    27752790
     
    28822897mode_value=get(handles.ListPairMode,'Value');
    28832898mode=mode_list{mode_value};
    2884 find_netcpair_civ(handles,1);% update the menu of pairs depending on the available netcdf files
     2899errormsg=find_netcpair_civ(handles,1);% update the menu of pairs depending on the available netcdf files
    28852900if isequal(mode,'series(Di)') || ...% we do patch2 only
    28862901        (get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0)
    2887     find_netcpair_civ( handles,2);
    2888 end
     2902    errormsg=find_netcpair_civ( handles,2);
     2903end
     2904    if ~isempty(errormsg)
     2905    msgbox_uvmat('ERROR',errormsg)
     2906    end
    28892907
    28902908%------------------------------------------------------------------------
     
    28952913mode=mode_list{mode_value};
    28962914if isequal(get(handles.CheckCiv1,'Value'),0)|| isequal(mode,'series(Dj)')
    2897     find_netcpair_civ(handles,1);% update the menu of pairs depending on the available netcdf files
     2915    errormsg=find_netcpair_civ(handles,1);% update the menu of pairs depending on the available netcdf files
    28982916end
    28992917if isequal(mode,'series(Dj)') || ...
    29002918        (get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0)
    2901     find_netcpair_civ(handles,2);
    2902 end
    2903 %
     2919    errormsg=find_netcpair_civ(handles,2);
     2920end
     2921    if ~isempty(errormsg)
     2922    msgbox_uvmat('ERROR',errormsg)
     2923    end
    29042924
    29052925%------------------------------------------------------------------------
    29062926% determine the menu for checkciv1 pairs depending on existing netcdf file at the middle of
    29072927% the field series set by first_i, incr, last_i
    2908 function find_netcpair_civ(handles,index)
    2909 %------------------------------------------------------------------------
    2910 set(gcf,'Pointer','watch')
     2928function errormsg=find_netcpair_civ(handles,index)
     2929%------------------------------------------------------------------------
     2930set(gcf,'Pointer','watch')% set the mouse pointer to 'watch' (clock)
     2931
     2932%% initialisation
     2933errormsg='';
    29112934filebase=get(handles.RootName,'String');
    29122935[filepath,Nme,ext_dir]=fileparts(filebase);
     
    29282951
    29292952%% determine nom_type_nc, nomenclature type of the .nc files:
    2930 nom_type_nc='';%default
    2931 if isfield(browse,'nom_type_nc')
    2932     nom_type_nc=browse.nom_type_nc;
    2933 end
    2934 if isempty(nom_type_nc)
     2953% nom_type_nc='';%default
     2954% if isfield(browse,'nom_type_nc')
     2955%     nom_type_nc=browse.nom_type_nc;
     2956% end
     2957% if isempty(nom_type_nc)
    29352958    [nom_type_nc]=nomtype2pair(nom_type_ima,mode);
    2936 end
    2937 browse.nom_type_nc=nom_type_nc;
    2938 set(handles.RootName,'UserData',browse)
    2939 
    2940 %reads .nc subdirectoy and image numbers from the interface
     2959% end
     2960% browse.nom_type_nc=nom_type_nc;
     2961% set(handles.RootName,'UserData',browse)
     2962
     2963%% reads .nc subdirectoy and image numbers from the interface
    29412964subdir_civ1=get(handles.txt_SubdirCiv1,'String');%subdirectory subdir_civ1 for the netcdf data
    29422965subdir_civ2=get(handles.txt_SubdirCiv2,'String');%subdirectory subdir_civ2 for the netcdf data
     
    29522975displ_num=get(handles.ListPairCiv1,'UserData');
    29532976
    2954 %eliminate the first pairs inconsistent with the position
     2977%% eliminate the first pairs inconsistent with the position
    29552978if isempty(displ_num)
    29562979    nbpair=0;
     
    29652988nbpair=min(200,nbpair);%limit the number of displayed pairs to 200
    29662989
    2967 %look for existing processed pairs involving the field at the middle of the series if checkciv1 will not
     2990%% case with no Civ1 operation, netcdf files need to exist for reading
    29682991% be performed, while the result is needed for next steps.
    29692992displ_pair={''};
    29702993select=ones(size(1:nbpair));%flag for displayed pairs =1 for display
    29712994testpair=0;
    2972 
    2973 %% case with no Civ1 operation, netcdf files need to exist for reading
    29742995[RootPath,RootFile]=fileparts(filebase);
    29752996if index==1 % case civ1
    2976 if ~get(handles.CheckCiv1,'Value') %
    2977     if ~exist(fullfile(filepath,subdir_civ1,ext_dir),'dir')
    2978         msgbox_uvmat('ERROR',['no civ1 file available: subdirectory ' subdir_civ1 ' does not exist']);
    2979         set(handles.ListPairCiv1,'String',{});
    2980         return
    2981     end
    2982     for ipair=1:nbpair
    2983         filename=fullfile_uvmat(RootPath,subdir_civ1,RootFile,'.nc',nom_type_nc,...
    2984             ref_i+displ_num(3,ipair),ref_i+displ_num(4,ipair),ref_j+displ_num(1,ipair),ref_j+displ_num(2,ipair));
    2985         select(ipair)=exist(filename,'file')==2;% put flag to 0 if the file does not exist
    2986     end   
    2987     % case of no displayed pair
    2988     if isequal(select,zeros(size(1:nbpair)))
    2989         if isfield(browse,'incr_pair') && ~isequal(browse.incr_pair,[0 0])
    2990             num_i1=ref_i-floor(browse.incr_pair(1)/2);
    2991             num_i2=ref_i+ceil(browse.incr_pair(1)/2);
    2992             num_j1=ref_j-floor(browse.incr_pair(2)/2);
    2993             num_j2=ref_j+ceil(browse.incr_pair(2)/2);
    2994             filename=fullfile_uvmat(RootPath,subdir_civ1,RootFile,'.nc',nom_type_nc,num_i1,num_i2,num_j1,num_j2);
    2995             select(1)=exist(filename,'file')==2;
    2996             testpair=1;
    2997         else
    2998             if  isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)')
    2999                 msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ1]);
     2997    if ~get(handles.CheckCiv1,'Value') %
     2998        if ~exist(fullfile(filepath,subdir_civ1,ext_dir),'dir')
     2999            errormsg=['no civ1 file available: subdirectory ' subdir_civ1 ' does not exist'];
     3000            set(handles.ListPairCiv1,'String',{});
     3001            return
     3002        end
     3003        for ipair=1:nbpair
     3004            filename=fullfile_uvmat(RootPath,subdir_civ1,RootFile,'.nc',nom_type_nc,...
     3005                ref_i+displ_num(3,ipair),ref_i+displ_num(4,ipair),ref_j+displ_num(1,ipair),ref_j+displ_num(2,ipair));
     3006            select(ipair)=exist(filename,'file')==2;% put flag to 0 if the file does not exist
     3007        end
     3008        % case of no displayed pair
     3009        if isequal(select,zeros(size(1:nbpair)))
     3010            if isfield(browse,'incr_pair') && ~isequal(browse.incr_pair,[0 0])
     3011                num_i1=ref_i-floor(browse.incr_pair(1)/2);
     3012                num_i2=ref_i+ceil(browse.incr_pair(1)/2);
     3013                num_j1=ref_j-floor(browse.incr_pair(2)/2);
     3014                num_j2=ref_j+ceil(browse.incr_pair(2)/2);
     3015                filename=fullfile_uvmat(RootPath,subdir_civ1,RootFile,'.nc',nom_type_nc,num_i1,num_i2,num_j1,num_j2);
     3016                select(1)=exist(filename,'file')==2;
     3017                testpair=1;
    30003018            else
    3001                 msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ1]);
    3002             end
    3003             set(handles.ListPairCiv1,'String',{''});
    3004             %COMPLETER CAS STEREO
    3005             return
    3006         end
    3007     end
    3008 end
    3009 else %case civ2
    3010 if ~get(handles.CheckCiv2,'Value') && ~get(handles.CheckCiv1,'Value') && ~get(handles.CheckFix1,'Value') && ~get(handles.CheckPatch1,'Value')
    3011     if ~exist(fullfile(filepath,subdir_civ2,ext_dir),'dir')
    3012         errordlg(['no civ2 file available: subdirectory ' subdir_civ2 ' does not exist'])
    3013         set(handles.ListPairCiv2,'Value',1);
    3014         set(handles.ListPairCiv2,'String',{''});
    3015         return
    3016     end
    3017     for ipair=1:nbpair
    3018         filename=fullfile_uvmat(RootPath,subdir_civ1,RootFile,'.nc',nom_type_nc,...
    3019             ref_i+displ_num(3,ipair),ref_i+displ_num(4,ipair),ref_j+displ_num(1,ipair),ref_j+displ_num(2,ipair));
    3020         select(ipair)=exist(filename,'file')==2;
    3021     end
    3022     if  isequal(select,zeros(size(1:nbpair)))
    3023         if isfield(browse,'incr_pair')
    3024             num_i1=ref_i-floor(browse.incr_pair(1)/2);
    3025             num_i2=ref_i+floor((browse.incr_pair(1)+1)/2);
    3026             num_j1=ref_j-floor(browse.incr_pair(2)/2);
    3027             num_j2=ref_j+floor((browse.incr_pair(2)+1)/2);
    3028             filename=fullfile_uvmat(RootPath,subdir_civ2,RootFile,'.nc',nom_type_nc,num_i1,num_i2,num_j1,num_j2);
    3029             select(1)=exist(filename,'file')==2;
    3030         else
    3031             if  isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)')
    3032                 msgbox_uvmat('ERROR',['no civ2 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ2])
    3033             else
    3034                 msgbox_uvmat('ERROR',['no civ2 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ2])
    3035             end
     3019                if  isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)')
     3020                    errormsg=['no civ1 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ1];
     3021                else
     3022                    errormsg=['no civ1 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ1];
     3023                end
     3024                set(handles.ListPairCiv1,'String',{''});
     3025                %COMPLETER CAS STEREO
     3026                return
     3027            end
     3028        end
     3029    end
     3030else %case civ2 alone
     3031    if ~get(handles.CheckCiv2,'Value') && ~get(handles.CheckCiv1,'Value') && ~get(handles.CheckFix1,'Value') && ~get(handles.CheckPatch1,'Value')
     3032        if ~exist(fullfile(filepath,subdir_civ2,ext_dir),'dir')
     3033            errordlg(['no civ2 file available: subdirectory ' subdir_civ2 ' does not exist'])
    30363034            set(handles.ListPairCiv2,'Value',1);
    30373035            set(handles.ListPairCiv2,'String',{''});
    30383036            return
    30393037        end
    3040     end
    3041 end
     3038        for ipair=1:nbpair
     3039            filename=fullfile_uvmat(RootPath,subdir_civ1,RootFile,'.nc',nom_type_nc,...
     3040                ref_i+displ_num(3,ipair),ref_i+displ_num(4,ipair),ref_j+displ_num(1,ipair),ref_j+displ_num(2,ipair));
     3041            select(ipair)=exist(filename,'file')==2;
     3042        end
     3043        if  isequal(select,zeros(size(1:nbpair)))
     3044            if isfield(browse,'incr_pair')
     3045                num_i1=ref_i-floor(browse.incr_pair(1)/2);
     3046                num_i2=ref_i+floor((browse.incr_pair(1)+1)/2);
     3047                num_j1=ref_j-floor(browse.incr_pair(2)/2);
     3048                num_j2=ref_j+floor((browse.incr_pair(2)+1)/2);
     3049                filename=fullfile_uvmat(RootPath,subdir_civ2,RootFile,'.nc',nom_type_nc,num_i1,num_i2,num_j1,num_j2);
     3050                select(1)=exist(filename,'file')==2;
     3051            else
     3052                if  isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)')
     3053                    errormsg=['no civ2 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ2];
     3054                else
     3055                    errormsg=['no civ2 file available for the selected reference index i=' num2str(ref_i) ' and subdirectory ' subdir_civ2];
     3056                end
     3057                set(handles.ListPairCiv2,'Value',1);
     3058                set(handles.ListPairCiv2,'String',{''});
     3059                return
     3060            end
     3061        end
     3062    end
    30423063end
    30433064
     
    31013122    displ_pair={'Di=Dj=0'};
    31023123end
     3124if index==1
    31033125set(handles.ListPairCiv1,'String',displ_pair');
     3126end
    31043127
    31053128%% determine the default selection in the pair menu
     
    36853708end
    36863709set(handles.txt_SubdirCiv1,'String',SubDir);
    3687 find_netcpair_civ(handles,1)
    3688 
     3710errormsg=find_netcpair_civ(handles,1);
     3711if ~isempty(errormsg)
     3712    msgbox_uvmat('ERROR',errormsg)
     3713end
     3714   
    36893715%------------------------------------------------------------------------
    36903716% --- Executes on button press in ListSubdirCiv2.
     
    44824508        Data.Civ1_V_Diff=Data.Civ1_V_Diff(Data.Civ1_FF==0);
    44834509        DiffVel(irho)=sqrt(mean(Data.Civ1_U_Diff.*Data.Civ1_U_Diff+Data.Civ1_V_Diff.*Data.Civ1_V_Diff))
    4484         NbSites(irho)=Data.Civ1_NbSites/numel(Data.Civ1_U_Diff);
     4510        NbSites(irho,:)=Data.Civ1_NbSites*numel(Data.Civ1_NbSites)/numel(Data.Civ1_U_Diff);
    44854511        Param.Patch1.SmoothingParam=2*Param.Patch1.SmoothingParam;
    44864512    end
  • trunk/src/find_file_series.m

    r360 r362  
    181181    for ifile=1:nbpair
    182182        rr=regexp(dirpair(ifile).name,detect_string,'names');
     183        if ~isempty(rr)
    183184        i1=str2num(rr.i1);
    184185        i2=str2num(rr.i2);
     
    232233            j2_series(ref_i+1,ref_j+1,nb_pairs+1)=j2;
    233234        end
     235        end
    234236    end
    235237    % look for the numerical string of the first files to update the NomType (take into account the 0 before the number)
  • trunk/src/tps_coeff.m

    r356 r362  
    2626% X=reshape(X,[],1);
    2727% Y=reshape(Y,[],1);
    28 % N=numel(X);
     28N=size(ctrs,1);
    2929% rhs = reshape(U,[],1);
    3030U = [U; zeros(3,1)];
Note: See TracChangeset for help on using the changeset viewer.