Changeset 270 for trunk/src/civ_uvmat.m
- Timestamp:
- Nov 12, 2011, 4:46:54 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/civ_uvmat.m
r257 r270 6 6 Data.Program='civ_uvmat'; 7 7 Data.CivStage=0;%default 8 ListVarCiv1={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_C','Civ1_F'}; 8 ListVarCiv1={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_C','Civ1_F'}; %variables to read 9 9 ListVarFix1={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_C','Civ1_F','Civ1_FF'}; 10 10 mask=''; 11 11 maskname='';%default 12 12 test_civx=0;%default 13 test_civ1=0;%default 14 test_patch1=0;%default 13 15 14 16 %% Civ1 15 17 if isfield (Param,'Civ1') 18 test_civ1=1;% test for further use of civ1 results 16 19 par_civ1=Param.Civ1; 17 20 image1=imread(par_civ1.filename_ima_a); … … 75 78 Data.CivStage=1; 76 79 else 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 80 81 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 86 83 [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 attributes89 % 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;101 84 else 102 103 85 if isfield(Param,'Fix1') 104 86 Data=nc2struct(ncfile,ListVarCiv1);%read civ1 data in the existing netcdf file … … 147 129 %% Patch1 148 130 if isfield (Param,'Patch1') 131 test_patch1=1; 149 132 Data.ListGlobalAttribute=[Data.ListGlobalAttribute {'Patch1_Rho','Patch1_Threshold','Patch1_SubDomain'}]; 150 133 Data.Patch1_Rho=str2double(Param.Patch1.Rho); … … 175 158 if isfield (Param,'Civ2') 176 159 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 185 186 % shiftx=str2num(par_civ1.shiftx); 186 187 % shifty=str2num(par_civ1.shifty); 187 188 % TO GET shift from par_civ2.filename_nc1 189 % shiftx=velocity interpolated at position 188 190 miniy=max(1+isy2+shifty,1+iby2); 189 191 minix=max(1+isx2-shiftx,1+ibx2); … … 261 263 Data.CivStage=5; 262 264 end 265 263 266 end 264 267 … … 287 290 Data.Civ2_V_Diff(ind_good)=Data.Civ2_V(ind_good)-Vres; 288 291 Data.Civ2_FF(ind_good)=FFres; 289 Data.CivStage= 3;292 Data.CivStage=6; 290 293 end 291 294
Note: See TracChangeset
for help on using the changeset viewer.