Changeset 380 for trunk


Ignore:
Timestamp:
Jan 29, 2012, 2:31:56 PM (13 years ago)
Author:
sommeria
Message:

reading of civ data, new format, improved: bugs for reading u and v repairedd

Location:
trunk/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/calc_field.m

    r247 r380  
    6464    RoleList={};
    6565    units_cell={};
    66     % new civ data
     66   
     67    %% interpolation with new civ data
    6768    if isfield(DataIn,'X_SubRange')
    6869        XMax=max(max(DataIn.X_SubRange));
     
    8889        DataOut.V=zeros(size(XI));
    8990        DataOut.vort=zeros(size(XI));
     91       
    9092        DataOut.div=zeros(size(XI));
    9193        nbval=zeros(size(XI));
     
    126128                        ListFields={'vort'};
    127129                        VarAttributes{1}.Role='scalar';
    128 %                         EMX = [DMXY(:,:,1) PM];
    129 %                         EMY = [DMXY(:,:,2) PM];
    130 %                         DataIn.U_tps(nbvec_sub+1,isub)=0;%constant value suppressed by spatial derivatives
    131 %                         DataIn.V_tps(nbvec_sub+1,isub)=0;%constant value suppressed by spatial derivatives
    132 %                         DataIn.V_tps(nbvec_sub+2,isub)=0;% X coefficient suppressed for x wise derivatives
    133 %                         DataIn.U_tps(nbvec_sub+3,isub)=0;% Y coefficient suppressed for x wise derivatives
    134130                        DataOut.vort(ind_sel)=DataOut.vort(ind_sel)+EMDY *DataIn.U_tps(1:nbvec_sub+3,isub)-EMDX *DataIn.V_tps(1:nbvec_sub+3,isub);
    135131                    case 'div'
    136132                        ListFields={'div'};
    137133                        VarAttributes{1}.Role='scalar';
    138 %                         EMX = [DMXY(:,:,1) PM];
    139 %                         EMY = [DMXY(:,:,2) PM];
    140 %                         DataIn.U_tps(nbvec_sub+1,isub)=0;%constant value suppressed by spatial derivatives
    141 %                         DataIn.V_tps(nbvec_sub+1,isub)=0;%constant value suppressed by spatial derivatives
    142 %                         DataIn.V_tps(nbvec_sub+2,isub)=0;% X coefficient suppressed for x wise derivatives
    143 %                         DataIn.U_tps(nbvec_sub+3,isub)=0;% Y coefficient suppressed for x wise derivatives
    144134                        DataOut.div(ind_sel)=DataOut.div(ind_sel)+EMDX*DataIn.U_tps(1:nbvec_sub+3,isub)+EMDY *DataIn.V_tps(1:nbvec_sub+3,isub);
    145135                end
     
    161151        DataOut.VarAttribute={[],[]};
    162152        DataOut.VarAttribute{3}.Role='errorflag';
    163         DataOut.VarAttribute=[DataOut.VarAttribute VarAttributes];      
     153        DataOut.VarAttribute=[DataOut.VarAttribute VarAttributes];   
    164154    else   
     155       
     156    %% civx data   
    165157        DataOut=DataIn;
    166158        for ilist=1:length(FieldName)
  • trunk/src/check_files.m

    r375 r380  
    5252    'editxml.fig';...%interface for editxml
    5353    'fileparts_uvmat';...% extracts the root name,field indexes and nomenclature type from an input filename
     54    'fill_GUI';...% fill a GUI with handles 'handles' from input data Param
    5455    'find_field_indices';...% group the variables of a nc-formated Matlab structure into 'fields' with common dimensions
    5556    'find_file_series';...%check the content of an input file and find the corresponding file series
     
    5960    'get_field';...% choose and plot a field from a Netcdf file
    6061    'get_field.fig';...%interface for get_field
     62    'get_file_series';...% determine the list of file names and file indices for functions called by 'series'.
     63    'get_file_type';...% determine info about a file (image, multimage, civdata,...) .
    6164    'griddata_uvmat';...%make 2D linear interpolation using griddata, with input appropriate for both Matlab 6.5 and 7
    6265    'hist_update';...%  update of a current global histogram by inclusion of a new field
     
    8386    'read_GUI';... %read all parameters set by a GUI as a Matlab structure
    8487    'read_imatext';...%read .civ files (obsolete, but can be adapted to other text documentation files)
    85     'read_set_object';...%read the data on the set_object interface, TODO: use instead the general function read_GUI
    8688    'read_xls';...%read excel files containing the list of the experiments
    8789    'reinit';...% suppress the personal parameter file 'uvmat_perso.mat'
  • trunk/src/fill_GUI.m

    r379 r380  
     1%'fill_GUI': fill a GUI with handles 'handles' from input data Param
    12% -----------------------------------------------------------------------
    2 % --- read a GUI with handle 'handle' producing a structure 'struct'
    33function errormsg=fill_GUI(Param,handles)
    44%------------------------------------------------------------------------
  • trunk/src/get_file_type.m

    r376 r380  
    1   %'get_file_series': determine the list of file names and file indices for functions called by 'series'.
     1%'get_file_type': determine info about a file (image, multimage, civdata,...) .
    22%------------------------------------------------------------------------
    3 % [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param)
     3% [FileType,FileInfo,Object]=get_file_type(fileinput)
    44%
    55% OUTPUT:
  • trunk/src/read_civdata.m

    r379 r380  
    4747% 'nc2struct': reads a netcdf file
    4848
    49 function [Field,VelTypeOut,errormsg]=read_civdata(filename,FieldNames,VelType,XI,YI)
     49function [Field,VelTypeOut,errormsg]=read_civdata(filename,FieldNames,VelType,CivStage)
    5050errormsg='';
    5151VelTypeOut=VelType;%default
     
    6565
    6666%% reading data
    67 [varlist,role,units,vel_type_out_cell]=varcivx_generator(FieldNames,VelType);
    68 [Field,vardetect,ichoice]=nc2struct(filename,varlist);%read the variables in the netcdf file
     67[varlist,role,units,VelTypeOut]=varcivx_generator(FieldNames,VelType,CivStage);
     68[Field,vardetect]=nc2struct(filename,varlist);%read the variables in the netcdf file
    6969if isfield(Field,'Txt')
    7070    errormsg=Field.Txt;
     
    7575     return
    7676end
    77 switch vel_type_out_cell{ichoice}
    78     case{'civ1','fix1','patch1'}
    79         Field.dt=Field.Civ1_Dt;
    80     case{'civ2','fix2','patch2'}
    81         Field.dt=Field.Civ2_Dt;
     77switch VelTypeOut
     78    case{'civ1','civ-filter1','filter1'}
     79        Field.Dt=Field.Civ1_Dt;
     80    case{'civ2','civ-filter2','filter2'}
     81        Field.Dt=Field.Civ2_Dt;
    8282end
    83 Field.ListGlobalAttribute=[Field.ListGlobalAttribute {'dt'}];
     83Field.ListGlobalAttribute=[Field.ListGlobalAttribute {'Dt'}];
    8484var_ind=find(vardetect);
    8585for ivar=1:min(numel(var_ind),numel(Field.VarAttribute))
     
    8888    Field.VarAttribute{ivar}.Mesh=0.1;%typical mesh for histograms O.1 pixel
    8989end
    90 if ~isempty(ichoice)
    91     VelTypeOut=vel_type_out_cell{ichoice};
    92 end
    9390
    94 
    95 %% renaming for standard conventions
    96 %Field.NbCoord=Field.nb_coord;
    97 %Field.NbDim=2;%Field.nb_dim;
    98 
    99 %% CivStage
    100 % if isfield(Field,'patch2')&& isequal(Field.patch2,1)
    101 %     Field.CivStage=6;
    102 % elseif isfield(Field,'fix2')&& isequal(Field.fix2,1)
    103 %     Field.CivStage=5;
    104 % elseif isfield(Field,'civ2')&& isequal(Field.civ2,1)
    105 %     Field.CivStage=4;
    106 % elseif isfield(Field,'patch')&& isequal(Field.patch,1)
    107 %     Field.CivStage=3;
    108 % elseif isfield(Field,'fix')&& isequal(Field.fix,1)
    109 %     Field.CivStage=2;
    110 % else
    111 %     Field.CivStage=1;
    112 % end
    11391Field.ListGlobalAttribute=[Field.ListGlobalAttribute {'NbCoord','NbDim','TimeUnit','CoordUnit'}];
    114 % %determine the appropriate constant for time and dt for the PIV pair
    115 % test_civ1=isequal(VelTypeOut,'civ1')||isequal(VelTypeOut,'interp1')||isequal(VelTypeOut,'filter1');
    116 % test_civ2=isequal(VelTypeOut,'civ2')||isequal(VelTypeOut,'interp2')||isequal(VelTypeOut,'filter2');
    117 % Field.Time=0; %default
    118 % Field.TimeUnit='s';
    119 % if test_civ1
    120 %     if isfield(Field,'absolut_time_T0')
    121 %         Field.Time=double(Field.absolut_time_T0);
    122 %         Field.dt=double(Field.dt);
    123 %     else
    124 %        Field.Txt='the input file is not civx';
    125 %        Field.CivStage=0;
    126 %        Field.dt=0;
    127 %     end
    128 % elseif test_civ2
    129 %     Field.Time=double(Field.absolut_time_T0_2);
    130 %     Field.dt=double(Field.dt2);
    131 % else
    132 %     Field.Txt='the input file is not civx';
    133 %     Field.CivStage=0;
    134 %     Field.dt=0;
    135 % end
    136 %
    137 %
    138 %
    13992% %% update list of global attributes
    140 % List=Field.ListGlobalAttribute;
    141 % ind_remove=[];
    142 % for ilist=1:length(List)
    143 %     switch(List{ilist})
    144 %         case {'patch2','fix2','civ2','patch','fix','dt2','absolut_time_T0','absolut_time_T0_2','nb_coord','nb_dim','pixcmx','pixcmy'}
    145 %             ind_remove=[ind_remove ilist];
    146 %             Field=rmfield(Field,List{ilist});
    147 %     end
    148 % end
    149 % List(ind_remove)=[];
    150 % Field.ListGlobalAttribute=[{'NbCoord'},{'NbDim'} List {'Time','TimeUnit','CivStage','CoordUnit'}];
    15193Field.NbCoord=2;
    15294Field.NbDim=2;
     
    15799
    158100%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    159 % TAKEN FROM read_civxdata NOT USED
    160101% [var,role,units,vel_type_out]=varcivx_generator(FieldNames,vel_type)
    161102%INPUT:
     
    166107%             
    167108% vel_type: character string indicating the types of velocity fields to read ('civ1','civ2'...)
    168 %            if vel_type=[] or'*', a  priority choice, given by vel_type_out{1,2}, is done depending
    169 %            if vel_type='filter'; a structured field is sought (filter2 in priority, then filter1)
     109%            if vel_type=[] or'*', a  priority choice is done, civ2 considered better than civ1 )
    170110
    171 function [var,role,units,vel_type_out]=varcivx_generator(FieldNames,vel_type)
     111function [var,role,units,vel_type_out]=varcivx_generator(FieldNames,vel_type,CivStage)
    172112
    173113%% default input values
     
    187127        case {'vort','div','strain'}
    188128            testder=1;
     129           
    189130    end
    190131    end
    191132end   
     133
     134if isempty(vel_type)
     135    switch CivStage
     136        case {6} %filter2 available
     137            vel_type='civ2';
     138        case {4,5}% civ2 available but not filter2
     139            if testder% derivatives needed
     140                vel_type='civ1';
     141            else
     142                vel_type='civ2';
     143            end
     144        case {1,2,3}% civ1 available but not civ2
     145            vel_type='civ1';
     146    end
     147end
     148if strcmp(vel_type,'civ2') && testder
     149    vel_type='filter2';
     150elseif stcmp(vel_type,'civ1') && testder
     151    vel_type='filter1';
     152end
     153
    192154switch vel_type
    193     case 'civ1'
    194         var={'X','Y','Z','U','V','W','C','F','FF';...
    195             'Civ1_X','Civ1_Y','Civ1_Z','Civ1_U','Civ1_V','Civ1_W','Civ1_C','Civ1_F','Civ1_FF'};
    196         role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','warnflag','errorflag'};
    197         units={'pixel','pixel','pixel','pixel','pixel','pixel',[],[],[]};
    198     case 'interp1'
     155    case {'civ1'}
     156        var={'X','Y','Z','U','V','W','C','F','FF','X_tps','Y_tps','Z_tps','U_tps','V_tps','W_tps','X_SubRange','Y_SubRange','NbSites';...
     157            'Civ1_X','Civ1_Y','Civ1_Z','Civ1_U','Civ1_V','Civ1_W','Civ1_C','Civ1_F','Civ1_FF',...
     158            'Civ1_X_tps','Civ1_Y_tps','','Civ1_U_tps','Civ1_V_tps','','Civ1_X_SubRange','Civ1_Y_SubRange','Civ1_NbSites'};
     159        role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','warnflag','errorflag','','','','','','','','',''};
     160        units={'pixel','pixel','pixel','pixel','pixel','pixel','','','','pixel','pixel','pixel','pixel','pixel','pixel','pixel','pixel',''};
     161    case 'civ-filter1'
    199162        var={'X','Y','Z','U','V','W','FF';...
    200163            'Civ1_X','Civ1_Y','','Civ1_U_Diff','Civ1_V_Diff','','Civ1_FF'};
     
    207170        units={'pixel','pixel','pixel','pixel','pixel','pixel','pixel','pixel',''};
    208171    case 'civ2'
    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         role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','warnflag','errorflag'};
    212         units={'pixel','pixel','pixel','pixel','pixel','pixel',[],[],[]};
    213     case 'interp2'
     172        var={'X','Y','Z','U','V','W','C','F','FF','X_tps','Y_tps','Z_tps','U_tps','V_tps','W_tps','X_SubRange','Y_SubRange','NbSites';...
     173            'Civ2_X','Civ2_Y','Civ2_Z','Civ2_U','Civ2_V','Civ2_W','Civ2_C','Civ2_F','Civ2_FF',...
     174            'Civ2_X_tps','Civ2_Y_tps','','Civ2_U_tps','Civ2_V_tps','','Civ2_X_SubRange','Civ2_Y_SubRange','Civ2_NbSites'};
     175        role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','warnflag','errorflag','','','','','','','','',''};
     176        units={'pixel','pixel','pixel','pixel','pixel','pixel','','','','pixel','pixel','pixel','pixel','pixel','pixel','pixel','pixel',''};
     177%         var={'X','Y','Z','U','V','W','C','F','FF';...
     178%             'Civ2_X','Civ2_Y','Civ2_Z','Civ2_U','Civ2_V','Civ2_W','Civ2_C','Civ2_F','Civ2_FF'};
     179%         role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','warnflag','errorflag'};
     180%         units={'pixel','pixel','pixel','pixel','pixel','pixel',[],[],[]};
     181    case 'civ-filter2'
    214182        var={'X','Y','Z','U','V','W','FF';...
    215183            'Civ2_X','Civ2_Y','','Civ2_U_Diff','Civ2_V_Diff','','Civ2_FF'};
     
    221189        role={'','','','','','','','',''};
    222190        units={'pixel','pixel','pixel','pixel','pixel','pixel','pixel','pixel',''};
    223     otherwise % if VelType=[], choose the best field, civ in priority, or patch2 for derivatives
    224         if testpatch
    225             var={'X_tps','Y_tps','Z_tps','U_tps','V_tps','W_tps','X_SubRange','Y_SubRange','NbSites';...
    226                 'Civ2_X_tps','Civ2_Y_tps','','Civ2_U_tps','Civ2_V_tps','','Civ2_X_SubRange','Civ2_Y_SubRange','Civ2_NbSites';...
    227                 'Civ1_X_tps','Civ1_Y_tps','','Civ1_U_tps','Civ1_V_tps','','Civ1_X_SubRange','Civ1_Y_SubRange','Civ1_NbSites'};
    228             role={'','','','','','','',''};
    229             units={'pixel','pixel','pixel','pixel','pixel','pixel','pixel','pixel'};
    230         else
    231             var={'X','Y','Z','U','V','W','C','F','FF';...
    232                 'Civ2_X','Civ2_Y','Civ2_Z','Civ2_U','Civ2_V','Civ2_W','Civ2_C','Civ2_F','Civ2_FF';...
    233                 'Civ1_X','Civ1_Y','Civ1_Z','Civ1_U','Civ1_V','Civ1_W','Civ1_C','Civ1_F','Civ1_FF'};
    234             role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','warnflag','errorflag'};
    235             units={'pixel','pixel','pixel','pixel','pixel','pixel',[],[],[]};
    236         end
    237191end
    238 if isempty(vel_type) || isequal(vel_type,'*') %undefined velocity type (civ1,civ2...)
    239     if testder
    240          vel_type_out{1}='filter2'; %priority to filter2 for scalar reading, filter1 as second
    241         vel_type_out{2}='filter1';
    242     else
    243         vel_type_out{1}='civ2'; %priority to civ2 for vector reading, civ1 as second priority     
    244         vel_type_out{2}='civ1';
    245     end
    246 elseif isequal(vel_type,'filter')
    247         vel_type_out{1}='filter2'; %priority to filter2 for scalar reading, filter1 as second
    248         vel_type_out{2}='filter1';
    249         if ~testder
    250             vel_type_out{3}='civ1';%civ1 as third priority if derivatives are not needed
    251         end
    252 elseif testder
    253     test_civ1=isequal(vel_type,'civ1')||isequal(vel_type,'interp1')||isequal(vel_type,'filter1');
    254     if test_civ1
    255         vel_type_out{1}='filter1'; %switch to filter for reading spatial derivatives
    256     else
    257         vel_type_out{1}='filter2';
    258     end
    259 else   
    260     vel_type_out{1}=vel_type;%imposed velocity field
    261 end
    262 vel_type_out=vel_type_out';
     192vel_type_out=vel_type;
    263193
    264194
     
    266196
    267197
    268 
  • trunk/src/read_civxdata.m

    r247 r380  
    4949function [Field,VelTypeOut,errormsg]=read_civxdata(filename,FieldNames,VelType)
    5050errormsg='';
    51 DataTest=nc2struct(filename,'ListGlobalAttribute','Conventions');
     51DataTest=nc2struct(filename,'ListGlobalAttribute','Conventions','CivStage');
    5252if isfield(DataTest,'Txt')
    53     errormsg=DataTest.Txt;   
     53    errormsg=DataTest.Txt;
     54    return
    5455elseif isequal(DataTest.Conventions,'uvmat/civdata')%test for new civ format
    55      [Field,VelTypeOut]=read_civdata(filename,FieldNames,VelType);
     56     [Field,VelTypeOut,errormsg]=read_civdata(filename,FieldNames,VelType,DataTest.CivStage);
     57%      if ~isempty(errormsg)
     58%          msgbox_uvmat('ERROR',errormsg)
     59%      end
    5660     return
    5761end
  • trunk/src/read_field.m

    r379 r380  
    5656            field_index=strcmp(ParamIn.FieldName,FieldList);%look for ParamIn.FieldName in the list of possible fields for Civx data
    5757            if isempty(find(field_index,1))% ParamIn.FieldName is not in the list, check whether Civx data exist
    58                 Data=nc2struct(ObjectName,'ListGlobalAttribute','Conventions','absolut_time_T0','civ');
     58                Data=nc2struct(ObjectName,'ListGlobalAttribute','Conventions','absolut_time_T0','civ','CivStage');
    5959                % case of new civdata conventions
    6060                if isequal(Data.Conventions,'uvmat/civdata')
     
    6262                    ParamOut.ColorVar='ima_cor';
    6363                    InputField=[{ParamOut.FieldName} {ParamOut.ColorVar}];
    64                     [Field,ParamOut.VelType,errormsg]=read_civdata(ObjectName,InputField,ParamIn.VelType);
     64                    [Field,ParamOut.VelType,errormsg]=read_civdata(ObjectName,InputField,ParamIn.VelType,Data.CivStage);
    6565                    test_civx=Field.CivStage;
    6666                    %case of old civx conventions
  • trunk/src/uvmat.m

    r379 r380  
    21032103    set(handles.VelType_1,'Visible','on')
    21042104    set(handles.FixVelType,'Visible','on')
    2105     menu=set_veltype_display(ParamOut.CivStage);
     2105    menu=set_veltype_display(ParamOut.CivStage,FileType);
    21062106    index_menu=strcmp(ParamOut.VelType,menu);%look for VelType in  the menu
    21072107    index_val=find(index_menu,1);
     
    21932193    end
    21942194end
    2195 
    2196 % menu_transform=get(handles.transform_fct,'String');
    21972195choice_value=get(handles.transform_fct,'Value');
    21982196transform_list=get(handles.transform_fct,'UserData');
     
    28072805        set(handles.VelType_1,'Visible','off')
    28082806    end
    2809 %     set_veltype_display([handles.VelType_1 handles.interp1_1 handles.filter1_1 ...
    2810 %             handles.civ2_1 handles.interp2_1 handles.filter2_1],0)
    28112807    if isfield(UvData,'XmlData_1')
    28122808        UvData=rmfield(UvData,'XmlData_1');
     
    30563052%------------------------------------------------------------------------
    30573053% --- set the visibility of relevant velocity type menus:
    3058 function menu=set_veltype_display(Civ)
     3054function menu=set_veltype_display(Civ,FileType)
    30593055%------------------------------------------------------------------------
    30603056if isequal(Civ,0)
     
    30693065    imax=6;
    30703066end
     3067if ~exist('FileType','var')
     3068    FileType='civx';
     3069end
     3070switch FileType
     3071    case 'civx'
    30713072menu={'civ1';'interp1';'filter1';'civ2';'interp2';'filter2'};
     3073    case 'civdata'
     3074    menu={'civ1';'civ-filter1';'filter1';'civ2';'civ-filter2';'filter2'};   
     3075end
    30723076menu=menu(1:imax);
    30733077
Note: See TracChangeset for help on using the changeset viewer.