Changeset 406 for trunk/src


Ignore:
Timestamp:
May 3, 2012, 7:30:05 PM (13 years ago)
Author:
sommeria
Message:

bugs corrected in civ_matlab and object projection

Location:
trunk/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/calc_field.m

    r405 r406  
    9393%% interpolation with new civ data
    9494if isfield(DataIn,'SubRange') && isfield(DataIn,'Coord_tps') && (exist('Coord_interp','var') || check_grid ||check_der)
    95    
    96     DataOut.ListGlobalAttribute=DataIn.ListGlobalAttribute; %reproduce global attribute
     95    %reproduce global attributes
     96    DataOut.ListGlobalAttribute=DataIn.ListGlobalAttribute;
    9797    for ilist=1:numel(DataOut.ListGlobalAttribute)
    9898        DataOut.(DataOut.ListGlobalAttribute{ilist})=DataIn.(DataIn.ListGlobalAttribute{ilist});
    9999    end
    100     DataOut.ListVarName={'coord_y','coord_x','FF'};
    101     DataOut.VarDimName{1}='coord_y';
    102     DataOut.VarDimName{2}='coord_x';
    103     XMax=max(max(DataIn.SubRange(1,:,:)));% extrema of the coordinates
    104     YMax=max(max(DataIn.SubRange(2,:,:)));
    105     XMin=min(min(DataIn.SubRange(1,:,:)));
    106     YMin=min(min(DataIn.SubRange(2,:,:)));
     100
    107101    %create a default grid if needed
    108102    if  ~exist('Coord_interp','var')
     103            XMax=max(max(DataIn.SubRange(1,:,:)));% extrema of the coordinates
     104            YMax=max(max(DataIn.SubRange(2,:,:)));
     105            XMin=min(min(DataIn.SubRange(1,:,:)));
     106            YMin=min(min(DataIn.SubRange(2,:,:)));
    109107        if ~isfield(DataIn,'Mesh')
    110108            DataIn.Mesh=sqrt(2*(XMax-XMin)*(YMax-YMin)/numel(DataIn.Coord_tps));
     
    121119        coord_x=XMin:DataIn.Mesh:XMax;
    122120        coord_y=YMin:DataIn.Mesh:YMax;
     121        npx=length(coord_x);
     122        npy=length(coord_y);
     123        DataOut.coord_x=[XMin XMax];
     124        DataOut.coord_y=[YMin YMax];
    123125        [XI,YI]=meshgrid(coord_x,coord_y);
    124126        XI=reshape(XI,[],1);
     
    126128        Coord_interp=[XI YI];
    127129    end
     130   
     131    %initialise output
    128132    nb_sites=size(Coord_interp,1);
    129133    nb_coord=size(Coord_interp,2);
    130     %initialise output
     134    nbval=zeros(nb_sites,1);
     135    NbSubDomain=size(DataIn.SubRange,3);
     136    DataOut.ListVarName={'coord_y','coord_x'};
     137    DataOut.VarDimName={{'coord_y'},{'coord_x'}};
     138    DataOut.VarAttribute{1}=[];
     139    DataOut.VarAttribute{2}=[];
    131140    for ilist=1:length(FieldList)
    132141        switch FieldList{ilist}
     
    135144                DataOut.V=zeros(nb_sites,1);
    136145            otherwise
    137                 %          case{'vort','div','strain'}% case of spatial derivatives
    138146                DataOut.(FieldList{ilist})=zeros(nb_sites,1);
    139                 %                 otherwise % case of a scalar
    140                 %                     check_val=1;
    141                 %                     DataOut.(FieldList{ilist})=zeros(size(Coord_interp,1));
    142         end
    143     end
    144     nbval=zeros(nb_sites,1);
    145     NbSubDomain=size(DataIn.SubRange,3);
    146     %DataIn.Coord_tps=DataIn.Coord_tps(1:end-3,:,:);% suppress the 3 zeros used to fit with the dimensions of variables
     147        end
     148    end
     149   
     150    % interpolate data in each subdomain
    147151    for isub=1:NbSubDomain
    148152        nbvec_sub=DataIn.NbSites(isub);
     
    159163            [EMDX,EMDY] = tps_eval_dxy(Coord_interp(ind_sel,:),DataIn.Coord_tps(1:nbvec_sub,:,isub));%kernels for calculating the spatial derivatives from tps 'sources'
    160164        end
     165        var_count=0;
    161166        for ilist=1:length(FieldList)
    162167            switch FieldList{ilist}
    163168                case 'velocity'
    164169                    ListFields={'U', 'V'};
    165                     VarAttributes{1}.Role='vector_x';
    166                     VarAttributes{2}.Role='vector_y';
     170                    VarAttributes{var_count+1}.Role='vector_x';
     171                    VarAttributes{var_count+2}.Role='vector_y';
    167172                    DataOut.U(ind_sel)=DataOut.U(ind_sel)+EM *DataIn.U_tps(1:nbvec_sub+3,isub);
    168173                    DataOut.V(ind_sel)=DataOut.V(ind_sel)+EM *DataIn.V_tps(1:nbvec_sub+3,isub);
    169174                case 'u'
    170                     ListFields={'U'};
    171                     VarAttributes{1}.Role='scalar';
    172                     DataOut.U(ind_sel)=DataOut.U(ind_sel)+EM *DataIn.U_tps(1:nbvec_sub+3,isub);
     175                    ListFields={'u'};
     176                    VarAttributes{var_count+1}.Role='scalar';
     177                    DataOut.u(ind_sel)=DataOut.u(ind_sel)+EM *DataIn.U_tps(1:nbvec_sub+3,isub);
    173178                case 'v'
    174                     ListFields={'V'};
    175                     VarAttributes{1}.Role='scalar';
    176                     DataOut.V(ind_sel)=DataOut.V(ind_sel)+EM *DataIn.V_tps(1:nbvec_sub+3,isub);
     179                    ListFields={'v'};
     180                    VarAttributes{var_count+1}.Role='scalar';
     181                    DataOut.v(ind_sel)=DataOut.v(ind_sel)+EM *DataIn.V_tps(1:nbvec_sub+3,isub);
    177182                case 'norm_vel'
    178183                    ListFields={'norm_vel'};
    179                     VarAttributes{1}.Role='scalar';
     184                    VarAttributes{var_count+1}.Role='scalar';
    180185                    V=DataOut.U(ind_sel)+EM *DataIn.U_tps(1:nbvec_sub+3,isub);
    181186                    V=DataOut.V(ind_sel)+EM *DataIn.V_tps(1:nbvec_sub+3,isub);
     
    183188                case 'vort'
    184189                    ListFields={'vort'};
    185                     VarAttributes{1}.Role='scalar';
     190                    VarAttributes{var_count+1}.Role='scalar';
    186191                    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);
    187192                case 'div'
    188193                    ListFields={'div'};
    189                     VarAttributes{1}.Role='scalar';
     194                    VarAttributes{var_count+1}.Role='scalar';
    190195                    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);
    191196                case 'strain'
    192197                    ListFields={'strain'};
    193                     VarAttributes{1}.Role='scalar';
     198                    VarAttributes{var_count+1}.Role='scalar';
    194199                    DataOut.strain(ind_sel)=DataOut.strain(ind_sel)+EMDY*DataIn.U_tps(1:nbvec_sub+3,isub)+EMDX *DataIn.V_tps(1:nbvec_sub+3,isub);
    195200            end
    196         end
    197         DataOut.FF=nbval==0; %put errorflag to 1 for points outside the interpolation rang
    198         nbval(nbval==0)=1;
    199         DataOut.ListVarName=[DataOut.ListVarName ListFields];
    200         for ilist=3:numel(DataOut.ListVarName)
    201             DataOut.VarDimName{ilist}={'coord_y','coord_x'};
    202         end
    203         DataOut.VarAttribute={[],[]};
    204         DataOut.VarAttribute{3}.Role='errorflag';
    205         DataOut.VarAttribute=[DataOut.VarAttribute VarAttributes];
     201            DataOut.FF=nbval==0; %put errorflag to 1 for points outside the interpolation rang
     202            nbval(nbval==0)=1;
     203            DataOut.ListVarName=[DataOut.ListVarName ListFields {'FF'}];
     204            for ilist=1:numel(ListFields)
     205                VarDimName{ilist}={'coord_y','coord_x'};
     206                DataOut.(ListFields{ilist})=reshape(DataOut.(ListFields{ilist}),npy,npx);
     207            end
     208            DataOut.FF=reshape(DataOut.FF,npy,npx);
     209            DataOut.VarDimName=[DataOut.VarDimName VarDimName {{'coord_y','coord_x'}}] ;
     210            VarAttributes{length(ListFields)+1}.Role='errorflag';
     211            DataOut.VarAttribute=[DataOut.VarAttribute VarAttributes];
     212        end
    206213    end
    207214else
  • trunk/src/check_field_structure.m

    r404 r406  
    1717
    1818function [errormsg,ListDimName,DimValue,VarDimIndex]=check_field_structure(Data)
    19 DataOut=[]; %default
    20 errormsg=[];
     19errormsg='';
     20ListDimName={};
     21DimValue=[]; %default
     22VarDimIndex={};
    2123if ~isstruct(Data)
    2224    errormsg='input field is not a structure';
  • trunk/src/civ.m

    r399 r406  
    12531253            Param.Civ1.ImageWidth=ImageInfo.Width;
    12541254            Param.Civ1.ImageHeight=ImageInfo.Height;
    1255             Param.Civ1.i1=i1_civ1;
    1256             Param.Civ1.i2=i2_civ1;
     1255            Param.Civ1.i1=i1_civ1(ifile,j);
     1256            Param.Civ1.i2=i2_civ1(ifile,j);
    12571257            % read mask parameters
    12581258            if Param.Civ1.CheckMask % the lines below should be changed with the new gui
     
    14311431            Param.Civ2.ImageWidth=ImageInfo.Width;
    14321432            Param.Civ2.ImageHeight=ImageInfo.Height;
    1433             Param.Civ2.i1=i1_civ2;
    1434             Param.Civ2.i2=i2_civ2;
     1433            Param.Civ2.i1=i1_civ2(ifile,j);
     1434            Param.Civ2.i2=i2_civ2(ifile,j);
    14351435            switch CivMode
    14361436                case 'CivX'
     
    15861586                        if isempty(errormsg)
    15871587                            display([filecell.nc.civ1{ifile,j} ' written'])
    1588 %                         else
    1589 %                             msgbox_uvmat('ERROR',errormsg)
    15901588                        end
    15911589                    end
  • trunk/src/civ_matlab.m

    r399 r406  
    5858%% Civ1
    5959if isfield (Param,'Civ1')
    60     check_civ1=1;% test for further use of civ1 results
     60%     check_civ1=1;% test for further use of civ1 results
    6161    % %% prepare images
    6262    par_civ1=Param.Civ1;
     
    102102    list_param=(fieldnames(Param.Civ1))';
    103103    Civ1_param=list_param;%default
     104    %set the values of all the global attributes in list_param
    104105    for ilist=1:length(list_param)
    105106        Civ1_param{ilist}=['Civ1_' list_param{ilist}];
  • trunk/src/read_civdata.m

    r404 r406  
    4848
    4949function [Field,VelTypeOut,errormsg]=read_civdata(filename,FieldNames,VelType,CivStage)
    50 errormsg='';
     50
    5151%% default input
    5252if ~exist('VelType','var')
     
    6262    FieldNames=[]; %default
    6363end
     64errormsg='';
    6465
    6566%% reading data
    6667[varlist,role,units,VelTypeOut]=varcivx_generator(FieldNames,VelType,CivStage);
    67 [Field,vardetect]=nc2struct(filename,varlist);%read the variables in the netcdf file
     68if isempty(varlist)
     69    erromsg=['error in read_civdata: unknow velocity type ' VelType];
     70    return
     71else
     72    [Field,vardetect]=nc2struct(filename,varlist);%read the variables in the netcdf file
     73end
    6874if isfield(Field,'Txt')
    6975    errormsg=Field.Txt;
     
    106112%            if vel_type=[] or'*', a  priority choice is done, civ2 considered better than civ1 )
    107113
    108 function [var,role,units,vel_type_out]=varcivx_generator(FieldNames,vel_type,CivStage)
     114function [var,role,units,vel_type_out,errormsg]=varcivx_generator(FieldNames,vel_type,CivStage)
    109115
    110116%% default input values
     
    113119if ~exist('FieldNames','var'),FieldNames={'ima_cor'};end;%default scalar
    114120if ischar(FieldNames), FieldNames={FieldNames}; end;
     121errormsg='';
    115122
    116123%% select the priority order for automatic vel_type selection
     
    127134    end
    128135end
    129 if isempty(vel_type)
     136if isempty(vel_type)||strcmp(vel_type,'*')
    130137    switch CivStage
    131138        case {6} %filter2 available
     
    146153    vel_type='filter1';
    147154end
    148 
     155var={};
    149156switch vel_type
    150157    case 'civ1'
  • trunk/src/read_field.m

    r405 r406  
    9494                ParamOut.CivStage=Field.CivStage;
    9595            end
    96         end
    97         ParamOut.FieldList=[{'image'};FieldList;{'get_field...'}];
     96            ParamOut.FieldList=[{'image'};FieldList;{'get_field...'}];
     97        end
     98%         ParamOut.FieldList=[{'image'};FieldList;{'get_field...'}];
    9899        if CivStage==0% read the field names on the interface get_field.
    99100            hget_field=findobj(allchild(0),'Name',GUIName);%find the get_field... GUI
  • trunk/src/uvmat.m

    r405 r406  
    7979% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   DATA FLOW  (for run0_Callback) %%%%%%%%%%%%%%%%%%%%:
    8080%
    81 % fields are opened and visualised by the sub-function refresh_field.m
    82 % (called by uvmat_opening, RUN0, runp and runm)
     81%
     82% 1) Input filenames are determined by MenuBrowse (first field), MenuBrowse_1
     83% (second field), or by the stored file names under  Browse, or as an input of uvmat.
     84% 2) These functions call 'display_file_name.m' which detects the file series, and fills the file index boxes
     85% 3) Then 'update_rootinfo.m' Updates information about a new field series (indices to scan, timing, calibration from an xml file)
     86% 4) Then fields are opened and visualised by the main sub-function 'refresh_field.m'
    8387% The function first reads the name of the input file from the edit boxes  of the GUI
    84 % A second input file can be introduced for filed comparison
     88% A second input file can be introduced for file comparison
    8589% It then reads the input file(s) with the appropriate function, read for
    8690% images, read_civxdata.m for CIVx PIV data, nc2struct for other netcdf
     
    168172%------------------------------------------------------------------------
    169173%------------------------------------------------------------------------
    170 %  I - MAIN FUNCTION UVMAT
     174%  I - MAIN FUNCTION uvmat
    171175%------------------------------------------------------------------------
    172176%------------------------------------------------------------------------
     
    343347if ~isempty(inputfile)
    344348    %%%%% display the input field %%%%%%%
    345     display_file_name(hObject, eventdata, handles,inputfile)
     349    display_file_name(handles,inputfile)
    346350    %%%%%%%
    347351    testinputfield=1;
     
    442446
    443447% display the selected field and related information
    444 display_file_name(hObject, eventdata, handles,fileinput)
     448display_file_name( handles,fileinput)
    445449
    446450% -----------------------------------------------------------------------
     
    449453%------------------------------------------------------------------------
    450454fileinput=get(handles.MenuFile_1,'Label');
    451 display_file_name(hObject, eventdata, handles,fileinput)
     455display_file_name( handles,fileinput)
    452456
    453457% -----------------------------------------------------------------------
     
    456460%------------------------------------------------------------------------
    457461fileinput=get(handles.MenuFile_2,'Label');
    458 display_file_name(hObject, eventdata, handles,fileinput)
     462display_file_name(handles,fileinput)
    459463
    460464% -----------------------------------------------------------------------
     
    463467%------------------------------------------------------------------------
    464468fileinput=get(handles.MenuFile_3,'Label');
    465 display_file_name(hObject, eventdata, handles,fileinput)
     469display_file_name(handles,fileinput)
    466470
    467471% -----------------------------------------------------------------------
     
    470474%------------------------------------------------------------------------
    471475fileinput=get(handles.MenuFile_4,'Label');
    472 display_file_name(hObject, eventdata, handles,fileinput)
     476display_file_name(handles,fileinput)
    473477
    474478% -----------------------------------------------------------------------
     
    477481%------------------------------------------------------------------------
    478482fileinput=get(handles.MenuFile_5,'Label');
    479 display_file_name(hObject, eventdata, handles,fileinput)
     483display_file_name(handles,fileinput)
    480484
    481485%------------------------------------------------------------------------
     
    511515% refresh the current displayed field
    512516set(handles.SubField,'Value',1)
    513 display_file_name(hObject,eventdata,handles,fileinput_1,2)
     517display_file_name(handles,fileinput_1,2)
    514518
    515519%update list of recent files in the menubar
     
    550554fileinput_1=get(handles.MenuFile_1_1,'Label');
    551555set(handles.SubField,'Value',1)
    552 display_file_name(hObject,eventdata,handles,fileinput_1,2)
     556display_file_name(handles,fileinput_1,2)
    553557
    554558% -----------------------------------------------------------------------
     
    558562fileinput_1=get(handles.MenuFile_2_1,'Label');
    559563set(handles.SubField,'Value',1)
    560 display_file_name(hObject,eventdata,handles,fileinput_1,2)
     564display_file_name(handles,fileinput_1,2)
    561565
    562566% -----------------------------------------------------------------------
     
    566570fileinput_1=get(handles.MenuFile_3_1,'Label');
    567571set(handles.SubField,'Value',1)
    568 display_file_name(hObject,eventdata,handles,fileinput_1,2)
     572display_file_name(handles,fileinput_1,2)
    569573
    570574% -----------------------------------------------------------------------
     
    574578fileinput_1=get(handles.MenuFile_4_1,'Label');
    575579set(handles.SubField,'Value',1)
    576 display_file_name(hObject,eventdata,handles,fileinput_1,2)
     580display_file_name(handles,fileinput_1,2)
    577581
    578582% -----------------------------------------------------------------------
     
    582586fileinput_1=get(handles.MenuFile_5_1,'Label');
    583587set(handles.SubField,'Value',1)
    584 display_file_name(hObject,eventdata,handles,fileinput_1,2)
     588display_file_name(handles,fileinput_1,2)
    585589
    586590%------------------------------------------------------------------------
     
    593597[RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileType,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]);
    594598% initiate the input file series and refresh the current field view:
    595 update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject);
     599update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileType,MovieObject,1);
    596600
    597601%-----------------------------------------------------------------------
     
    674678%------------------------------------------------------------------------
    675679% --- Fills the edit boxes RootPath, RootFile,NomType...from an input file name 'fileinput'
    676 function display_file_name(hObject, eventdata, handles,fileinput,index)
     680function display_file_name(handles,fileinput,index)
    677681%------------------------------------------------------------------------
    678682%% look for the input file existence
     
    687691drawnow
    688692
    689 %% define the relevant handles for the first fiel series (index=1) or the second file series (index=2)
     693%% define the relevant handles for the first field series (index=1) or the second file series (index=2)
    690694if ~exist('index','var')
    691695    index=1;
     
    698702    handles_NomType=handles.NomType;
    699703    handles_FileExt=handles.FileExt;
    700 %     handles_Fields=handles.Fields;
    701704elseif index==2
    702705    handles_RootPath=handles.RootPath_1;
     
    706709    handles_NomType=handles.NomType_1;
    707710    handles_FileExt=handles.FileExt_1;
    708 %     handles_Fields=handles.Fields_1;
    709711    set(handles.RootPath_1,'Visible','on')
    710712    set(handles.RootFile_1,'Visible','on')
     
    782784            else
    783785                set(handles.SubField,'Value',0)
    784                 SubField_Callback(hObject, eventdata, handles)
     786                SubField_Callback([], [], handles)
    785787            end
    786788        end
     
    11321134end
    11331135
    1134 %% update list of recent files in the menubar
     1136%% update list of recent files in the menubar and save it for future opening
    11351137MenuFile=[{get(handles.MenuFile_1,'Label')};{get(handles.MenuFile_2,'Label')};...
    11361138    {get(handles.MenuFile_3,'Label')};{get(handles.MenuFile_4,'Label')};{get(handles.MenuFile_5,'Label')}];
     
    29612963    end
    29622964     % display the selected field and related information
    2963     display_file_name(hObject, eventdata, handles,imagename)%display the image
     2965    display_file_name(handles,imagename)%display the image
    29642966    return
    29652967else
     
    29732975        filename=[PathName FileName];
    29742976        % display the selected field and related information
    2975         display_file_name(hObject, eventdata, handles,filename)
     2977        display_file_name( handles,filename)
    29762978        return
    29772979    end
     
    30683070            set(handles.num_Npx,'Visible','on')
    30693071            set(handles.num_Npy,'Visible','on')
    3070             display_file_name(hObject, eventdata, handles,imagename,2)%display the imag
     3072            display_file_name(handles,imagename,2)%display the imag
    30713073        end
    30723074    otherwise
     
    43324334    if isfield(UvData.Field,'Mesh')&&~isempty(UvData.Field.Mesh)
    43334335        data.RangeX=[UvData.Field.XMin UvData.Field.XMax];
    4334         data.RangeY=[UvData.Field.YMin UvData.Field.YMax];
     4336        if strcmp(data.Type,'line')||rcmp(data.Type,'polyline')
     4337            data.RangeY=UvData.Field.Mesh;
     4338        else
     4339            data.RangeY=[UvData.Field.YMin UvData.Field.YMax];
     4340        end
    43354341        data.DX=UvData.Field.Mesh;
    43364342        data.DY=UvData.Field.Mesh;
     4343       
    43374344%     elseif isfield(Field,'AX')&& isfield(Field,'AY')&& isfield(Field,'A')%only image
    43384345%         np=size(Field.A);
  • trunk/src/view_field.m

    r405 r406  
    8787set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function
    8888set(hObject,'WindowButtonUpFcn',{'mouse_up',handles_mouse})
    89 set(hObject,'CloseRequestFcn',{@closefcn})%
     89set(hObject,'DeleteFcn',{@closefcn})%
    9090ViewFieldData.axes3=[];%initiates the record of the current field (will be updated by plot_field)
    9191set(handles.view_field,'UserData',ViewFieldData);%store the current field
Note: See TracChangeset for help on using the changeset viewer.