Changeset 1168


Ignore:
Timestamp:
Dec 9, 2024, 7:40:14 PM (12 days ago)
Author:
sommeria
Message:

bugs repaired in civ TEST mode

Location:
trunk/src
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r1163 r1168  
    257257end
    258258ytable=npy_ima-ytable+1;%reverse from j index to image coordinate y
    259 result_conv=result_conv*corrmax/sum_square;% keep the last (not normalised) correlation matrix for output
     259result_conv=result_conv/sum_square;% keep the last correlation matrix for output
    260260
    261261
  • trunk/src/mouse_motion.m

    r1163 r1168  
    276276                        'LineStyle','-','Tag','PIV_box_marker');
    277277                    rectangle('Curvature',[0 0],...
    278                         'Position',[xround-isx2+shiftx yround-isy2+shifty 2*isx2 2*isy2],'EdgeColor','m',...
     278                        'Position',[xround-isx2-ibx2+shiftx yround-isy2-iby2+shifty 2*isx2+2*ibx2 2*isy2+2*iby2],'EdgeColor','m',...
    279279                        'LineStyle','- -','Tag','PIV_search_marker');
    280280                else
    281281                    set(hhh,'Position',[xround-ibx2 yround-iby2 2*ibx2 2*iby2])
    282                     set(hhhh,'Position',[xround-isx2+shiftx yround-isy2+shifty 2*isx2 2*isy2])
     282                    set(hhhh,'Position',[xround-isx2-ibx2+shiftx yround-isy2-iby2+shifty 2*isx2+2*ibx2 2*isy2+2*iby2])
    283283                end
    284284               
    285285                % perform the PIV calculation as the single point xround yround
    286                 Param.CheckFix1=0;
    287                 Param.CheckPatch1=0;%desactivate all calculations except Civ2 or Civ1
     286                Param.ActionInput.CheckCiv1=1;
     287%                 Param.CheckFix1=0;
     288%                 Param.CheckPatch1=0;%desactivate all calculations except Civ2 or Civ1
    288289                Param.Action.RUN=1;
    289290                Param.ActionInput.ListCompareMode='PIV';
     
    299300                    text_displ_5=errormsg;
    300301                else
    301                     rangx(1)=-(isx2-ibx2)+shiftx;
    302                     rangx(2)=isx2-ibx2+shiftx;
    303                     rangy(1)=-(isy2-iby2)-shifty;
    304                     rangy(2)=(isy2-iby2)-shifty;
     302%                     rangx(1)=-(isx2-ibx2)+shiftx;
     303%                     rangx(2)=isx2-ibx2+shiftx;
     304%                     rangy(1)=-(isy2-iby2)-shifty;
     305%                     rangy(2)=(isy2-iby2)-shifty;
     306                    rangx(1)=-isx2+shiftx;
     307                    rangx(2)=isx2+shiftx;
     308                    rangy(1)=-isy2-shifty;
     309                    rangy(2)=isy2-shifty;
    305310                    hcorr=[];
    306311                    if isfield(AxeData,'CurrentCorrImage')
  • trunk/src/series.m

    r1161 r1168  
    32243224        FirstFileName=fullfile_uvmat(Param.InputTable{iview,1},Param.InputTable{iview,2},Param.InputTable{iview,3},...
    32253225            Param.InputTable{iview,5},Param.InputTable{iview,4},i1,i2,j1,j2);
    3226         Data=nc2struct(FirstFileName);
     3226       
     3227        [FileInfo,VideoObject]=get_file_info(FirstFileName);
     3228       
     3229       
     3230%         Data=nc2struct(FirstFileName);
    32273231        if isfield(Data,'Civ2_Mask')
     3232            if exist(Data.Civ2_Mask,'file')
    32283233            MaskTable{iview,1}=Data.Civ2_Mask;
    32293234            checkmask=1;
     3235            end
    32303236        end
    32313237        if ~checkmask
  • trunk/src/series/civ_series.m

    r1165 r1168  
    284284        end
    285285    end
    286     if CheckInputFile
     286%     if CheckInputFile
     287    if CheckOutputFile
    287288        OutputPath=fullfile(Param.OutputPath,Param.Experiment,Param.Device);
    288289        if iview_A==0 % no nc file has been entered
     
    488489       
    489490        % caluclate velocity data
    490         tstart_civ1=tic;
     491       % tstart_civ1=tic;
    491492        [Data.Civ1_X,Data.Civ1_Y,Data.Civ1_U,Data.Civ1_V,Data.Civ1_C,Data.Civ1_FF, result_conv, errormsg] = civ (par_civ1);
    492493        if ~isempty(errormsg)
  • trunk/src/transform_field/FFT2_detrend.m

    r1127 r1168  
    1 % 'FFT2_detrend': calculate the 2D spectrum of the input scalar after removing the linear trend
     1% 'FFT2_detrend': calculate the 2D spectrum of the input scalar or image after removing the linear trend
    22%------------------------------------------------------------------------
    33%%%%  Use the general syntax for transform fields with a single input %%%%
     
    3434end
    3535%%%%%%%%%%%%%%%%%%%%%%%%%
    36 [CellInfo,NbDim,errormsg]=find_field_cells(DataIn);
     36[CellInfo,NbDim,errormsg]=find_field_cells(DataIn);% detect the input fields
    3737if ~isempty(errormsg)
    3838    DataOut.Txt=errormsg;
     
    4242DataOut.VarDimName={};
    4343for ilist=1:numel(CellInfo)
    44     if NbDim(ilist)==2 && numel(CellInfo{ilist}.CoordIndex)==2 % field with structured coordinates
     44    if NbDim(ilist)==2 && numel(CellInfo{ilist}.CoordIndex)==2 % field with structured 2D coordinates
     45        %process scalar
     46        ivar=CellInfo{ilist}.VarIndex_scalar(1);
     47        VarName=DataIn.ListVarName{ivar};% name o the scalar field
     48        z=double(DataIn.(VarName));% transform integer input to double real
     49        z(isnan(z))=0;% set NaN values to 0
     50        [npy,npx]=size(z);
     51       
    4552        %process coordinates
    4653        CoordName=DataIn.ListVarName(CellInfo{ilist}.CoordIndex);
    47         x1 = DataIn.(CoordName{2}); y1 = DataIn.(CoordName{1});
    48         [x y] = meshgrid(x1,y1);
    49         coeff(1,1) = sum(sum(x.^2)); coeff(1,2) = sum(sum(x.*y)); coeff(1,3) = sum(sum(x));
    50         coeff(2,1) = sum(sum(x.*y)); coeff(2,2) = sum(sum(y.^2)); coeff(2,3) = sum(sum(y));
    51         coeff(3,1) = sum(sum(x)); coeff(3,2) = sum(sum(y)); coeff(3,3) = length(x1)*length(y1);
     54        x1 = linspace(DataIn.(CoordName{2})(1),DataIn.(CoordName{2})(end),npx);
     55        y1 =linspace(DataIn.(CoordName{1})(1),DataIn.(CoordName{1})(end),npy);
     56        [x,y] = meshgrid(x1,y1);% 2D grid of coordinates
     57       
     58        % prepare the grid of wave vectors
    5259        delta_x = x1(2) - x1(1); delta_y = y1(2) - y1(1);
    5360        Nx = length(x1); Ny = length(y1);
     
    5562        ssx = find(Nxa<Nx/2); ssy = find(Nya<Ny/2);
    5663        Nxa(Nx-ssx+1) = -Nxa(ssx)+1; Nya(Ny-ssy+1) = -Nya(ssy)+1;
    57         [Nxa Ix] = sort(Nxa); [Nya Iy] = sort(Nya);
     64        [Nxa, Ix] = sort(Nxa); [Nya, Iy] = sort(Nya);         
    5865        kx1 = (2*pi/delta_x/Nx)*(Nxa-1); ky1 = (2*pi/delta_y/Ny)*(Nya-1);
    5966        ss = find(ky1>=0); ky1 = ky1(ss);
    60         [kx ky] = meshgrid(kx1,ky1);
     67        [kx,ky] = meshgrid(kx1,ky1);
    6168        DataOut.(CoordName{2}) = kx1; DataOut.(CoordName{1}) = ky1;
    6269        if isfield(DataIn,'CoordUnit')
    63             DataOut.CoordUnit=[DataIn.CoordUnit '^{-1}'];
     70            DataOut.CoordUnit=[DataIn.CoordUnit '^{-1}'];%unit of wave vectors
    6471            DataOut.ListGlobalAttribute={'CoordUnit'};
    6572        end
    66         %process scalar
    67         ivar=CellInfo{ilist}.VarIndex_scalar(1);
    68         VarName=DataIn.ListVarName{ivar};
    69         z=DataIn.(VarName);
    70         z(isnan(z))=0;% set to 0 NaN values
     73       
     74        % get the coeff to calulate the linear trend
     75        coeff(1,1) = sum(sum(x.^2)); coeff(1,2) = sum(sum(x.*y)); coeff(1,3) = sum(sum(x));
     76        coeff(2,1) = sum(sum(x.*y)); coeff(2,2) = sum(sum(y.^2)); coeff(2,3) = sum(sum(y));
     77        coeff(3,1) = sum(sum(x)); coeff(3,2) = sum(sum(y)); coeff(3,3) = length(x1)*length(y1);
    7178        rhs(1) = sum(sum(x.*z)); rhs(2) = sum(sum(y.*z)); rhs(3) = sum(sum(z));
    72         lin_coeff = inv(coeff)*rhs';
     79       % lin_coeff = inv(coeff)*rhs';
     80       lin_coeff = coeff\rhs';
    7381        lin_trend = lin_coeff(1)*x + lin_coeff(2)*y + lin_coeff(3);
    74         z2 = z - lin_trend;
    75         spec2 = abs(fft2(z2)).^2;
     82        z2 = z - lin_trend;% substract the linear trend to the input field
     83       
     84        spec2 = abs(fft2(z2)).^2;% get spectrum as squared of fft modulus
    7685        spec2 = spec2(Iy,Ix);
    7786        spec2 = spec2(ss,:);
    78         DataOut.(VarName) = log10(spec2);
     87        DataOut.(VarName) = log10(spec2);% take the log10 of spectrum
    7988        %DataOut.(VarName) = spec2;
    80         spec_sum=sum(sum(spec2));
    81         kx_mean=sum(sum(spec2.*kx))/spec_sum;
    82         ky_mean=sum(sum(spec2.*ky))/spec_sum;
    83         theta=atand(ky_mean/kx_mean);
    84         lambda=2*pi/(sqrt(kx_mean*kx_mean+ky_mean*ky_mean));
     89%         spec_sum=sum(sum(spec2));
     90%         kx_mean=sum(sum(spec2.*kx))/spec_sum;
     91%         ky_mean=sum(sum(spec2.*ky))/spec_sum;
     92%         theta=atand(ky_mean/kx_mean);
     93%         lambda=2*pi/(sqrt(kx_mean*kx_mean+ky_mean*ky_mean));
    8594       
    8695        DataOut.ListVarName=[CoordName {VarName}];%list of variables
  • trunk/src/transform_field/ima_filter.m

    r1127 r1168  
    3939    dlg_title = 'get the filter size in x and y';
    4040    num_lines= 2;
    41     def     = { '20';'20'};
     41    def     = { '21';'21'};
    4242    if isfield(Param,'TransformInput')&&isfield(Param.TransformInput,'FilterBoxSize_x')&&...
    4343            isfield(Param.TransformInput,'FilterBoxSize_y')
     
    7474            else
    7575                DataOut.(VarName)=filter2(Mfiltre,DataIn.(VarName));
     76               %DataOut.(VarName)=filter2_uvmat(Param.TransformInput.FilterBoxSize_x,Param.TransformInput.FilterBoxSize_y,DataIn.(VarName));
    7677                DataOut.(VarName)=feval(Atype,DataOut.(VarName));%transform to the initial image format
    7778            end
  • trunk/src/uvmat.m

    r1167 r1168  
    22942294            set(handles.j2,'String',num2stra(j2,NomType));
    22952295            if isfield(FileInfo,'MaskFile')
     2296                if exist(FileInfo.MaskFile)
    22962297                set(handles.CheckMask,'Value',1)
     2298                else
     2299                    set(handles.CheckMask,'Value',0)
     2300                end
    22972301                 Mask.File=FileInfo.MaskFile;
    22982302                 if isfield(FileInfo,'MaskNbSlice')
     
    29322936        Mask.File=filemask;
    29332937        [RootPath,SubDir,RootFile,i1_series,i2,j1,j2,NomType]=find_file_series(MaskPath,[FileName FileExt]);
    2934         Mask.NbSlice=1;%default
     2938        Mask.NbSlice=[];%default
    29352939        Mask.VolumeScan=0;% TO UPDATE ***
    29362940        if strcmp(NomType,'_1')
     
    29442948        set(handles.CheckMask,'UserData',Mask);
    29452949        errormsg=update_mask(handles);
     2950        if ~isempty(errormsg)
     2951             msgbox_uvmat(['ERROR','error in displaying mask, ' errormsg]);
     2952        end
    29462953        testmask=1;
    29472954    end
     
    29692976MaskInfo=get(handles.CheckMask,'UserData');
    29702977if isfield(MaskInfo,'File')
    2971     if isfield(MaskInfo,'NbSlice')
     2978    if isfield(MaskInfo,'NbSlice')&& ~isempty(MaskInfo.NbSlice)
    29722979        if isfield(MaskInfo,'VolumeScan') &&  MaskInfo.VolumeScan
    29732980            MaskIndex_i=str2num(get(handles.j1,'String'));
Note: See TracChangeset for help on using the changeset viewer.