Changeset 270 for trunk


Ignore:
Timestamp:
Nov 12, 2011, 4:46:54 PM (12 years ago)
Author:
sommeria
Message:

minor bug repairs

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r269 r270  
    11621162else
    11631163    mode_list=get(handles.mode,'String')
     1164    if isempty(mode_list)
     1165        msgbox_uvmat('ERROR','please enter an input image or netcdf file')
     1166        return
     1167    end
    11641168    mode_value=get(handles.mode,'Value')
    11651169    mode=mode_list{mode_value};
     
    22202224                        RUN_STLIN(filecell.ncA.civ2{ifile,j},filecell.nc.civ2{ifile,j},'civ2',filecell.st{ifile,j},...
    22212225                            str2num(nx_patch2),str2num(ny_patch2),str2num(thresh_patch2),[filebase_A '.xml'],[filebase_B '.xml'])
     2226                    else
     2227                        Param.Patch2.Rho=rho_patch2;
     2228                        Param.Patch2.Threshold=thresh_patch2;
     2229                        Param.Patch2.SubDomain=subdomain_patch2;
    22222230                    end
    22232231                end
     
    22292237                        msgbox_uvmat('ERROR',errormsg)
    22302238                    end
     2239
    22312240                end
    22322241        end
  • trunk/src/civ_uvmat.m

    r257 r270  
    66Data.Program='civ_uvmat';
    77Data.CivStage=0;%default
    8 ListVarCiv1={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_C','Civ1_F'};
     8ListVarCiv1={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_C','Civ1_F'}; %variables to read
    99ListVarFix1={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_C','Civ1_F','Civ1_FF'};
    1010mask='';
    1111maskname='';%default
    1212test_civx=0;%default
     13test_civ1=0;%default
     14test_patch1=0;%default
    1315
    1416%% Civ1
    1517if isfield (Param,'Civ1')
     18    test_civ1=1;% test for further use of civ1 results
    1619    par_civ1=Param.Civ1;
    1720    image1=imread(par_civ1.filename_ima_a);
     
    7578    Data.CivStage=1;
    7679else
    77     Data=nc2struct(ncfile,'ListGlobalAttribute','absolut_time_T0');
    78    
    79     % read Civx data
     80    Data=nc2struct(ncfile,'ListGlobalAttribute','absolut_time_T0'); %look for the constant 'absolut_time_T0' to detect old civx data format
    8081    if ~isempty(Data.absolut_time_T0')%read civx file
    81 %         var={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_C','Civ1_F','Civ1_FF';...
    82 %             'vec_X','vec_Y','vec_U','vec_V','vec_C','vec_F','vec_FixFlag'};
    83 
    84         %var=varcivx_generator('velocity','Civ1');%determine the names of constants and variables to read
    85         test_civx=1;
     82        test_civx=1;% test for old civx data format
    8683        [Data,vardetect,ichoice]=nc2struct(ncfile);%read the variables in the netcdf file
    87 %         Data.ListGlobalAttribute=[{'Conventions','Program','CivStage'} Data.ListGlobalAttribute {'Civ1_Time','Civ1_Dt'}];
    88 %         Data.Conventions='uvmat/civdata';% states the conventions used for the description of field variables and attributes
    89 %         Data.Program='civ_uvmat';
    90 %         Data.Civ1_Time=double(Data.absolut_time_T0);
    91 %         Data.Civ1_Dt=double(Data.dt);
    92 %         Data.VarDimName={'nbvec1','nbvec1','nbvec1','nbvec1','nbvec1','nbvec1','nbvec1'};
    93 %         Data.VarAttribute{1}.Role='coord_x';
    94 %         Data.VarAttribute{2}.Role='coord_y';
    95 %         Data.VarAttribute{3}.Role='vector_x';
    96 %         Data.VarAttribute{4}.Role='vector_y';
    97 %         Data.VarAttribute{5}.Role='ancillary';
    98 %         Data.VarAttribute{6}.Role='warnflag';
    99 %         Data.VarAttribute{7}.Role='errorflag';
    100 %         Data.CivStage=1;
    10184    else
    102 
    10385        if isfield(Param,'Fix1')
    10486            Data=nc2struct(ncfile,ListVarCiv1);%read civ1 data in the existing netcdf file
     
    147129%% Patch1
    148130if isfield (Param,'Patch1')
     131    test_patch1=1;
    149132    Data.ListGlobalAttribute=[Data.ListGlobalAttribute {'Patch1_Rho','Patch1_Threshold','Patch1_SubDomain'}];
    150133    Data.Patch1_Rho=str2double(Param.Patch1.Rho);
     
    175158if isfield (Param,'Civ2')
    176159    par_civ2=Param.Civ2;
    177     image1=imread(par_civ2.filename_ima_a);
    178     image2=imread(par_civ2.filename_ima_b);
    179     stepx=str2num(par_civ2.dx);
    180     stepy=str2num(par_civ2.dy);
    181     ibx2=ceil(str2num(par_civ2.ibx)/2);
    182     iby2=ceil(str2num(par_civ2.iby)/2);
    183     isx2=4;
    184     isy2=4;
     160    if ~test_civ1 || ~strcmp(par_civ1.filename_ima_a,par_civ2.filename_ima_a)
     161            image1=imread(par_civ2.filename_ima_a);%read first image if not already done for civ1
     162    end
     163    if ~test_civ1|| ~strcmp(par_civ1.filename_ima_b,par_civ2.filename_ima_b)
     164            image2=imread(par_civ2.filename_ima_b);%read second image if not already done for civ1
     165    end
     166    stepx=str2double(par_civ2.dx);
     167    stepy=str2double(par_civ2.dy);
     168    ibx2=ceil(str2double(par_civ2.ibx)/2);
     169    iby2=ceil(str2double(par_civ2.iby)/2);
     170    isx2=ibx2+2;
     171    isy2=iby2+2;
     172    %get the previous guess for displacement
     173    if ~test_patch1
     174        [Guess,VelType]=read_civdata(ObjectName,InputField,ParamIn.VelType);%TO DEVELOP
     175    else
     176        Data.Civ1_U_Diff=zeros(size(Data.Civ1_X));
     177        Data.Civ1_V_Diff=zeros(size(Data.Civ1_X));
     178        if isfield(Data,'Civ1_FF')
     179            ind_good=find(Data.Civ1_FF==0);
     180        else
     181            ind_good=1:numel(Data.Civ1_X);
     182        end
     183            [Data.Civ1_X_SubRange,Data.Civ1_Y_SubRange,Data.Civ1_NbSites,FFres,Ures, Vres,Data.Civ1_X_tps,Data.Civ1_Y_tps,Data.Civ1_U_tps,Data.Civ1_V_tps]=...
     184                                patch_uvmat(Data.Civ1_X(ind_good)',Data.Civ1_Y(ind_good)',Data.Civ1_U(ind_good)',Data.Civ1_V(ind_good)',Data.Patch1_Rho,Data.Patch1_Threshold,Data.Patch1_SubDomain);
     185        end
    185186%     shiftx=str2num(par_civ1.shiftx);
    186187%     shifty=str2num(par_civ1.shifty);
    187188% TO GET shift from par_civ2.filename_nc1
     189    % shiftx=velocity interpolated at position
    188190    miniy=max(1+isy2+shifty,1+iby2);
    189191    minix=max(1+isx2-shiftx,1+ibx2);
     
    261263        Data.CivStage=5;   
    262264    end
     265   
    263266end   
    264267
     
    287290      Data.Civ2_V_Diff(ind_good)=Data.Civ2_V(ind_good)-Vres;
    288291      Data.Civ2_FF(ind_good)=FFres;
    289       Data.CivStage=3;                             
     292      Data.CivStage=6;                             
    290293end   
    291294
Note: See TracChangeset for help on using the changeset viewer.