Changeset 246 for trunk/src/read_civdata.m
- Timestamp:
- Apr 28, 2011, 10:52:31 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/read_civdata.m
r237 r246 47 47 % 'nc2struct': reads a netcdf file 48 48 49 function [Field,VelTypeOut,errormsg]=read_civdata(filename,FieldNames,VelType )49 function [Field,VelTypeOut,errormsg]=read_civdata(filename,FieldNames,VelType,XI,YI) 50 50 errormsg=''; 51 51 VelTypeOut=VelType;%default 52 52 %% default input 53 53 if ~exist('VelType','var') 54 VelType= [];54 VelType=''; 55 55 end 56 56 if isequal(VelType,'*') 57 VelType=[]; 57 VelType=''; 58 end 59 if isempty(VelType) 60 VelType=''; 58 61 end 59 62 if ~exist('FieldNames','var') … … 62 65 63 66 %% reading data 64 %[var,role,units,vel_type_out_cell]=varcivx_generator(FieldNames,VelType);%determine the names of constants and variables to read 65 % if isempty(VelType) 66 % VelType='civ1'; 67 % end 68 % if isequal(VelType,'civ1') 69 % varlist=[{'X','Y','U','V','C','F','FF'};... %output names 70 % {'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_C','Civ1_F','Civ1_FF'}];%names in file 71 % role={'coord_x','coord_y','vector_x','vector_y','ancillary','warnflag','errorflag'}; 72 % units={'pixel','pixel','pixel','pixel','','',''}; 73 % elseif isequal(VelType,'interp1')|| isequal(VelType,'filter1')% read diff between spline and initial data (change name interp1 -> splinediff 74 % varlist=[{'X','Y','U','V'};... %output names 75 % {'Civ1_X','Civ1_Y','Patch1_U','Patch1_V'}]; 76 % role = {'coord_x','coord_y','vector_x','vector_y'}; 77 % units={'pixel','pixel','pixel','pixel'}; 78 % end 79 [varlist,role,units,vel_type_out_cell]=varcivx_generator(FieldNames,VelType); 67 [varlist,role,units,vel_type_out_cell]=varcivx_generator(FieldNames,VelType); 80 68 [Field,vardetect,ichoice]=nc2struct(filename,varlist);%read the variables in the netcdf file 81 69 if isfield(Field,'Txt') … … 93 81 Field.VarAttribute{ivar}.Mesh=0.1;%typical mesh for histograms O.1 pixel 94 82 end 95 96 83 if ~isempty(ichoice) 97 84 VelTypeOut=vel_type_out_cell{ichoice}; 98 85 end 99 % Field.CivStage=3;%for patch, to generalise 100 % return 86 101 87 102 88 %% renaming for standard conventions … … 162 148 163 149 150 164 151 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 165 152 % TAKEN FROM read_civxdata NOT USED … … 178 165 179 166 %% default input values 180 if ~exist('vel_type','var'),vel_type= [];end;167 if ~exist('vel_type','var'),vel_type='';end; 181 168 if iscell(vel_type),vel_type=vel_type{1}; end;%transform cell to string if needed 182 169 if ~exist('FieldNames','var'),FieldNames={'ima_cor'};end;%default scalar … … 185 172 %% select the priority order for automatic vel_type selection 186 173 testder=0; 174 testpatch=0; 187 175 for ilist=1:length(FieldNames) 188 176 if ~isempty(FieldNames{ilist}) 189 177 switch FieldNames{ilist} 178 case{'u','v'} 179 testpatch=1; 190 180 case {'vort','div','strain'} 191 181 testder=1; 192 182 end 193 183 end 194 end 184 end 185 switch vel_type 186 case 'civ1' 187 var={'X','Y','Z','U','V','W','C','F','FF';... 188 'Civ1_X','Civ1_Y','Civ1_Z','Civ1_U','Civ1_V','Civ1_W','Civ1_C','Civ1_F','Civ1_FF'}; 189 role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','warnflag','errorflag'}; 190 units={'pixel','pixel','pixel','pixel','pixel','pixel',[],[],[]}; 191 case 'interp1' 192 var={'X','Y','Z','U','V','W','FF';... 193 'Civ1_X','Civ1_Y','','Civ1_U_Diff','Civ1_V_Diff','','Civ1_FF'}; 194 role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','errorflag'}; 195 units={'pixel','pixel','pixel','pixel','pixel','pixel',[]}; 196 case 'filter1' 197 var={'X_tps','Y_tps','Z_tps','U_tps','V_tps','W_tps','X_SubRange','Y_SubRange','NbSites';... 198 'Civ1_X_tps','Civ1_Y_tps','','Civ1_U_tps','Civ1_V_tps','','Civ1_X_SubRange','Civ1_Y_SubRange','Civ1_NbSites'}; 199 role={'','','','','','','','',''}; 200 units={'pixel','pixel','pixel','pixel','pixel','pixel','pixel','pixel',''}; 201 otherwise % if VelType=[] 202 if testpatch 203 var={'X_tps','Y_tps','Z_tps','U_tps','V_tps','W_tps','X_SubRange','Y_SubRange','NbSites';... 204 'Civ2_X_tps','Civ2_Y_tps','','Civ2_U_tps','Civ2_V_tps','','Civ2_X_SubRange','Civ2_Y_SubRange','Civ2_NbSites';... 205 'Civ1_X_tps','Civ1_Y_tps','','Civ1_U_tps','Civ1_V_tps','','Civ1_X_SubRange','Civ1_Y_SubRange','Civ1_NbSites'}; 206 role={'','','','','','','',''}; 207 units={'pixel','pixel','pixel','pixel','pixel','pixel','pixel','pixel'}; 208 else 209 var={'X','Y','Z','U','V','W','C','F','FF';... 210 'Civ2_X','Civ2_Y','Civ2_Z','Civ2_U','Civ2_V','Civ2_W','Civ2_C','Civ2_F','Civ2_FF';... 211 'Civ1_X','Civ1_Y','Civ1_Z','Civ1_U','Civ1_V','Civ1_W','Civ1_C','Civ1_F','Civ1_FF'}; 212 role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','warnflag','errorflag'}; 213 units={'pixel','pixel','pixel','pixel','pixel','pixel',[],[],[]}; 214 end 215 end 195 216 if isempty(vel_type) || isequal(vel_type,'*') %undefined velocity type (civ1,civ2...) 196 217 if testder … … 219 240 vel_type_out=vel_type_out'; 220 241 221 %% determine names of netcdf variables to read 222 var={'X','Y','Z','U','V','W','C','F','FF'}; 223 role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','warnflag','errorflag'}; 224 units={'pixel','pixel','pixel','pixel','pixel','pixel',[],[],[]}; 225 if testder 226 var=[var {'DjUi(:,1,1)','DjUi(:,1,2)','DjUi(:,2,1)','DjUi(:,2,2)'}]; 227 role=[role {'tensor','tensor','tensor','tensor'}]; 228 units=[units {'pixel','pixel','pixel','pixel'}]; 229 end 230 for ilist=1:length(vel_type_out) 231 var=[var;varname1(vel_type_out{ilist},FieldNames)]; 232 end 233 234 %------------------------------------------------------------------------ 235 % TAKEN FROM read_civxdata NOT USED 236 %--- determine var names to read 237 238 function varin=varname1(vel_type,FieldNames) 239 %------------------------------------------------------------------------ 240 testder=0; 241 C1=''; 242 C2=''; 243 for ilist=1:length(FieldNames) 244 if ~isempty(FieldNames{ilist}) 245 switch FieldNames{ilist} 246 case 'ima_cor' %image correlation corresponding to a vel vector 247 C1='vec_C'; 248 C2='vec2_C'; 249 case 'error' 250 C1='vec_E'; 251 C2='vec2_E'; 252 case {'vort','div','strain'} 253 testder=1; 254 end 255 end 256 end 257 switch vel_type 258 case 'civ1' 259 varin={'Civ1_X','Civ1_Y','Civ1_Z','Civ1_U','Civ1_V','Civ1_W','Civ1_C','Civ1_F','Civ1_FF'}; 260 case 'interp1' 261 varin={'','','','','','','','',''}; 262 case 'filter1' 263 varin={'Civ1_X','Civ1_Y','','Civ1_U_Spline','Civ1_V_Spline','','','',''}; 264 case 'civ2' 265 varin={'vec2_X','vec2_Y','vec2_Z','vec2_U','vec2_V','vec2_W',C2,'vec2_F','vec2_FixFlag'}; 266 case 'interp2' 267 varin={'vec2_patch_X','vec2_patch_Y','vec2_patch_Z','vec2_patch0_U','vec2_patch0_V','vec2_patch0_W','','',''}; 268 case 'filter2' 269 varin={'vec2_patch_X','vec2_patch_Y','vec2_patch_Z','vec2_patch_U','vec2_patch_V','vec2_patch0_W','','',''}; 270 end 271 if testder 272 switch vel_type 273 case 'filter1' 274 varin=[varin {'vec_patch_DUDX','vec_patch_DVDX','vec_patch_DUDY','vec_patch_DVDY'}]; 275 case 'filter2' 276 varin=[varin {'vec2_patch_DUDX','vec2_patch_DVDX','vec2_patch_DUDY','vec2_patch_DVDY'}]; 277 end 278 end 242 243 244 245 246
Note: See TracChangeset
for help on using the changeset viewer.