Changeset 859


Ignore:
Timestamp:
Jan 27, 2015, 9:21:37 AM (6 years ago)
Author:
sommeria
Message:

bug_repair

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/mouse_motion.m

    r858 r859  
    7373    test_piv=1;
    7474end
    75 
    7675%find the current axe 'CurrentAxes' and display the current mouse position or uicontrol tag
    7776text_displ_1='';
     
    126125        end
    127126    end
    128     FigData=get(hCurrentFig,'UserData');
    129     tagaxes=get(CurrentAxes,'tag');
     127    FigData=get(hCurrentFig,'UserData'); % user data of the current figure
     128    tagaxes=get(CurrentAxes,'tag'); % tag name of the current axes, for instance PlotAxes
    130129    if isfield(FigData,tagaxes)
    131         Field=FigData.(tagaxes);
     130        Field=FigData.(tagaxes); % the current field is sought as substructure of FigData with key tagaxes
    132131        if isfield(Field,'ListVarName')
    133132            [CellInfo,NbDimArray]=find_field_cells(Field);%analyse the physical fields contained in Field
     
    227226                    pos=cos_om*pos+sin_om*cross(OmAxis,pos)+(1-cos_om)*(OmAxis*pos')*OmAxis;
    228227                end
    229                % pos=pos+[Field.ProjObjectCoord 0];
    230228               pos=pos+Field.ProjObjectCoord;
    231229                text_displ_3=[text_displ_3 'x,y,z=' num2str(pos,4)];
    232230            end
    233             %                     if ~isempty(z)
    234             %                         text_displ_1=[text_displ_1 ' z=' num2str(z,4)];
    235             %                     end
    236231            % case of PIV correlation display
    237232            if test_piv
     
    260255                yround=Field.Y(ind_pt);
    261256               
    262                 % mark the correlation box with a rectangle
     257                % mark the correlation box with a rectangle in view_field
    263258                ibx2=floor((par_civ.CorrBoxSize(1)-1)/2);
    264259                iby2=floor((par_civ.CorrBoxSize(2)-1)/2);
  • trunk/src/series/civ_input.m

    r858 r859  
    11491149%------------------------------------------------------------------------
    11501150
     1151% --- Executes on button press in CheckDeformation.
     1152function CheckDeformation_Callback(hObject, eventdata, handles)
     1153set(handles.configSource,'String','NEW')
     1154set(handles.OK,'BackgroundColor',[1 0 1])
     1155
    11511156%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    11521157% Callbacks in the uipanel Fix1
     
    18861891     Param.Action.RUN=1;
    18871892     Param.ActionInput=read_GUI(handles.civ_input);
     1893     if isfield(Param,'OutputSubDir')
    18881894     Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series
    1889      Param.ActionInput.Civ2.SmoothParam=0;% launch Civ2 with no data point (to get the image names for A and B)
     1895     end
     1896     Param.ActionInput.Civ2.CorrSmooth=0;% launch Civ2 with no data point (to get the image names for A and B)
    18901897     set(handles.Civ1,'BackgroundColor',[1 1 0])
     1898     set(handles.Fix1,'BackgroundColor',[1 1 0])
     1899     set(handles.Patch1,'BackgroundColor',[1 1 0])
    18911900     [Data,errormsg]=civ_series(Param);% get the civ1+fix1 results
    18921901     
     
    19161925    hhview_field=guihandles(hview_field);%
    19171926    set(hview_field,'CurrentAxes',hhview_field.PlotAxes)
    1918     %ViewData=get(hview_field,'UserData');
     1927    ViewData=get(hview_field,'UserData'); % get the currently plotted field (the image A)
    19191928    % store info in the UserData of view-field
    19201929    ViewData.CivHandle=handles.civ_input;% indicate the handle of the civ GUI in view_field
     
    19221931    ViewData.PlotAxes.X=Data.Civ2_X';
    19231932    ViewData.PlotAxes.Y=Data.Civ2_Y';
    1924     ViewData.PlotAxes.ShiftX=Data.Civ2_U';
     1933    ViewData.PlotAxes.ShiftX=Data.Civ2_U';% shift at each point (from patch1) estimated by running civ2
    19251934    ViewData.PlotAxes.ShiftY=Data.Civ2_V';
    19261935    ViewData.PlotAxes.Civ1_SubRange=Data.Civ1_SubRange;
     
    19321941    ViewData.PlotAxes.Civ2_Dt=Data.Civ2_Dt;
    19331942    set(hview_field,'UserData',ViewData)% store the info in the UserData of image view_field
     1943    bckcolor=get(handles.civ_input,'Color');
     1944    set(handles.Civ1,'BackgroundColor',bckcolor)% indicate civ1 calmculation is finished
     1945    set(handles.Fix1,'BackgroundColor',bckcolor)
     1946    set(handles.Patch1,'BackgroundColor',bckcolor)
     1947    drawnow
    19341948   
    19351949    %% look for a current figure for image correlation display
     
    22452259% --- Executes on button press in TestPatch2.
    22462260function TestPatch2_Callback(hObject, eventdata, handles)
     2261
     2262
     2263
  • trunk/src/series/civ_series.m

    r858 r859  
    2020%     Param.OutputSubDir: sets the folder name of output file(s,
    2121%           if absent no file is produced, result in the output structure Data (test mode)
    22 %     Param.ActionInput: substructure with the parameters provided by the GUI civ_input 
     22%     Param.ActionInput: substructure with the parameters provided by the GUI civ_input
    2323%                      .Civ1: parameters for civ1
    2424%                      .Fix1: parameters for fix1
    25 %                      .Patch1: 
     25%                      .Patch1:
    2626%                      .Civ2: for civ2
    27 %                      .Fix2: 
     27%                      .Fix2:
    2828%                      .Patch2:
    2929
     
    3232%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    3333%     This is part of the toolbox UVMAT.
    34 % 
     34%
    3535%     UVMAT is free software; you can redistribute it and/or modify
    3636%     it under the terms of the GNU General Public License as published by
    3737%     the Free Software Foundation; either version 2 of the License, or
    3838%     (at your option) any later version.
    39 % 
     39%
    4040%     UVMAT is distributed in the hope that it will be useful,
    4141%     but WITHOUT ANY WARRANTY; without even the implied warranty of
     
    4848
    4949%% set the input elements needed on the GUI series when the action is selected in the menu ActionName or InputTable refreshed
    50 if isstruct(Param) && isequal(Param.Action.RUN,0)% function activated from the GUI series but not RUN 
     50if isstruct(Param) && isequal(Param.Action.RUN,0)% function activated from the GUI series but not RUN
    5151    path_series=fileparts(which('series'));
    5252    addpath(fullfile(path_series,'series'))
     
    8282%% test input
    8383if ~isfield(Param,'ActionInput')
    84      disp_uvmat('ERROR','no parameter set for PIV',checkrun)
    85         return
     84    disp_uvmat('ERROR','no parameter set for PIV',checkrun)
     85    return
    8686end
    8787iview_A=0;%default values
     
    105105    if isfield(Param,'InputTable')
    106106        [tild,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param);
    107         % iview_nc=0;% series index (iview) for an input nc file (for civ2 or patch2)
    108107        iview_A=0;% series index (iview) for the first image series
    109108        iview_B=0;% series index (iview) for the second image series (only non zero for option 'shift' comparing two image series )
     
    158157                    end
    159158                end
    160                 %             i1_series_Civ1=i1_series_Civ1(~check_bounds);
    161                 %             i2_series_Civ1=i2_series_Civ1(~check_bounds);
    162                 %             j1_series_Civ1=j1_series_Civ1(~check_bounds);
    163                 %             j2_series_Civ1=j2_series_Civ1(~check_bounds);
    164159            case 'displacement'
    165160                i1_series_Civ1=Param.ActionInput.OriginIndex*ones(size(i1_series{1}));
     
    271266    OutputDir='';
    272267    if CheckOutputFile
    273     OutputDir=[Param.OutputSubDir Param.OutputDirExt];
     268        OutputDir=[Param.OutputSubDir Param.OutputDirExt];
    274269    end
    275270end
     
    280275Data.Program='civ_series';
    281276Data.CivStage=0;%default
    282 maskname='';%default
    283277check_civx=0;%default
    284278
     
    440434                [xtable, ytable, utable, vtable, ctable, F, result_conv, errormsg] = civ (par_civ1);
    441435                if ~isempty(errormsg)
    442                      disp_uvmat('ERROR',errormsg,checkrun)
     436                    disp_uvmat('ERROR',errormsg,checkrun)
    443437                    return
    444438                end
     
    468462        if exist('ncfile','var')
    469463            CivFile=ncfile;
    470             %         elseif isfield(Param.Patch1,'CivFile')
    471             %             CivFile=Param.Patch1.CivFile;
    472             %         end
    473464            [Data,tild,tild,errormsg]=nc2struct(CivFile,'ListGlobalAttribute','absolut_time_T0'); %look for the constant 'absolut_time_T0' to detect old civx data format
    474465            if ~isempty(errormsg)
     
    476467                return
    477468            end
    478             if ~isempty(Data.absolut_time_T0')%read civx file
    479                 check_civx=1;% test for old civx data format
    480                 [Data,vardetect,ichoice]=nc2struct(CivFile);%read the variables in the netcdf file
    481             else
    482                 [Data,tild,tild,errormsg]=nc2struct(CivFile);%read civ1 and fix1 data in the existing netcdf file
    483             end
     469            [Data,tild,tild,errormsg]=nc2struct(CivFile);%read civ1 and fix1 data in the existing netcdf file
    484470        elseif isfield(Param,'Civ1_X')
    485471            Data.ListGlobalAttribute={};
     
    490476            Data.Civ1_U=Param.Civ1_U;
    491477            Data.Civ1_V=Param.Civ1_V;
    492             Data.Civ1_FF=Param.Civ1_FF;         
     478            Data.Civ1_FF=Param.Civ1_FF;
    493479        end
    494480    end
     
    502488                Data=rmfield(Data,Data.ListGlobalAttribute{Fix1_attr(ilist)});
    503489            end
    504         end 
     490        end
    505491        list_param=fieldnames(Param.ActionInput.Fix1)';
    506492        Fix1_param=regexprep(list_param,'^.+','Fix1_$0');% insert 'Fix1_' before  each string in ListFixParam
    507         %indicate the values of all the global attributes in the output data 
     493        %indicate the values of all the global attributes in the output data
    508494        for ilist=1:length(list_param)
    509495            Data.(Fix1_param{ilist})=Param.ActionInput.Fix1.(list_param{ilist});
    510496        end
    511497        Data.ListGlobalAttribute=[Data.ListGlobalAttribute Fix1_param];
    512 %         
    513 %         for ilist=1:length(ListFixParam)
    514 %             ParamName=ListFixParam{ilist};
    515 %             ListName=['Fix1_' ParamName];
    516 %             eval(['Data.ListGlobalAttribute=[Data.ListGlobalAttribute ''' ParamName '''];'])
    517 %             eval(['Data.' ListName '=Param.ActionInput.Fix1.' ParamName ';'])
    518 %         end
    519         if check_civx
    520             if ~isfield(Data,'fix')
    521                 Data.ListGlobalAttribute=[Data.ListGlobalAttribute 'fix'];
    522                 Data.fix=1;
    523                 Data.ListVarName=[Data.ListVarName {'vec_FixFlag'}];
    524                 Data.VarDimName=[Data.VarDimName {'nb_vectors'}];
    525             end
    526             Data.vec_FixFlag=fix(Param.ActionInput.Fix1,Data.vec_F,Data.vec_C,Data.vec_U,Data.vec_V,Data.vec_X,Data.vec_Y);
    527         else
    528             Data.ListVarName=[Data.ListVarName {'Civ1_FF'}];
    529             Data.VarDimName=[Data.VarDimName {'nb_vec_1'}];
    530             nbvar=length(Data.ListVarName);
    531             Data.VarAttribute{nbvar}.Role='errorflag';
    532             Data.Civ1_FF=fix(Param.ActionInput.Fix1,Data.Civ1_F,Data.Civ1_C,Data.Civ1_U,Data.Civ1_V);
    533             Data.CivStage=2;
    534         end
     498        Data.ListVarName=[Data.ListVarName {'Civ1_FF'}];
     499        Data.VarDimName=[Data.VarDimName {'nb_vec_1'}];
     500        nbvar=length(Data.ListVarName);
     501        Data.VarAttribute{nbvar}.Role='errorflag';
     502        Data.Civ1_FF=fix(Param.ActionInput.Fix1,Data.Civ1_F,Data.Civ1_C,Data.Civ1_U,Data.Civ1_V);
     503        Data.CivStage=2;
    535504    end
    536505    %% Patch1
     
    570539        end
    571540       
    572        % perform Patch calculation using the UVMAT fct 'filter_tps'
     541        % perform Patch calculation using the UVMAT fct 'filter_tps'
    573542        [Data.Civ1_SubRange,Data.Civ1_NbCentres,Data.Civ1_Coord_tps,Data.Civ1_U_tps,Data.Civ1_V_tps,tild,Ures, Vres,tild,FFres]=...
    574543            filter_tps([Data.Civ1_X(ind_good) Data.Civ1_Y(ind_good)],Data.Civ1_U(ind_good),Data.Civ1_V(ind_good),[],Data.Patch1_SubDomainSize,Data.Patch1_FieldSmooth,Data.Patch1_MaxDiff);
     
    647616                U_tps=Data.Civ2_U_tps;
    648617                V_tps=Data.Civ2_V_tps;
    649                 CivStage=Data.CivStage;
     618                CivStage=Data.CivStage;%store the current CivStage
    650619                Civ1_Dt=Data.Civ2_Dt;
    651620                Data=[];%reinitialise the result structure Data
     
    653622                Data.Conventions='uvmat/civdata';% states the conventions used for the description of field variables and attributes
    654623                Data.Program='civ_series';
    655                 Data.CivStage=CivStage;
     624                Data.CivStage=CivStage+1;%update the current civStage after reinitialisation of Data
    656625                Data.ListVarName={};
    657626                Data.VarDimName={};
     
    663632                V_tps=Data.Civ1_V_tps;
    664633                Civ1_Dt=Data.Civ1_Dt;
     634                Data.CivStage=4;
    665635            end
    666636        else
     
    672642            Civ1_Dt=par_civ2.Civ1_Dt;
    673643            Civ2_Dt=par_civ2.Civ1_Dt;
    674                          Data.ListVarName={};
    675                 Data.VarDimName={};
     644            Data.ListVarName={};
     645            Data.VarDimName={};
    676646        end
    677647        Shiftx=zeros(size(par_civ2.Grid,1),1);% shift expected from civ1 data
     
    683653            ind_sel=find(par_civ2.Grid(:,1)>=SubRange(1,1,isub) & par_civ2.Grid(:,1)<=SubRange(1,2,isub) &...
    684654                par_civ2.Grid(:,2)>=SubRange(2,1,isub) & par_civ2.Grid(:,2)<=SubRange(2,2,isub));
    685             epoints = par_civ2.Grid(ind_sel,:);% coordinates of interpolation sites
    686             ctrs=Coord_tps(1:nbvec_sub,:,isub) ;%(=initial points) ctrs
    687             nbval(ind_sel)=nbval(ind_sel)+1;% records the number of values for each interpolation point (in case of subdomain overlap)
    688             EM = tps_eval(epoints,ctrs);
    689             Shiftx(ind_sel)=Shiftx(ind_sel)+EM*U_tps(1:nbvec_sub+3,isub);
    690             Shifty(ind_sel)=Shifty(ind_sel)+EM*V_tps(1:nbvec_sub+3,isub);
    691             if par_civ2.CheckDeformation
    692                 [EMDX,EMDY] = tps_eval_dxy(epoints,ctrs);%2D matrix of distances between extrapolation points epoints and spline centres (=site points) ctrs
    693                 DUDX(ind_sel)=DUDX(ind_sel)+EMDX*U_tps(1:nbvec_sub+3,isub);
    694                 DUDY(ind_sel)=DUDY(ind_sel)+EMDY*U_tps(1:nbvec_sub+3,isub);
    695                 DVDX(ind_sel)=DVDX(ind_sel)+EMDX*V_tps(1:nbvec_sub+3,isub);
    696                 DVDY(ind_sel)=DVDY(ind_sel)+EMDY*V_tps(1:nbvec_sub+3,isub);
     655            if ~isempty(ind_sel)
     656                epoints = par_civ2.Grid(ind_sel,:);% coordinates of interpolation sites
     657                ctrs=Coord_tps(1:nbvec_sub,:,isub) ;%(=initial points) ctrs
     658                nbval(ind_sel)=nbval(ind_sel)+1;% records the number of values for each interpolation point (in case of subdomain overlap)
     659                EM = tps_eval(epoints,ctrs);
     660                Shiftx(ind_sel)=Shiftx(ind_sel)+EM*U_tps(1:nbvec_sub+3,isub);
     661                Shifty(ind_sel)=Shifty(ind_sel)+EM*V_tps(1:nbvec_sub+3,isub);
     662                if par_civ2.CheckDeformation
     663                    [EMDX,EMDY] = tps_eval_dxy(epoints,ctrs);%2D matrix of distances between extrapolation points epoints and spline centres (=site points) ctrs
     664                    DUDX(ind_sel)=DUDX(ind_sel)+EMDX*U_tps(1:nbvec_sub+3,isub);
     665                    DUDY(ind_sel)=DUDY(ind_sel)+EMDY*U_tps(1:nbvec_sub+3,isub);
     666                    DVDX(ind_sel)=DVDX(ind_sel)+EMDX*V_tps(1:nbvec_sub+3,isub);
     667                    DVDY(ind_sel)=DVDY(ind_sel)+EMDY*V_tps(1:nbvec_sub+3,isub);
     668                end
    697669            end
    698670        end
     
    726698            par_civ2.DVDY=DVDY./nbval;
    727699        end
    728         par_civ2
     700       
    729701        % calculate velocity data (y and v in indices, reverse to y component)
    730702        [xtable, ytable, utable, vtable, ctable, F,result_conv,errormsg] = civ (par_civ2);
    731703       
    732704        list_param=(fieldnames(Param.ActionInput.Civ2))';
     705        list_param(strcmp('TestCiv2',list_param))=[];% remove the parameter TestCiv2 from the list
    733706        Civ2_param=regexprep(list_param,'^.+','Civ2_$0');% insert 'Civ2_' before  each string in list_param
    734707        Civ2_param=[{'Civ2_ImageA','Civ2_ImageB','Civ2_Time','Civ2_Dt'} Civ2_param]; %insert the names of the two input images
    735708        %indicate the values of all the global attributes in the output data
    736709        if exist('ImageName_A','var')
    737         Data.Civ2_ImageA=ImageName_A;
    738         Data.Civ2_ImageB=ImageName_B;
    739         Data.Civ2_Time=(time(i2+1,j2+1)+time(i1+1,j1+1))/2;
    740         Data.Civ2_Dt=Civ2_Dt;
     710            Data.Civ2_ImageA=ImageName_A;
     711            Data.Civ2_ImageB=ImageName_B;
     712            Data.Civ2_Time=(time(i2+1,j2+1)+time(i1+1,j1+1))/2;
     713            Data.Civ2_Dt=Civ2_Dt;
    741714        end
    742715        %         Data.Civ2_Time=1;
     
    748721       
    749722        nbvar=numel(Data.ListVarName);
    750         Data.ListVarName=[Data.ListVarName {'Civ2_X','Civ2_Y','Civ2_U','Civ2_V','Civ2_F','Civ2_C'}];%  cell array containing the names of the fields to record
    751         Data.VarDimName=[Data.VarDimName {'nb_vec_2','nb_vec_2','nb_vec_2','nb_vec_2','nb_vec_2','nb_vec_2'}];
    752         Data.VarAttribute{nbvar+1}.Role='coord_x';
    753         Data.VarAttribute{nbvar+2}.Role='coord_y';
    754         Data.VarAttribute{nbvar+3}.Role='vector_x';
    755         Data.VarAttribute{nbvar+4}.Role='vector_y';
    756         Data.VarAttribute{nbvar+5}.Role='warnflag';
     723        % define the Civ2 variable (if Civ2 data are not replaced from previous calculation)
     724        if isempty(find(strcmp('Civ2_X',Data.ListVarName),1))
     725            Data.ListVarName=[Data.ListVarName {'Civ2_X','Civ2_Y','Civ2_U','Civ2_V','Civ2_F','Civ2_C'}];%  cell array containing the names of the fields to record
     726            Data.VarDimName=[Data.VarDimName {'nb_vec_2','nb_vec_2','nb_vec_2','nb_vec_2','nb_vec_2','nb_vec_2'}];
     727            Data.VarAttribute{nbvar+1}.Role='coord_x';
     728            Data.VarAttribute{nbvar+2}.Role='coord_y';
     729            Data.VarAttribute{nbvar+3}.Role='vector_x';
     730            Data.VarAttribute{nbvar+4}.Role='vector_y';
     731            Data.VarAttribute{nbvar+5}.Role='warnflag';
     732        end
    757733        Data.Civ2_X=reshape(xtable,[],1);
    758734        Data.Civ2_Y=reshape(size(par_civ2.ImageA,1)-ytable+1,[],1);
     
    761737        Data.Civ2_C=reshape(ctable,[],1);
    762738        Data.Civ2_F=reshape(F,[],1);
    763         Data.CivStage=Data.CivStage+1;
    764739    end
    765740   
     
    768743        list_param=fieldnames(Param.ActionInput.Fix2)';
    769744        Fix2_param=regexprep(list_param,'^.+','Fix2_$0');% insert 'Fix1_' before  each string in ListFixParam
    770         %indicate the values of all the global attributes in the output data 
     745        %indicate the values of all the global attributes in the output data
    771746        for ilist=1:length(list_param)
    772747            Data.(Fix2_param{ilist})=Param.ActionInput.Fix2.(list_param{ilist});
    773748        end
    774         Data.ListGlobalAttribute=[Data.ListGlobalAttribute Fix2_param];     
    775 %         
    776 %         ListFixParam=fieldnames(Param.ActionInput.Fix2);
    777 %         for ilist=1:length(ListFixParam)
    778 %             ParamName=ListFixParam{ilist};
    779 %             ListName=['Fix2_' ParamName];
    780 %             eval(['Data.ListGlobalAttribute=[Data.ListGlobalAttribute ''' ParamName '''];'])
    781 %             eval(['Data.' ListName '=Param.ActionInput.Fix2.' ParamName ';'])
    782 %         end
     749        Data.ListGlobalAttribute=[Data.ListGlobalAttribute Fix2_param];
     750        %
     751        %         ListFixParam=fieldnames(Param.ActionInput.Fix2);
     752        %         for ilist=1:length(ListFixParam)
     753        %             ParamName=ListFixParam{ilist};
     754        %             ListName=['Fix2_' ParamName];
     755        %             eval(['Data.ListGlobalAttribute=[Data.ListGlobalAttribute ''' ParamName '''];'])
     756        %             eval(['Data.' ListName '=Param.ActionInput.Fix2.' ParamName ';'])
     757        %         end
    783758        if check_civx
    784759            if ~isfield(Data,'fix2')
     
    802777    %% Patch2
    803778    if isfield (Param.ActionInput,'Patch2')
    804                 list_param=fieldnames(Param.ActionInput.Patch2)';
     779        list_param=fieldnames(Param.ActionInput.Patch2)';
     780        list_param(strcmp('TestPatch2',list_param))=[];% remove the parameter TestCiv1 from the list
    805781        Patch2_param=regexprep(list_param,'^.+','Patch2_$0');% insert 'Fix1_' before  each string in ListFixParam
    806         %indicate the values of all the global attributes in the output data 
     782        %indicate the values of all the global attributes in the output data
    807783        for ilist=1:length(list_param)
    808784            Data.(Patch2_param{ilist})=Param.ActionInput.Patch2.(list_param{ilist});
     
    811787       
    812788       
    813 %         Data.ListGlobalAttribute=[Data.ListGlobalAttribute {'Patch2_FieldSmooth','Patch2_MaxDiff','Patch2_SubDomainSize'}];
    814 %         Data.Patch2_FieldSmooth=Param.ActionInput.Patch2.FieldSmooth;
    815 %         Data.Patch2_MaxDiff=Param.ActionInput.Patch2.MaxDiff;
    816 %         Data.Patch2_SubDomainSize=Param.ActionInput.Patch2.SubDomainSize;
     789        %         Data.ListGlobalAttribute=[Data.ListGlobalAttribute {'Patch2_FieldSmooth','Patch2_MaxDiff','Patch2_SubDomainSize'}];
     790        %         Data.Patch2_FieldSmooth=Param.ActionInput.Patch2.FieldSmooth;
     791        %         Data.Patch2_MaxDiff=Param.ActionInput.Patch2.MaxDiff;
     792        %         Data.Patch2_SubDomainSize=Param.ActionInput.Patch2.SubDomainSize;
    817793        nbvar=length(Data.ListVarName);
    818794        Data.ListVarName=[Data.ListVarName {'Civ2_U_smooth','Civ2_V_smooth','Civ2_SubRange','Civ2_NbCentres','Civ2_Coord_tps','Civ2_U_tps','Civ2_V_tps'}];
     
    841817   
    842818    %% write result in a netcdf file if requested
    843     if CheckOutputFile 
     819    if CheckOutputFile
    844820        errormsg=struct2nc(ncfile,Data);
    845821        if isempty(errormsg)
     
    886862
    887863%% prepare measurement grid
    888 if isfield(par_civ,'Grid')% grid points set as input 
     864if isfield(par_civ,'Grid')% grid points set as input
    889865    if ischar(par_civ.Grid)%read the grid file if the input is a file name
    890866        par_civ.Grid=dlmread(par_civ.Grid);
     
    903879nbvec=size(par_civ.Grid,1);
    904880
    905 %% prepare correlation and search boxes 
     881%% prepare correlation and search boxes
    906882ibx2=ceil(par_civ.CorrBoxSize(1)/2);
    907883iby2=ceil(par_civ.CorrBoxSize(2)/2);
     
    924900result_conv=[];
    925901errormsg='';
    926    
     902
    927903%% prepare mask
    928904if isfield(par_civ,'Mask') && ~isempty(par_civ.Mask)
     
    964940
    965941%% Apply mask
    966     % Convention for mask IDEAS TO IMPLEMENT ?
    967     % mask >200 : velocity calculated
    968     %  200 >=mask>150;velocity not calculated, interpolation allowed (bad spots)
    969     % 150>=mask >100: velocity not calculated, nor interpolated
    970     %  100>=mask> 20: velocity not calculated, impermeable (no flux through mask boundaries)
    971     %  20>=mask: velocity=0
     942% Convention for mask IDEAS TO IMPLEMENT ?
     943% mask >200 : velocity calculated
     944%  200 >=mask>150;velocity not calculated, interpolation allowed (bad spots)
     945% 150>=mask >100: velocity not calculated, nor interpolated
     946%  100>=mask> 20: velocity not calculated, impermeable (no flux through mask boundaries)
     947%  20>=mask: velocity=0
    972948checkmask=0;
    973949MinA=min(min(par_civ.ImageA));
    974950MinB=min(min(par_civ.ImageB));
    975951if isfield(par_civ,'Mask') && ~isempty(par_civ.Mask)
    976    checkmask=1;
    977    if ~isequal(size(par_civ.Mask),[npy_ima npx_ima])
     952    checkmask=1;
     953    if ~isequal(size(par_civ.Mask),[npy_ima npx_ima])
    978954        errormsg='mask must be an image with the same size as the images';
    979955        return
    980    end
    981   %  check_noflux=(par_civ.Mask<100) ;%TODO: to implement
     956    end
     957    %  check_noflux=(par_civ.Mask<100) ;%TODO: to implement
    982958    check_undefined=(par_civ.Mask<200 & par_civ.Mask>=20 );
    983959    par_civ.ImageA(check_undefined)=MinA;% put image A to zero (i.e. the min image value) in the undefined  area
     
    1007983        check1_y=subrange1_y>=1 & subrange1_y<=par_civ.ImageHeight;
    1008984        check2_x=subrange2_x>=1 & subrange2_x<=par_civ.ImageWidth;% check which points in the subimage 2 are contained in the initial image 2
    1009         check2_y=subrange2_y>=1 & subrange2_y<=par_civ.ImageHeight;     
     985        check2_y=subrange2_y>=1 & subrange2_y<=par_civ.ImageHeight;
    1010986        image1_crop(check1_y,check1_x)=par_civ.ImageA(subrange1_y(check1_y),subrange1_x(check1_x));%extract a subimage (correlation box) from image A
    1011987        image2_crop(check2_y,check2_x)=par_civ.ImageB(subrange2_y(check2_y),subrange2_x(check2_x));%extract a larger subimage (search box) from image B
     
    10311007                YIant=YI-par_civ.DVDX(ivec)*XI-par_civ.DVDY(ivec)*YI+ceil(size(image1_crop,1)/2);
    10321008                image1_crop=interp2(image1_crop,XIant,YIant);
     1009                image1_crop(isnan(image1_crop))=0;
    10331010                xi=(1:mesh:size(image2_crop,2));
    10341011                yi=(1:mesh:size(image2_crop,1))';
    10351012                image2_crop=interp2(image2_crop,xi,yi);
     1013                image2_crop(isnan(image2_crop))=0;
     1014                %%
    10361015            end
    10371016            sum_square=sum(sum(image1_crop.*image1_crop));
     
    10661045            else
    10671046                F(ivec)=3;
     1047                [y,x]
    10681048            end
    10691049        end
     
    11331113    c11=(1/4)*sum(sum(c11));
    11341114    c20=(1/6)*sum(sum(c20));
    1135     c02=(1/6)*sum(sum(c02)); 
     1115    c02=(1/6)*sum(sum(c02));
    11361116    deltax=(c11*c01-2*c10*c02)/(4*c20*c02-c11^2);
    11371117    deltay=(c11*c10-2*c01*c20)/(4*c20*c02-c11^2);
     
    11511131%filename: name of the netcdf file (used as input and output)
    11521132%field: structure specifying the names of the fields to fix (depending on civ1 or civ2)
    1153     %.vel_type='civ1' or 'civ2';
    1154     %.nb=name of the dimension common to the field to fix ('nb_vectors' for civ1);
    1155     %.fixflag=name of fix flag variable ('vec_FixFlag' for civ1)
    1156 %flagindex: flag specifying which values of vec_f are removed: 
    1157         % if flagindex(1)=1: vec_f=-2 vectors are removed
    1158         % if flagindex(2)=1: vec_f=3 vectors are removed
    1159         % if flagindex(3)=1: vec_f=2 vectors are removed (if iter=1) or vec_f=4 vectors are removed (if iter=2)
     1133%.vel_type='civ1' or 'civ2';
     1134%.nb=name of the dimension common to the field to fix ('nb_vectors' for civ1);
     1135%.fixflag=name of fix flag variable ('vec_FixFlag' for civ1)
     1136%flagindex: flag specifying which values of vec_f are removed:
     1137% if flagindex(1)=1: vec_f=-2 vectors are removed
     1138% if flagindex(2)=1: vec_f=3 vectors are removed
     1139% if flagindex(3)=1: vec_f=2 vectors are removed (if iter=1) or vec_f=4 vectors are removed (if iter=2)
    11601140%iter=1 for civ1 fields and iter=2 for civ2 fields
    11611141%thresh_vecC: threshold in the image correlation vec_C
     
    12201200            if ~isempty(r)
    12211201                NomTypeNc='_1_1-2';
    1222             end           
     1202            end
    12231203        end
    12241204    end
     
    12261206        display('wrong pair mode input option')
    12271207    else
    1228     ind1=stra2num(r.num1);
    1229     ind2=stra2num(r.num2);
     1208        ind1=stra2num(r.num1);
     1209        ind2=stra2num(r.num2);
    12301210    end
    12311211end
Note: See TracChangeset for help on using the changeset viewer.