Changeset 236


Ignore:
Timestamp:
Apr 12, 2011, 12:12:19 AM (13 years ago)
Author:
sommeria
Message:

correct Matlab PIV, remove call to image tool box. Improve menu of uvmat VelType? (replacement of buttons)

Location:
trunk/src
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/calc_field.m

    r180 r236  
    3434% the scalar is calculated from other fields, as explicited below
    3535
    36 %list_scal={title, type, civ1 var name,civ2 var name}
    3736list_field={'velocity';...%image correlation corresponding to a vel vector
    3837    'ima_cor';...%image correlation corresponding to a vel vector
     
    5453    end
    5554    if ischar(FieldName)
    56         FieldName={FieldName};
     55        FieldName={FieldName};%convert a string input to a cell with one string element
    5756    end
    5857    if isfield(DataIn,'Z')&& isequal(size(DataIn.Z),size(DataIn.X))
  • trunk/src/civ.m

    r233 r236  
    819819else
    820820    mode_list=get(handles.mode,'String');
     821    if ischar(mode_list)
     822        mode_list={mode_list};
     823    end
    821824    mode_value=get(handles.mode,'Value');
    822825    mode=mode_list{mode_value};
     
    14261429    display(errormsg)
    14271430    msgbox_uvmat('ERROR',errormsg)
    1428 elseif  isfield(handles,'status') && ~isequal(get(handles.CivAll,'Value'),3)
     1431elseif  isfield(handles,'status') %&& ~isequal(get(handles.CivAll,'Value'),3)
    14291432    set(handles.status,'Value',1);%suppress status display
    14301433    status_Callback(hObject, eventdata, handles)
     
    43194322PointCoord(:,1)=reshape(GridX,[],1);
    43204323PointCoord(:,2)=reshape(GridY,[],1);
    4321 
    43224324% caluclate velocity data (y and v in indices, reverse to y component)
    4323 [xtable ytable utable vtable ctable typevector] = pivlab (image1,image2,ibx2,iby2,isx2,isy2,shiftx,shifty,PointCoord, 1, []);
    4324 Data.ListGlobalAttribute={'title','Time','Dt'};
    4325 Data.title='PIVlab';
     4325[xtable ytable utable vtable ctable F] = pivlab (image1,image2,ibx2,iby2,isx2,isy2,shiftx,shifty,PointCoord, 1, []);
     4326Data.ListGlobalAttribute=[{'Conventions','Program','CivStage'} {'Time','Dt'}];
     4327Data.Conventions='uvmat/civdata';
     4328Data.Program='civ_uvmat';
     4329Data.CivStage=1;
     4330% list_param=fieldnames(Param.Civ1);
     4331% for ilist=1:length(list_param)
     4332%     eval(['Data.Civ1_' list_param{ilist} '=Param.Civ1.' list_param{ilist} ';'])
     4333% end
    43264334Data.Time=str2double(par_civ1.T0);
    43274335Data.Dt=str2double(par_civ1.Dt);
    4328 Data.ListVarName={'X','Y','U','V','C','FF'};%  cell array containing the names of the fields to record
     4336Data.ListVarName={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_C','Civ1_F'};%  cell array containing the names of the fields to record
    43294337Data.VarDimName={'nbvec','nbvec','nbvec','nbvec','nbvec','nbvec'};
    43304338Data.VarAttribute{1}.Role='coord_x';
     
    43324340Data.VarAttribute{3}.Role='vector_x';
    43334341Data.VarAttribute{4}.Role='vector_y';
    4334 Data.VarAttribute{5}.Role='errorflag';
    4335 Data.X=reshape(xtable,[],1);
    4336 Data.Y=reshape(size(image1,1)-ytable+1,[],1);
    4337 Data.U=reshape(utable,[],1);
    4338 Data.V=reshape(-vtable,[],1);
    4339 Data.C=reshape(ctable,[],1);
    4340 Data.FF=reshape(~typevector,[],1);
     4342Data.VarAttribute{5}.Role='warnflag';
     4343Data.Civ1_X=reshape(xtable,[],1);
     4344Data.Civ1_Y=reshape(size(image1,1)-ytable+1,[],1);
     4345Data.Civ1_U=reshape(utable,[],1);
     4346Data.Civ1_V=reshape(-vtable,[],1);
     4347Data.Civ1_C=reshape(ctable,[],1);
     4348Data.Civ1_F=reshape(F,[],1);
    43414349
    43424350%------------------------------------------------------------------------
     
    47254733    ViewData.CivHandle=handles.civ;% indicate the handle of the civ GUI in view_field
    47264734    ViewData.axes3.B=imread(filecell.ima2.civ1{1});%store the second image in the UserData of the GUI view_field
    4727     ViewData.axes3.X=Data.X; %keep the set of points in memeory
    4728     ViewData.axes3.Y=Data.Y;
     4735    ViewData.axes3.X=Data.Civ1_X; %keep the set of points in memeory
     4736    ViewData.axes3.Y=Data.Civ1_Y;
    47294737    set(hview_field,'UserData',ViewData)
    47304738    corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display
  • trunk/src/find_field_indices.m

    r187 r236  
    142142        return
    143143    end
    144     if numel(ivar_vector_x)>1 || numel(ivar_vector_y)>1 || numel(ivar_vector_z)>1
    145         errormsg='multiply defined vector components in the same cell';
    146         return
    147     end 
     144%     if ivar_vector_x>1
     145%         ivar_vector_x=ivar_vector_x(1);
     146%     end
     147%     if ivar_vector_y>1
     148%         ivar_vector_y=ivar_vector_y(1);
     149%     end
     150%     if ivar_vector_z>1
     151%         ivar_vector_z=ivar_vector_z(1);
     152%     end
    148153    if numel(ivar_errorflag)>1
    149154        errormsg='multiply defined error flag in the same cell';
  • trunk/src/get_field.m

    r231 r236  
    240240        set(handles.check_vector,'Value',1)
    241241        set(handles.check_scalar,'Value',0)
    242         set(handles.vector_x,'Value',VarType{imax}.vector_x)
    243         set(handles.vector_y,'Value',VarType{imax}.vector_y)
     242        set(handles.vector_x,'Value',VarType{imax}.vector_x(1))
     243        set(handles.vector_y,'Value',VarType{imax}.vector_y(1))
    244244        if ~isempty(VarType{imax}.coord_x) && ~isempty(VarType{imax}.coord_y)
    245245            set(handles.coord_x_vectors,'Value',VarType{imax}.coord_x+1)
  • trunk/src/griddata_uvmat.m

    r147 r236  
    11%'griddata_uvmat': function griddata_uvmat(vec2_X,vec2_Y,vec2_U,vec_X,vec_Y,'linear')
    22%adapt the input of the matlab function griddata to the appropriate version of Matlab
    3 function ZI = griddata_uvmat(X,Y,Z,XI,YI)
    4 txt=ver('MATLAB');
    5 Release=txt.Release;
    6 relnumb=str2num(Release(3:4));
    7 if relnumb >= 20
    8     ZI=griddata(double(X),double(Y),double(Z),double(XI),double(YI),'linear',{'QJ'});
    9 elseif relnumb >=14
    10     ZI=griddata(X,Y,Z,XI,YI,'linear',{'QJ'});
    11 else   
    12     ZI=griddata(X,Y,Z,XI,YI,'linear');
     3function ZI = griddata_uvmat(X,Y,Z,XI,YI,rho)
     4if ~exist('rho','var')|| isequal(rho,0)
     5    txt=ver('MATLAB');
     6    Release=txt.Release;
     7    relnumb=str2num(Release(3:4));
     8    if relnumb >= 20
     9        ZI=griddata(double(X),double(Y),double(Z),double(XI),double(YI),'linear',{'QJ'});
     10    elseif relnumb >=14
     11        ZI=griddata(X,Y,Z,XI,YI,'linear',{'QJ'});
     12    else
     13        ZI=griddata(X,Y,Z,XI,YI,'linear');
     14    end
     15else %smooth with thin plate spline
     16    [ZI,Z_diff]=patch_uvmat(X,Y,Z,XI,YI,rho);
     17    diff_norm=mean(Z_diff.*Z_diff)
     18    ind_good=find(abs(Z_diff)<5*diff_norm);
     19    nb_remove=numel(Z_diff)-numel(ind_good)
     20    if nb_remove>0
     21    X=X(ind_good);
     22    Y=Y(ind_good);
     23    Z=Z(ind_good);
     24    [ZI,Z_diff]=patch_uvmat(X,Y,Z,XI,YI,rho);
     25    diff_norm_new=mean(Z_diff.*Z_diff)
     26    end
    1327end
    14 
  • trunk/src/nc2struct.m

    r227 r236  
    107107        end
    108108        try
    109             if ischar(valuestr) & length(valuestr)<200 & double(valuestr)<=122 & double(valuestr)>=48 %usual characters
     109            if ischar(valuestr) %& length(valuestr)<200 & double(valuestr)<=122 & double(valuestr)>=48 %usual characters
    110110               % valuestr=regexprep(valuestr,{'\\','\/','\.','\-',' '},{'_','_','_','_','_'})%remove  '\','.' or '-' if exists
    111111                eval(['Data.' keystr '=''' valuestr ''';'])
  • trunk/src/pivlab.m

    r233 r236  
    1919% mask: =[] for no mask
    2020% roi: 4 element vector defining a region of interest: x position, y position, width, height, (in image indices), for the whole image, roi=[];
    21 function [xtable ytable utable vtable ctable typevector result_conv errormsg] = pivlab (image1,image2,ibx2,iby2,isx2,isy2,shiftx,shifty, GridIndices, subpixfinder,mask)
     21function [xtable ytable utable vtable ctable F result_conv errormsg] = pivlab (image1,image2,ibx2,iby2,isx2,isy2,shiftx,shifty, GridIndices, subpixfinder,mask)
    2222%this funtion performs the DCC PIV analysis. Recent window-deformation
    2323%methods perform better and will maybe be implemented in the future.
    24 errormsg='';
    25 warning off %MATLAB:log:logOfZero
    26 [npy_ima npx_ima]=size(image1);
    27 if ~isequal(size(image1),size(image2))
    28     errormsg='image pair with unequal size';
    29     return
    30 end
    31     xroi=0;
    32     yroi=0;
    33     image1_roi=double(image1);
    34     image2_roi=double(image2);
    35 if numel(mask)>0
    36     cellmask=mask;
    37     mask=zeros(size(image1));
    38     for i=1:size(cellmask,1);
    39         masklayerx=cellmask{i,1};
    40         masklayery=cellmask{i,2};
    41         mask = mask + poly2mask(masklayerx-xroi,masklayery-yroi,npy_ima,npx_ima); %kleineres eingangsbild und maske geshiftet
    42     end
    43 else
    44     mask=zeros(size(image1));
    45 end
    46 mask(mask>1)=1;
    47 
    48 % ibx=2*ibx2-1;%ibx and iby odd, reduced by 1 if even
    49 % iby=2*iby2-1;
    50 % miniy=1+iby2
    51 % minix=1+ibx2
    52 % maxiy=step*(floor(size(image1_roi,1)/step))-(iby-1)+iby2 %statt size deltax von ROI nehmen
    53 % maxix=step*(floor(size(image1_roi,2)/step))-(ibx-1)+ibx2
    54 % numelementsy=floor((maxiy-miniy)/step+1);
    55 % numelementsx=floor((maxix-minix)/step+1);
    56 %
    57 % LAy=miniy;
    58 % LAx=minix;
    59 % LUy=size(image1_roi,1)-maxiy;
    60 % LUx=size(image1_roi,2)-maxix;
    61 % shift4centery=round((LUy-LAy)/2);
    62 % shift4centerx=round((LUx-LAx)/2);
    63 % if shift4centery<0 %shift4center will be negative if in the unshifted case the left border is bigger than the right border. the vectormatrix is hence not centered on the image. the matrix cannot be shifted more towards the left border because then image2_crop would have a negative index. The only way to center the matrix would be to remove a column of vectors on the right side. but then we weould have less data....
    64 %     shift4centery=0;
    65 % end
    66 % if shift4centerx<0 %shift4center will be negative if in the unshifted case the left border is bigger than the right border. the vectormatrix is hence not centered on the image. the matrix cannot be shifted more towards the left border because then image2_crop would have a negative index. The only way to center the matrix would be to remove a column of vectors on the right side. but then we weould have less data....
    67 %     shift4centerx=0;
    68 % end
    69 % miniy=miniy+shift4centery;
    70 % minix=minix+shift4centerx;
    71 % maxix=maxix+shift4centerx;
    72 % maxiy=maxiy+shift4centery;
    73 
    74 image1_roi=padarray(image1_roi,[iby2 ibx2], min(min(image1_roi)));%add a border around the image with minimum image value
    75 image2_roi=padarray(image2_roi,[iby2 ibx2], min(min(image1_roi)));
    76 mask=padarray(mask,[iby2 ibx2],0);
    77 %SubPixOffset=0.5;%odd values chosen for ibx and iby
    78 
    7924nbvec=size(GridIndices,1);
    8025xtable=zeros(nbvec,1);
     
    8227utable=xtable;
    8328vtable=xtable;
    84 u2table=xtable;
    85 v2table=xtable;
    86 s2n=xtable;
    87 typevector=ones(size(xtable));
     29ctable=xtable;
     30F=xtable;
     31result_conv=[];
     32errormsg='';
     33%warning off %MATLAB:log:logOfZero
     34[npy_ima npx_ima]=size(image1);
     35if ~isequal(size(image2),[npy_ima npx_ima])
     36    errormsg='image pair with unequal size';
     37    return
     38end
    8839
    89 nrx=0;
    90 nrxreal=0;
    91 nry=0;
    92 increments=0;
     40%% mask
     41testmask=0;
     42if exist('mask','var') && ~isempty(mask)
     43   testmask=1;
     44   if ~isequal(size(mask),[npy_ima npx_ima])
     45        errormsg='mask must be an image with the same size as the images';
     46        return
     47   end
     48    % Convention for mask
     49    % mask >200 : velocity calculated
     50    %  200 >=mask>150;velocity not calculated, interpolation allowed (bad spots)
     51    % 150>=mask >100: velocity not calculated, nor interpolated
     52    %  100>=mask> 20: velocity not calculated, impermeable (no flux through mask boundaries)
     53    %  20>=mask: velocity=0
     54    test_noflux=(mask<=100) ;
     55    test_undefined=(mask<=200 & mask>100 );
     56    image1(test_undefined)=min(min(image1))*ones(size(image1));% put image to zero in the undefined  area
     57    image2(test_undefined)=min(min(image1))*ones(size(image1));% put image to zero in the undefined  area
     58end
     59image1=double(image1);
     60image2=double(image2);
    9361
    94 %% MAINLOOP
     62%% calculate correlations: MAINLOOP
     63corrmax=0;
     64sum_square=1;% default
    9565for ivec=1:nbvec
    9666    iref=GridIndices(ivec,1);
    9767    jref=GridIndices(ivec,2);
    98     %jref=npy_ima-PointCoord(ivec,2)+1;
    99     image1_crop=image1_roi(jref-iby2:jref+iby2,iref-ibx2:iref+ibx2);
    100     image2_crop=image2_roi(jref+shifty-isy2:jref+shifty+isy2,iref+shiftx-isx2:iref+shiftx+isx2);
    101     image1_crop=image1_crop-mean(mean(image1_crop));
    102     image2_crop=image2_crop-mean(mean(image2_crop));
    103         if mask(jref,iref)==0
    104            %reference: Oliver Pust, PIV: Direct Cross-Correlation
    105            % image2_crop: sub image with the size of the search area in image 2
    106            % image1_crop: sub image of the correlation box in image 1
    107            % %image2_crop is bigger than image1_crop. Zeropading is therefore not
    108             result_conv= conv2(image2_crop,rot90(image1_crop,2),'valid');         
    109             %necessary. 'Valid' makes sure that no zero padded content is returned.
    110             corrmax= max(max(result_conv));
    111             result_conv=(result_conv/corrmax)*255; %normalize, peak=always 255
    112            % result_conv=flipdim(result_conv,2);%reverse x direction
    113             %Find the 255 peak
    114             [y,x] = find(result_conv==255);
    115             if isnan(y)==0 & isnan(x)==0
    116                 try
    117                     if subpixfinder==1
    118                         [vector] = SUBPIXGAUSS (result_conv,x,y);
    119                     elseif subpixfinder==2
    120                         [vector] = SUBPIX2DGAUSS (result_conv,x,y);
    121                     end
    122                 catch ME
    123                     errormsg=ME.message
    124                     vector=[0 0]; %if something goes wrong with cross correlation.....
     68    testmask_ij=0;
     69    test0=0;
     70    if testmask
     71        if mask(jref,iref)<=20
     72           vector=[0 0];
     73           test0=1;
     74        else
     75            mask_crop1=mask(jref-iby2:jref+iby2,iref-ibx2:iref+ibx2);
     76            mask_crop2=mask(jref+shifty-isy2:jref+shifty+isy2,iref+shiftx-isx2:iref+shiftx+isx2);
     77            if ~isempty(find(mask_crop1<=200 & mask_crop1>100,1)) || ~isempty(find(mask_crop2<=200 & mask_crop2>100,1));
     78                testmask_ij=1;
     79            end
     80        end
     81    end
     82    if ~test0
     83        image1_crop=image1(jref-iby2:jref+iby2,iref-ibx2:iref+ibx2);
     84        image2_crop=image2(jref+shifty-isy2:jref+shifty+isy2,iref+shiftx-isx2:iref+shiftx+isx2);
     85        image1_crop=image1_crop-mean(mean(image1_crop));
     86        image2_crop=image2_crop-mean(mean(image2_crop));
     87        %reference: Oliver Pust, PIV: Direct Cross-Correlation
     88        result_conv= conv2(image2_crop,flipdim(flipdim(image1_crop,2),1),'valid');
     89        corrmax= max(max(result_conv));
     90        result_conv=(result_conv/corrmax)*255; %normalize, peak=always 255
     91        %Find the correlation max, at 255
     92        [y,x] = find(result_conv==255);
     93        if ~isnan(y) & ~isnan(x)
     94            try
     95                if subpixfinder==1
     96                    [vector] = SUBPIXGAUSS (result_conv,x,y);
     97                elseif subpixfinder==2
     98                    [vector] = SUBPIX2DGAUSS (result_conv,x,y);
    12599                end
    126             else
     100                sum_square=sum(sum(image1_crop.*image1_crop));
     101                ctable(ivec)=corrmax/sum_square;% correlation value
     102                if vector(1)>shiftx+isx2-ibx2+subpixfinder || vector(2)>shifty+isy2-iby2+subpixfinder
     103                    F(ivec)=-2;%vector reaches the border of the search zone
     104                end
     105            catch ME
    127106                vector=[0 0]; %if something goes wrong with cross correlation.....
     107                F(ivec)=3;
    128108            end
    129         else %if mask was not 0 then
    130             vector=[0 0];
    131             typevector(ivec)=0;
     109        else
     110            vector=[0 0]; %if something goes wrong with cross correlation.....
     111            F(ivec)=3;
    132112        end
    133 
    134         %Create the vector matrix x, y, u, v
    135         xtable(ivec)=GridIndices(ivec,1);
    136         ytable(ivec)=GridIndices(ivec,2);
    137         utable(ivec)=vector(1);
    138         vtable(ivec)=vector(2);
    139         sum_square=sum(sum(image1_crop.*image1_crop));
    140         ctable(ivec)=corrmax/sum_square;
     113        if testmask_ij
     114            F(ivec)=3;
     115        end
     116    end
     117   
     118    %Create the vector matrix x, y, u, v
     119    xtable(ivec)=iref+vector(1)/2;% convec flow (velocity taken at the point middle from imgae1 and 2)
     120    ytable(ivec)=jref+vector(2)/2;
     121    utable(ivec)=vector(1);
     122    vtable(ivec)=vector(2);
    141123end
    142 result_conv=result_conv/255;
     124result_conv=result_conv*corrmax/(255*sum_square);% keep the last correlation matrix for output
    143125
    144126
  • trunk/src/proj_field.m

    r231 r236  
    11891189            end
    11901190        elseif isequal(ObjectData.ProjMode,'interp')||isequal(ObjectData.ProjMode,'filter')%interpolate data on a regular grid
     1191            if isequal(ObjectData.ProjMode,'filter')
     1192                rho=1000;%smoothing parameter, (small for strong smoothing)
     1193            else
     1194                rho=0;
     1195            end
    11911196            coord_x_proj=XMin:DX:XMax;
    11921197            coord_y_proj=YMin:DY:YMax;
     
    12251230                        eval(['FieldData.' VarName '=FieldData.' VarName '(indsel);'])
    12261231                    end
    1227                     eval(['ProjData.' VarName '=griddata_uvmat(double(coord_X),double(coord_Y),double(FieldData.' VarName '),coord_x_proj,coord_y_proj'');'])
     1232                    eval(['ProjData.' VarName '=griddata_uvmat(double(coord_X),double(coord_Y),double(FieldData.' VarName '),coord_x_proj,coord_y_proj'',rho);'])
    12281233                    eval(['varline=reshape(ProjData.' VarName ',1,length(coord_y_proj)*length(coord_x_proj));'])
    12291234                    FFlag= isnan(varline); %detect undefined values NaN
     
    13941399                ProjData=FieldData;% no change by projection
    13951400            else
    1396                 test_direct
    1397                 indY=NbDim-1
     1401                indY=NbDim-1;
    13981402                if test_direct(indY)
    13991403                    min_indy=ceil((YMin-Coord{indY}(1))/DYinit)+1;
     
    14021406                    Ybound(2)=Coord{indY}(1)+DYinit*(max_indy-1);
    14031407                else
    1404                     min_indy=ceil((Coord{indY}(1)-YMax)/DYinit)+1
    1405                     max_indy=floor((Coord{indY}(1)-YMin)/DYinit)+1
    1406                     Ybound(2)=Coord{indY}(1)-DYinit*(max_indy-1)
    1407                     Ybound(1)=Coord{indY}(1)-DYinit*(min_indy-1)
     1408                    min_indy=ceil((Coord{indY}(1)-YMax)/DYinit)+1;
     1409                    max_indy=floor((Coord{indY}(1)-YMin)/DYinit)+1;
     1410                    Ybound(2)=Coord{indY}(1)-DYinit*(max_indy-1);
     1411                    Ybound(1)=Coord{indY}(1)-DYinit*(min_indy-1);
    14081412                end
    14091413                if test_direct(NbDim)==1
     
    14231427                if test90y
    14241428                    ind_new=[3 2 1];
    1425                     DimCell={AYProjName,AXProjName}
     1429                    DimCell={AYProjName,AXProjName};
    14261430%                     DimValue=DimValue(ind_new);
    14271431                    iz=ceil((ObjectData.Coord(1,1)-Coord{3}(1))/DX)+1;
     
    15681572ProjData
    15691573ProjData.VarDimName{3}
     1574
    15701575%-----------------------------------------------------------------
    15711576%projection in a volume
  • trunk/src/read_civxdata.m

    r221 r236  
    4747% 'nc2struct': reads a netcdf file
    4848
    49 function [Field,VelTypeOut]=read_civxdata(filename,FieldNames,VelType)
     49function [Field,VelTypeOut,errormsg]=read_civxdata(filename,FieldNames,VelType)
     50errormsg='';
     51DataTest=nc2struct(filename,'ListGlobalAttribute','Conventions');
     52if isequal(DataTest.Conventions,'uvmat/civdata')%test for new civ format
     53     [Field,VelTypeOut]=read_civdata(filename,FieldNames,VelType);
     54     return
     55end
     56   
    5057%% default input
    5158if ~exist('VelType','var')
     
    6471[Field,vardetect,ichoice]=nc2struct(filename,var);%read the variables in the netcdf file
    6572if isfield(Field,'Txt')
     73    errormsg=Field.Txt;
    6674    return
    6775end
    6876if vardetect(1)==0
    69      Field.Txt=[ 'requested field not available in ' filename '/' VelType];
     77     errormsg=[ 'requested field not available in ' filename '/' VelType];
    7078     return
    7179end
     
    117125        Field.dt=double(Field.dt);
    118126    else
    119        Field.Txt='the input file is not civx';
     127       errormsg='the input file is not civx';
    120128       Field.CivStage=0;
    121129       Field.dt=0;
     
    125133    Field.dt=double(Field.dt2);
    126134else
    127     Field.Txt='the input file is not civx';
     135    errormsg='the input file is not civx';
    128136    Field.CivStage=0;
    129137    Field.dt=0;
  • trunk/src/read_field.m

    r233 r236  
    3636if strcmp(FileType,'netcdf')  %read the first nc field
    3737    ParamOut.FieldName=ParamIn.FieldName;
    38     GUIName='get_field'; %default name of the GUI getç_field
     38    GUIName='get_field'; %default name of the GUI get_field
    3939    if isfield(ParamIn,'GUIName')
    4040        GUIName=ParamIn.GUIName;
     
    4444        FieldList=calc_field;%list of possible fields for Civx data
    4545        ParamOut.ColorVar='';%default
    46         field_index=strcmp(ParamOut.FieldName,FieldList);%look for ParamOut.FieldName in the list
    47         if isempty(find(field_index,1))% ParamOut.FieldName is not in the list, check whether Civx data exist
    48             Data=nc2struct(ObjectName,'ListGlobalAttribute','absolut_time_T0','civ');
    49             if ~isempty(Data.absolut_time_T0)&& ~isequal(Data.civ,0)
     46        field_index=strcmp(ParamIn.FieldName,FieldList);%look for ParamIn.FieldName in the list of possible fields for Civx data
     47        if isempty(find(field_index,1))% ParamIn.FieldName is not in the list, check whether Civx data exist
     48            Data=nc2struct(ObjectName,'ListGlobalAttribute','Conventions','absolut_time_T0','civ');
     49            if isequal(Data.Conventions,'uvmat/civdata')
     50                ParamOut.FieldName='velocity';%Civx data found, set .FieldName='velocity' by default
     51                ParamOut.ColorVar='ima_cor';
     52                InputField=[{ParamOut.FieldName} {ParamOut.ColorVar}];
     53                [Field,ParamOut.VelType]=read_civdata(ObjectName,InputField,ParamIn.VelType);
     54                test_civx=Field.CivStage;
     55            elseif ~isempty(Data.absolut_time_T0)&& ~isequal(Data.civ,0)
    5056                ParamOut.FieldName='velocity';%Civx data found, set .FieldName='velocity' by default
    5157                ParamOut.ColorVar='ima_cor';
     
    6773                InputField=[InputField {ParamOut.ColorVar}];
    6874            end
    69             [Field,ParamOut.VelType]=read_civxdata(ObjectName,InputField,ParamIn.VelType);
     75            [Field,ParamOut.VelType,errormsg]=read_civxdata(ObjectName,InputField,ParamIn.VelType);
     76            if ~isempty(errormsg)
     77                return
     78            end
    7079            test_civx=Field.CivStage;
    7180            ParamOut.CivStage=Field.CivStage;
  • trunk/src/update_menu.m

    r19 r236  
    1313menu_str=get(handle,'String');
    1414nbmenu=length(menu_str);
    15 ichoice=0;%default
    16 for imenu=1:nbmenu
    17     if isequal(menu_str{imenu},strinput)
    18        ichoice=imenu;
    19     end
    20 end
    21 if ichoice==0%the input string does not exist in the menu
     15ichoice=find(strcmp(strinput,menu_str),1);
     16if isempty(ichoice)%the input string does not exist in the menu
    2217    menu_str{nbmenu+1}=menu_str{nbmenu};%shift  the last item ('more...')
    2318    menu_str{nbmenu}=strinput;
  • trunk/src/uvmat.m

    r235 r236  
    5050%          .MovieObject_1: idem for a second input series (_1)
    5151%          .filename_1 : last second input file name (to deal with a constant second input without reading again the file)
    52 %          .VelType_1: last velocity type (civ1, civ2...) for the second input series
     52%          .VelType_1: last velocity type (VelType, civ2...) for the second input series
    5353%          .FieldName_1: last field name(velocity, vorticity...) for the second input series
    5454%          .ZMin, .ZMax: range of the z coordinate
     
    387387    end
    388388end
     389
    389390set_vec_col_bar(handles) %update the display of color code for vectors
    390391
     
    518519    return
    519520end
    520 [RootPath,RootFile,i1,i2,str_a,str_b,ext,NomType,SubDir]=name2display(fileinput);
     521[RootPath,RootFile,i1,i2,str_a,str_b,ext,NomType,SubDir]=name2display(fileinput);%extract information from the file name
    521522ext_test=''; %default
    522 if ~isempty(ext)
     523if ~isempty(ext) % if a file extension is detected
    523524    form=imformats(ext(2:end));%test valid Matlab image formats
    524525    if ~isempty(form)
     
    533534            [RootPath,RootFile]=fileparts(fileinput); %include the indices in the root file
    534535        end
    535     elseif isequal(lower(ext),'.avi')
     536    elseif isequal(lower(ext),'.avi')%case of avi movie file
    536537        ext_test='.image';
    537538        i1='1'; % set the frame counter to 1 by default
     
    663664UvData.TestInputFile=1;
    664665set(handles.fix_pair,'Value',1) % activate by default the comp_input '-'input window
    665 
     666set(handles.FixVelType,'Value',0); %desactivate fixed veltype
    666667[FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
    667668if ~exist(FileName,'file')
     
    873874if ~testima
    874875    testcivx=0;
    875     % hget_field=findobj('Name','get_field');
    876     %     if isequal(FileExt,'.nc')||isequal(FileExt,'.cdf')
    877876    if isfield(UvData,'FieldsString') && isequal(UvData.FieldsString,{'get_field...'})% field menu defined as input (from get_field)
    878877        set(handles.Fields,'Value',1)
     
    880879        UvData=rmfield(UvData,'FieldsString');
    881880    else
    882         %if isempty(hget_field)
    883         Data=nc2struct(FileName,'ListGlobalAttribute','absolut_time_T0','civ');
    884         if ~isempty(Data.absolut_time_T0)&& ~isequal(Data.civ,0)%if the new input is Civx
     881        Data=nc2struct(FileName,'ListGlobalAttribute','Conventions','absolut_time_T0','civ');
     882        if strcmp(Data.Conventions,'uvmat/civdata') ||( ~isempty(Data.absolut_time_T0)&& ~isequal(Data.civ,0))%if the new input is Civx
    885883            FieldList=calc_field;
    886884            set(handles.Fields,'String',[{'image'};FieldList;{'get_field...'}]);%standard menu for civx data
     
    890888            testcivx=1;
    891889        end
    892         %     else
    893         %          hhget_field=guidata(hget_field);
    894         %         if ~strcmp(get(hhget_field.inputfile,'String'),FileName)%delete any existing get_field GUI with file name different than the input
    895         %             delete(hget_field)
    896         %         end
    897         %     end
    898890        if ~testcivx
    899891            set(handles.Fields,'Value',1) % set menu to 'get_field...
     
    902894        end
    903895        set(handles.col_vec,'String',col_vec)
    904         %     else
    905         %         msgbox_uvmat('ERROR',['invalid input file extension ' FileExt])
    906         %         return
    907         %     end
    908896    end
    909897end
     
    1001989        '*.dat','.dat text files ';...
    1002990        '*.*',  'All Files (*.*)'}, ...
    1003         'Pick a file',RootPath);
     991        'Pick a second file for comparison',RootPath);
    1004992fileinput_1=[PathName FileName];%complete file name
    1005 % testblank=findstr(fileinput_1,' ');%look for blanks
    1006 % if ~isempty(testblank)
    1007 %     msgbox_uvmat('ERROR',['The input file name ' fileinput_1 ' contains blank character : This is not allowed. Please change name'])
    1008 %     return
    1009 % end
    1010993sizf=size(fileinput_1);
    1011994if (~ischar(fileinput_1)||~isequal(sizf(1),1)),return;end
     
    11811164
    11821165% % default choice of fields
    1183 % if isequal(ext_test,'.image')
    1184 % %    set(handles.Fields_1,'String',{'';'image';'get_field...';'velocity';'vort';'div';'more...'})
    1185 % %    set(handles.Fields_1,'Value',2) % set menu to 'image'
    1186 % elseif strcmp(FileExt_1,'.nc')||strcmp(FileExt_1,'.cdf')
    1187 %    Data=nc2struct(fileinput_1,[]);
    1188 % %    if isfield(Data,'absolut_time_T0')
    1189 % %        set(handles.Fields_1,'String',{'';'image';'get_field...';'velocity';'vort';'div';'more...'})
    1190 % %        set(handles.Fields_1,'Value',4) % set menu to 'velocity'
    1191 % %    else   
    1192 % %        set(handles.Fields_1,'Value',2) % set menu to 'get_field...'
    1193 % %        set(handles.Fields_1,'String',{'';'get_field...'});
    1194 % %    end
    1195 % end 
    1196 set(handles.SubField,'Visible','on')
     1166%set(handles.SubField,'Visible','on')
    11971167set(handles.SubField,'Value',1)
    11981168RootPath_1_Callback(hObject,eventdata,handles); 
     
    12301200    msgbox_uvmat('ERROR',['input file ' FileName ' not found']);
    12311201end
     1202set(handles.FixVelType,'Value',0); %desactivate fixed veltype
    12321203nbfield_1=[];%default
    12331204nburst_1=[];%default
     
    21342105        FieldName= list_fields{index_fields}; % selected field
    21352106        if ~strcmp(FieldName,'get_field...')
    2136            VelType=setfield(handles);% read the velocity type.
     2107           TestVelType=get(handles.FixVelType,'Value');
     2108           if TestVelType
     2109               VelType=setfield(handles);% read the velocity type.
     2110           end
    21372111        end
    21382112        if strcmp(FieldName,'velocity')
     
    21772151        return
    21782152    end
     2153       
    21792154    if isfield(ParamOut,'Npx')&& isfield(ParamOut,'Npy')
    21802155        set(handles.npx,'String',num2str(ParamOut.Npx));% display image size on the interface
     
    21892164end
    21902165
    2191 %% choose a second field if Subfield option is 'on', and if the field has changed
     2166%% choose a second field filename_1 if defined
    21922167VelType_1=[];%default
    21932168FieldName_1=[];
     
    22012176        FieldName_1=[];%default
    22022177        VelType_1=[];%default
    2203         Ext_1=get(handles.FileExt_1,'String');
     2178        if strcmp(get(handles.FileExt_1,'Visible'),'on')
     2179            Ext_1=get(handles.FileExt_1,'String');
     2180        else
     2181            Ext_1=get(handles.FileExt,'String');%read the file extension for the first series (case of veltype comparison within a single file)
     2182        end
    22042183        NomType_1=get(handles.FileIndex_1,'UserData');
    22052184        if isequal(Ext_1,'.nc')||isequal(Ext_1,'.cdf')
     
    22202199            end
    22212200        else
     2201           if length(Ext_1)>=2
    22222202           form=imformats(Ext_1(2:end));
    22232203           if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
     
    22282208               end
    22292209           end
     2210           end
    22302211        end
    22312212        if strcmp(FileType_1,'netcdf')
     
    22342215            FieldName_1= list_fields{index_fields}; % selected field
    22352216            if ~isequal(FieldName_1,'get_field...')% read the field names on the interface get_field...
    2236                 VelType_1=setfield_1(handles);
     2217                VelType_1='';
     2218                if get(handles.FixVelType,'Value')
     2219                    VelTypeList=get(handles.VelType_1,'String');
     2220                    index=get(handles.VelType_1,'Value');
     2221                    VelType_1=VelTypeList{index};
     2222                end
    22372223            end
    22382224            if strcmp(VelType_1,'*')% free veltype choice
     
    22692255            [Field{2},ParamOut_1,errormsg] = read_field(Name,FileType_1,ParamIn,num_i1);
    22702256            if ~isempty(errormsg)
    2271                 errormsg=['error in reading ' filename_1 ': ' errormsg];
     2257                errormsg=['error in reading ' FieldName_1 ' in ' filename_1 ': ' errormsg];
    22722258                return
    22732259            end
     
    22862272end
    22872273
    2288 %% update the display buttons for the first velocity type (first menuline)
    2289 veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
     2274%% update the display menu for the first velocity type (first menuline)
     2275% veltype_handles=[handles.VelType handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
     2276% if ~isequal(FileType,'netcdf')|| isequal(FieldName,'get_field...')
     2277%     set(veltype_handles,'Visible','off')
     2278% else% if isempty(ParamOut.VelType) && ~isequal(FieldName,'get_field...')
     2279%     set_veltype_display(veltype_handles,ParamOut.CivStage)%update the display of available velocity types for the first field
     2280%     if isempty(ParamOut.VelType)
     2281%         reset_vel_type(veltype_handles)
     2282%     else
     2283%         handle1=eval(['handles.' ParamOut.VelType]);
     2284%         reset_vel_type(veltype_handles,handle1)
     2285%     end
     2286% end
     2287test_veltype=0;
    22902288if ~isequal(FileType,'netcdf')|| isequal(FieldName,'get_field...')
    2291 %     reset_vel_type(veltype_handles)
    2292     set(veltype_handles,'Visible','off')
    2293 else% if isempty(ParamOut.VelType) && ~isequal(FieldName,'get_field...')
    2294     set_veltype_display(veltype_handles,ParamOut.CivStage)%update the display of available velocity types for the first field
    2295     if isempty(ParamOut.VelType)
    2296         reset_vel_type(veltype_handles)
    2297     else
    2298         handle1=eval(['handles.' ParamOut.VelType]);
    2299         reset_vel_type(veltype_handles,handle1)
    2300     end
     2289    set(handles.VelType,'Visible','off')
     2290else
     2291    test_veltype=1;
     2292    set(handles.VelType,'Visible','on')
     2293    set(handles.VelType_1,'Visible','on')
     2294    set(handles.FixVelType,'Visible','on')
     2295    menu=set_veltype_display(ParamOut.CivStage);
     2296    index_menu=strcmp(ParamOut.VelType,menu);
     2297    set(handles.VelType,'Value',find(index_menu,1))
     2298    set(handles.VelType,'String',menu)
     2299%     set(handles.VelType_1,'Value',1)
     2300%     set(handles.VelType_1,'String',[{''};menu])
    23012301end
    23022302field_index=strcmp(ParamOut.FieldName,ParamOut.FieldList);
     
    23042304set(handles.Fields,'Value',find(field_index,1))
    23052305
    2306 %% update the display buttons for the second velocity type (second menuline)
    2307 if ~isempty(filename_1)
    2308     veltype_handles_1=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
     2306%% update the display menu for the second velocity type (second menuline)
     2307% if ~isempty(filename_1)
     2308%     veltype_handles_1=[handles.VelType_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
     2309%     if ~isequal(FileType_1,'netcdf')|| isequal(FieldName_1,'get_field...')
     2310%         set(veltype_handles_1,'Visible','off')
     2311%         %reset_vel_type(veltype_handles_1)
     2312%     else %if isempty(VelType_1) && ~isequal(FieldName_1,'get_field...')
     2313%         set_veltype_display(veltype_handles_1,ParamOut_1.CivStage)%update the display of available velocity types for the first field
     2314%         if isempty(ParamOut_1.VelType)
     2315%             reset_vel_type(veltype_handles_1)
     2316%         else
     2317%             handle1=eval(['handles.' ParamOut_1.VelType '_1']);
     2318%             reset_vel_type(veltype_handles_1,handle1)
     2319%         end
     2320%     end
     2321%     field_index=strcmp(ParamOut_1.FieldName,ParamOut_1.FieldList);
     2322%     set(handles.Fields_1,'String',ParamOut_1.FieldList); %update the field menu
     2323%     set(handles.Fields_1,'Value',find(field_index,1))
     2324% end
     2325test_veltype_1=0;
     2326if isempty(filename_1)
     2327    set(handles.Fields_1,'Value',1); %update the field menu
     2328    set(handles.Fields_1,'String',[{''};ParamOut.FieldList]); %update the field menu
     2329else
    23092330    if ~isequal(FileType_1,'netcdf')|| isequal(FieldName_1,'get_field...')
    2310         set(veltype_handles_1,'Visible','off')
    2311         %reset_vel_type(veltype_handles_1)
    2312     else %if isempty(VelType_1) && ~isequal(FieldName_1,'get_field...')
    2313         set_veltype_display(veltype_handles_1,ParamOut_1.CivStage)%update the display of available velocity types for the first field
    2314         if isempty(ParamOut_1.VelType)
    2315             reset_vel_type(veltype_handles_1)
    2316         else
    2317             handle1=eval(['handles.' ParamOut_1.VelType '_1']);
    2318             reset_vel_type(veltype_handles_1,handle1)
    2319         end
    2320     end
    2321     field_index=strcmp(ParamOut_1.FieldName,ParamOut_1.FieldList);
    2322     set(handles.Fields_1,'String',ParamOut_1.FieldList); %update the field menu
    2323     set(handles.Fields_1,'Value',find(field_index,1))
    2324 end
    2325 
     2331        set(handles.VelType_1,'Visible','off')
     2332    else
     2333        test_veltype_1=1;
     2334        set(handles.VelType_1,'Visible','on')
     2335        if ~get(handles.FixVelType,'Value')
     2336            menu=set_veltype_display(ParamOut_1.CivStage);
     2337            index_menu=strcmp(ParamOut_1.VelType,menu);
     2338            set(handles.VelType_1,'Value',1+find(index_menu,1))
     2339            set(handles.VelType_1,'String',[{''};menu])
     2340        end
     2341    end
     2342end
     2343if test_veltype||test_veltype_1
     2344     set(handles.FixVelType,'Visible','on')
     2345else
     2346     set(handles.FixVelType,'Visible','off')
     2347end
     2348   
    23262349%% introduce w as background image by default for a new series (only for nbdim=2)
    23272350if ~isfield(UvData,'NewSeries')
     
    24322455       NbDim=2;
    24332456    end
    2434 elseif VarType{imax}.coord(NbDim)>0 %structured coordinate 
     2457elseif numel(VarType)>=imax && numel(VarType{imax}.coord)>=NbDim && VarType{imax}.coord(NbDim)>0 %structured coordinate 
    24352458    XName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim)};
    24362459    if NbDim>1
    24372460        YName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim-1)}; %structured coordinates
    24382461    end
     2462else
     2463    errormsg='input field coordinates not defined';
     2464    return
    24392465end
    24402466if NbDim==3
     
    25682594
    25692595% main projection object (uvmat display)
     2596list_object=get(handles.list_object_1,'String');
     2597if isequal(list_object,{''})%refresh list of objects if the menu is empty
     2598    UvData.Object={[]};
     2599    set(handles.list_object_1,'Value',1)
     2600    set(handles.list_object_2,'Value',1)
     2601    set(handles.list_object_2,'String',{''})
     2602    set(handles.list_object_2,'Visible','off')
     2603end
    25702604IndexObj(1)=get(handles.list_object_1,'Value');%selected projection object for main view
    25712605if IndexObj(1)> numel(UvData.Object)
     
    28742908end
    28752909test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]);
    2876 test_civ1=isequal(get(handles.civ1,'BackgroundColor'),[1 1 0]);
     2910test_civ1=isequal(get(handles.VelType,'BackgroundColor'),[1 1 0]);
    28772911if ~test_civ2 && ~test_civ1
    28782912    msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields')
     
    29252959%determines the fields to read from the interface
    29262960%------------------------------------------------------------------
    2927 function [VelType,civ]=setfield(handles)
    2928 
    2929 VelType=[]; %default
    2930 if (get(handles.civ1,'Value') == 1);
    2931         VelType='civ1';
    2932 % interp1   
    2933 elseif (get(handles.interp1,'Value') == 1);
    2934     VelType='interp1';
    2935 % filter1   
    2936 elseif (get(handles.filter1,'Value') == 1);
    2937     VelType='filter1'; 
    2938 % CIV2
    2939 elseif (get(handles.civ2,'Value') == 1);
    2940     VelType='civ2';
    2941 % interp2   
    2942 elseif (get(handles.interp2,'Value') == 1);
    2943     VelType='interp2';
    2944 % filter2   
    2945 elseif (get(handles.filter2,'Value') == 1); 
    2946     VelType='filter2';
    2947 end
    2948 
    2949 if isequal(get(handles.filter2,'Visible'),'on');
    2950     civ=6;
    2951 % interp1   
    2952 elseif isequal(get(handles.interp2,'Visible'),'on');
    2953     civ=5;
    2954 % filter1   
    2955 elseif isequal(get(handles.civ2,'Visible'),'on');
    2956     civ=4; 
    2957 % CIV2
    2958 elseif isequal(get(handles.filter1,'Visible'),'on');
    2959    civ=3;
    2960 % interp2   
    2961 elseif isequal(get(handles.interp1,'Visible'),'on');
    2962     civ=2;
    2963 % filter2   
    2964 elseif isequal(get(handles.civ1,'Visible'),'on'); 
    2965     civ=1;
    2966 else
    2967     civ=0;
    2968 end
     2961function VelType=setfield(handles)
     2962VelTypeList=get(handles.VelType,'String');
     2963index=get(handles.VelType,'Value');
     2964VelType=VelTypeList{index};
     2965
     2966% VelType=[]; %default
     2967% if (get(handles.VelType,'Value') == 1);
     2968%         VelType='civ1';
     2969% % interp1   
     2970% elseif (get(handles.interp1,'Value') == 1);
     2971%     VelType='interp1';
     2972% % filter1   
     2973% elseif (get(handles.filter1,'Value') == 1);
     2974%     VelType='filter1'; 
     2975% % CIV2
     2976% elseif (get(handles.civ2,'Value') == 1);
     2977%     VelType='civ2';
     2978% % interp2   
     2979% elseif (get(handles.interp2,'Value') == 1);
     2980%     VelType='interp2';
     2981% % filter2   
     2982% elseif (get(handles.filter2,'Value') == 1); 
     2983%     VelType='filter2';
     2984% end
     2985%
     2986% if isequal(get(handles.filter2,'Visible'),'on');
     2987%     civ=6;
     2988% % interp1   
     2989% elseif isequal(get(handles.interp2,'Visible'),'on');
     2990%     civ=5;
     2991% % filter1   
     2992% elseif isequal(get(handles.civ2,'Visible'),'on');
     2993%     civ=4; 
     2994% % CIV2
     2995% elseif isequal(get(handles.filter1,'Visible'),'on');
     2996%    civ=3;
     2997% % interp2   
     2998% elseif isequal(get(handles.interp1,'Visible'),'on');
     2999%     civ=2;
     3000% % filter2   
     3001% elseif isequal(get(handles.VelType,'Visible'),'on'); 
     3002%     civ=1;
     3003% else
     3004%     civ=0;
     3005% end
    29693006
    29703007%-------------------------------------------------------------------
     
    29723009%------------------------------------------------------------------
    29733010function VelType=setfield_1(handles)
    2974 
    2975 VelType=[]; %default
    2976 if (get(handles.civ1_1,'Value') == 1);
    2977     VelType='civ1';
    2978 % interp1   
    2979 elseif (get(handles.interp1_1,'Value') == 1);
    2980     VelType='interp1';
    2981 % filter1   
    2982 elseif (get(handles.filter1_1,'Value') == 1);
    2983     VelType='filter1'; 
    2984 % CIV2
    2985 elseif (get(handles.civ2_1,'Value') == 1);
    2986     VelType='civ2';
    2987 % interp2   
    2988 elseif (get(handles.interp2_1,'Value') == 1);
    2989     VelType='interp2';
    2990 % filter2   
    2991 elseif (get(handles.filter2_1,'Value') == 1); 
    2992     VelType='filter2';
    2993 end
     3011VelTypeList=get(handles.VelType_1,'String');
     3012index=get(handles.VelType_1,'Value');
     3013VelType=VelTypeList{index};
     3014% VelType=[]; %default
     3015% if (get(handles.VelType_1,'Value') == 1);
     3016%     VelType='civ1';
     3017% % interp1   
     3018% elseif (get(handles.interp1_1,'Value') == 1);
     3019%     VelType='interp1';
     3020% % filter1   
     3021% elseif (get(handles.filter1_1,'Value') == 1);
     3022%     VelType='filter1'; 
     3023% % CIV2
     3024% elseif (get(handles.civ2_1,'Value') == 1);
     3025%     VelType='civ2';
     3026% % interp2   
     3027% elseif (get(handles.interp2_1,'Value') == 1);
     3028%     VelType='interp2';
     3029% % filter2   
     3030% elseif (get(handles.filter2_1,'Value') == 1); 
     3031%     VelType='filter2';
     3032% end
    29943033
    29953034
     
    29973036% --- Executes on button press in SubField
    29983037function SubField_Callback(hObject, eventdata, handles)
    2999 huvmat=get(handles.run0,'parent');
    3000 UvData=get(huvmat,'UserData');
     3038% huvmat=get(handles.run0,'parent');
     3039UvData=get(handles.uvmat,'UserData');
    30013040if get(handles.SubField,'Value')==0% if the subfield button is desactivated   
    30023041    set(handles.RootPath_1,'String','')
     
    30113050    set(handles.FileExt_1,'Visible','off');
    30123051    set(handles.Fields_1,'Value',1);%set to blank state
    3013     set_veltype_display([handles.civ1_1 handles.interp1_1 handles.filter1_1 ...
    3014             handles.civ2_1 handles.interp2_1 handles.filter2_1],0)
     3052    set(handles.VelType_1,'Value',1);%set to blank state
     3053    if ~strcmp(get(handles.VelType,'Visible'),'on')
     3054        set(handles.VelType_1,'Visible','off')
     3055    end
     3056%     set_veltype_display([handles.VelType_1 handles.interp1_1 handles.filter1_1 ...
     3057%             handles.civ2_1 handles.interp2_1 handles.filter2_1],0)
    30153058    if isfield(UvData,'XmlData_1')
    30163059        UvData=rmfield(UvData,'XmlData_1');
    30173060    end
    3018     set(huvmat,'UserData',UvData);
     3061    set(handles.uvmat,'UserData',UvData);
    30193062    run0_Callback(hObject, eventdata, handles); %run
    30203063else
     
    30943137field= list_fields{index_fields(1)}; % selected string
    30953138if isequal(field,'get_field...')
    3096      veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
    3097      set_veltype_display(veltype_handles,0) % unvisible civ buttons
     3139     set(handles.FixVelType,'visible','off')
     3140      set(handles.VelType,'visible','off')
     3141       set(handles.VelType_1,'visible','off')
     3142%      veltype_handles=[handles.VelType handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
     3143%      set_veltype_display(veltype_handles,0) % unvisible civ buttons
    30983144     filename=read_file_boxes(handles);
    30993145     hget_field=findobj(allchild(0),'name','get_field');
     
    31523198        return
    31533199%     end
    3154 %     veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
     3200%     veltype_handles=[handles.VelType handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
    31553201%     set_veltype_display(veltype_handles,0) % unvisible civ buttons
    31563202else
     
    31683214       %  MenuBrowse_Callback(hObject, eventdata, handles)
    31693215    end
    3170     if isequal(field,'vort') || isequal(field,'div') || isequal(field,'strain')
    3171         set(handles.civ1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
    3172         set(handles.civ2,'BackgroundColor',[0.702 0.702 0.702])
    3173         set(handles.interp1,'BackgroundColor',[0.702 0.702 0.702])
    3174         set(handles.interp2,'BackgroundColor',[0.702 0.702 0.702])
    3175     elseif isequal(field,'more...');
    3176         set(handles.civ1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
    3177         set(handles.civ2,'BackgroundColor',[0.702 0.702 0.702])
    3178         str=calc_field;%get the list of available scalars by the function calc_scal
    3179         [ind_answer] = listdlg('PromptString','Select a file:',...
    3180                 'SelectionMode','single',...
    3181                 'ListString',str);
    3182        % edit the choice in the field and action menu
    3183         scalar=cell2mat(str(ind_answer));
    3184         menu=update_menu(handles.Fields,scalar);
    3185         menu=[{''};menu];
    3186         set(handles.Fields_1,'String',menu);% store the selected scalar type
    3187     end
     3216%     if isequal(field,'vort') || isequal(field,'div') || isequal(field,'strain')
     3217% %         set(handles.VelType,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
     3218% %         set(handles.civ2,'BackgroundColor',[0.702 0.702 0.702])
     3219% %         set(handles.interp1,'BackgroundColor',[0.702 0.702 0.702])
     3220% %         set(handles.interp2,'BackgroundColor',[0.702 0.702 0.702])
     3221%     elseif isequal(field,'more...');
     3222%         set(handles.VelType,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
     3223%         set(handles.civ2,'BackgroundColor',[0.702 0.702 0.702])
     3224%         str=calc_field;%get the list of available scalars by the function calc_scal
     3225%         [ind_answer] = listdlg('PromptString','Select a file:',...
     3226%                 'SelectionMode','single',...
     3227%                 'ListString',str);
     3228%        % edit the choice in the field and action menu
     3229%         scalar=cell2mat(str(ind_answer));
     3230%         menu=update_menu(handles.Fields,scalar);
     3231%         menu=[{''};menu];
     3232%         set(handles.Fields_1,'String',menu);% store the selected scalar type
     3233%     end
    31883234end
    31893235indices=name_generator('',str2double(str1),str2double(str_a),'',NomTypeNew,1,str2double(str2),str2double(str_b),'');
     
    32583304
    32593305if isequal(field_1,'get_field...')
    3260      veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
     3306     veltype_handles=[handles.VelType handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
    32613307     set_veltype_display(veltype_handles,0) % unvisible civ buttons
    32623308     filename=read_file_boxes_1(handles);
     
    32763322if isequal(field_1,'image')
    32773323    % transform netc type to the corresponding image type
    3278 %     set(handles.FileExt_1,'String','.png');
    32793324    if isequal(NomType_1,'_i1-i2_j')||isequal(NomType_1,'_i_j1-j2')|| isequal(NomType_1,'#_ab')|| isequal(NomType_1,'_i1-i2')
    3280         UvData.SubDir_1=get(handles.SubDir_1,'String'); %preserve the subdir in memory
    3281 %         set(handles.SubDir_1,'String','')
    3282 %         set(handles.FileExt_1,'String','.png');       
     3325        UvData.SubDir_1=get(handles.SubDir_1,'String'); %preserve the subdir in memory   
    32833326        if isequal(NomType_1,'_i1-i2_j')||isequal(NomType_1,'_i_j1-j2')
    32843327            NomTypeNew='_i_j';
     
    33053348    display_file_name_1(hObject, eventdata, handles,imagename)%display the image
    33063349    return
    3307 %     veltype_handles=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
    3308 %     set_veltype_display(veltype_handles,0) % unvisible civ buttons
    33093350else
    33103351    set(handles.SubDir_1,'Visible','on')
    33113352    if ~isequal(FileExt_prev,'.nc') %find the new NomType if the previous display was not already a netcdf file
    3312         veltype_handles=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
    3313         set_veltype_display(veltype_handles,6); % make all civ buttons visible
     3353%         veltype_handles=[handles.VelType_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
     3354%         set_veltype_display(veltype_handles,6); % make all civ buttons visible
    33143355        RootPath_1=get(handles.RootPath_1,'String');
    33153356        RootFile_1=get(handles.RootFile_1,'String');
    3316         if isempty(RootPath_1)|isequal(RootPath_1,'')
     3357        if isempty(RootPath_1)||isequal(RootPath_1,'')
    33173358            set(handles.RootPath_1,'String','"')
    33183359        end
    3319         if isempty(RootFile_1) | isequal(RootFile_1,'')
     3360        if isempty(RootFile_1) || isequal(RootFile_1,'')
    33203361            set(handles.RootFile_1,'String','"')
    33213362        end
    3322         if ~isempty(RootFile_1)&(isequal(RootFile_1(1),'/')|isequal(RootFile_1(1),'\'))
     3363        if ~isempty(RootFile_1)&&(isequal(RootFile_1(1),'/')||isequal(RootFile_1(1),'\'))
    33233364            RootFile_1(1)=[];
    33243365        end
     
    33573398        set(handles.SubDir_1,'String',SubDir_1);
    33583399    end
    3359     if isequal(field,'vort') | isequal(field,'div') | isequal(field,'strain')
    3360         set(handles.civ1_1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
     3400    if isequal(field,'vort') || isequal(field,'div') || isequal(field,'strain')
     3401        set(handles.VelType_1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
    33613402        set(handles.civ2_1,'BackgroundColor',[0.702 0.702 0.702])
    33623403        set(handles.interp1_1,'BackgroundColor',[0.702 0.702 0.702])
    33633404        set(handles.interp2_1,'BackgroundColor',[0.702 0.702 0.702])
    33643405    elseif isequal(field_1,'more...'); %add new item to the menu
    3365         set(handles.civ1_1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
     3406        set(handles.VelType_1,'BackgroundColor',[0.702 0.702 0.702]) % put their color to grey
    33663407        set(handles.civ2_1,'BackgroundColor',[0.702 0.702 0.702])
    33673408        str=calc_field;%get the list of available scalars by the function calc_scal
     
    33843425
    33853426%common to Fields_Callback
    3386 if isequal(field,'image')|isequal(field_1,'image')
     3427if isequal(field,'image')||isequal(field_1,'image')
    33873428    set(handles.npx_title,'Visible','on')% visible npx,pxcm... buttons
    33883429    set(handles.npy_title,'Visible','on')
     
    33973438%     set(handles.fix_pair,'Value',1)
    33983439end
    3399 if isequal(field,'velocity')|isequal(field_1,'velocity');
     3440if isequal(field,'velocity')||isequal(field_1,'velocity');
    34003441    state_vect='on';
    34013442else
    34023443    state_vect='off';
    34033444end
    3404 if ~isequal(field,'velocity')|(~isequal(field_1,'velocity')&~isequal(field_1,''));
     3445if ~isequal(field,'velocity')||(~isequal(field_1,'velocity')&~isequal(field_1,''));
    34053446    state_scal='on';
    34063447else
     
    34153456%------------------------------------------------------------------------
    34163457% --- set the visibility of relevant velocity type menus:
    3417 function set_veltype_display(handles,Civ)
    3418 %------------------------------------------------------------------------
    3419 %Civ=0; all states 'off'
    3420 %Civ=6; all states 'on'
     3458function menu=set_veltype_display(Civ)
     3459%------------------------------------------------------------------------
    34213460if isequal(Civ,0)
    34223461    imax=0;
    3423 %    set(handles(1),'Visible','on')  % unvisible civ buttons
    3424 % else
    3425 %    set(handles(1),'String','civ1')
    3426 % end
    34273462elseif isequal(Civ,1) || isequal(Civ,2)
    34283463   imax=1;
     
    34343469    imax=6;
    34353470end
    3436 for ibutton=1:imax;
    3437     set(handles(ibutton),'Visible','on')  % unvisible civ buttons
    3438 end
    3439 % for ibutton=max(imax+1,2):6;
    3440 for ibutton=imax+1:6;
    3441     set(handles(ibutton),'Visible','off')  % unvisible civ buttons
    3442     set(handles(ibutton),'Value',0)%unactivate unvisible buttons
    3443 end
    3444 
    3445 %-------------------------------------------------------------------
    3446 % --- Executes on button press in civ1.
    3447 function civ1_Callback(hObject, eventdata, handles)
    3448 %-------------------------------------------------------------------
    3449 if get(handles.civ1,'Value')==1
    3450     reset_vel_type([handles.interp1 handles.civ2 handles.filter1 handles.interp1 handles.interp2 handles.filter2],handles.civ1)
    3451 else
    3452     reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
    3453 end
     3471menu={'civ1';'interp1';'filter1';'civ2';'interp2';'filter2'};
     3472menu=menu(1:imax);
     3473% for ibutton=1:imax;
     3474%     set(handles(ibutton),'Visible','on')  % unvisible civ buttons
     3475% end
     3476% % for ibutton=max(imax+1,2):6;
     3477% for ibutton=imax+1:6;
     3478%     set(handles(ibutton),'Visible','off')  % unvisible civ buttons
     3479%     set(handles(ibutton),'Value',0)%unactivate unvisible buttons
     3480% end
     3481
     3482%-------------------------------------------------------------------
     3483% --- Executes on button press in VelType.
     3484function VelType_Callback(hObject, eventdata, handles)
     3485%-------------------------------------------------------------------
     3486% if get(handles.VelType,'Value')==1
     3487%     reset_vel_type([handles.interp1 handles.civ2 handles.filter1 handles.interp1 handles.interp2 handles.filter2],handles.VelType)
     3488% else
     3489%     reset_vel_type([handles.VelType handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
     3490% end
     3491set(handles.FixVelType,'Value',1)
    34543492run0_Callback(hObject, eventdata, handles)
    34553493
    3456 %-------------------------------------------------------------------
    3457 % --- Executes on button press in interp1.
    3458 function interp1_Callback(hObject, eventdata, handles)
    3459 %-------------------------------------------------------------------
    3460 if get(handles.interp1,'Value')==1
    3461     reset_vel_type([handles.civ1 handles.civ2 handles.filter1 handles.interp2 handles.filter2],handles.interp1)
    3462 else
    3463      reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
    3464 end
    3465 run0_Callback(hObject, eventdata, handles)
    3466 
    3467 %-------------------------------------------------------------------
    3468 % --- Executes on button press in filter1.
    3469 function filter1_Callback(hObject, eventdata, handles)
    3470 %-------------------------------------------------------------------
    3471 if get(handles.filter1,'Value')==1
    3472     reset_vel_type([handles.civ1 handles.civ2 handles.interp1 handles.interp2 handles.filter2],handles.filter1)
    3473 else
    3474      reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
    3475 end
    3476 run0_Callback(hObject, eventdata, handles)
    3477 
    3478 %-------------------------------------------------------------------
    3479 % --- Executes on button press in civ2.
    3480 function civ2_Callback(hObject, eventdata, handles)
    3481 %-------------------------------------------------------------------
    3482 if get(handles.civ2,'Value')==1
    3483     reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.interp2 handles.filter2],handles.civ2)
    3484 else
    3485      reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
    3486 end
    3487 run0_Callback(hObject, eventdata, handles)
    3488 
    3489 %-----------------------------------------
    3490 % --- Executes on button press in interp2.
    3491 %-------------------------------------------
    3492 function interp2_Callback(hObject, eventdata, handles)
    3493 if get(handles.interp2,'Value')==1
    3494     reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.filter2],handles.interp2)
    3495 else
    3496      reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
    3497 end
    3498 run0_Callback(hObject, eventdata, handles)
    34993494%---------------------------------------------
    3500 % --- Executes on button press in filter2.
    3501 %-------------------------------------------
    3502 function filter2_Callback(hObject, eventdata, handles)
    3503 if get(handles.filter2,'Value')==1
    3504     reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2],handles.filter2)
    3505 else
    3506      reset_vel_type([handles.civ1 handles.filter1 handles.interp1 handles.civ2 handles.interp2 handles.filter2])
    3507 end
    3508 run0_Callback(hObject, eventdata, handles)
    3509 
     3495function VelType_1_Callback(hObject, eventdata, handles)
    35103496%---------------------------------------------
    3511 function civ1_1_Callback(hObject, eventdata, handles)
    3512 %---------------------------------------------
    3513 if get(handles.civ1_1,'Value')==1
    3514     reset_vel_type([handles.interp1_1 handles.civ2_1 handles.filter1_1 handles.interp1_1 handles.interp2_1 handles.filter2_1],handles.civ1_1)
    3515 else
    3516      reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
    3517 end
    3518 run0_Callback(hObject, eventdata, handles)
    3519 
    3520 %--------------------------------------------
    3521 function interp1_1_Callback(hObject, eventdata, handles)
    3522 %--------------------------------------------
    3523 if get(handles.interp1_1,'Value')==1
    3524     reset_vel_type([handles.civ1_1 handles.civ2_1 handles.filter1_1 handles.interp2_1 handles.filter2_1],handles.interp1_1)
    3525 else
    3526     reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
    3527 end
    3528 run0_Callback(hObject, eventdata, handles)
    3529 
    3530 %--------------------------------------------
    3531 function filter1_1_Callback(hObject, eventdata, handles)
    3532 %--------------------------------------------
    3533 if get(handles.filter1_1,'Value')==1
    3534     reset_vel_type([handles.interp1_1 handles.civ2_1 handles.interp1_1 handles.interp2_1 handles.filter2_1],handles.filter1_1)
    3535 else
    3536     reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
    3537 end
    3538 run0_Callback(hObject, eventdata, handles)
    3539 
    3540 %--------------------------------------------
    3541 function civ2_1_Callback(hObject, eventdata, handles)
    3542 %--------------------------------------------
    3543 if get(handles.civ2_1,'Value')==1
    3544     reset_vel_type([handles.civ1_1 handles.interp1_1  handles.filter1_1 handles.interp2_1 handles.filter2_1],handles.civ2_1)
    3545 else
    3546     reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
    3547 end
    3548 run0_Callback(hObject, eventdata, handles)
    3549 
    3550 %--------------------------------------------
    3551 function interp2_1_Callback(hObject, eventdata, handles)
    3552 %--------------------------------------------
    3553 if get(handles.interp2_1,'Value')==1
    3554     reset_vel_type([handles.civ1_1 handles.civ2_1 handles.filter1_1 handles.interp1_1 handles.filter2_1],handles.interp2_1)
    3555 else
    3556     reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
    3557 end
    3558 run0_Callback(hObject, eventdata, handles)
    3559 
    3560 %--------------------------------------------
    3561 function filter2_1_Callback(hObject, eventdata, handles)
    3562 %--------------------------------------------
    3563 if get(handles.filter2_1,'Value')==1
    3564     reset_vel_type([handles.civ1_1 handles.interp1_1 handles.civ2_1 handles.filter1_1 handles.interp1_1 handles.interp2_1],handles.filter2_1)
    3565 else
    3566     reset_vel_type([handles.civ1_1 handles.filter1_1 handles.interp1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1])
    3567 end
    3568 run0_Callback(hObject, eventdata, handles)
     3497 
     3498set(handles.FixVelType,'Value',1)
     3499%refresh field with a second filename=first fiel name
     3500set(handles.run0,'BackgroundColor',[1 1 0])%paint the command button in yellow
     3501drawnow
     3502filename=read_file_boxes(handles);
     3503if get(handles.SubField,'Value')
     3504    filename_1=read_file_boxes_1(handles);
     3505else
     3506    index=get(handles.VelType_1,'Value');
     3507    if index==1
     3508        filename_1='';% we plot the current field without the second field
     3509    else
     3510        filename_1=filename;
     3511    end
     3512end
     3513num_i1=stra2num(get(handles.i1,'String'));
     3514num_i2=stra2num(get(handles.i2,'String'));
     3515num_j1=stra2num(get(handles.j1,'String'));
     3516num_j2=stra2num(get(handles.j2,'String'));
     3517
     3518errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2);
     3519
     3520if ~isempty(errormsg)
     3521    msgbox_uvmat('ERROR',errormsg);
     3522else
     3523    set(handles.i1,'BackgroundColor',[1 1 1])
     3524    set(handles.i2,'BackgroundColor',[1 1 1])
     3525    set(handles.j1,'BackgroundColor',[1 1 1])
     3526    set(handles.j2,'BackgroundColor',[1 1 1])
     3527    set(handles.FileIndex,'BackgroundColor',[1 1 1])
     3528    set(handles.FileIndex_1,'BackgroundColor',[1 1 1])
     3529end
     3530set(handles.run0,'BackgroundColor',[1 0 0])
    35693531
    35703532%-----------------------------------------------
     
    36413603if isequal(get(handles.edit_vect,'Value'),1)
    36423604    test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]);
    3643     test_civ1=isequal(get(handles.civ1,'BackgroundColor'),[1 1 0]);
     3605    test_civ1=isequal(get(handles.VelType,'BackgroundColor'),[1 1 0]);
    36443606    if ~test_civ2 && ~test_civ1
    36453607        msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields')
     
    47764738    param.index_fields_1=param.index_fields_1-1;
    47774739end
    4778 param.civ1=get(handles.civ1,'Value');
     4740param.civ1=get(handles.VelType,'Value');
    47794741param.civ2=get(handles.civ2,'Value');
    47804742param.interp1=get(handles.interp1,'Value');
     
    50735035end
    50745036
    5075 
     5037% --- Executes on button press in FixVelType.
     5038function FixVelType_Callback(hObject, eventdata, handles)
     5039val=get(handles.FixVelType,'Value');
     5040if ~val
     5041    run0_Callback(hObject, eventdata, handles)
     5042end
     5043
     5044
Note: See TracChangeset for help on using the changeset viewer.