Changeset 1098 for trunk/src/series


Ignore:
Timestamp:
Apr 13, 2021, 7:19:35 PM (3 years ago)
Author:
sommeria
Message:

various bugs repaired

Location:
trunk/src/series
Files:
2 edited

Legend:

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

    r1097 r1098  
    17951795
    17961796if get(handles.TestPatch1,'Value')% if TestPatch1 is activated
    1797      set(handles.TestPatch1,'BackgroundColor',[1 1 0])%paint TestPatch1 button in yellow to indicate activation
    1798      set(handles.Civ1,'BackgroundColor',[1 1 0])% indicate civ1 calculation is performed
    1799      hseries=findobj(allchild(0),'Tag','series');
    1800      Param=read_GUI(hseries);
    1801      Param.Action.RUN=1;
    1802      Param.ActionInput=read_GUI(handles.civ_input);
    1803      if isfield(Param.ActionInput,'Civ2')%remove options that may be selected beyond Patch1
    1804          Param.ActionInput=rmfield(Param.ActionInput,'Civ2');
    1805      end
    1806      if isfield(Param.ActionInput,'Fix2')
    1807          Param.ActionInput=rmfield(Param.ActionInput,'Fix2');
    1808      end
    1809      if isfield(Param.ActionInput,'Patch2')
    1810          Param.ActionInput=rmfield(Param.ActionInput,'Patch2');
    1811      end
    1812      if isfield(Param,'OutputSubDir')
    1813          Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series
    1814      end
    1815      ParamPatch1=Param.ActionInput.Patch1; %store the patch1 parameters
    1816      Param.ActionInput=rmfield(Param.ActionInput,'Patch1');% does not execute Patch
    1817      Param.IndexRange.first_i=str2num(get(handles.ref_i,'String'));
    1818      Param.IndexRange.last_i=Param.IndexRange.first_i;
    1819      if strcmp(get(handles.ref_j,'Visible'),'on')
    1820          Param.IndexRange.first_j=str2num(get(handles.ref_j,'String'));
    1821          Param.IndexRange.last_j=Param.IndexRange.first_j;
    1822      else
    1823          Param.IndexRange.first_j=1;
    1824          Param.IndexRange.last_j=1;
    1825      end
    1826      [Data,errormsg]=civ_series(Param);% get the civ1+fix1 results
    1827      bckcolor=get(handles.civ_input,'Color');
    1828      set(handles.Civ1,'BackgroundColor',bckcolor)% indicate civ1 calculation is finished
    1829      
    1830      %% prepare Param for iterative Patch processing without input file reading
    1831      Param.Civ1_X=Data.Civ1_X;
    1832      Param.Civ1_Y=Data.Civ1_Y;
    1833      Param.Civ1_U=Data.Civ1_U;
    1834      Param.Civ1_V=Data.Civ1_V;
    1835      Param.Civ1_FF=Data.Civ1_FF;
    1836      Param=rmfield(Param,'InputTable');%desactivate input file reading
    1837     if isfield(Param.ActionInput,'Civ1')
    1838         Param.ActionInput=rmfield(Param.ActionInput,'Civ1');%desactivate civ1: remove civ1 input param if relevant
    1839     end
    1840     if isfield(Param.ActionInput,'Fix1')
    1841         Param.ActionInput=rmfield(Param.ActionInput,'Fix1');%desactivate fix1:remove fix1 input param if relevant
    1842     end
    1843     SmoothingParam=(ParamPatch1.FieldSmooth/10)*2.^(1:7);%scan the smoothing param from 1/10 to 12.8 current value
    1844     NbGood=numel(find(Data.Civ1_FF==0));
    1845     NbExclude=zeros(1,7);% initialize the set of smoothing parameters
    1846     DiffVel=zeros(1,7);% initialize the rms difference between patch and civ
    1847     Param.ActionInput.Patch1=ParamPatch1;% retrieve Patch1 parameters
    1848     for irho=1:7
    1849         Param.ActionInput.Patch1.FieldSmooth=SmoothingParam(irho);
    1850         [Data,errormsg]= civ_series(Param);%apply the processing fct
    1851         if ~isempty(errormsg)
    1852             msgbox_uvmat('ERROR',errormsg)
    1853             return
    1854         end
    1855         ind_good=find(Data.Civ1_FF==0);
    1856         Civ1_U_Diff=Data.Civ1_U(ind_good)-Data.Civ1_U_smooth(ind_good);
    1857         Civ1_V_Diff=Data.Civ1_V(ind_good)-Data.Civ1_V_smooth(ind_good);
    1858         DiffVel(irho)=sqrt(mean(Civ1_U_Diff.*Civ1_U_Diff+Civ1_V_Diff.*Civ1_V_Diff));
    1859         NbExclude(irho)=(NbGood-numel(ind_good))/NbGood;
    1860     end
    1861     figure(1)
    1862     semilogx(SmoothingParam,DiffVel,'b',SmoothingParam,NbExclude,'r',SmoothingParam,0.2*ones(size(SmoothingParam)),'m')
    1863     grid on
    1864     legend('rms velocity diff. Patch1-Civ1 (pixels)','proportion of excluded vectors (between 0 to 1)','recommended diff Patch1-Civ1')
    1865     xlabel('smoothing parameter')
    1866     ylabel('smoothing effect')
    1867     set(handles.TestPatch1,'BackgroundColor',[0 1 0])
    1868 else
    1869     corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display
    1870     if ~isempty(corrfig)
    1871         delete(corrfig)
    1872     end
    1873     hview_field=findobj(allchild(0),'tag','view_field');% look for view_field
    1874     if ~isempty(hview_field)
    1875         delete(hview_field)
    1876     end
    1877 end
    1878 
     1797    hseries=findobj(allchild(0),'Tag','series');
     1798    Param=read_GUI(hseries);
     1799    CivDir=fullfile(Param.OutputPath,Param.Experiment,Param.Device,[Param.OutputSubDir Param.OutputDirExt]);
     1800    % ListXml=dir(CivXmlDir);
     1801    if exist(CivDir,'dir')
     1802        CivFile=uigetfile_uvmat('pick .nc file with civ1-fix1 data',CivDir,'.nc');
     1803        [Field,VelTypeOut,errormsg]=read_civdata(CivFile)
     1804        for ilist=1:numel(Field.ListGlobalAttribute)
     1805            r=regexp(Field.ListGlobalAttribute{ilist},'Civ1_(?<field>.+)','names');% \D = not a digit, \d =digi
     1806            if ~isempty(r)
     1807                ParamTest.Civ1.(r.field)=(Field.(['Civ1_' r.field]));
     1808            end
     1809            r=regexp(Field.ListGlobalAttribute{ilist},'Fix1_(?<field>.+)','names');% \D = not a digit, \d =digi
     1810            if ~isempty(r)
     1811                ParamTest.Fix1.(r.field)=(Field.(['Fix1_' r.field]));
     1812            end
     1813        end
     1814        fill_GUI(ParamTest,handles.civ_input)% fill the elements of the GUI series with the input parameters
     1815        drawnow
     1816        update_CivOptions(handles,0)
     1817       
     1818        set(handles.TestPatch1,'BackgroundColor',[1 1 0])%paint TestPatch1 button in yellow to indicate activation
     1819%         set(handles.Civ1,'BackgroundColor',[1 1 0])% indicate civ1 calculation is performed
     1820        Param.Action.RUN=1;
     1821         Param.ActionInput=read_GUI(handles.civ_input);
     1822         Param.ActionInput.CheckCiv1=0;% do not repeat Civ1 computation       
     1823        if isfield(Param.ActionInput,'Civ2')%remove options that may be selected beyond Patch1
     1824            Param.ActionInput=rmfield(Param.ActionInput,'Civ2');
     1825        end
     1826        if isfield(Param.ActionInput,'Fix2')
     1827            Param.ActionInput=rmfield(Param.ActionInput,'Fix2');
     1828        end
     1829        if isfield(Param.ActionInput,'Patch2')
     1830            Param.ActionInput=rmfield(Param.ActionInput,'Patch2');
     1831        end
     1832        if isfield(Param,'OutputSubDir')
     1833            Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series
     1834        end
     1835        ParamPatch1=Param.ActionInput.Patch1; %store the patch1 parameters
     1836        Param.ActionInput=rmfield(Param.ActionInput,'Patch1');% does not execute Patch
     1837        Param.IndexRange.first_i=str2num(get(handles.ref_i,'String'));
     1838        Param.IndexRange.last_i=Param.IndexRange.first_i;
     1839        if strcmp(get(handles.ref_j,'Visible'),'on')
     1840            Param.IndexRange.first_j=str2num(get(handles.ref_j,'String'));
     1841            Param.IndexRange.last_j=Param.IndexRange.first_j;
     1842        else
     1843            Param.IndexRange.first_j=1;
     1844            Param.IndexRange.last_j=1;
     1845        end
     1846        [Data,errormsg]=civ_series(Param);% get the civ1+fix1 results
     1847        bckcolor=get(handles.civ_input,'Color');
     1848        set(handles.Civ1,'BackgroundColor',bckcolor)% indicate civ1 calculation is finished
     1849       
     1850        %% prepare Param for iterative Patch processing without input file reading
     1851        Param.Civ1_X=Data.Civ1_X;
     1852        Param.Civ1_Y=Data.Civ1_Y;
     1853        Param.Civ1_U=Data.Civ1_U;
     1854        Param.Civ1_V=Data.Civ1_V;
     1855        Param.Civ1_FF=Data.Civ1_FF;
     1856        Param=rmfield(Param,'InputTable');%desactivate input file reading
     1857        if isfield(Param.ActionInput,'Civ1')
     1858            Param.ActionInput=rmfield(Param.ActionInput,'Civ1');%desactivate civ1: remove civ1 input param if relevant
     1859        end
     1860        if isfield(Param.ActionInput,'Fix1')
     1861            Param.ActionInput=rmfield(Param.ActionInput,'Fix1');%desactivate fix1:remove fix1 input param if relevant
     1862        end
     1863        SmoothingParam=(ParamPatch1.FieldSmooth/10)*2.^(1:7);%scan the smoothing param from 1/10 to 12.8 current value
     1864        NbGood=numel(find(Data.Civ1_FF==0));
     1865        NbExclude=zeros(1,7);% initialize the set of smoothing parameters
     1866        DiffVel=zeros(1,7);% initialize the rms difference between patch and civ
     1867        Param.ActionInput.Patch1=ParamPatch1;% retrieve Patch1 parameters
     1868        for irho=1:7
     1869            Param.ActionInput.Patch1.FieldSmooth=SmoothingParam(irho);
     1870            [Data,errormsg]= civ_series(Param);%apply the processing fct
     1871            if ~isempty(errormsg)
     1872                msgbox_uvmat('ERROR',errormsg)
     1873                return
     1874            end
     1875            ind_good=find(Data.Civ1_FF==0);
     1876            Civ1_U_Diff=Data.Civ1_U(ind_good)-Data.Civ1_U_smooth(ind_good);
     1877            Civ1_V_Diff=Data.Civ1_V(ind_good)-Data.Civ1_V_smooth(ind_good);
     1878            DiffVel(irho)=sqrt(mean(Civ1_U_Diff.*Civ1_U_Diff+Civ1_V_Diff.*Civ1_V_Diff));
     1879            NbExclude(irho)=(NbGood-numel(ind_good))/NbGood;
     1880        end
     1881        figure(1)
     1882        semilogx(SmoothingParam,DiffVel,'b',SmoothingParam,NbExclude,'r',SmoothingParam,0.2*ones(size(SmoothingParam)),'m')
     1883        grid on
     1884        legend('rms velocity diff. Patch1-Civ1 (pixels)','proportion of excluded vectors (between 0 to 1)','recommended diff Patch1-Civ1')
     1885        xlabel('smoothing parameter')
     1886        ylabel('smoothing effect')
     1887        set(handles.TestPatch1,'BackgroundColor',[0 1 0])
     1888    else
     1889        corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display
     1890        if ~isempty(corrfig)
     1891            delete(corrfig)
     1892        end
     1893        hview_field=findobj(allchild(0),'tag','view_field');% look for view_field
     1894        if ~isempty(hview_field)
     1895            delete(hview_field)
     1896        end
     1897    end
     1898else
     1899    msgbox_uvmat('ERROR','no output file: first perform a civ1-fix1 computation')
     1900    return
     1901end
     1902 
    18791903%------------------------------------------------------------------------
    18801904% --- Executes on button press in TestCiv2.
  • trunk/src/series/sub_background_special.m

    r1097 r1098  
    5050%     UVMAT is free software; you can redistribute it and/or modify
    5151%     it under the terms of the GNU General Public License as published
    52 %     by the Free Software Foundation; either version 2 of the license,
     52%     by the Free Software Foundation; either version 2 of the license,series
    5353%     or (at your option) any later version.
    5454%
     
    6666    ParamOut.AllowInputSort='off';% allow alphabetic sorting of the list of input file SubDir (options 'off'/'on', 'off' by default)
    6767    ParamOut.WholeIndexRange='on';% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default)
    68     ParamOut.NbSlice='off'; %nbre of slices ('off' by default)
     68    ParamOut.NbSlice='on'; %nbre of slices ('off' by default)
    6969    ParamOut.VelType='off';% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
    7070    ParamOut.FieldName='off';% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
     
    9393end
    9494%% estimate the position of bottom and mask for each Z Index
    95 BottomIndex=[1900 1800 1700 1650 1650 1600 1600 1600 1600 1600 1600];
     95NbSlice=Param.IndexRange.NbSlice;
     96switch NbSlice
     97    case 11
     98        BottomIndex=[1900 1800 1700 1650 1650 1600 1600 1600 1600 1600 1600];
     99    case 4
     100        BottomIndex=[1950 1850 1740 1700];
     101end
    96102MaxIndex=BottomIndex+100;
    97103MinIndex=BottomIndex-100;
     104
    98105maskindex=[665 1080];% range of x index perturbed by shadows
    99 NbSlice=11;
    100106Bfilter=ones(1,20)/20;
    101107%% root input file names and nomenclature type (cell arrays with one element)
    102 OutputDir=[Param.OutputSubDir Param.OutputDirExt];
     108OutputDir=[Param.OutputSubDir Param.OutputDirExt];4
    103109nbj=numel(Param.IndexRange.first_i:Param.IndexRange.last_i);
    104110for i_ind=Param.IndexRange.first_i:Param.IndexRange.last_i
Note: See TracChangeset for help on using the changeset viewer.