Changeset 581


Ignore:
Timestamp:
Mar 12, 2013, 12:52:13 PM (12 years ago)
Author:
sommeria
Message:

clean the transform field functions

Location:
trunk/src
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/browse_data.m

    r576 r581  
    2222function varargout = browse_data(varargin)
    2323
    24 % Last Modified by GUIDE v2.5 15-Feb-2013 19:41:48
     24% Last Modified by GUIDE v2.5 07-Mar-2013 18:55:00
    2525
    2626% Begin initialization code - DO NOT EDIT
     
    4747function browse_data_OpeningFcn(hObject, eventdata, handles, Campaign)
    4848%------------------------------------------------------------------------
    49 % Choose default command line output for browse_data
     49
     50%% Choose default command line output for browse_data
    5051handles.output = 'Cancel';
    5152
    52 % Update handles structure
     53%% Update handles structure
    5354guidata(hObject, handles);
    54 
    55 % Determine the position of the dialog - centered on the screen
     55set(hObject,'WindowButtonDownFcn',{'mouse_down'}) % allows mouse action with right button (zoom for uicontrol display)
     56
     57%% Determine the position of the dialog - centered on the screen
    5658FigPos=get(0,'DefaultFigurePosition');
    5759OldUnits = get(hObject, 'Units');
     
    9597   set(handles.OK,'Visible','on')
    9698   set(handles.Cancel,'Visible','on')
    97    set(handles.figure,'WindowStyle','modal')% Make% Make the GUI modal
     99   set(handles.browse_data,'WindowStyle','modal')% Make the GUI modal
    98100   set(hObject,'Visible','on')
    99101   drawnow
    100102   % UIWAIT makes GUI wait for user response (see UIRESUME)
    101    uiwait(handles.figure);
     103   uiwait(handles.browse_data);
    102104end
    103105
     
    108110% Get default command line output from handles structure
    109111varargout{1} = handles.output;
    110 delete(handles.figure)
     112delete(handles.browse_data)
    111113
    112114%------------------------------------------------------------------------
     
    312314set(handles.ListExperiments,'Value',1)
    313315ListExperiments_Callback(hObject, eventdata, handles)%update the overview of the experiment directories
    314 DataviewData=get(handles.figure,'UserData');
     316DataviewData=get(handles.browse_data,'UserData');
    315317List=DataviewData.List;
    316318Currentpath=get(handles.SourceDir,'String');
     
    580582set(handles.ListExperiments,'Value',1)
    581583ListExperiments_Callback(hObject, eventdata, handles)%update the overview of the experiment directories
    582 DataviewData=get(handles.figure,'UserData')
     584DataviewData=get(handles.browse_data,'UserData')
    583585List=DataviewData.List;
    584586Currentpath=get(handles.SourceDir,'String');
     
    654656handles.output.Device=Device;
    655657guidata(hObject, handles);% Update handles structure
    656 uiresume(handles.figure);
     658uiresume(handles.browse_data);
    657659drawnow
    658660return
     
    676678
    677679%update all the selected xml files
    678 DataviewData=get(handles.figure,'UserData');
     680DataviewData=get(handles.browse_data,'UserData');
    679681% answer=msgbox_uvmat('INPUT_Y-N',[num2str(length(Value)) ' xml files for device ' ListDevices{1} ' will be refreshed with ' ...
    680682%     DataviewData.GeometryCalib.CalibrationType ' calibration data'])
     
    771773% handles.output ='OK, Calibration replicated';
    772774% guidata(hObject, handles);% Update handles structure
    773 % uiresume(handles.figure);
     775% uiresume(handles.browse_data);
    774776
    775777% --- Executes on button press in Cancel.
     
    778780guidata(hObject, handles); % Update handles structure
    779781% Use UIRESUME instead of delete because the OutputFcn needs
    780 uiresume(handles.figure);
    781 
    782 % --- Executes when user attempts to close figure.
    783 function figure_CloseRequestFcn(hObject, eventdata, handles)
    784 if isequal(get(handles.figure, 'waitstatus'), 'waiting')
     782uiresume(handles.browse_data);
     783
     784% --- Executes when user attempts to close browse_data.
     785function browse_data_CloseRequestFcn(hObject, eventdata, handles)
     786if isequal(get(handles.browse_data, 'waitstatus'), 'waiting')
    785787    % The GUI is still in UIWAIT, us UIRESUME
    786     uiresume(handles.figure);
     788    uiresume(handles.browse_data);
    787789else
    788790    % The GUI is no longer waiting, just close it
    789     delete(handles.figure);
     791    delete(handles.browse_data);
    790792end
    791793
    792794% --- Executes on key press over figure1 with no controls selected.
    793 function figure_KeyPressFcn(hObject, eventdata, handles)
     795function browse_data_KeyPressFcn(hObject, eventdata, handles)
    794796% Check for "enter" or "escape"
    795797if isequal(get(hObject,'CurrentKey'),'escape')
     
    800802    guidata(hObject, handles);
    801803   
    802     uiresume(handles.figure);
     804    uiresume(handles.browse_data);
    803805end
    804806if isequal(get(hObject,'CurrentKey'),'return')
    805     uiresume(handles.figure);
     807    uiresume(handles.browse_data);
    806808end
  • trunk/src/calc_field_tps.m

    r575 r581  
    22%'calc_field_tps': defines fields (velocity, vort, div...) from civ data and calculate them with tps interpolation
    33%---------------------------------------------------------------------
    4 % [DataOut,VarAttribute,errormsg]=calc_field_tps(Coord_tps,NbSites,SubRange,FieldVar,Operation,Coord_interp)
     4% [DataOut,VarAttribute,errormsg]=calc_field_tps(Coord_tps,NbSites,SubRange,FieldVar,FieldName,Coord_interp)
    55%
    66% OUTPUT:
     
    1212% SubRange
    1313% FieldVar
    14 % Operation: cell array representing the list of operations (eg div, rot..)
     14% FieldName: cell array representing the list of operations (eg div, rot..)
    1515% Coord_interp: coordiantes of sites on which the fields need to be calculated
    1616
    17 function [DataOut,VarAttribute,errormsg]=calc_field_tps(Coord_tps,NbSites,SubRange,FieldVar,Operation,Coord_interp)
     17function [DataOut,VarAttribute,errormsg]=calc_field_tps(Coord_tps,NbSites,SubRange,FieldVar,FieldName,Coord_interp)
    1818
    1919%list of defined scalars to display in menus (in addition to 'ima_cor').
     
    4444check_grid=0;
    4545check_der=0;
    46 for ilist=1:length(Operation)
    47     OperationType=regexprep(Operation{ilist},'(.+','');
    48     switch OperationType
     46for ilist=1:length(FieldName)
     47    FieldNameType=regexprep(FieldName{ilist},'(.+','');
     48    switch FieldNameType
    4949        case 'vec'
    5050            check_grid=1;
     
    5555        case {'U','V','norm'}
    5656            check_grid=1;
    57             DataOut.(OperationType)=zeros(nb_sites,1);
     57            DataOut.(FieldNameType)=zeros(nb_sites,1);
    5858            VarAttribute{1}.Role='scalar';
    5959        case {'curl','div','strain'}
    6060            check_der=1;
    61             DataOut.(OperationType)=zeros(nb_sites,1);
     61            DataOut.(FieldNameType)=zeros(nb_sites,1);
    6262            VarAttribute{1}.Role='scalar';
    6363    end
     
    7979    end
    8080    ListVar={};
    81     for ilist=1:length(Operation)
     81    for ilist=1:length(FieldName)
    8282        var_count=numel(ListVar);
    83         switch Operation{ilist}
     83        switch FieldName{ilist}
    8484            case 'vec(U,V)'
    8585                ListVar=[ListVar {'U', 'V'}];
  • trunk/src/check_files.m

    r570 r581  
    3232svn_info.status=[];
    3333list_fct={...
     34    'xmltree';...%function for editing xml files (toolbox outside uvmat)
    3435    'browse_data';...% function for scanning directories in a project/campaign
    3536    'browse_data.fig';...% GUI corresponding to dataview
     
    101102    'set_object.m';...%  edit a projection object
    102103    'set_object.fig';...% interface for set_object
     104    'set_subdomains';...% sort a set of points defined by scattered coordinates in subdomains, as needed for tps interpolation
    103105    'stra2num';...% transform letters (a, b, A, B,) or numerical strings ('1','2'..) to the corresponding numbers
    104106    'sub_field';...% combine the two input fields,
     
    106108    'struct2xml';... transform a matlab structure to a xml tree.
    107109    'tps_coeff';...% calculate the thin plate spline (tps) coefficients
     110    'tps_coeff_field';...% calculate the thin plate spline (tps) coefficients with subdomains for a field structure
    108111    'tps_eval';... %calculate the thin plate spline (tps) interpolation at a set of points
    109112    'tps_eval_dxy';...% calculate the derivatives of thin plate spline (tps) interpolation at a set of points (limited to the 2D case)
  • trunk/src/civ.m

    r576 r581  
    2424%TODO: search range
    2525
    26 % Last Modified by GUIDE v2.5 24-Jul-2012 13:14:00
     26% Last Modified by GUIDE v2.5 09-Mar-2013 22:50:23
    2727% Begin initialization code - DO NOT EDIT
    2828gui_Singleton = 1;
     
    37053705handle_txtbox=findobj(hchildren,'tag','txt_Mask');
    37063706if isequal(get(hObject,'Value'),0)
    3707     set(handles.num_SubdomainSize,'Visible','on')
     3707    set(handles.num_SubDomainSize,'Visible','on')
    37083708    set(handles.num_FieldSmooth,'Visible','on')
    37093709else
    3710     set(handles.num_SubdomainSize,'Visible','off')
     3710    set(handles.num_SubDomainSize,'Visible','off')
    37113711    set(handles.num_FieldSmooth,'Visible','off')
    37123712end
     
    37173717% %------------------------------------------------------------------------
    37183718% if isequal(get(handles.CheckStereo,'Value'),0)
    3719 %     set(handles.num_SubdomainSize,'Visible','on')
     3719%     set(handles.num_subdomainsize,'Visible','on')
    37203720%     set(handles.num_FieldSmooth,'Visible','on')
    37213721% else
    3722 %     set(handles.num_SubdomainSize,'Visible','off')
     3722%     set(handles.num_subdomainsize,'Visible','off')
    37233723%     set(handles.num_FieldSmooth,'Visible','off')
    37243724% end
  • trunk/src/civ_matlab.m

    r578 r581  
    165165   
    166166    Data.ListGlobalAttribute=[Data.ListGlobalAttribute {'Patch1_Rho','Patch1_Threshold','Patch1_SubDomain'}];
    167     Data.Patch1_Rho=Param.Patch1.FieldSmooth;
    168     Data.Patch1_Threshold=Param.Patch1.MaxDiff;
    169     Data.Patch1_SubDomain=Param.Patch1.SubdomainSize;
     167    Data.Patch1_FieldSmooth=Param.Patch1.FieldSmooth;
     168    Data.Patch1_MaxDiff=Param.Patch1.MaxDiff;
     169    Data.Patch1_SubDomainSize=Param.Patch1.SubDomainSize;
    170170    nbvar=length(Data.ListVarName);
    171171    Data.ListVarName=[Data.ListVarName {'Civ1_U_smooth','Civ1_V_smooth','Civ1_SubRange','Civ1_NbSites','Civ1_Coord_tps','Civ1_U_tps','Civ1_V_tps'}];
     
    185185    end
    186186    [Data.Civ1_SubRange,Data.Civ1_NbSites,Data.Civ1_Coord_tps,Data.Civ1_U_tps,Data.Civ1_V_tps,tild,Ures, Vres,tild,FFres]=...
    187         filter_tps([Data.Civ1_X(ind_good) Data.Civ1_Y(ind_good)],Data.Civ1_U(ind_good),Data.Civ1_V(ind_good),[],Data.Patch1_SubDomain,Data.Patch1_Rho,Data.Patch1_Threshold);
     187        filter_tps([Data.Civ1_X(ind_good) Data.Civ1_Y(ind_good)],Data.Civ1_U(ind_good),Data.Civ1_V(ind_good),[],Data.Patch1_SubDomainSize,Data.Patch1_FieldSmooth,Data.Patch1_MaxDiff);
    188188    Data.Civ1_U_smooth(ind_good)=Ures;
    189189    Data.Civ1_V_smooth(ind_good)=Vres;
     
    373373if isfield (Param,'Patch2')
    374374    Data.ListGlobalAttribute=[Data.ListGlobalAttribute {'Patch2_Rho','Patch2_Threshold','Patch2_SubDomain'}];
    375     Data.Patch2_Rho=Param.Patch2.FieldSmooth;
    376     Data.Patch2_Threshold=Param.Patch2.MaxDiff;
    377     Data.Patch2_SubDomain=Param.Patch2.SubdomainSize;
     375    Data.Patch2_FieldSmooth=Param.Patch2.FieldSmooth;
     376    Data.Patch2_MaxDiff=Param.Patch2.MaxDiff;
     377    Data.Patch2_SubDomainSize=Param.Patch2.SubdomainSize;
    378378    nbvar=length(Data.ListVarName);
    379379    Data.ListVarName=[Data.ListVarName {'Civ2_U_smooth','Civ2_V_smooth','Civ2_SubRange','Civ2_NbSites','Civ2_Coord_tps','Civ2_U_tps','Civ2_V_tps'}];
     
    394394    end
    395395    [Data.Civ2_SubRange,Data.Civ2_NbSites,Data.Civ2_Coord_tps,Data.Civ2_U_tps,Data.Civ2_V_tps,tild,Ures, Vres,tild,FFres]=...
    396         filter_tps([Data.Civ2_X(ind_good) Data.Civ2_Y(ind_good)],Data.Civ2_U(ind_good),Data.Civ2_V(ind_good),[],Data.Patch2_SubDomain,Data.Patch2_Rho,Data.Patch2_Threshold);
     396        filter_tps([Data.Civ2_X(ind_good) Data.Civ2_Y(ind_good)],Data.Civ2_U(ind_good),Data.Civ2_V(ind_good),[],Data.Patch2_SubDomainSize,Data.Patch2_FieldSmooth,Data.Patch2_MaxDiff);
    397397    Data.Civ2_U_smooth(ind_good)=Ures;
    398398    Data.Civ2_V_smooth(ind_good)=Vres;
  • trunk/src/filter_tps.m

    r494 r581  
    11%'filter_tps': find the thin plate spline coefficients for interpolation-smoothing
    22%------------------------------------------------------------------------
    3 % [SubRange,NbSites,Coord_tps,U_tps,V_tps,W_tps,U_smooth,V_smooth,W_smooth,FF] =filter_tps(Coord,U,V,W,SubDomain,Rho,Threshold)
     3% [SubRange,NbCentres,Coord_tps,U_tps,V_tps,W_tps,U_smooth,V_smooth,W_smooth,FF] =filter_tps(Coord,U,V,W,SubDomain,Rho,Threshold)
    44%
    55% OUTPUT:
    66% SubRange(NbCoord,NbSubdomain,2): range (min, max) of the coordiantes x and y respectively, for each subdomain
    7 % NbSites(NbSubdomain): number of source points for each subdomain
     7% NbCentres(NbSubdomain): number of source points for each subdomain
    88% FF: false flags
    99% U_smooth, V_smooth: filtered velocity components at the positions of the initial data
    10 % Coord_tps(NbSites,NbCoord,NbSubdomain): positions of the tps centres
     10% Coord_tps(NbCentres,NbCoord,NbSubdomain): positions of the tps centres
    1111% U_tps,V_tps: weight of the tps for each subdomain
    1212% to get the interpolated field values, use the function calc_field.m
     
    1919% Subdomain: estimated number of data points in each subdomain
    2020
    21 function [SubRange,NbSites,Coord_tps,U_tps,V_tps,W_tps,U_smooth,V_smooth,W_smooth,FF] =filter_tps(Coord,U,V,W,SubDomain,Rho,Threshold)
    22 %subdomain decomposition
     21function [SubRange,NbCentres,Coord_tps,U_tps,V_tps,W_tps,U_smooth,V_smooth,W_smooth,FF] =filter_tps(Coord,U,V,W,SubDomain,Rho,Threshold)
     22
     23%% adjust subdomain decomposition
    2324warning off
    24 nbvec=size(Coord,1);
    25 W_tps=[];%default
    26 W_smooth=[];
     25NbVec=size(Coord,1);
    2726NbCoord=size(Coord,2);
    28 NbSubDomain=nbvec/SubDomain;
    29 MinCoord=min(Coord,[],1);
    30 MaxCoord=max(Coord,[],1);
     27MinCoord=min(Coord,[],1);%lower coordinate bounds
     28MaxCoord=max(Coord,[],1);%upper coordinate bounds
    3129Range=MaxCoord-MinCoord;
    3230AspectRatio=Range(2)/Range(1);
     31NbSubDomain=NbVec/SubDomain;
    3332NbSubDomainX=max(floor(sqrt(NbSubDomain/AspectRatio)),1);
    3433NbSubDomainY=max(floor(sqrt(NbSubDomain*AspectRatio)),1);
     
    4140CentreY=reshape(CentreY,1,[]);% Y positions of subdomain centres
    4241CentreX=reshape(CentreX,1,[]);% X positions of subdomain centres
    43 rho=Siz(1)*Siz(2)*Rho/1000;%optimum rho increase as the area of the subdomain (division by 10^6 to reach good values with the default GUI input)
    44 U_tps_sub=zeros(nbvec,NbSubDomain);%default spline
    45 V_tps_sub=zeros(nbvec,NbSubDomain);%default spline
    46 Indices_tps=zeros(nbvec,NbSubDomain);%default indices
    47 U_smooth=zeros(nbvec,1);
    48 V_smooth=zeros(nbvec,1);
    49 nb_select=zeros(nbvec,1);
    50 FF=zeros(nbvec,1);
     42
     43%% smoothing parameter
     44rho=Siz(1)*Siz(2)*Rho/1000;%optimum rho increase as the area of the subdomain (division by 1000 to reach good values with the default GUI input)
     45
     46%% default output
     47SubRange=zeros(NbCoord,2,NbSubDomain);%initialise the positions of subdomains
     48NbCentres=zeros(NbSubDomain);%number of interpolated values per subdomain, =0 by default
     49Coord_tps=zeros(NbVec,NbCoord,NbSubDomain);% default positions of the tps source= initial positions of the good vectors sorted by subdomain
     50U_tps=zeros(NbVec,NbSubDomain);%default spline
     51V_tps=zeros(NbVec,NbSubDomain);%default spline
     52W_tps=[];%default (2 component case)
     53U_smooth=zeros(NbVec,1); % smoothed velocity U at the initial positions
     54V_smooth=zeros(NbVec,1);% smoothed velocity V at the initial positions
     55W_smooth=[];%default (2 component case)
     56FF=zeros(NbVec,1);
     57nb_select=zeros(NbVec,1);
    5158check_empty=zeros(1,NbSubDomain);
    52 SubRange=zeros(NbCoord,2,NbSubDomain);%initialise the positions of subdomains
    53 % SubRangy=zeros(NbSubDomain,2);
     59
     60%% calculate tps coeff in each subdomain
    5461for isub=1:NbSubDomain
    5562    SubRange(1,:,isub)=[CentreX(isub)-0.55*Siz(1) CentreX(isub)+0.55*Siz(1)];
     
    5764    ind_sel_previous=[];
    5865    ind_sel=0;
    59     while numel(ind_sel)>numel(ind_sel_previous) %increase the subdomain during four iterations at most
     66    %increase iteratively the subdomain if it contains less than SubDomainNbVec/4 source vectors
     67    while numel(ind_sel)>numel(ind_sel_previous)
    6068        ind_sel_previous=ind_sel;
    6169        ind_sel=find(Coord(:,1)>=SubRange(1,1,isub) & Coord(:,1)<=SubRange(1,2,isub) & Coord(:,2)>=SubRange(2,1,isub) & Coord(:,2)<=SubRange(2,2,isub));
    6270        % if no vector in the subdomain, skip the subdomain
    6371        if isempty(ind_sel)
    64             check_empty(isub)=1;   
     72            check_empty(isub)=1;
    6573            U_tps(1,isub)=0;%define U_tps and V_tps by default
    6674            V_tps(1,isub)=0;
     
    7078            SubRange(:,1,isub)=SubRange(:,1,isub)-Siz'/4;
    7179            SubRange(:,2,isub)=SubRange(:,2,isub)+Siz'/4;
    72         else         
     80        else
    7381            [U_smooth_sub,U_tps_sub]=tps_coeff(Coord(ind_sel,:),U(ind_sel),rho);
    7482            [V_smooth_sub,V_tps_sub]=tps_coeff(Coord(ind_sel,:),V(ind_sel),rho);
     
    7886            ind_ind_sel=1:numel(ind_sel);%default
    7987            if exist('Threshold','var')
    80             FF(ind_sel)=20*(NormDiff>Threshold);%put FF value to 20 to identify the criterium of elimmination
    81             ind_ind_sel=find(FF(ind_sel)==0); % select the indices of ind_sel corresponding to the remaining vectors
     88                FF(ind_sel)=20*(NormDiff>Threshold);%put FF value to 20 to identify the criterium of elimmination
     89                ind_ind_sel=find(FF(ind_sel)==0); % select the indices of ind_sel corresponding to the remaining vectors
    8290            end
    8391            % if no value exceeds threshold, the result is recorded
     
    8593                U_smooth(ind_sel)=U_smooth(ind_sel)+U_smooth_sub;
    8694                V_smooth(ind_sel)=V_smooth(ind_sel)+V_smooth_sub;
    87                 NbSites(isub)=numel(ind_sel);
    88                 Coord_tps(1:NbSites(isub),:,isub)=Coord(ind_sel,:);
    89                 U_tps(1:NbSites(isub)+3,isub)=U_tps_sub;
    90                 V_tps(1:NbSites(isub)+3,isub)=V_tps_sub;         
     95                NbCentres(isub)=numel(ind_sel);
     96                Coord_tps(1:NbCentres(isub),:,isub)=Coord(ind_sel,:);
     97                U_tps(1:NbCentres(isub)+3,isub)=U_tps_sub;
     98                V_tps(1:NbCentres(isub)+3,isub)=V_tps_sub;
    9199                nb_select(ind_sel)=nb_select(ind_sel)+1;
    92100                display('good')
    93101                break
    94             % if too few selected vectors, increase the subrange for next iteration
     102                % if too few selected vectors, increase the subrange for next iteration
    95103            elseif numel(ind_ind_sel)<SubDomain/4 && ~isequal( ind_sel,ind_sel_previous);
    96104                SubRange(:,1,isub)=SubRange(:,1,isub)-Siz'/4;
    97105                SubRange(:,2,isub)=SubRange(:,2,isub)+Siz'/4;
    98             % else interpolation-smoothing is done again with the selected vectors
     106                % else interpolation-smoothing is done again with the selected vectors
    99107            else
    100108                [U_smooth_sub,U_tps_sub]=tps_coeff(Coord(ind_sel(ind_ind_sel),:),U(ind_sel(ind_ind_sel)),rho);
    101109                [V_smooth_sub,V_tps_sub]=tps_coeff(Coord(ind_sel(ind_ind_sel),:),V(ind_sel(ind_ind_sel)),rho);
    102110                U_smooth(ind_sel(ind_ind_sel))=U_smooth(ind_sel(ind_ind_sel))+U_smooth_sub;
    103                 V_smooth(ind_sel(ind_ind_sel))=V_smooth(ind_sel(ind_ind_sel))+V_smooth_sub;   
    104                 NbSites(isub)=numel(ind_ind_sel);
    105                 Coord_tps(1:NbSites(isub),:,isub)=Coord(ind_sel(ind_ind_sel),:);
    106                 U_tps(1:NbSites(isub)+3,isub)=U_tps_sub;
    107                 V_tps(1:NbSites(isub)+3,isub)=V_tps_sub;
     111                V_smooth(ind_sel(ind_ind_sel))=V_smooth(ind_sel(ind_ind_sel))+V_smooth_sub;
     112                NbCentres(isub)=numel(ind_ind_sel);
     113                Coord_tps(1:NbCentres(isub),:,isub)=Coord(ind_sel(ind_ind_sel),:);
     114                U_tps(1:NbCentres(isub)+3,isub)=U_tps_sub;
     115                V_tps(1:NbCentres(isub)+3,isub)=V_tps_sub;
    108116                nb_select(ind_sel(ind_ind_sel))=nb_select(ind_sel(ind_ind_sel))+1;
    109117                display('good2')
     
    113121    end
    114122end
     123
     124%% remove empty subdomains
    115125ind_empty=find(check_empty);
    116 %remove empty subdomains
    117126if ~isempty(ind_empty)
    118127    SubRange(:,:,ind_empty)=[];
     
    121130    V_tps(:,ind_empty)=[];
    122131end
    123 nb_select(nb_select==0)=1;%ones(size(find(nb_select==0)));
    124 U_smooth=U_smooth./nb_select;
     132
     133%% final adjustments
     134nb_select(nb_select==0)=1;
     135U_smooth=U_smooth./nb_select;% take the average at the intersection of several subdomains
    125136V_smooth=V_smooth./nb_select;
    126137fill=zeros(NbCoord+1,NbCoord,size(SubRange,3)); %matrix of zeros to complement the matrix Data.Civ1_Coord_tps (conveninent for file storage)
  • trunk/src/find_field_cells.m

    r580 r581  
    1 %'find_field_cells': test field structure for input in proj_field and plot_field
    2 %    group the variables  into 'fields' with common dimensions
     1%'find_field_cells': analyse the field structure for input in uvmat functions, grouping the variables  into 'fields' with common coordinates
    32%------------------------------------------------------------------------
    43% function  [CellInfo,NbDim,errormsg]=find_field_cells(Data)
     
    98%     .CoordIndex: array of the indices of the variables representing the coordinates (in the order z,y,x)
    109%     .CoordSize: array of the nbre of values for each  coordinate in a grid, nbre of points in the unstructured case
    11 %     .NbSite_tps:
     10%     .NbCentres_tps:
    1211%     .SubRange_tps
    1312%     .VarIndex: arrays of the variable indices in the field cell
     
    1918%              _vector_x,_y,_z: indices of variables giving the vector components x, y, z
    2019%              _warnflag: index of warnflag   
    21 %      .FieldRequest= 'interp_lin', 'interp_tps' indicate whether lin interpolation  or derivatives (tps) is needed to calculate the requested field
     20%      .ProjModeRequest= 'interp_lin', 'interp_tps' indicate whether lin interpolation  or derivatives (tps) is needed to calculate the requested field
    2221%      .FieldName = operation to be performed to finalise the field cell after projection
    2322%      .SubCheck=0 /1 indicate that the field must be substracted (second  entry in uvmat)
     
    6160
    6261function [CellInfo,NbDim,errormsg]=find_field_cells(Data)
    63 
     62CellInfo={};
    6463NbDim=0;
    6564errormsg='';
    6665if ~isfield(Data,'ListVarName'), errormsg='the list of variables .ListVarName is missing';return;end
    6766if ~isfield(Data,'VarDimName'), errormsg='the list of dimensions .VarDimName is missing';return;end
    68 nbvar=numel(Data.ListVarName);%number of field variables
     67nbvar=numel(Data.ListVarName);%number of variables in the field structure
    6968if ~isequal(numel(Data.VarDimName),nbvar), errormsg='.ListVarName and .VarDimName have unequal length';return;end
    7069% check the existence of variable data
     
    8685%   'ancillary','image','color','discrete','scalar','coord_tps'};% rmq vector_x_tps and vector_y_tps to be replaced by vector_x and vector_y
    8786Role=num2cell(blanks(nbvar));%initialize a cell array of nbvar blanks
    88 FieldRequest=regexprep(Role,' ',''); % fieldRequest set to '' by default
     87ProjModeRequest=regexprep(Role,' ',''); % fieldRequest set to '' by default
    8988FieldName=cell(size(Role)); % fieldRequest set to {} by default
    9089CheckSub=zeros(size(Role));% =1 for fields to substract
     
    9594            Role{ivar}=Data.VarAttribute{ivar}.Role;
    9695        end
    97         if isfield(Data.VarAttribute{ivar},'FieldRequest')
    98             FieldRequest{ivar}=Data.VarAttribute{ivar}.FieldRequest;
     96        if isfield(Data.VarAttribute{ivar},'ProjModeRequest')
     97            ProjModeRequest{ivar}=Data.VarAttribute{ivar}.ProjModeRequest;
    9998        end
    10099        if isfield(Data.VarAttribute{ivar},'FieldName')
     
    162161check_coord_tps= strcmp('coord_tps',Role(~check_select));
    163162ivar_tps=ivar_remain(check_coord_tps);% variable indices corresponding to tps coordinates
     163
     164% loop on the tps coordinate sets
    164165for icell_tps=1:numel(ivar_tps)
     166    check_cell=zeros(1,nbvar);% =1 for the variables selected in the current cell
     167    check_cell(ivar_tps(icell_tps))=1;% mark the coordiante variable as selected
    165168    DimCell=Data.VarDimName{ivar_tps(icell_tps)};% dimension names for the current tps coordinate variable
    166169    icell=numel(CellInfo)+icell_tps; % new field cell index
    167170    CellInfo{icell}.CoordIndex=ivar_tps(icell_tps);% index of the  tps coordinate variable
    168     %CellInfo{icell}.VarIndex_subrange_tps=[];
    169     %CellInfo{icell}.VarIndex_nbsites_tps=[];
    170171    if numel(DimCell)==3
    171172        VarDimName=Data.VarDimName(~check_select);
    172173        for ivardim=1:numel(VarDimName)
    173174            if strcmp(VarDimName{ivardim},DimCell{3})
    174                 CellInfo{icell}.NbSite_tps= ivar_remain(ivardim);
    175                 check_cell(ivar_remain(ivardim))=1;% nbre of sites for each tps subdomain
     175                CellInfo{icell}.NbCentres_tps= ivar_remain(ivardim);% nbre of sites for each tps subdomain
     176                check_cell(ivar_remain(ivardim))=1;% mark the variable as selected
    176177            elseif strcmp(VarDimName{ivardim}{1},DimCell{2}) && strcmp(VarDimName{ivardim}{3},DimCell{3})
    177                 CellInfo{icell}.SubRange_tps=ivar_remain(ivardim);
    178                 check_cell(ivar_remain(ivardim))=1;% subrange definiton for tps
    179             elseif strcmp(VarDimName{ivardim}{1},DimCell{1}) && strcmp(VarDimName{ivardim}{2},DimCell{3})
    180                 check_cell(ivar_remain(ivardim))=1;% variable
     178                CellInfo{icell}.SubRange_tps=ivar_remain(ivardim);% subrange definiton for tps
     179                check_cell(ivar_remain(ivardim))=1;% mark the variable as selected
     180            elseif strcmp(VarDimName{ivardim}{1},DimCell{1}) && strcmp(VarDimName{ivardim}{2},DimCell{3})% variable
     181                check_cell(ivar_remain(ivardim))=1;% mark the variable as selected
    181182            end
    182183        end
     
    222223    end
    223224end
    224 ListCoordIndex=ListCoordIndex(check_coord_select);% list of coordinate variable indices
     225ListCoordIndex=ListCoordIndex(check_keep);% list of coordinate variable indices
    225226ListCoordName=ListCoordName(check_keep);% list of coordinate variable names
    226227ListDimName=ListDimName(check_keep);% list of coordinate dimension names
     
    315316            CellInfo{icell}.(['VarIndex_' Role{ivar}])= ivar;
    316317        end
    317         if ~isempty(FieldRequest{ivar})
    318             CellInfo{icell}.FieldRequest=FieldRequest{ivar};
     318        if ~isempty(ProjModeRequest{ivar})
     319            CellInfo{icell}.ProjModeRequest=ProjModeRequest{ivar};
    319320        end
    320321        if ~isempty(FieldName{ivar})
  • trunk/src/get_field.m

    r538 r581  
    1 %'get_field': display variables and attributes from a Netcdf file, and RUN selected fields
     1%'get_field': display variables and attributes from a Netcdf file, and OK selected fields
    22%------------------------------------------------------------------------
    33%function varargout = get_field(varargin)
     
    2222function varargout = get_field(varargin)
    2323
    24 % Last Modified by GUIDE v2.5 26-Jul-2012 09:11:23
     24% Last Modified by GUIDE v2.5 10-Mar-2013 21:19:52
    2525
    2626% Begin initialization code - DO NOT EDIT
    27 gui_Singleton = 0;
     27gui_Singleton = 1;
    2828gui_State = struct('gui_Name',       mfilename, ...
    2929                   'gui_Singleton',  gui_Singleton, ...
     
    4545%------------------------------------------------------------------------
    4646% --- Executes just before get_field is made visible.
    47 function get_field_OpeningFcn(hObject, eventdata, handles,filename,multiple)
     47function get_field_OpeningFcn(hObject, eventdata, handles,filename,ParamIn)
    4848%------------------------------------------------------------------------
    4949global nb_builtin % nbre of functions to include by default in the menu of  functions called by RUN
    5050
    51 
    52 
    5351%% Choose default command line output for get_field
    54 handles.output = hObject;
     52handles.output = 'Cancel';
    5553
    5654%% Update handles structure
     
    5856set(hObject,'WindowButtonDownFcn',{'mouse_down'}) % allows mouse action with right button (zoom for uicontrol display)
    5957
    60 %% prepare the list of RUN fcts and set their paths
    61 % functions included by default in 'get_field.m
    62 % menu_str={'PLOT';'FFT';'filter_band'};
    63 % nb_builtin=numel(menu_str);
    64 % path_uvmat=fileparts(which('uvmat'));%path of the function 'uvmat'
    65 % addpath(fullfile(path_uvmat,'get_field'))
    66 % testexist=zeros(size(menu_str'));%default
    67 % for ilist=1:length(menu_str)
    68 %     if exist(menu_str{ilist},'file')
    69 %         fct_handle{ilist,1}=str2func(menu_str{ilist});
    70 %         testexist(ilist)=1;
    71 %     else
    72 %         fct_handle{ilist,1}=[];
    73 %         testexist(ilist)=0;
    74 %     end
    75 % end
    76 % rmpath(fullfile(path_uvmat,'get_field'))
    77 % dir_perso=prefdir;
    78 
    79 % look for functions previously used (names and paths saved in the personal file uvmat_perso.mat):
    80 % profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
    81 % if exist(profil_perso,'file')
    82 %       h=load (profil_perso);
    83 %      if isfield(h,'get_field_fct') && iscell(h.get_field_fct)
    84 %          for ilist=1:length(h.get_field_fct)
    85 %             [path,file]=fileparts(h.get_field_fct{ilist});
    86 %             addpath(path)       
    87 %             if exist(file,'file')
    88 %                 h_func=str2func(file);
    89 %                 testexist=[testexist 1];
    90 %              else
    91 %                 h_func=[];
    92 %                 testexist=[testexist 0];
    93 %              end
    94 %              fct_handle=[fct_handle; {h_func}]; %concatene the list of paths
    95 %              rmpath(path)
    96 %              menu_str=[menu_str; {file}];
    97 %          end
    98 %      end
    99 % end
    100 
    101 % menu_str=menu_str(testexist==1);%=menu_str(testexist~=0)
    102 % fct_handle=fct_handle(testexist==1);
    103 % menu_str=[menu_str;{'more...'}];
    104 % set(handles.ACTION,'String',menu_str)
    105 % set(handles.ACTION,'UserData',fct_handle)% store the list of path in UserData of ACTION
    106 % set(handles.path_action,'String',fullfile(path_uvmat,'get_field'))
    107 % set(handles.ACTION,'Value',1)% PLOT option selected
    108 
    109 %% settings for 'slave' mode, called by uvamt, or 'master' mode
     58%% settings for 'slave' mode, called by uvmat, or 'master' mode
    11059if exist('filename','var') && ischar(filename) %transfer input file name in slave mode
    11160    set(handles.inputfile,'String',filename)% prefill the input file name
    112     Field=nc2struct(filename,[]);% reads the  field structure, without variables
     61    Field=nc2struct(filename,[]);% reads the  field structure, without the variables
    11362    if isfield(Field,'Txt')
    114         msgbox_uvmat('ERROR',Field.Txt)
     63        msgbox_uvmat('ERROR',['get_field/nc2struct/' Field.Txt])
    11564    else
    11665        set(handles.get_field,'UserData',Field);
    117         Field_input(handles,Field);
     66        if ~exist('ParamIn','var')
     67            ParamIn=[];
     68        end
     69        Field_input(handles,Field,ParamIn);
    11870    end
    11971else  %master mode
     
    12173end
    12274
    123 %% load the list of previously browsed files for the upper bar menu Open
    124 % dir_perso=prefdir;
    125 % profil_perso=fullfile(dir_perso,'uvmat_perso.mat');%
    126 % if exist(profil_perso,'file')
    127 %     h=load (profil_perso);
    128 %     if isfield(h,'MenuFile_1')
    129 %         set(handles.MenuFile_1,'Label',h.MenuFile_1);
    130 %     end
    131 %     if isfield(h,'MenuFile_1')
    132 %         set(handles.MenuFile_2,'Label',h.MenuFile_2);
    133 %     end
    134 %     if isfield(h,'MenuFile_1')
    135 %         set(handles.MenuFile_3,'Label',h.MenuFile_3);
    136 %     end
    137 %     if isfield(h,'MenuFile_1')
    138 %         set(handles.MenuFile_4,'Label',h.MenuFile_4);
    139 %     end
    140 %     if isfield(h,'MenuFile_1')
    141 %         set(handles.MenuFile_5,'Label',h.MenuFile_5);
    142 %     end
    143 % end
    144 
    14575%% put the GUI on the lower right of the sceen
     76set(hObject,'Unit','pixel')
    14677pos_view_field=get(hObject,'Position');
    14778ScreenSize=get(0,'ScreenSize');
     
    15081set(hObject,'Position',pos_view_field)
    15182
    152 %% remove already opened get_field GUI with name get_field
    153 if ~(exist('multiple','var') && isequal(multiple,1)) %set single occurrence
    154     hget_field=findobj(allchild(0),'Name','get_field'); %hget_field(1)= new GUI
    155     if length(hget_field)>1
    156         delete(hget_field(2))
    157     end
    158 else
    159     set(hObject,'name','get_field_1')
    160 end
    161 
     83% if ~(exist('multiple','var') && isequal(multiple,1)) %set single occurrence
     84%     hget_field=findobj(allchild(0),'Name','get_field'); %hget_field(1)= new GUI
     85%     if length(hget_field)>1
     86%         delete(hget_field(2))
     87%     end
     88% else
     89%     set(hObject,'name','get_field_1')
     90% end
     91set(handles.get_field,'WindowStyle','modal')% Make the GUI modal
     92drawnow
     93 uiwait(handles.get_field);
    16294
    16395%------------------------------------------------------------------------
     
    16698%------------------------------------------------------------------------
    16799varargout{1} = handles.output;
     100delete(handles.get_field)
    168101
    169102%------------------------------------------------------------------------
     
    186119%------------------------------------------------------------------------
    187120% --- update the display when a new field is introduced.
    188 function Field_input(handles,Field)
     121function Field_input(handles,Field,ParamInput)
    189122%------------------------------------------------------------------------
    190123if isfield(Field,'ListDimName')&&~isempty(Field.ListDimName)
     
    203136set(handles.variables,'String',[{'*'} Txt])
    204137variables_Callback(handles.variables,[], handles)
     138
     139if exist('ParamInput','var')
     140    fill_GUI(ParamInput,handles);
     141    return
     142else
    205143set(handles.abscissa,'String',[{''} Txt ])
    206144set(handles.ordinate,'String',Txt)
     
    209147set(handles.vector_z,'String',[{''} Txt ])
    210148set(handles.vec_color,'String',[{''} Txt ])
    211 set(handles.coord_x_scalar,'String',[{''} Txt ])
    212 set(handles.coord_y_scalar,'String',[{''} Txt ])
    213 set(handles.coord_x_vectors,'String',[{''} Txt ])
    214 set(handles.coord_y_vectors,'String',[{''} Txt ])
    215 set(handles.coord_z_scalar,'String',[{''} Txt ])
    216 set(handles.coord_z_vectors,'String',[{''} Txt ])
     149% set(handles.XVarName,'String',[{''} Txt ])
     150% set(handles.ZVarName,'String',[{''} Txt ])
     151% set(handles.coord_x_vectors,'String',[{''} Txt ])
     152% set(handles.coord_y_vectors,'String',[{''} Txt ])
     153% set(handles.YVarName,'String',[{''} Txt ])
     154% set(handles.TimeVarName,'String',[{''} Txt ])
    217155set(handles.scalar,'Value',1)
    218156
    219157set(handles.scalar,'String', Txt )
    220158[CellInfo,NbDim,errormsg]=find_field_cells(Field);
    221 % [CellVarIndex,NbDim,CoordType,VarRole,errormsg]=find_field_cells(Field);
    222159if ~isempty(errormsg) 
    223160    msgbox_uvmat('ERROR',['get_field / Field_input / find_field_cells: ' errormsg])
    224161    return
    225162end 
    226 % for icell=1:numel(CellInfo)
    227 %     NbDim(icell)=max(NbDim(icell),numel(CellInfo{icell}.VarIndex));
    228 % end
    229163[maxdim,imax]=max(NbDim);
    230    
     164
     165%% set time mode
     166if maxdim>=4
     167    set(handles.SwitchVarIndexTime,'Value',4)
     168else
     169    time_index=[];
     170    if isfield(Field,'ListGlobalAttribute')
     171    time_index=find(~cellfun('isempty',regexp(Field.ListGlobalAttribute,'Time')));% index of the attributes containing the string 'Time'
     172    end
     173    if isempty(time_index)
     174        set(handles.SwitchVarIndexTime,'Value',1)
     175    else
     176        set(handles.SwitchVarIndexTime,'Value',2)
     177    end
     178end
     179SwitchVarIndexTime_Callback([],[], handles)
     180
    231181if maxdim>=3
    232182    set(handles.vector_z,'Visible','on')
    233183    set(handles.vector_z,'String',[{''} Txt ])
    234     set(handles.coord_z_vectors,'Visible','on')
    235     set(handles.coord_z_vectors,'String',[{''} Txt ])
    236     set(handles.coord_z_scalar,'Visible','on')
    237     set(handles.coord_z_scalar,'String',[{''} Txt ])
     184        set(handles.ZVarName,'Visible','on')
     185    set(handles.SwitchVarIndexZ,'Visible','on')
     186    set(handles.Z_title,'Visible','on')
     187%     set(handles.TimeVarName,'Visible','on')
     188%     set(handles.TimeVarName,'String',[{''} Txt ])
     189%     set(handles.YVarName,'Visible','on')
     190%     set(handles.YVarName,'String',[{''} Txt ])
    238191else
    239192    set(handles.vector_z,'Visible','off')
    240     set(handles.coord_z_vectors,'Visible','off')
    241     set(handles.coord_z_scalar,'Visible','off')
     193    set(handles.ZVarName,'Visible','off')
     194    set(handles.SwitchVarIndexZ,'Visible','off')
     195    set(handles.Z_title,'Visible','off')
    242196end
    243197if maxdim>=2
     
    248202        set(handles.vector_x,'Value',CellInfo{imax}.VarIndex_vector_x(1))
    249203        set(handles.vector_y,'Value',CellInfo{imax}.VarIndex_vector_y(1))
    250         if strcmp(CellInfo{imax}.CoordType,'scattered')
    251             set(handles.coord_x_vectors,'Value',CellInfo{imax}.CoordIndex(end))
    252             set(handles.coord_y_vectors,'Value',CellInfo{imax}.CoordIndex(end-1))
    253         elseif strcmp(CellInfo{imax}.CoordType,'grid')
    254             set(handles.coord_x_vectors,'Value',CellInfo{imax}.CoordIndex(end)+1)
    255             set(handles.coord_y_vectors,'Value',CellInfo{imax}.CoordIndex(end-1)+1)
    256         end
     204%         if strcmp(CellInfo{imax}.CoordType,'scattered')
     205%             set(handles.coord_x_vectors,'Value',CellInfo{imax}.CoordIndex(end))
     206%             set(handles.coord_y_vectors,'Value',CellInfo{imax}.CoordIndex(end-1))
     207%         elseif strcmp(CellInfo{imax}.CoordType,'grid')
     208%             set(handles.coord_x_vectors,'Value',CellInfo{imax}.CoordIndex(end)+1)
     209%             set(handles.coord_y_vectors,'Value',CellInfo{imax}.CoordIndex(end-1)+1)
     210%         end
    257211    else
    258212        set(handles.CheckScalar,'Value',1)
    259213        set(handles.CheckVector,'Value',0)
    260         if isfield(CellInfo{imax},'VarIndex_scalar')
    261             set(handles.scalar,'Value',CellInfo{imax}.VarIndex_scalar(1))
    262                 set(handles.coord_x_scalar,'Value',CellInfo{imax}.CoordIndex(end)+1)
    263                 set(handles.coord_y_scalar,'Value',CellInfo{imax}.CoordIndex(end-1)+1)
    264             if numel(CellInfo{imax}.CoordIndex)==3
    265                 set(handles.coord_z_scalar,'Value',CellInfo{imax}.CoordIndex(1)+1)
    266             end
    267         end
    268     end
    269     CheckPlot1D_Callback(handles.CheckPlot1D, [], handles)
    270     CheckScalar_Callback(handles.CheckScalar, [], handles)
    271     CheckVector_Callback(handles.CheckVector, [], handles)
    272 end
     214%         if isfield(CellInfo{imax},'VarIndex_scalar')
     215%             set(handles.scalar,'Value',CellInfo{imax}.VarIndex_scalar(1))
     216%                 set(handles.XVarName,'Value',CellInfo{imax}.CoordIndex(end)+1)
     217%                 set(handles.ZVarName,'Value',CellInfo{imax}.CoordIndex(end-1)+1)
     218%             if numel(CellInfo{imax}.CoordIndex)==3
     219%                 set(handles.YVarName,'Value',CellInfo{imax}.CoordIndex(1)+1)
     220%             end
     221%         end
     222    end
     223else
     224    set(handles.CheckPlot1D,'Value',1)
     225    set(handles.CheckScalar,'Value',0)
     226    set(handles.CheckVector,'Value',0)
     227end
     228end
     229CheckPlot1D_Callback(handles.CheckPlot1D, [], handles)
     230CheckScalar_Callback(handles.CheckScalar, [], handles)
     231CheckVector_Callback(handles.CheckVector, [], handles)
    273232
    274233%------------------------------------------------------------------------
     
    324283%     set(handles.variables,'Value',xindex+1)%outline  in the list of variables
    325284%     variables_Callback(hObject, eventdata, handles)  %display properties of the TimeVariable (dim, attributes)
    326 %     if  ~test_2D &  ~test_scalar% look for possible varaibles to RUN in ordinate   
     285%     if  ~test_2D &  ~test_scalar% look for possible varaibles to OK in ordinate   
    327286%         index=Field.VarDimIndex{xindex};%dimension indices of the TimeVariable selected for abscissa
    328287%         VarIndex=[];
     
    330289%             index_i=Field.VarDimIndex{ilist};
    331290%             if ~isempty(index_i)
    332 %                 if isequal(index_i(1),index(1))%if the first dimension of the TimeVariable coincide with the selected one, RUN is possible
     291%                 if isequal(index_i(1),index(1))%if the first dimension of the TimeVariable coincide with the selected one, OK is possible
    333292%                     VarIndex=[VarIndex ilist];
    334293%                 end
     
    378337
    379338string_coord=[{''};string(test_coord==1)];
    380 val=get(handles.coord_x_scalar,'Value');
     339val=get(handles.XVarName,'Value');
    381340if val>numel(string_coord)
    382     set(handles.coord_x_scalar,'Value',1)
    383 end
    384 set(handles.coord_x_scalar,'String',string_coord);
    385 val=get(handles.coord_y_scalar,'Value');
     341    set(handles.XVarName,'Value',1)
     342end
     343set(handles.XVarName,'String',string_coord);
     344val=get(handles.ZVarName,'Value');
    386345if val>numel(string_coord)
    387     set(handles.coord_y_scalar,'Value',1)
    388 end
    389 set(handles.coord_y_scalar,'String',string_coord);
    390 val=get(handles.coord_y_scalar,'Value');
     346    set(handles.ZVarName,'Value',1)
     347end
     348set(handles.ZVarName,'String',string_coord);
     349val=get(handles.ZVarName,'Value');
    391350if val>numel(string_coord)
    392     set(handles.coord_y_scalar,'Value',1)
    393 end
    394 set(handles.coord_z_scalar,'String',string_coord);
    395 
    396 
    397 %------------------------------------------------------------------------
    398 % --- Executes on selection change in coord_x_scalar.
    399 function coord_x_scalar_Callback(hObject, eventdata, handles)
    400 %------------------------------------------------------------------------
    401 index=get(handles.coord_x_scalar,'Value');
    402 string=get(handles.coord_x_scalar,'String');
     351    set(handles.ZVarName,'Value',1)
     352end
     353set(handles.YVarName,'String',string_coord);
     354
     355
     356%------------------------------------------------------------------------
     357% --- Executes on selection change in XVarName.
     358function XVarName_Callback(hObject, eventdata, handles)
     359%------------------------------------------------------------------------
     360index=get(handles.XVarName,'Value');
     361string=get(handles.XVarName,'String');
    403362VarName=string{index};
    404363update_field(hObject, eventdata, handles,VarName)
    405364
    406365%------------------------------------------------------------------------
    407 % --- Executes on selection change in coord_y_scalar.
    408 function coord_y_scalar_Callback(hObject, eventdata, handles)
    409 %------------------------------------------------------------------------
    410 index=get(handles.coord_y_scalar,'Value');
    411 string=get(handles.coord_y_scalar,'String');
     366% --- Executes on selection change in ZVarName.
     367function ZVarName_Callback(hObject, eventdata, handles)
     368%------------------------------------------------------------------------
     369index=get(handles.ZVarName,'Value');
     370string=get(handles.ZVarName,'String');
    412371VarName=string{index};
    413372update_field(hObject, eventdata, handles,VarName)
    414373
    415374%------------------------------------------------------------------------
    416 % --- Executes on selection change in coord_z_scalar.
    417 function coord_z_scalar_Callback(hObject, eventdata, handles)
    418 %------------------------------------------------------------------------
    419 index=get(handles.coord_z_scalar,'Value');
    420 string=get(handles.coord_z_scalar,'String');
     375% --- Executes on selection change in YVarName.
     376function YVarName_Callback(hObject, eventdata, handles)
     377%------------------------------------------------------------------------
     378index=get(handles.YVarName,'Value');
     379string=get(handles.YVarName,'String');
    421380VarName=string{index};
    422381update_field(hObject, eventdata, handles,VarName)
     
    480439end
    481440set(handles.coord_y_vectors,'String',string_coord);
    482 val=get(handles.coord_z_vectors,'Value');
     441val=get(handles.TimeVarName,'Value');
    483442if val>numel(string_coord)
    484     set(handles.coord_z_vectors,'Value',1)
    485 end
    486 set(handles.coord_z_vectors,'String',string_coord);
     443    set(handles.TimeVarName,'Value',1)
     444end
     445set(handles.TimeVarName,'String',string_coord);
    487446
    488447update_field(hObject, eventdata, handles,VarName)
     
    525484
    526485%------------------------------------------------------------------------
    527 % --- Executes on selection change in coord_z_scalar.
    528 function coord_z_vectors_Callback(hObject, eventdata, handles)
    529 %------------------------------------------------------------------------
    530 index=get(handles.coord_z_vectors,'Value');
    531 string=get(handles.coord_z_vectors,'String');
     486% --- Executes on selection change in YVarName.
     487function TimeVarName_Callback(hObject, eventdata, handles)
     488%------------------------------------------------------------------------
     489index=get(handles.TimeVarName,'Value');
     490string=get(handles.TimeVarName,'String');
    532491VarName=string{index};
    533492update_field(hObject, eventdata, handles,VarName)
     
    689648VarIndex.y=name2index(list_var,Field.ListVarName);
    690649if isequal(VarIndex.A,VarIndex.y)
    691     set(handles.coord_y_scalar,'Value',1)
     650    set(handles.ZVarName,'Value',1)
    692651elseif isequal(VarIndex.u,VarIndex.y)||isequal(VarIndex.v,VarIndex.y)||isequal(VarIndex.w,VarIndex.y)
    693652   set(handles.coord_y_vectors,'Value',1)%ordinate cannot be the same as scalar or vector components
     
    811770
    812771%---------------------------------------------------------
    813 % --- Executes on button press in RUN.
    814 
    815 function RUN_Callback(hObject, eventdata, handles)
     772% --- Executes on button press in OK.
     773
     774function OK_Callback(hObject, eventdata, handles)
    816775%---------------------------------------------------------
     776
     777handles.output=read_GUI(handles.get_field);
     778guidata(hObject, handles);% Update handles structure
     779uiresume(handles.get_field);
     780drawnow
     781return
     782
     783%%%% SKIPPED %%%%
    817784hfield=[];
    818785huvmat=findobj(allchild(0),'tag','uvmat');
     
    911878if strcmp(list_fig{val},'uvmat')
    912879    set(handles.inputfile,'Enable','off')% desactivate the input file edit box   
    913     set(handles.RUN,'Visible','off')% RUN button not visible (passive mode, get_field used to define the field for uvamt)
     880    set(handles.OK,'Visible','off')% RUN button not visible (passive mode, get_field used to define the field for uvamt)
    914881    set(handles.MenuOpen,'Visible','off')
    915882    set(handles.MenuExport,'Visible','off')
     
    933900% %------------------------------------------------
    934901% % --- Executes on button press in Plot_histo.
    935 % %RUN global histograms
     902% %OK global histograms
    936903% %-------------------------------------------------
    937904% function RUN_histo_Callback(hObject, eventdata, handles)
    938 % % hObject    handle to RUN (see GCBO)
     905% % hObject    handle to OK (see GCBO)
    939906% % eventdata  reserved - to be defined in a future version of MATLAB
    940907% % handles    structure with handles and user data (see GUIDATA)
     
    16721639    set(handles.TimeIndexValue,'Visible','off')
    16731640end
    1674 
    1675 %------------------------------------------------------------------------
    1676 % --- Executes on selection change in TimeDimensionMenu.
    1677 function TimeDimensionMenu_Callback(hObject, eventdata, handles)
    1678 %------------------------------------------------------------------------
    1679 index=get(handles.TimeDimensionMenu,'Value');
    1680 DimList=get(handles.TimeDimensionMenu,'String');
    1681 DimName=DimList{index};
    1682 Field=get(handles.get_field,'UserData');
    1683 DimIndex=find(strcmp(DimName,Field.ListDimName),1);
    1684 ref_index=round(Field.DimValue(DimIndex)/2);   
    1685 set(handles.TimeIndexValue,'String',num2str(ref_index))
    1686 scalar_Callback(hObject, eventdata, handles)
    1687 vector_x_Callback(hObject, eventdata, handles)% update menus of coordinates (remove time)
    1688  % look for a corresponding time variable and value
    1689  time_test=zeros(size(Field.VarDimName));
    1690  for ilist=1:numel(Field.VarDimName)
    1691      if isequal(Field.VarDimName{ilist},{DimName})
    1692          time_test(ilist)=1;
    1693      end
    1694  end
    1695  ListVariable=Field.ListVarName(time_test==1);
    1696  set(handles.TimeVariableMenu,'Value',1)
    1697  if isempty(ListVariable)     
    1698      set(handles.TimeVariableMenu,'String',{''})
    1699      set(handles.TimeVarValue,'String','')
    1700  else
    1701     set(handles.TimeVariableMenu,'String',ListVariable)
    1702     TimeVarName=ListVariable{1};
    1703     VarIndex=find(strcmp(TimeVarName,Field.ListVarName),1);%index in the list of variables
    1704     inputfile=get(handles.inputfile,'String');% read the input file
    1705     SubField=nc2struct(inputfile,{TimeVarName});
    1706     eval(['TimeValue=SubField.' TimeVarName '(ref_index);'])
    1707     set(handles.TimeVarValue,'Visible','on')
    1708     set(handles.TimeVariableMenu,'Visible','on')
    1709     set(handles.TimeVarValue,'String',num2str(TimeValue))
    1710  end
    1711 
    1712 
     1641%
     1642% %------------------------------------------------------------------------
     1643% % --- Executes on selection change in TimeDimensionMenu.
     1644% function TimeDimensionMenu_Callback(hObject, eventdata, handles)
     1645% %------------------------------------------------------------------------
     1646% index=get(handles.TimeDimensionMenu,'Value');
     1647% DimList=get(handles.TimeDimensionMenu,'String');
     1648% DimName=DimList{index};
     1649% Field=get(handles.get_field,'UserData');
     1650% DimIndex=find(strcmp(DimName,Field.ListDimName),1);
     1651% ref_index=round(Field.DimValue(DimIndex)/2);   
     1652% set(handles.TimeIndexValue,'String',num2str(ref_index))
     1653% scalar_Callback(hObject, eventdata, handles)
     1654% vector_x_Callback(hObject, eventdata, handles)% update menus of coordinates (remove time)
     1655%  % look for a corresponding time variable and value
     1656%  time_test=zeros(size(Field.VarDimName));
     1657%  for ilist=1:numel(Field.VarDimName)
     1658%      if isequal(Field.VarDimName{ilist},{DimName})
     1659%          time_test(ilist)=1;
     1660%      end
     1661%  end
     1662%  ListVariable=Field.ListVarName(time_test==1);
     1663%  set(handles.TimeVariableMenu,'Value',1)
     1664%  if isempty(ListVariable)     
     1665%      set(handles.TimeVariableMenu,'String',{''})
     1666%      set(handles.TimeVarValue,'String','')
     1667%  else
     1668%     set(handles.TimeVariableMenu,'String',ListVariable)
     1669%     TimeVarName=ListVariable{1};
     1670%     VarIndex=find(strcmp(TimeVarName,Field.ListVarName),1);%index in the list of variables
     1671%     inputfile=get(handles.inputfile,'String');% read the input file
     1672%     SubField=nc2struct(inputfile,{TimeVarName});
     1673%     eval(['TimeValue=SubField.' TimeVarName '(ref_index);'])
     1674%     set(handles.TimeVarValue,'Visible','on')
     1675%     set(handles.TimeVariableMenu,'Visible','on')
     1676%     set(handles.TimeVarValue,'String',num2str(TimeValue))
     1677%  end
     1678%
     1679%
     1680% % % -----------------------------------------------------------------------
     1681% % % --- Executes on button press in TimeVariable.
     1682% % function TimeVariable_Callback(hObject, eventdata, handles)
     1683% % % -----------------------------------------------------------------------
     1684% % val=get(handles.TimeVariable,'Value');
     1685% % if val
     1686% %     Field=get(handles.get_field,'UserData');
     1687% %     time_test=zeros(size(Field.VarDimName));
     1688% %     for ilist=1:numel(Field.VarDimName)
     1689% %         if isequal(numel(Field.VarDimName{ilist}),1)%select variables with a single dimension
     1690% %             time_test(ilist)=1;
     1691% %         end
     1692% %     end
     1693% %     ind_test=find(time_test);
     1694% %     if isempty(time_test)
     1695% %         set(handles.TimeVariable,'Value',0)
     1696% %         set(handles.TimeVariableMenu,'Visible','off')
     1697% %         set(handles.TimeVarValue,'Visible','off')
     1698% %     else
     1699% %         set(handles.TimeVariableMenu,'Visible','on')
     1700% %         set(handles.TimeVarValue,'Visible','on')
     1701% %         if get(handles.TimeVariableMenu,'Value')>numel(ind_test)
     1702% %             set(handles.TimeVariableMenu,'Value',1)
     1703% %         end
     1704% %         set(handles.TimeVariableMenu,'String',Field.ListVarName(ind_test))
     1705% %         TimeVariableMenu_Callback(hObject, eventdata, handles)
     1706% %         set(handles.TimeDimension,'Value',0) %deseselect alternative option sfor time
     1707% %         set(handles.TimeAttribute,'Value',0)
     1708% %         TimeAttribute_Callback(hObject, eventdata, handles)
     1709% %     end
     1710% % else
     1711% %     set(handles.TimeVariableMenu,'Visible','off')
     1712% %     set(handles.TimeVarValue,'Visible','off')
     1713% % end
     1714%
    17131715% % -----------------------------------------------------------------------
    1714 % % --- Executes on button press in TimeVariable.
    1715 % function TimeVariable_Callback(hObject, eventdata, handles)
     1716% % --- Executes on selection change in TimeVariableMenu.
     1717% function TimeVariableMenu_Callback(hObject, eventdata, handles)
    17161718% % -----------------------------------------------------------------------
    1717 % val=get(handles.TimeVariable,'Value');
    1718 % if val
    1719 %     Field=get(handles.get_field,'UserData');
    1720 %     time_test=zeros(size(Field.VarDimName));
    1721 %     for ilist=1:numel(Field.VarDimName)
    1722 %         if isequal(numel(Field.VarDimName{ilist}),1)%select variables with a single dimension
    1723 %             time_test(ilist)=1;
    1724 %         end
    1725 %     end
    1726 %     ind_test=find(time_test);
    1727 %     if isempty(time_test)
    1728 %         set(handles.TimeVariable,'Value',0)
    1729 %         set(handles.TimeVariableMenu,'Visible','off')
    1730 %         set(handles.TimeVarValue,'Visible','off')
    1731 %     else
    1732 %         set(handles.TimeVariableMenu,'Visible','on')
    1733 %         set(handles.TimeVarValue,'Visible','on')
    1734 %         if get(handles.TimeVariableMenu,'Value')>numel(ind_test)
    1735 %             set(handles.TimeVariableMenu,'Value',1)
    1736 %         end
    1737 %         set(handles.TimeVariableMenu,'String',Field.ListVarName(ind_test))
    1738 %         TimeVariableMenu_Callback(hObject, eventdata, handles)
    1739 %         set(handles.TimeDimension,'Value',0) %deseselect alternative option sfor time
    1740 %         set(handles.TimeAttribute,'Value',0)
    1741 %         TimeAttribute_Callback(hObject, eventdata, handles)
    1742 %     end
    1743 % else
    1744 %     set(handles.TimeVariableMenu,'Visible','off')
    1745 %     set(handles.TimeVarValue,'Visible','off')
     1719% ListVar=get(handles.TimeVariableMenu,'String');
     1720% index=get(handles.TimeVariableMenu,'Value');
     1721% TimeVariable=ListVar{index};% name of the selected variable
     1722% if isempty(TimeVariable)% case of blank selection
     1723%     return
    17461724% end
    1747 
    1748 % -----------------------------------------------------------------------
    1749 % --- Executes on selection change in TimeVariableMenu.
    1750 function TimeVariableMenu_Callback(hObject, eventdata, handles)
    1751 % -----------------------------------------------------------------------
    1752 ListVar=get(handles.TimeVariableMenu,'String');
    1753 index=get(handles.TimeVariableMenu,'Value');
    1754 TimeVariable=ListVar{index};% name of the selected variable
    1755 if isempty(TimeVariable)% case of blank selection
    1756     return
    1757 end
    1758 Field=get(handles.get_field,'UserData'); %index of
    1759 VarIndex=find(strcmp(TimeVariable,Field.ListVarName),1);%index in the list of variables
    1760 DimName=Field.VarDimName{VarIndex}; % dimension corresponding to the variable
    1761 set(handles.TimeDimensionMenu,'Value',1)
    1762 set(handles.TimeDimensionMenu,'String',DimName)
    1763 inputfile=get(handles.inputfile,'String');% read the input file
    1764 SubField=nc2struct(inputfile,{TimeVariable});
    1765 eval(['TimeDimension=numel(SubField.' TimeVariable ');'])
    1766 ref_index=round(TimeDimension/2);
    1767 eval(['TimeValue=SubField.' TimeVariable '(ref_index);'])
    1768 set(handles.TimeIndexValue,'String',num2str(ref_index))
    1769 set(handles.TimeVarValue,'String',num2str(TimeValue))
    1770 
    1771 
    1772 function TimeValue_Callback(hObject, eventdata, handles)
    1773 %TO suppress
    1774 
    1775 % -----------------------------------------------------------------------
    1776 function TimeIndexValue_Callback(hObject, eventdata, handles)
    1777 % -----------------------------------------------------------------------
    1778 TimeIndex=str2double(get(handles.TimeIndexValue,'String'));
    1779 TimeVarName=Field.ListVarName{time_index};
    1780 set(handles.TimeVariable,'Value',1)
    1781 set(handles.TimeName,'String',TimeVarName)
    1782 fileinput=get(handles.inputfile,'String');
    1783 SubField=nc2struct(fileinput,{TimeVarName});
    1784 eval(['TimeValue=SubField.' TimeVarName '(ref_index);']);
    1785 set(handles.TimeValue,'Visible','on')
    1786 set(handles.TimeValue,'String',num2str(TimeValue))
    1787 
    1788 % -----------------------------------------------------------------------
    1789 function SelectFigure_Callback(hObject, eventdata, handles)
    1790 % -----------------------------------------------------------------------
    1791 val=get(handles.SelectFigure,'Value');
    1792 if val
    1793     set(handles.list_fig,'Visible','on')
    1794     %% look at the existing figures in the work space
    1795     browse_fig(handles.list_fig)
    1796 else
    1797    set(handles.list_fig,'Visible','off')
    1798 end
    1799 
    1800 
    1801 function TimeVarValue_Callback(hObject, eventdata, handles)
    1802 
     1725% Field=get(handles.get_field,'UserData'); %index of
     1726% VarIndex=find(strcmp(TimeVariable,Field.ListVarName),1);%index in the list of variables
     1727% DimName=Field.VarDimName{VarIndex}; % dimension corresponding to the variable
     1728% set(handles.TimeDimensionMenu,'Value',1)
     1729% set(handles.TimeDimensionMenu,'String',DimName)
     1730% inputfile=get(handles.inputfile,'String');% read the input file
     1731% SubField=nc2struct(inputfile,{TimeVariable});
     1732% eval(['TimeDimension=numel(SubField.' TimeVariable ');'])
     1733% ref_index=round(TimeDimension/2);
     1734% eval(['TimeValue=SubField.' TimeVariable '(ref_index);'])
     1735% set(handles.TimeIndexValue,'String',num2str(ref_index))
     1736% set(handles.TimeVarValue,'String',num2str(TimeValue))
    18031737
    18041738
    18051739% --- Executes on button press in check_rgb.
    18061740function check_rgb_Callback(hObject, eventdata, handles)
     1741
     1742
     1743% --- Executes when user attempts to close get_field.
     1744function get_field_CloseRequestFcn(hObject, eventdata, handles)
     1745if isequal(get(handles.get_field, 'waitstatus'), 'waiting')
     1746    % The GUI is still in UIWAIT, us UIRESUME
     1747    uiresume(handles.get_field);
     1748else
     1749    % The GUI is no longer waiting, just close it
     1750    delete(handles.get_field);
     1751end
     1752
     1753
     1754
     1755
     1756
     1757% --- Executes on selection change in listbox30.
     1758function listbox30_Callback(hObject, eventdata, handles)
     1759% hObject    handle to listbox30 (see GCBO)
     1760% eventdata  reserved - to be defined in a future version of MATLAB
     1761% handles    structure with handles and user data (see GUIDATA)
     1762
     1763% Hints: contents = cellstr(get(hObject,'String')) returns listbox30 contents as cell array
     1764%        contents{get(hObject,'Value')} returns selected item from listbox30
     1765
     1766
     1767% --- Executes on selection change in SwitchVarIndexX.
     1768function SwitchVarIndexX_Callback(hObject, eventdata, handles)
     1769% hObject    handle to SwitchVarIndexX (see GCBO)
     1770% eventdata  reserved - to be defined in a future version of MATLAB
     1771% handles    structure with handles and user data (see GUIDATA)
     1772
     1773% Hints: contents = cellstr(get(hObject,'String')) returns SwitchVarIndexX contents as cell array
     1774%        contents{get(hObject,'Value')} returns selected item from SwitchVarIndexX
     1775
     1776
     1777% --- Executes on selection change in SwitchVarIndexTime.
     1778function SwitchVarIndexTime_Callback(hObject, eventdata, handles)
     1779menu=get(handles.SwitchVarIndexTime,'String');
     1780option=menu{get(handles.SwitchVarIndexTime,'Value')};
     1781switch option
     1782    case 'file index'
     1783        set(handles.TimeVarName, 'Visible','off')
     1784    case 'attribute'
     1785        set(handles.TimeVarName, 'Visible','on')
     1786        time_index=[];
     1787        ListAttributes=get(handles.attributes,'String');
     1788        if ~isempty(ListAttributes)
     1789            time_index=find(~cellfun('isempty',regexp(ListAttributes,'Time')));% index of the attributes containing the string 'Time'
     1790        end
     1791        if ~isempty(time_index)
     1792            set(handles.TimeVarName,'Value',time_index(1))
     1793        else
     1794            set(handles.TimeVarName,'Value',1)
     1795        end
     1796        set(handles.TimeVarName, 'String',ListAttributes)
     1797    case 'variable'
     1798        ListDim=get(handles.dimensions,'String');
     1799        Field=get(handles.get_field,'UserData');
     1800        for idim=1:numel(ListDim)
     1801            var_count=[];
     1802            for ilist=1:numel(Field.VarDimName)
     1803                DimName=Field.VarDimName{ilist};
     1804                if strcmp(DimName,ListDim{idim})||strcmp(DimName,{ListDim{idim}}) %if the variable has a single dim ( 1D array)
     1805                    var_count=[var_count ilist];
     1806                end
     1807            end
     1808            if numel(var_count)==1
     1809                TimeVarName=[TimeVarName;Field.ListVarName{var_count}];
     1810            end
     1811        end
     1812        set(handles.TimeVarName, 'Visible','on')
     1813        List=get(handles.TimeVarName,'String');
     1814        option=List{get(handles.TimeVarName,'Value')};
     1815        ind=find(strcmp(option,get(handles.dimensions,'String')));
     1816        if isempty(ind)
     1817            set(handles.TimeVarName, 'Value',1);
     1818        else
     1819            set(handles.TimeVarName, 'Value',ind);
     1820        end
     1821        set(handles.TimeVarName, 'String',TimeVarName)
     1822    case 'dim index'
     1823        set(handles.TimeVarName, 'Visible','on')
     1824        List=get(handles.TimeVarName,'String');
     1825        option=List{get(handles.TimeVarName,'Value')};
     1826        ind=find(strcmp(option,get(handles.dimensions,'String')));
     1827        if isempty(ind)
     1828            set(handles.TimeVarName, 'Value',1);
     1829        else
     1830            set(handles.TimeVarName, 'Value',ind);
     1831        end
     1832        set(handles.TimeVarName, 'String',get(handles.dimensions,'String'))
     1833end
     1834
     1835   
  • trunk/src/msgbox_uvmat.m

    r507 r581  
    77%INPUT:
    88% title: string indicating the type of message box:
    9 %          title= 'INPUT_TXT','CONFIMATION' ,'ERROR', 'WARNING', 'INPUT_Y-N', default = 'INPUT_TXT' (the title is displayed in the upper bar of the fig).
     9%          title= 'INPUT_TXT','CONFIMATION' ,'ERROR', 'WARNING', 'INPUT_Y-N','INPUT_MENU' default = 'INPUT_TXT' (the title is displayed in the upper bar of the fig).
    1010%          if title='INPUT_TXT', input data is asked in an edit box
    1111%          if title='CONFIMATION'', 'ERROR', 'WARNING', the figure remains  opened until a button 'OK' is pressed
     
    3737% End initialization code - DO NOT EDIT
    3838
     39%------------------------------------------------------------------------
    3940% --- Executes just before msgbox_uvmat is made visible.
    4041function msgbox_uvmat_OpeningFcn(hObject, eventdata, handles,title,display_str,default_answer,Position)
     42%------------------------------------------------------------------------
    4143% This function has no output args, see OutputFcn.
    4244
     
    8991            testinputstring=1;
    9092            testCancel=1; %no cancel button
     93        case 'INPUT_MENU'
     94            testinputstring=2;
     95            testCancel=1; %no cancel button
    9196        otherwise
    9297          %  testinputstring=1;
     
    98103    set(handles.text1, 'String', display_str);
    99104end
    100 % if testinputstring
    101 %     set(handles.edit_box, 'Visible', 'on');
    102 % else
    103 %     set(handles.text1, 'Position', [0.15 0.3 0.85 0.7]);
    104 % end
    105 if testinputstring
    106     % set(handles.figure1,'Position',[40,80,20*length(default_answer),50])
     105
     106if testinputstring==1
    107107    set(handles.edit_box, 'Visible', 'on');
    108108    if ~exist('default_answer','var');
     
    111111    set(handles.edit_box, 'String', default_answer);
    112112    if exist('Position','var')
    113     if iscell(default_answer)
    114         widthstring=max(max(cellfun('length',default_answer)),length(display_str));
    115         heightstring=size(default_answer,1);%nbre of expected lines
    116         set(handles.edit_box,'Max',2);
    117     else
    118         widthstring=max(length(default_answer),length(display_str));
    119         heightstring=1;
    120     end
    121     widthstring=max(widthstring,length(title)+20);
    122     boxsize=[10*widthstring 20*heightstring];%size of the display edit box
    123     set(handles.edit_box,'Units','pixels')
    124     set(handles.edit_box,'FontUnits','pixels')
    125     set(handles.edit_box,'FontSize',12) 
    126    set(handles.edit_box,'Position',[5,34,boxsize(1),boxsize(2)])
    127    FigPos(3)=10+boxsize(1);
    128    FigPos(4)=56+boxsize(2);
    129    FigPos(2)=Position(2)-FigPos(4)-25;
    130    set(handles.figure1,'Position',FigPos)
    131     end
    132 %     set(handles.figure1,'Position',[40,40,20*length(default_answer),50])
     113        if iscell(default_answer)
     114            widthstring=max(max(cellfun('length',default_answer)),length(display_str));
     115            heightstring=size(default_answer,1);%nbre of expected lines
     116            set(handles.edit_box,'Max',2);
     117        else
     118            widthstring=max(length(default_answer),length(display_str));
     119            heightstring=1;
     120        end
     121        widthstring=max(widthstring,length(title)+20);
     122        boxsize=[10*widthstring 20*heightstring];%size of the display edit box
     123        set(handles.edit_box,'Units','pixels')
     124        set(handles.edit_box,'FontUnits','pixels')
     125        set(handles.edit_box,'FontSize',12)
     126        set(handles.edit_box,'Position',[5,34,boxsize(1),boxsize(2)])
     127        FigPos(3)=10+boxsize(1);
     128        FigPos(4)=56+boxsize(2);
     129        FigPos(2)=Position(2)-FigPos(4)-25;
     130        set(handles.figure1,'Position',FigPos)
     131    end
     132elseif testinputstring==2
     133    set(handles.edit_box,'style','listbox')
     134    set(handles.edit_box, 'Visible', 'on');
     135    set(handles.edit_box,'String', default_answer)
    133136else
    134137    set(handles.text1, 'Position', [0.15 0.3 0.85 0.7]);
     
    189192uiwait(handles.figure1);
    190193
    191 
     194%------------------------------------------------------------------------
    192195% --- Outputs from this function are returned to the command line.
    193196function varargout = msgbox_uvmat_OutputFcn(hObject, eventdata, handles)
     197%------------------------------------------------------------------------
    194198
    195199% Get default command line output from handles structure
     
    200204        varargout{1}='No';
    201205    else
     206        if strcmp(get(handles.edit_box,'Style'),'listbox')
     207             varargout{1}=get(handles.edit_box,'Value');
     208        else
    202209        varargout{1}=get(handles.edit_box,'String');
    203         if isempty(varargout{1}) || isequal(varargout{1},'')
     210        end
     211        if isempty(varargout{1})
    204212            varargout{1}='Yes';
    205213        end
     
    208216end
    209217 delete(handles.figure1);
    210  
     218
     219%------------------------------------------------------------------------
    211220% --- Executes on button press in OK.
    212221function OK_Callback(hObject, eventdata, handles)
     222%------------------------------------------------------------------------
    213223handles.output = get(hObject,'String');
    214224guidata(hObject, handles);% Update handles structure
    215225uiresume(handles.figure1);
    216226
     227%------------------------------------------------------------------------
    217228% --- Executes on button press in No.
    218229function No_Callback(hObject, eventdata, handles)
     230%------------------------------------------------------------------------
    219231handles.output='No';
    220232guidata(hObject, handles);
    221233uiresume(handles.figure1);
    222234
     235%------------------------------------------------------------------------
    223236% --- Executes on button press in Cancel.
    224237function Cancel_Callback(hObject, eventdata, handles)
     238%------------------------------------------------------------------------
    225239handles.output = get(hObject,'String');
    226240%handles.output = 'Cancel'
     
    230244uiresume(handles.figure1);
    231245
    232 
     246%------------------------------------------------------------------------
    233247% --- Executes when user attempts to close figure1.
    234248function figure1_CloseRequestFcn(hObject, eventdata, handles)
     249%------------------------------------------------------------------------
    235250if isequal(get(handles.figure1, 'waitstatus'), 'waiting')
    236251    % The GUI is still in UIWAIT, us UIRESUME
     
    241256end
    242257
     258%------------------------------------------------------------------------
    243259% --- Executes on key press over figure1 with no controls selected.
    244260function figure1_KeyPressFcn(hObject, eventdata, handles)
     261%------------------------------------------------------------------------
    245262% Check for "enter" or "escape"
    246263if isequal(get(hObject,'CurrentKey'),'escape')
  • trunk/src/plot_field.m

    r569 r581  
    249249function errormsg=plot_text(FieldData,CellInfo,htext)
    250250%-------------------------------------------------------------------
    251 errormsg=[];
     251errormsg='';
    252252txt_cell={};
    253253Data={};
     
    10451045   
    10461046    %decimate by a factor 2 in vector mesh(4 in nbre of vectors)
     1047    check_decimate=0;
    10471048    if isfield(PlotParam.Vectors,'CheckDecimate4') && PlotParam.Vectors.CheckDecimate4
     1049        check_decimate=1;
    10481050        diffy=diff(vec_Y); %difference dy=vec_Y(i+1)-vec_Y(i)
    10491051        dy_thresh=max(abs(diffy))/2;
     
    10551057        nb_sel=length(ind_sel);
    10561058        ind_sel=ind_sel(1:2:nb_sel);% take half the points on a line
     1059    elseif isfield(PlotParam.Vectors,'CheckDecimate16') && PlotParam.Vectors.CheckDecimate16
     1060        check_decimate=1;
     1061        diffy=diff(vec_Y); %difference dy=vec_Y(i+1)-vec_Y(i)
     1062        dy_thresh=max(abs(diffy))/2;
     1063        ind_jump=find(abs(diffy) > dy_thresh); %indices with diff(vec_Y)> max/2, detect change of line
     1064        ind_sel=1:ind_jump(1);%select the first line
     1065        for i=2:4:length(ind_jump)-1
     1066            ind_sel=[ind_sel (ind_jump(i)+1:ind_jump(i+1))];% select the odd lines
     1067        end
     1068        nb_sel=length(ind_sel);
     1069        ind_sel=ind_sel(1:4:nb_sel);% take half the points on a line
     1070    end
     1071    if check_decimate
    10571072        vec_X=vec_X(ind_sel);
    10581073        vec_Y=vec_Y(ind_sel);
  • trunk/src/proj_field.m

    r576 r581  
    142142        return
    143143    end
    144 elseif  ~isequal(ObjectData.ProjMode,'interp')
     144elseif  ~isequal(ObjectData.ProjMode,'interp_lin')
    145145    errormsg=(['ProjMode option ' ObjectData.ProjMode ' not available in proj_field']);
    146146        return
     
    223223                    Var=FieldData.(VarName)(indsel);
    224224                    ProjData.(VarName)(ipoint,1)=mean(Var);
    225                     if isequal(ObjectData.ProjMode,'interp')
     225                    if isequal(ObjectData.ProjMode,'interp_lin')
    226226                         ProjData.(VarName)(ipoint,1)=griddata_uvmat(coord_x(indsel),coord_y(indsel),Var,Xpoint(1),Xpoint(2));
    227227                    end
     
    524524theta=angle(dlinx+1i*dliny);%angle of each segment
    525525theta(siz_line(1))=theta(siz_line(1)-1);
    526 % determine a rectangles at +-width from the line (only used for the ProjMode='projection or 'filter')
     526% determine a rectangles at +-width from the line (only used for the ProjMode='projection or 'interp_tps')
    527527xsup=zeros(1,siz_line(1)); xinf=zeros(1,siz_line(1)); ysup=zeros(1,siz_line(1)); yinf=zeros(1,siz_line(1));
    528 if isequal(ProjMode,'projection') || isequal(ProjMode,'filter')
     528if isequal(ProjMode,'projection') || isequal(ProjMode,'interp_tps')
    529529    xsup(1)=ObjectData.Coord(1,1)-width*sin(theta(1));
    530530    xinf(1)=ObjectData.Coord(1,1)+width*sin(theta(1));
     
    580580    % check needed object properties for unstructured positions (position given by the variables with role coord_x, coord_y
    581581    if strcmp(CellInfo{icell}.CoordType,'scattered')
    582         if  ~isequal(ProjMode,'interp')
     582        if  ~isequal(ProjMode,'interp_lin')
    583583            if width==0
    584584                errormsg='range of the projection object is missing';
    585585                return     
    586586            else
    587                 lambda=2/(width*width); %smoothing factor used for filter: weight exp(-2) at distance width from the line
     587                lambda=2/(width*width); %smoothing factor used for interp_tps: weight exp(-2) at distance width from the line
    588588            end
    589589        end
     
    621621                flagsel=ones(size(coord_x));
    622622            end
    623             if isequal(ProjMode,'projection') | isequal(ProjMode,'filter')
     623            if isequal(ProjMode,'projection') || isequal(ProjMode,'interp_tps')
    624624                flagsel=flagsel & ((coord_y -yinf(ip))*(xinf(ip+1)-xinf(ip))>(coord_x-xinf(ip))*(yinf(ip+1)-yinf(ip))) ...
    625625                & ((coord_y -ysup(ip))*(xsup(ip+1)-xsup(ip))<(coord_x-xsup(ip))*(ysup(ip+1)-ysup(ip))) ...
     
    649649                     end
    650650                end
    651             elseif isequal(ProjMode,'interp') %linear interpolation:
     651            elseif isequal(ProjMode,'interp_lin') %linear interpolation:
    652652                npoint=floor(linelength/DX)+1;% nbre of points in the profile (interval DX)
    653653                Xproj=linelength/(2*npoint):linelength/npoint:linelength-linelength/(2*npoint);
     
    659659                     end
    660660                end
    661             elseif isequal(ProjMode,'filter') %filtering
     661            elseif isequal(ProjMode,'interp_tps') %filtering
    662662                npoint=floor(linelength/DX)+1;% nbre of points in the profile (interval DX)
    663663                Xproj=linelength/(2*npoint):linelength/npoint:linelength-linelength/(2*npoint);
     
    983983for icell=1:numel(CellInfo)% TODO: recalculate coordinates here to get the bounds in the rotated coordinates
    984984    ProjMode{icell}=ObjectData.ProjMode;
    985     if isfield(CellInfo{icell},'FieldRequest')
    986         switch CellInfo{icell}.FieldRequest
     985    if isfield(CellInfo{icell},'ProjModeRequest')
     986        switch CellInfo{icell}.ProjModeRequest
    987987            case 'interp_lin'
    988                 ProjMode{icell}='interp';
     988                ProjMode{icell}='interp_lin';
    989989            case 'interp_tps'
    990                 ProjMode{icell}='filter';
    991         end
    992     end
    993     if strcmp(ProjMode{icell},'interp')||strcmp(ProjMode{icell},'filter')
     990                ProjMode{icell}='interp_tps';
     991        end
     992    end
     993    if strcmp(ProjMode{icell},'interp_lin')||strcmp(ProjMode{icell},'interp_tps')
    994994        check_grid=1;
    995995    end
     
    10431043        %% case of input fields with unstructured coordinates
    10441044        case 'scattered'
    1045             if strcmp(ProjMode{icell},'filter')
    1046                 continue %skip for filter (needs tps field cell)
     1045            if strcmp(ProjMode{icell},'interp_tps')
     1046                continue %skip for interp_tps (needs tps field cell)
    10471047            end
    10481048            coord_x=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(end)});% initial x coordinates
     
    11481148                        end
    11491149                    end
    1150                 case 'interp'%interpolate data on a regular grid
     1150                case 'interp_lin'%interpolate data on a regular grid
    11511151                    coord_x_proj=XMin:DX:XMax;
    11521152                    coord_y_proj=YMin:DY:YMax;
     
    12051205            end
    12061206
    1207             %% case of tps interpolation (applies only in filter mode and for spatial derivatives)
     1207            %% case of tps interpolation (applies only in interp_tps mode and for spatial derivatives)
    12081208        case 'tps'
    1209             if strcmp(ProjMode{icell},'filter')
     1209            if strcmp(ProjMode{icell},'interp_tps')
    12101210                Coord=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex});
    1211                 NbSites=FieldData.(FieldData.ListVarName{CellInfo{icell}.NbSite_tps});
     1211                NbCentres=FieldData.(FieldData.ListVarName{CellInfo{icell}.NbCentres_tps});
    12121212                SubRange=FieldData.(FieldData.ListVarName{CellInfo{icell}.SubRange_tps});
    12131213                if isfield(CellInfo{icell},'VarIndex_vector_x_tps')&&isfield(CellInfo{icell},'VarIndex_vector_y_tps')
     
    12211221                XI=XI+ObjectData.Coord(1,1);
    12221222                YI=YI+ObjectData.Coord(1,2);
    1223                 [DataOut,VarAttribute,errormsg]=calc_field_tps(Coord,NbSites,SubRange,FieldVar,CellInfo{icell}.FieldName,cat(3,XI,YI));   
     1223                [DataOut,VarAttribute,errormsg]=calc_field_tps(Coord,NbCentres,SubRange,FieldVar,CellInfo{icell}.FieldName,cat(3,XI,YI));   
    12241224                ListFieldProj=(fieldnames(DataOut))';
    12251225                VarDimName=cell(size(ListFieldProj));
     
    14611461                    YIMA=reshape(round(YIMA),1,npX*npY);
    14621462                    flagin=XIMA>=1 & XIMA<=DimValue(2) & YIMA >=1 & YIMA<=DimValue(1);%flagin=1 inside the original image
    1463                     if isequal(ProjMode{icell},'filter')
    1464                         npx_filter=ceil(abs(DX/DAX));
    1465                         npy_filter=ceil(abs(DY/DAY));
    1466                         Mfilter=ones(npy_filter,npx_filter)/(npx_filter*npy_filter);
    1467                         test_filter=1;
     1463                    if isequal(ProjMode{icell},'interp_tps')
     1464                        npx_interp_tps=ceil(abs(DX/DAX));
     1465                        npy_interp_tps=ceil(abs(DY/DAY));
     1466                        Minterp_tps=ones(npy_interp_tps,npx_interp_tps)/(npx_interp_tps*npy_interp_tps);
     1467                        test_interp_tps=1;
    14681468                    else
    1469                         test_filter=0;
     1469                        test_interp_tps=0;
    14701470                    end
    14711471                    eval(['ProjData.' AYName '=[coord_y_proj(1) coord_y_proj(end)];']) %record the new (projected ) y coordinates
     
    14761476                            eval(['ProjData.' VarName '=interp2(Coord{2},Coord{1},FieldData.' VarName ',Coord_x,Coord_y'');']) %TO TEST
    14771477                        end
    1478                         %filter the field (image) if option 'filter' is used
    1479 %                         if test_filter
    1480 %                             Aclass=class(FieldData.A);
    1481 %                             eval(['ProjData.' VarName '=filter2(Mfilter,FieldData.' VarName ',''valid'');'])
    1482 %                             if ~isequal(Aclass,'double')
    1483 %                                 eval(['ProjData.' VarName '=' Aclass '(FieldData.' VarName ');'])%revert to integer values
    1484 %                             end
    1485 %                         end
    14861478                        eval(['vec_A=reshape(FieldData.' VarName ',[],nbcolor);'])%put the original image in line
    14871479                        %ind_in=find(flagin);
     
    15251517                else
    15261518                    errormsg='projection of structured coordinates on oblique plane not yet implemented';
    1527                     %TODO: use interp3
     1519                    %TODO: use interp_lin3
    15281520                    return
    15291521                end
     
    18011793                end
    18021794            end 
    1803         elseif isequal(ObjectData.ProjMode,'interp')||isequal(ObjectData.ProjMode,'filter')%interpolate data on a regular grid
     1795        elseif isequal(ObjectData.ProjMode,'interp_lin')||isequal(ObjectData.ProjMode,'interp_tps')%interpolate data on a regular grid
    18041796            coord_x_proj=XMin:DX:XMax;
    18051797            coord_y_proj=YMin:DY:YMax;
     
    20742066                YIMA=reshape(round(YIMA),1,npX*npY);
    20752067                flagin=XIMA>=1 & XIMA<=DimValue(2) & YIMA >=1 & YIMA<=DimValue(1);%flagin=1 inside the original image
    2076                 if isequal(ObjectData.ProjMode,'filter')
    2077                     npx_filter=ceil(abs(DX/DAX));
    2078                     npy_filter=ceil(abs(DY/DAY));
    2079                     Mfilter=ones(npy_filter,npx_filter)/(npx_filter*npy_filter);
    2080                     test_filter=1;
     2068                if isequal(ObjectData.ProjMode,'interp_tps')
     2069                    npx_interp_tps=ceil(abs(DX/DAX));
     2070                    npy_interp_tps=ceil(abs(DY/DAY));
     2071                    Minterp_tps=ones(npy_interp_tps,npx_interp_tps)/(npx_interp_tps*npy_interp_tps);
     2072                    test_interp_tps=1;
    20812073                else
    2082                     test_filter=0;
     2074                    test_interp_tps=0;
    20832075                end
    20842076                eval(['ProjData.' AYName '=[coord_y_proj(1) coord_y_proj(end)];']) %record the new (projected ) y coordinates
     
    20892081                          eval(['ProjData.' VarName '=interp2(Coord{2},Coord{1},FieldData.' VarName ',Coord_x,Coord_y'');']) %TO TEST
    20902082                    end
    2091                     %filter the field (image) if option 'filter' is used
    2092                     if test_filter 
     2083                    %filter the field (image) if option 'interp_tps' is used
     2084                    if test_interp_tps 
    20932085                         Aclass=class(FieldData.A);
    2094                          ProjData.(VarName)=filter2(Mfilter,FieldData.(VarName),'valid');
     2086                         ProjData.(VarName)=interp_tps2(Minterp_tps,FieldData.(VarName),'valid');
    20952087                         if ~isequal(Aclass,'double')
    20962088                             ProjData.(VarName)=Aclass(FieldData.(VarName));%revert to integer values
  • trunk/src/read_civdata.m

    r580 r581  
    6262errormsg='';
    6363if ischar(FieldNames), FieldNames={FieldNames}; end;
    64 FieldRequest='';
     64ProjModeRequest='';
    6565for ilist=1:length(FieldNames)
    6666    if ~isempty(FieldNames{ilist})
    6767        switch FieldNames{ilist}
    6868            case{'U','V','norm(U,V)'}
    69                 FieldRequest='interp_lin';
     69                ProjModeRequest='interp_lin';
    7070            case {'curl(U,V)','div(U,V)','strain(U,V)'}
    71                 FieldRequest='interp_tps';
     71                ProjModeRequest='interp_tps';
    7272        end
    7373    end
     
    7676%% reading data
    7777Data=nc2struct(filename,'ListGlobalAttribute','CivStage');
    78 [varlist,role,VelTypeOut]=varcivx_generator(FieldRequest,VelType,Data.CivStage);
     78[varlist,role,VelTypeOut]=varcivx_generator(ProjModeRequest,VelType,Data.CivStage);
    7979if isempty(varlist)
    8080    erromsg=['error in read_civdata: unknow velocity type ' VelType];
     
    109109Field.ListGlobalAttribute=[Field.ListGlobalAttribute {'Dt','Time'}];
    110110ivar_U_tps=[];
     111ivar_V_tps=[];
    111112var_ind=find(vardetect);
    112113for ivar=1:numel(var_ind)
    113114    Field.VarAttribute{ivar}.Role=role{var_ind(ivar)};
    114     Field.VarAttribute{ivar}.FieldRequest=FieldRequest;
    115115    if strcmp(role{var_ind(ivar)},'vector_x')
    116116        Field.VarAttribute{ivar}.FieldName=FieldNames;
     117        Field.VarAttribute{ivar}.ProjModeRequest=ProjModeRequest;
    117118        ivar_U=ivar;
    118119    end
    119120    if strcmp(role{var_ind(ivar)},'vector_x_tps')
    120121        Field.VarAttribute{ivar}.FieldName=FieldNames;
     122        Field.VarAttribute{ivar}.ProjModeRequest=ProjModeRequest;
    121123        ivar_U_tps=ivar;
    122124    end
    123 %     Field.VarAttribute{ivar}.Unit=units{var_ind(ivar)};
     125    if strcmp(role{var_ind(ivar)},'vector_y')
     126        Field.VarAttribute{ivar}.FieldName=FieldNames;
     127        Field.VarAttribute{ivar}.ProjModeRequest=ProjModeRequest;
     128        ivar_V=ivar;
     129    end
     130    if strcmp(role{var_ind(ivar)},'vector_y_tps')
     131        Field.VarAttribute{ivar}.FieldName=FieldNames;
     132        Field.VarAttribute{ivar}.ProjModeRequest=ProjModeRequest;
     133        ivar_V_tps=ivar;
     134    end
    124135    Field.VarAttribute{ivar}.Mesh=0.1;%typical mesh for histograms O.1 pixel
    125136end
     
    127138    Field.VarAttribute{ivar_U}.VarIndex_tps=ivar_U_tps;
    128139end
    129 
     140if ~isempty(ivar_V_tps)
     141    Field.VarAttribute{ivar_V}.VarIndex_tps=ivar_V_tps;
     142end
     143
     144%% update list of global attributes
    130145Field.ListGlobalAttribute=[Field.ListGlobalAttribute {'NbCoord','NbDim','TimeUnit','CoordUnit'}];
    131 % %% update list of global attributes
    132146Field.NbCoord=2;
    133147Field.NbDim=2;
     
    146160%            if vel_type=[] or'*', a  priority choice is done, civ2 considered better than civ1 )
    147161
    148 function [var,role,vel_type_out,errormsg]=varcivx_generator(FieldRequest,vel_type,CivStage)
     162function [var,role,vel_type_out,errormsg]=varcivx_generator(ProjModeRequest,vel_type,CivStage)
    149163
    150164%% default input values
     
    154168
    155169%% select the priority order for automatic vel_type selection
    156 if strcmp(vel_type,'civ2') && strcmp(FieldRequest,'derivatives')
     170if strcmp(vel_type,'civ2') && strcmp(ProjModeRequest,'derivatives')
    157171    vel_type='filter2';
    158 elseif strcmp(vel_type,'civ1') && strcmp(FieldRequest,'derivatives')
     172elseif strcmp(vel_type,'civ1') && strcmp(ProjModeRequest,'derivatives')
    159173    vel_type='filter1';
    160174end
     
    164178            vel_type='filter2';
    165179        case {4,5}% civ2 available but not filter2
    166             if strcmp(FieldRequest,'derivatives')% derivatives needed
     180            if strcmp(ProjModeRequest,'derivatives')% derivatives needed
    167181                vel_type='filter1';
    168182            else
     
    203217       % units={'pixel','pixel','pixel','pixel','pixel','pixel','','','','pixel','pixel','pixel','pixel','pixel',''};
    204218end
    205 if ~strcmp(FieldRequest,'interp_tps')
     219if ~strcmp(ProjModeRequest,'interp_tps')
    206220    var=var(:,1:9);%suppress tps if not needed
    207221end
  • trunk/src/read_civxdata.m

    r579 r581  
    9595        Field.VarAttribute{ivar}.FieldName=FieldNames;
    9696        if testinterp
    97             Field.VarAttribute{ivar}.FieldRequest='interp_lin';
     97            Field.VarAttribute{ivar}.ProjModeRequest='interp_lin';
    9898        end
    9999    end
  • trunk/src/set_object.m

    r569 r581  
    249249    switch Type
    250250        case {'points','line','polyline','plane'}
    251             menu_proj={'projection';'interp';'filter';'none'};
     251            menu_proj={'projection';'interp_lin';'interp_tps';'none'};
    252252        case {'polygon','rectangle','ellipse'}
    253253            menu_proj={'inside';'outside';'mask_inside';'mask_outside'};
    254254        case 'volume'
    255             menu_proj={'interp';'none'};
     255            menu_proj={'interp_lin';'none'};
    256256        otherwise
    257             menu_proj={'projection';'interp';'filter';'none'};%default
     257            menu_proj={'projection';'interp_lin';'interp_tps';'none'};%default
    258258    end
    259259else
     
    288288set(handles.num_RangeX_2,'Visible','off')
    289289set(handles.num_RangeY_1,'Visible','off')
    290 if isequal(ProjMode,'interp')
     290if isequal(ProjMode,'interp_lin')
    291291    set(handles.num_RangeY_2,'Visible','off')
    292292else
     
    315315%         set(handles.YObject,'TooltipString','YObject: set of y coordinates defining the line')
    316316%         set(handles.ZObject,'TooltipString','ZObject: set of z coordinates defining the line')
    317         if isequal(ProjMode,'interp')|| isequal(ProjMode,'filter')
     317        if isequal(ProjMode,'interp_lin')|| isequal(ProjMode,'interp_tps')
    318318            set(handles.num_DX,'Visible','on')
    319319            set(handles.num_DX,'TooltipString','num_DX: mesh for the interpolated field along the line')
     
    338338            set(handles.num_RangeZ_2,'Visible','on')
    339339        end
    340         if isequal(ProjMode,'interp')|| isequal(ProjMode,'filter')
     340        if isequal(ProjMode,'interp_lin')|| isequal(ProjMode,'interp_tps')
    341341            set(handles.num_DX,'Visible','on')
    342342            set(handles.num_DY,'Visible','on')
     
    345345            set(handles.num_DY,'Visible','off')
    346346        end
    347         if  isequal(ProjMode,'interp')
     347        if  isequal(ProjMode,'interp_lin')
    348348            set(handles.num_DZ,'Visible','on') 
    349349        end
     
    360360        set(handles.num_RangeZ_1,'Visible','on')
    361361        set(handles.num_RangeZ_2,'Visible','on')
    362         if isequal(ProjMode,'interp')|| isequal(ProjMode,'filter')
     362        if isequal(ProjMode,'interp_lin')|| isequal(ProjMode,'interp_tps')
    363363            set(handles.num_DX,'Visible','on')
    364364            set(handles.num_DY,'Visible','on')
     
    485485    PlotType='text';
    486486else
    487     % create tps coeff if needed for ProjMode 'filter'
    488     if strcmp(ObjectData.ProjMode,'filter')&&~isfield(UvData.Field,'Coord_tps')     
     487    % create tps coeff if needed for ProjMode 'interp_tps'
     488    if strcmp(ObjectData.ProjMode,'interp_tps')&&~isfield(UvData.Field,'Coord_tps')     
    489489        UvData.Field=calc_tps(UvData.Field,1);
    490490    end
  • trunk/src/sub_field.m

    r580 r581  
    7575
    7676%% field request
    77 FieldRequest=cell(size(Field.ListVarName));
     77ProjModeRequest=cell(size(Field.ListVarName));
    7878for ilist=1:numel(Field.VarAttribute)
    79     if isfield(Field.VarAttribute{ilist},'FieldRequest')
    80         FieldRequest{ilist}=Field.VarAttribute{ilist}.FieldRequest;
     79    if isfield(Field.VarAttribute{ilist},'ProjModeRequest')
     80        ProjModeRequest{ilist}=Field.VarAttribute{ilist}.ProjModeRequest;
    8181    end
    8282end
    83 FieldRequest_1=cell(size(Field_1.ListVarName));
     83ProjModeRequest_1=cell(size(Field_1.ListVarName));
    8484for ilist=1:numel(Field_1.VarAttribute)
    85     if isfield(Field_1.VarAttribute{ilist},'FieldRequest')
    86         FieldRequest_1{ilist}=Field_1.VarAttribute{ilist}.FieldRequest;
     85    if isfield(Field_1.VarAttribute{ilist},'ProjModeRequest')
     86        ProjModeRequest_1{ilist}=Field_1.VarAttribute{ilist}.ProjModeRequest;
    8787    end
    8888end
     
    115115        VarVal=Field_1.(Field_1.ListVarName{ilist});
    116116        for i1=1:numel(Field.ListVarName)
    117             if (isempty(FieldRequest{i1})&&isempty(FieldRequest_1{ilist})||strcmp(FieldRequest{i1},FieldRequest_1{ilist})) && isequal(Field.(Field.ListVarName{i1}),VarVal)
     117            if (isempty(ProjModeRequest{i1})&&isempty(ProjModeRequest_1{ilist})||strcmp(ProjModeRequest{i1},ProjModeRequest_1{ilist})) && isequal(Field.(Field.ListVarName{i1}),VarVal)
    118118               ind_remove(ilist)=1;
    119119               NewDim=Field.VarDimName{i1};
  • trunk/src/tps_coeff.m

    r434 r581  
    88% The spatial derivatives are obtained as EMDX*U_tps and EMDY*U_tps, where
    99% EMDX and EMDY are obtained from the function tps_eval_dxy.
     10% for big data sets, a splitting in subdomains is needed, see functions
     11% set_subdomains and tps_coeff_field.
     12%
    1013%------------------------------------------------------------------------
    1114% [U_smooth,U_tps]=tps_coeff(ctrs,U,Smoothing)
     
    1316% OUPUT:
    1417% U_smooth: values of the quantity U at the N centres after smoothing
    15 % U_tps: tps weights of the centres
     18% U_tps: tps weights of the centres and columns of the linear
    1619
    1720%INPUT:
    18 % ctrs: Nxs matrix  representing the postions of the N centers, sources of the tps (s=space dimension)
     21% ctrs: NxNbDim matrix  representing the positions of the N centers, sources of the tps (NbDim=space dimension)
    1922% U: Nx1 column vector representing the values of the considered scalar measured at the centres ctrs
    2023% Smoothing: smoothing parameter: the result is smoother for larger Smoothing.
    21 
     24%
     25%related functions:
     26% tps_eval, tps_eval_dxy
     27% tps_coeff_field, set_subdomains, filter_tps, calc_field
    2228
    2329function [U_smooth,U_tps]=tps_coeff(ctrs,U,Smoothing)
    2430%------------------------------------------------------------------------
    25 %Smoothing smoothing parameter
    26 % X=reshape(X,[],1);
    27 % Y=reshape(Y,[],1);
    28 N=size(ctrs,1);
    29 % rhs = reshape(U,[],1);
    30 U = [U; zeros(3,1)];
    31 % ctrs = [X Y];% coordinates of measurement sites, radial base functions are located at the measurement sites
     31
     32N=size(ctrs,1);% nbre of source centres
     33NbDim=size(ctrs,2);% space dimension (2 or 3)
     34U = [U; zeros(NbDim+1,1)];
    3235EM = tps_eval(ctrs,ctrs);
    3336SmoothingMat=Smoothing*eye(N,N);%  Smoothing=1/(2*omega) , omega given by fasshauer;
    34 SmoothingMat=[SmoothingMat zeros(N,3)];
     37SmoothingMat=[SmoothingMat zeros(N,NbDim+1)];
    3538PM=[ones(N,1) ctrs];
    36 IM=[EM+SmoothingMat; [PM' zeros(3,3)]];
     39IM=[EM+SmoothingMat; [PM' zeros(NbDim+1,NbDim+1)]];
    3740U_tps=(IM\U);
    3841U_smooth=EM *U_tps;
  • trunk/src/tps_eval.m

    r434 r581  
    1616% related functions:
    1717% tps_coeff, tps_eval_dxy
     18% tps_coeff_field, set_subdomains, filter_tps, calc_field
    1819
    1920function EM = tps_eval(dsites,ctrs)
  • trunk/src/tps_eval_dxy.m

    r434 r581  
    1515% related functions:
    1616% tps_coeff, tps_eval
     17% tps_coeff_field, set_subdomains, filter_tps, calc_field
    1718
    1819  function [DMX,DMY] = tps_eval_dxy(dsites,ctrs)
  • trunk/src/uvmat.m

    r580 r581  
    6868%                    --->transform fct<---             transform (e.g. phys.m) and combine input fieldname 
    6969%                            |                                   
    70 %                        (calc_tps.m)               calculate tps coefficients (for filter projection or spatial derivatives).
     70%                        (tps_coeff_field.m)               calculate tps coefficients (for filter projection or spatial derivatives).
    7171%                            |
    7272%                       UvData.Field-------------->histogram
     
    10221022switch FileType
    10231023    case {'civx','civdata'}
    1024         [FieldList,ColorList]=calc_field;
     1024%         [FieldList,ColorList]=calc_field;
     1025        [FieldList,ColorList]=set_field_list('U','V','C');
    10251026        set(handles_Fields,'String',[{'image'};FieldList;{'get_field...'}]);%standard menu for civx data
    10261027        set(handles_Fields,'Value',2) % set menu to 'velocity
     
    20462047if  (strcmp(UvData.FileType{1},'civdata')||strcmp(UvData.FileType{1},'civx'))
    20472048    for iobj=1:numel(UvData.Object)
    2048         if isfield(UvData.Object{iobj},'ProjMode')&& strcmp(UvData.Object{iobj}.ProjMode,'filter')
     2049        if isfield(UvData.Object{iobj},'ProjMode')&& strcmp(UvData.Object{iobj}.ProjMode,'interp_tps')
    20492050            check_proj_tps=1;
    20502051            break
     
    24382439
    24392440%% calculate tps coefficients if needed
    2440 UvData.Field=calc_tps(UvData.Field,check_proj_tps);
     2441UvData.Field=tps_coeff_field(UvData.Field,check_proj_tps);
    24412442
    24422443%% analyse input field
     
    30423043function FieldName_Callback(hObject, eventdata, handles)
    30433044%------------------------------------------------------------------------
     3045UvData=get(handles.uvmat,'UserData');
    30443046list_fields=get(handles.FieldName,'String');% list menu fields
    30453047index_fields=get(handles.FieldName,'Value');% selected string index
    30463048field= list_fields{index_fields(1)}; % selected string
     3049
     3050%% fill the coordinates and variables from selections in get_field
    30473051if isequal(field,'get_field...')
     3052    if strcmp(get(handles.VelType,'Visible'),'on')
     3053        % we use the civ choice as default input
     3054        ParamIn.SwitchVarIndexTime='attribute';
     3055        ListVelType=get(handles.VelType,'String');
     3056        VelType=ListVelType{get(handles.VelType,'Value')};
     3057        switch VelType
     3058            case 'civ1'
     3059                 ParamIn.TimeVarName='Civ1_Time';
     3060                 ParamIn.vector_x='Civ1_U';
     3061                 ParamIn.vector_y='Civ1_V';
     3062            case 'filter1'
     3063                 ParamIn.TimeVarName='Civ1_Time';
     3064                 ParamIn.vector_x='Civ1_U_smooth';
     3065                 ParamIn.vector_y='Civ1_V_smooth';
     3066            case 'civ2'
     3067                 ParamIn.TimeVarName='Civ2_Time';
     3068                 ParamIn.vector_x='Civ2_U';
     3069                 ParamIn.vector_y='Civ2_V';
     3070            case 'filter2'
     3071                 ParamIn.TimeVarName='Civ2_Time';
     3072                 ParamIn.vector_x='Civ2_U_smooth';
     3073                 ParamIn.vector_y='Civ2_V_smooth';
     3074        end
     3075    end
    30483076    set(handles.FixVelType,'visible','off')
    3049     set(handles.VelType,'visible','off')
    3050     set(handles.VelType_1,'visible','off')
     3077    set(handles.VelType,'Visible','off')
     3078    set(handles.VelType_1,'Visible','off')
    30513079    [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
    30523080    FileName=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
    3053     hget_field=findobj(allchild(0),'name','get_field');
    3054     if ~isempty(hget_field)
    3055         delete(hget_field)
    3056     end
    3057     get_field(FileName);
     3081%     hget_field=findobj(allchild(0),'name','get_field');
     3082%     if ~isempty(hget_field)
     3083%         delete(hget_field)
     3084%     end
     3085    GetFieldData=get_field(FileName,ParamIn);
     3086    FieldList={};
     3087    VecColorList={};
     3088    XName='';
     3089    YName='';
     3090    if GetFieldData.CheckVector
     3091        UName=GetFieldData.PanelVectors.vector_x;
     3092        VName=GetFieldData.PanelVectors.vector_y;
     3093        XName=GetFieldData.PanelVectors.coord_x_vectors;
     3094        YName=GetFieldData.PanelVectors.coord_y_vectors;
     3095        CName=GetFieldData.PanelVectors.vec_color;
     3096        [FieldList,VecColorList]=set_field_list(UName,VName,CName);
     3097%         FieldList={['vec(' UName ',' VName ')'];...
     3098%             ['norm(' UName ',' VName ')'];...
     3099%             ['curl(' UName ',' VName ')'];...
     3100%             ['div(' UName ',' VName ')'];...
     3101%             ['strain(' UName ',' VName ')']};
     3102%         VecColorList={['norm(' UName ',' VName ')'];...
     3103%             UName;...
     3104%             VName};...
     3105%             if ~isempty(CName)
     3106%             VecColorList=[{CName};VecColorList];
     3107%             end
     3108    end
     3109    if GetFieldData.CheckScalar
     3110        AName=GetFieldData.PanelScalar.scalar;
     3111        XName=GetFieldData.PanelScalar.coord_x_scalar;
     3112        YName=GetFieldData.PanelScalar.coord_y_scalar;
     3113        FieldList={AName};
     3114    end
     3115    if GetFieldData.CheckPlot1D
     3116        XName=GetFieldData.CheckPlot1D.abscissa;
     3117        YName=GetFieldData.CheckPlot1D.ordinate;
     3118    end
     3119    set(handles.Coord_x,'String',{XName})
     3120    set(handles.Coord_y,'String',{YName})
     3121    set(handles.FieldName,'Value',1)
     3122    set(handles.FieldName,'String',[FieldList; {'get_field...'}]);
     3123    set(handles.ColorScalar,'Value',1)
     3124    set(handles.ColorScalar,'String',VecColorList);
     3125    UvData.FileType{1}='netcdf';
     3126    set(handles.uvmat,'UserData',UvData)
     3127    run0_Callback(hObject, eventdata, handles)
    30583128    return %no further action
    30593129end
    30603130
    3061 UvData=get(handles.uvmat,'UserData');
     3131
    30623132
    30633133%read the rootfile input display
     
    31073177indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2);
    31083178set(handles.FileIndex,'String',indices)
    3109 % set(handles.NomType,'String',NomType)
    31103179
    31113180%common to Fields_1_Callback
     
    34133482%
    34143483if isequal(get(handles.edit_vect,'Value'),1)
    3415     test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]);
    3416     test_civ1=isequal(get(handles.VelType,'BackgroundColor'),[1 1 0]);
    3417     if ~test_civ2 && ~test_civ1
     3484    VelTypeMenu=get(handles.VelType,'String');
     3485    VelType=VelTypeMenu{get(handles.VelType,'Value')};
     3486    if ~strcmp(VelType,'civ2') && ~strcmp(VelType,'civ1')
    34183487        msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields')
    34193488    end
     
    38143883function CheckDecimate4_Callback(hObject, eventdata, handles)
    38153884%------------------------------------------------------------------------
     3885if isequal(get(handles.CheckDecimate4,'Value'),1)
     3886    set(handles.CheckDecimate16,'Value',0)
     3887end
     3888update_plot(handles);
     3889
     3890%------------------------------------------------------------------------
     3891% --- Executes on selection change in CheckDecimate16 (nb_vec/16).
     3892function CheckDecimate16_Callback(hObject, eventdata, handles)
     3893%------------------------------------------------------------------------
     3894if isequal(get(handles.CheckDecimate16,'Value'),1)
     3895    set(handles.CheckDecimate4,'Value',0)
     3896end
    38163897update_plot(handles);
    38173898
     
    43414422% --------------------------------------------------------------------
    43424423function MenuExportAxis_Callback(hObject, eventdata, handles)
    4343 answer=msgbox_uvmat('CONFIRMATION','select a figure/axis on which the current uvmat plot will be exported')
    4344 if strcmp(answer,'Yes')
    4345 hchild=get(handles.PlotAxes,'children');
    4346 copyobj(hchild,gca);
    4347 end
     4424ListFig=findobj(allchild(0),'Type','figure');
     4425nb_option=0;
     4426menu={};
     4427for ilist=1:numel(ListFig)
     4428    FigName=get(ListFig(ilist),'name');
     4429    if isempty(FigName)
     4430        FigName=['figure ' num2str(ListFig(ilist))];
     4431    end
     4432    if ~strcmp(FigName,'uvmat')
     4433        ListAxes=findobj(ListFig(ilist),'Type','axes');
     4434        ListTags=get(ListAxes,'Tag');
     4435        if ~isempty(ListTags) && ~isempty(find(~strcmp('Colorbar',ListTags), 1))
     4436            ListAxes=ListAxes(~strcmp('Colorbar',ListTags));
     4437            if numel(ListAxes)==1
     4438                nb_option=nb_option+1;
     4439                menu{nb_option}=FigName ;
     4440                AxesHandle(nb_option)=ListAxes;
     4441            else
     4442                nb_axis=0;
     4443                for iaxes=1:numel(ListAxes)
     4444                    nb_axis=nb_axis+1;
     4445                    nb_option=nb_option+1;
     4446                    menu{nb_option}=[FigName '_' num2str(nb_axis)];
     4447                    AxesHandle(nb_option)=ListAxes(nb_axis);
     4448                end
     4449            end
     4450        end
     4451    end
     4452end
     4453if isempty(menu)
     4454    answer=msgbox_uvmat('INPUT_Y-N','no existing plotting axes available, create new figure?');
     4455    if strcmp(answer,'Yes')
     4456        hfig=figure;
     4457        copyobj(handles.PlotAxes,hfig);
     4458    else
     4459        return
     4460    end
     4461    map=colormap(handles.PlotAxes);
     4462    colormap(map);%transmit the current colormap to the zoom fig
     4463    colorbar
     4464else
     4465    answer=msgbox_uvmat('INPUT_MENU','select a figure/axis on which the current uvmat plot will be exported',menu);
     4466    if isempty(answer)
     4467        return
     4468    else
     4469        axes(AxesHandle(answer))
     4470        hold on
     4471        hchild=get(handles.PlotAxes,'children');
     4472        copyobj(hchild,gca);
     4473    end
     4474end
     4475
    43484476
    43494477%------------------------------------------------------------------------
     
    45054633%------------------------------------------------------------------------
    45064634data.Type='volume';
    4507 data.ProjMode='interp';%default
     4635data.ProjMode='interp_lin';%default
    45084636data.ProjModeMenu={};
    45094637% set(handles.create,'Visible','on')
     
    50195147% --- Executes on button press in CheckColorBar.
    50205148function CheckColorBar_Callback(hObject, eventdata, handles)
     5149
Note: See TracChangeset for help on using the changeset viewer.