Ignore:
Timestamp:
Apr 28, 2011, 10:52:31 AM (13 years ago)
Author:
sommeria
Message:

thin plate shell (patch) introduced

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/read_civdata.m

    r237 r246  
    4747% 'nc2struct': reads a netcdf file
    4848
    49 function [Field,VelTypeOut,errormsg]=read_civdata(filename,FieldNames,VelType)
     49function [Field,VelTypeOut,errormsg]=read_civdata(filename,FieldNames,VelType,XI,YI)
    5050errormsg='';
    5151VelTypeOut=VelType;%default
    5252%% default input
    5353if ~exist('VelType','var')
    54     VelType=[];
     54    VelType='';
    5555end
    5656if isequal(VelType,'*')
    57     VelType=[];
     57    VelType='';
     58end
     59if isempty(VelType)
     60    VelType='';
    5861end
    5962if ~exist('FieldNames','var')
     
    6265
    6366%% 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);
    8068[Field,vardetect,ichoice]=nc2struct(filename,varlist);%read the variables in the netcdf file
    8169if isfield(Field,'Txt')
     
    9381    Field.VarAttribute{ivar}.Mesh=0.1;%typical mesh for histograms O.1 pixel
    9482end
    95 
    9683if ~isempty(ichoice)
    9784    VelTypeOut=vel_type_out_cell{ichoice};
    9885end
    99 %  Field.CivStage=3;%for patch, to generalise
    100 % return
     86
    10187
    10288%% renaming for standard conventions
     
    162148
    163149
     150
    164151%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    165152% TAKEN FROM read_civxdata NOT USED
     
    178165
    179166%% default input values
    180 if ~exist('vel_type','var'),vel_type=[];end;
     167if ~exist('vel_type','var'),vel_type='';end;
    181168if iscell(vel_type),vel_type=vel_type{1}; end;%transform cell to string if needed
    182169if ~exist('FieldNames','var'),FieldNames={'ima_cor'};end;%default scalar
     
    185172%% select the priority order for automatic vel_type selection
    186173testder=0;
     174testpatch=0;
    187175for ilist=1:length(FieldNames)
    188176    if ~isempty(FieldNames{ilist})
    189177    switch FieldNames{ilist}
     178        case{'u','v'}
     179            testpatch=1;
    190180        case {'vort','div','strain'}
    191181            testder=1;
    192182    end
    193183    end
    194 end     
     184end   
     185switch 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   
     215end
    195216if isempty(vel_type) || isequal(vel_type,'*') %undefined velocity type (civ1,civ2...)
    196217    if testder
     
    219240vel_type_out=vel_type_out';
    220241
    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.