Changeset 382


Ignore:
Timestamp:
Feb 6, 2012, 11:46:39 PM (13 years ago)
Author:
sommeria
Message:

several bugs corrected
function filter_tps introduced (spline thin shell)

Location:
trunk/src
Files:
1 added
1 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/calc_field.m

    r380 r382  
    2323% file, depending on the scalar
    2424
    25 function [DataOut,errormsg]=calc_field(FieldName,DataIn)
     25function [DataOut,errormsg]=calc_field(FieldName,DataIn,VelType,XI,YI)
    2626
    2727%list of defined scalars to display in menus (in addition to 'ima_cor').
     
    6666   
    6767    %% interpolation with new civ data
    68     if isfield(DataIn,'X_SubRange')
    69         XMax=max(max(DataIn.X_SubRange));
    70         YMax=max(max(DataIn.Y_SubRange));
    71         XMin=min(min(DataIn.X_SubRange));
    72         YMin=min(min(DataIn.Y_SubRange));
    73         Mesh=sqrt((YMax-YMin)*(XMax-XMin)/numel(DataIn.X_tps));%2D
    74         xI=XMin:Mesh:XMax;
    75         yI=YMin:Mesh:YMax;
    76         [XI,YI]=meshgrid(xI,yI);
    77         XI=reshape(XI,[],1);
    78         YI=reshape(YI,[],1);
     68    %if isfield(DataIn,'X_SubRange')
     69    if strcmp(VelType,'filter1')||strcmp(VelType,'filter2')
     70        XMax=max(max(DataIn.SubRange(1,:,:)));
     71        YMax=max(max(DataIn.SubRange(2,:,:)));
     72        XMin=min(min(DataIn.SubRange(1,:,:)));
     73        YMin=min(min(DataIn.SubRange(2,:,:)));
     74        if ~(exist('XI','var')&&exist('YI','var'))
     75            Mesh=sqrt((YMax-YMin)*(XMax-XMin)/numel(DataIn.Coord_tps(:,1,:)));%2D
     76            xI=XMin:Mesh:XMax;
     77            yI=YMin:Mesh:YMax;
     78            [XI,YI]=meshgrid(xI,yI);
     79            XI=reshape(XI,[],1);
     80            YI=reshape(YI,[],1);
     81        end
    7982        DataOut.ListGlobalAttribute=DataIn.ListGlobalAttribute; %reproduce global attribute
    8083        for ilist=1:numel(DataOut.ListGlobalAttribute)
     
    8891        DataOut.U=zeros(size(XI));
    8992        DataOut.V=zeros(size(XI));
    90         DataOut.vort=zeros(size(XI));
    91        
     93        DataOut.vort=zeros(size(XI));       
    9294        DataOut.div=zeros(size(XI));
    9395        nbval=zeros(size(XI));
    94         [NbSubDomain,xx]=size(DataIn.X_SubRange);
     96        NbSubDomain=size(DataIn.SubRange,3);
    9597        for isub=1:NbSubDomain
    96             nbvec_sub=DataIn.NbSites(isub);         
    97                 ind_sel=find(XI>=DataIn.X_SubRange(isub,1) & XI<=DataIn.X_SubRange(isub,2) & YI>=DataIn.Y_SubRange(isub,1) & YI<=DataIn.Y_SubRange(isub,2));
     98            if isfield(DataIn,'NbSites')
     99                nbvec_sub=DataIn.NbSites(isub);
     100            else
     101                nbvec_sub=numel(find(DataIn.Indices_tps(:,isub)));
     102            end
     103                ind_sel=find(XI>=DataIn.SubRange(1,1,isub) & XI<=DataIn.SubRange(1,2,isub) & YI>=DataIn.SubRange(2,1,isub) & YI<=DataIn.SubRange(2,2,isub));
    98104                %rho smoothing parameter
    99105                epoints = [XI(ind_sel) YI(ind_sel)];% coordinates of interpolation sites
    100                 ctrs=[DataIn.X_tps(1:nbvec_sub,isub) DataIn.Y_tps(1:nbvec_sub,isub)];%(=initial points) ctrs
     106                ctrs=DataIn.Coord_tps(1:nbvec_sub,:,isub);%(=initial points) ctrs
    101107                nbval(ind_sel)=nbval(ind_sel)+1;% records the number of values for eacn interpolation point (in case of subdomain overlap)
    102108%                 PM = [ones(size(epoints,1),1) epoints];
  • trunk/src/check_field_structure.m

    r159 r382  
    5858        return
    5959    end
    60     eval(['sizvar=size(Data.' VarName ');'])% sizvar = dimension of variable
     60    sizvar=size(Data.(VarName));% sizvar = dimension of variable
    6161    DimCell=Data.VarDimName{ivar};
    6262    if ischar(DimCell)
     
    6565        errormsg=['wrong format for .VarDimName{' num2str(ivar) ' (must be the cell of dimension names of the variable ' VarName];
    6666        return
     67       
    6768    end
    6869    nbcoord=numel(sizvar);%nbre of coordinates for variable named VarName
     
    9192    else
    9293        if numel(DimCell)>nbcoord
    93             DimCell=DimCell(end-nbcoord+1:end);%first singleton diemensions omitted,
     94            sizvar(nbcoord+1:numel(DimCell))=1;% case of singleton dimensions (not seen by the function size)
     95           % DimCell=DimCell(end-nbcoord+1:end)%first singleton diemensions omitted,
    9496        elseif nbcoord > numel(DimCell)
    9597            errormsg=['nbre of declared dimensions in .VarDimName{' num2str(ivar) '} smaller than the nbre of dimensions =' num2str(nbcoord) ' of the variable ' VarName];
     
    98100    end
    99101    DimIndex=[];
    100     for idim=1:nbcoord %loop on the coordinates of variable #ivar
     102    %for idim=1:nbcoord
     103    for idim=1:numel(DimCell) %loop on the coordinates of variable #ivar
    101104        DimName=DimCell{idim};
    102105        iprev=find(strcmp(DimName,Data.ListDimName),1);%look for dimension name DimName in the current list
     
    112115        else % DimName is detected in the current list of dimension names
    113116            if ~isequal(Data.DimValue(iprev),sizvar(idim))
     117                Data.DimValue(iprev)
     118                sizvar(idim)
    114119                if isequal(Data.DimValue(iprev),2)&& RangeTest(iprev)  % the dimension has been already detected as a range [min max]
    115120                    Data.DimValue(iprev)=sizvar(idim); %update with actual value
  • trunk/src/civ.m

    r379 r382  
    3232    'gui_LayoutFcn',  [] , ...
    3333    'gui_Callback',   []);
    34 if nargin && ischar(varargin{1})
     34if nargin && ischar(varargin{1}) && ~isempty(regexp(varargin{1},'_Callback$','once'))
    3535    gui_State.gui_Callback = str2func(varargin{1});
    3636end
     
    15331533                        batch_file_list{length(batch_file_list)+1}=filename_bat;
    15341534                    else
    1535                         [Data,erromsg]=civ_matlab(Param,filecell.nc.civ1{ifile,j});
     1535                        [tild,errormsg]=civ_matlab(Param,filecell.nc.civ1{ifile,j});
    15361536                        if isempty(errormsg)
    15371537                            display([filecell.nc.civ1{ifile,j} ' written'])
  • trunk/src/civ_matlab.m

    r372 r382  
    33%   civ: PIV function itself
    44%   fix: removes false vectors after detection by various criteria
    5 %   patch: make interpolation-smoothing
     5%   filter_tps: make interpolation-smoothing
    66%------------------------------------------------------------------------
    77% function [Data,errormsg,result_conv]= civ_uvmat(Param,ncfile)
     
    169169    Data.Patch1_Threshold=Param.Patch1.MaxDiff;
    170170    Data.Patch1_SubDomain=Param.Patch1.SubdomainSize;
    171     Data.ListVarName=[Data.ListVarName {'Civ1_U_Diff','Civ1_V_Diff','Civ1_X_SubRange','Civ1_Y_SubRange','Civ1_NbSites','Civ1_X_tps','Civ1_Y_tps','Civ1_U_tps','Civ1_V_tps'}];
    172     Data.VarDimName=[Data.VarDimName {'NbVec1','NbVec1',{'NbSubDomain1','Two'},{'NbSubDomain1','Two'},'NbSubDomain1',...
    173              {'NbVec1Sub','NbSubDomain1'},{'NbVec1Sub','NbSubDomain1'},{'Nbtps1','NbSubDomain1'},{'Nbtps1','NbSubDomain1'}}];
     171    Data.ListVarName=[Data.ListVarName {'Civ1_U_Diff','Civ1_V_Diff','Civ1_SubRange','Civ1_NbSites','Civ1_Coord_tps','Civ1_U_tps','Civ1_V_tps'}];
     172    Data.VarDimName=[Data.VarDimName {'NbVec1','NbVec1',{'NbCoord','Two','NbSubDomain1'},{'NbSubDomain1'},...
     173             {'NbVec1Sub','NbCoord','NbSubDomain1'},{'Nbtps1','NbSubDomain1'},{'Nbtps1','NbSubDomain1'}}];
    174174    nbvar=length(Data.ListVarName);
    175175    Data.VarAttribute{nbvar-1}.Role='vector_x';
     
    182182        ind_good=1:numel(Data.Civ1_X);
    183183    end
    184     [Data.Civ1_X_SubRange,Data.Civ1_Y_SubRange,Data.Civ1_NbSites,FFres,Ures, Vres,Data.Civ1_X_tps,Data.Civ1_Y_tps,Data.Civ1_U_tps,Data.Civ1_V_tps]=...
    185                             patch(Data.Civ1_X(ind_good)',Data.Civ1_Y(ind_good)',Data.Civ1_U(ind_good)',Data.Civ1_V(ind_good)',Data.Patch1_Rho,Data.Patch1_Threshold,Data.Patch1_SubDomain);
     184%     [SubRange,NbPoints,Coord_tps,U_tps,V_tps,W_tps,U_smooth,V_smooth,W_smooth,FF]
     185    [Data.Civ1_SubRange,Data.Civ1_NbSites,Data.Civ1_Coord_tps,Data.Civ1_U_tps,Data.Civ1_V_tps,tild,Ures, Vres,tild,FFres]=...
     186                            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_Threshold,Data.Patch1_Rho);
    186187      Data.Civ1_U_Diff(ind_good)=Data.Civ1_U(ind_good)-Ures;
    187188      Data.Civ1_V_Diff(ind_good)=Data.Civ1_V(ind_good)-Vres;
     
    335336    Data.Patch2_Threshold=Param.Patch2.MaxDiff;
    336337    Data.Patch2_SubDomain=Param.Patch2.SubdomainSize;
    337     Data.ListVarName=[Data.ListVarName {'Civ2_U_Diff','Civ2_V_Diff','Civ2_X_SubRange','Civ2_Y_SubRange','Civ2_NbSites','Civ2_X_tps','Civ2_Y_tps','Civ2_U_tps','Civ2_V_tps'}];
    338     Data.VarDimName=[Data.VarDimName {'NbVec2','NbVec2',{'NbSubDomain2','Two'},{'NbSubDomain2','Two'},'NbSubDomain2',...
    339              {'NbVec2Sub','NbSubDomain2'},{'NbVec2Sub','NbSubDomain2'},{'Nbtps2','NbSubDomain2'},{'Nbtps2','NbSubDomain2'}}];
     338    Data.ListVarName=[Data.ListVarName {'Civ2_U_Diff','Civ2_V_Diff','Civ2_X_SubRange','Civ2_Y_SubRange','Civ2_X_tps','Civ2_Y_tps','Civ2_U_tps','Civ2_V_tps','Civ2_Indices_tps'}];
     339    Data.VarDimName=[Data.VarDimName {'NbVec2','NbVec2',{'NbSubDomain2','Two'},{'NbSubDomain2','Two'},...
     340             {'NbVec2Sub','NbSubDomain2'},{'NbVec2Sub','NbSubDomain2'},{'Nbtps2','NbSubDomain2'},{'Nbtps2','NbSubDomain2'},{'NbVec2Sub','NbSubDomain2'}}];
    340341    nbvar=length(Data.ListVarName);
    341342    Data.VarAttribute{nbvar-1}.Role='vector_x';
     
    348349        ind_good=1:numel(Data.Civ2_X);
    349350    end
    350     [Data.Civ2_X_SubRange,Data.Civ2_Y_SubRange,Data.Civ2_NbSites,FFres,Ures, Vres,Data.Civ2_X_tps,Data.Civ2_Y_tps,Data.Civ2_U_tps,Data.Civ2_V_tps]=...
    351                             patch(Data.Civ2_X(ind_good)',Data.Civ2_Y(ind_good)',Data.Civ2_U(ind_good)',Data.Civ2_V(ind_good)',Data.Patch2_Rho,Data.Patch2_Threshold,Data.Patch2_SubDomain);
     351    [Data.Civ2_SubRange,Data.Civ2_NbSites,Data.Civ2_Coord_tps,Data.Civ2_U_tps,Data.Civ2_V_tps,tild,Ures, Vres,tild,FFres]=...
     352                            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);
    352353      Data.Civ2_U_Diff(ind_good)=Data.Civ2_U(ind_good)-Ures;
    353354      Data.Civ2_V_Diff(ind_good)=Data.Civ2_V(ind_good)-Vres;
     
    697698
    698699
    699 %------------------------------------------------------------------------
    700 % patch function
    701 % OUTPUT:
    702 % SubRangx,SubRangy(NbSubdomain,2): range (min, max) of the coordiantes x and y respectively, for each subdomain
    703 % nbpoints(NbSubdomain): number of source points for each subdomain
    704 % FF: false flags
    705 % U_smooth, V_smooth: filtered velocity components at the positions of the initial data
    706 % X_tps,Y_tps,U_tps,V_tps: positions and weight of the tps for each subdomain
    707 %
    708 % INPUT:
    709 % X, Y: set of coordinates of the initial data
    710 % U,V: set of velocity components of the initial data
    711 % Rho: smoothing parameter
    712 % Threshold: max diff accepted between smoothed and initial data
    713 % Subdomain: estimated number of data points in each subdomain
    714 
    715 function [SubRangx,SubRangy,nbpoints,FF,U_smooth,V_smooth,X_tps,Y_tps,U_tps,V_tps] =patch(X,Y,U,V,Rho,Threshold,SubDomain)
    716 %subdomain decomposition
    717 warning off
    718 U=reshape(U,[],1);
    719 V=reshape(V,[],1);
    720 X=reshape(X,[],1);
    721 Y=reshape(Y,[],1);
    722 nbvec=numel(X);
    723 NbSubDomain=ceil(nbvec/SubDomain);
    724 MinX=min(X);
    725 MinY=min(Y);
    726 MaxX=max(X);
    727 MaxY=max(Y);
    728 RangX=MaxX-MinX;
    729 RangY=MaxY-MinY;
    730 AspectRatio=RangY/RangX;
    731 NbSubDomainX=max(floor(sqrt(NbSubDomain/AspectRatio)),1);
    732 NbSubDomainY=max(floor(sqrt(NbSubDomain*AspectRatio)),1);
    733 NbSubDomain=NbSubDomainX*NbSubDomainY;
    734 SizX=RangX/NbSubDomainX;%width of subdomains
    735 SizY=RangY/NbSubDomainY;%height of subdomains
    736 CentreX=linspace(MinX+SizX/2,MaxX-SizX/2,NbSubDomainX);
    737 CentreY=linspace(MinY+SizY/2,MaxY-SizY/2,NbSubDomainY);
    738 [CentreX,CentreY]=meshgrid(CentreX,CentreY);
    739 CentreY=reshape(CentreY,1,[]);% Y positions of subdomain centres
    740 CentreX=reshape(CentreX,1,[]);% X positions of subdomain centres
    741 rho=SizX*SizY*Rho/1000000;%optimum rho increase as the area of the subdomain (division by 10^6 to reach good values with the default GUI input)
    742 U_tps_sub=zeros(length(X),NbSubDomain);%default spline
    743 V_tps_sub=zeros(length(X),NbSubDomain);%default spline
    744 U_smooth=zeros(length(X),1);
    745 V_smooth=zeros(length(X),1);
    746 
    747 nb_select=zeros(length(X),1);
    748 FF=zeros(length(X),1);
    749 check_empty=zeros(1,NbSubDomain);
    750 SubRangx=zeros(NbSubDomain,2);%initialise the positions of subdomains
    751 SubRangy=zeros(NbSubDomain,2);
    752 for isub=1:NbSubDomain
    753     SubRangx(isub,:)=[CentreX(isub)-0.55*SizX CentreX(isub)+0.55*SizX];
    754     SubRangy(isub,:)=[CentreY(isub)-0.55*SizY CentreY(isub)+0.55*SizY];
    755     ind_sel_previous=[];
    756     ind_sel=0;
    757     while numel(ind_sel)>numel(ind_sel_previous) %increase the subdomain during four iterations at most
    758         ind_sel_previous=ind_sel;
    759         ind_sel=find(X>=SubRangx(isub,1) & X<=SubRangx(isub,2) & Y>=SubRangy(isub,1) & Y<=SubRangy(isub,2));
    760         % if no vector in the subdomain, skip the subdomain
    761         if isempty(ind_sel)
    762             check_empty(isub)=1;   
    763             U_tps(1,isub)=0;%define U_tps and V_tps by default
    764             V_tps(1,isub)=0;
    765             break
    766             % if too few selected vectors, increase the subrange for next iteration
    767         elseif numel(ind_sel)<SubDomain/4 && ~isequal( ind_sel,ind_sel_previous);
    768             SubRangx(isub,1)=SubRangx(isub,1)-SizX/4;
    769             SubRangx(isub,2)=SubRangx(isub,2)+SizX/4;
    770             SubRangy(isub,1)=SubRangy(isub,1)-SizY/4;
    771             SubRangy(isub,2)=SubRangy(isub,2)+SizY/4;
    772         else
    773            
    774             [U_smooth_sub,U_tps_sub]=tps_coeff([X(ind_sel) Y(ind_sel)],U(ind_sel),rho);
    775             [V_smooth_sub,V_tps_sub]=tps_coeff([X(ind_sel) Y(ind_sel)],V(ind_sel),rho);
    776             UDiff=U_smooth_sub-U(ind_sel);
    777             VDiff=V_smooth_sub-V(ind_sel);
    778             NormDiff=UDiff.*UDiff+VDiff.*VDiff;
    779             FF(ind_sel)=20*(NormDiff>Threshold);%put FF value to 20 to identify the criterium of elimmination
    780             ind_ind_sel=find(FF(ind_sel)==0); % select the indices of ind_sel corresponding to the remaining vectors
    781             % no value exceeds threshold, the result is recorded
    782             if isequal(numel(ind_ind_sel),numel(ind_sel))
    783                 U_smooth(ind_sel)=U_smooth(ind_sel)+U_smooth_sub;
    784                 V_smooth(ind_sel)=V_smooth(ind_sel)+V_smooth_sub;
    785                 nbpoints(isub)=numel(ind_sel);
    786                 X_tps(1:nbpoints(isub),isub)=X(ind_sel);
    787                 Y_tps(1:nbpoints(isub),isub)=Y(ind_sel);
    788                 U_tps(1:nbpoints(isub)+3,isub)=U_tps_sub;
    789                 V_tps(1:nbpoints(isub)+3,isub)=V_tps_sub;         
    790                 nb_select(ind_sel)=nb_select(ind_sel)+1;
    791                  display('good')
    792                 break
    793                 % too few selected vectors, increase the subrange for next iteration
    794             elseif numel(ind_ind_sel)<SubDomain/4 && ~isequal( ind_sel,ind_sel_previous);
    795                 SubRangx(isub,1)=SubRangx(isub,1)-SizX/4;
    796                 SubRangx(isub,2)=SubRangx(isub,2)+SizX/4;
    797                 SubRangy(isub,1)=SubRangy(isub,1)-SizY/4;
    798                 SubRangy(isub,2)=SubRangy(isub,2)+SizY/4;
    799 %                 display('fewsmooth')
    800                 % interpolation-smoothing is done again with the selected vectors
    801             else
    802                 [U_smooth_sub,U_tps_sub]=tps_coeff([X(ind_sel(ind_ind_sel)) Y(ind_sel(ind_ind_sel))],U(ind_sel(ind_ind_sel)),rho);
    803                 [V_smooth_sub,V_tps_sub]=tps_coeff([X(ind_sel(ind_ind_sel)) Y(ind_sel(ind_ind_sel))],V(ind_sel(ind_ind_sel)),rho);
    804                 U_smooth(ind_sel(ind_ind_sel))=U_smooth(ind_sel(ind_ind_sel))+U_smooth_sub;
    805                 V_smooth(ind_sel(ind_ind_sel))=V_smooth(ind_sel(ind_ind_sel))+V_smooth_sub;
    806                 nbpoints(isub)=numel(ind_ind_sel);
    807                 X_tps(1:nbpoints(isub),isub)=X(ind_sel(ind_ind_sel));
    808                 Y_tps(1:nbpoints(isub),isub)=Y(ind_sel(ind_ind_sel));
    809                 U_tps(1:nbpoints(isub)+3,isub)=U_tps_sub;
    810                 V_tps(1:nbpoints(isub)+3,isub)=V_tps_sub;
    811                 nb_select(ind_sel(ind_ind_sel))=nb_select(ind_sel(ind_ind_sel))+1;
    812                 display('good2')
    813                 break
    814             end
    815         end
    816     end
    817 end
    818 ind_empty=find(check_empty);
    819 %remove empty subdomains
    820 if ~isempty(ind_empty)
    821     SubRangx(ind_empty,:)=[];
    822     SubRangy(ind_empty,:)=[];
    823     X_tps(:,ind_empty)=[];
    824     Y_tps(:,ind_empty)=[];
    825     U_tps(:,ind_empty)=[];
    826     V_tps(:,ind_empty)=[];
    827 end
    828 nb_select(nb_select==0)=1;%ones(size(find(nb_select==0)));
    829 U_smooth=U_smooth./nb_select;
    830 V_smooth=V_smooth./nb_select;
    831 
    832 
    833 
    834 
    835 
     700
     701
     702
     703
  • trunk/src/proj_field.m

    r379 r382  
    8080%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    8181
    82 function [ProjData,errormsg]=proj_field(FieldData,ObjectData)
     82function [ProjData,errormsg]=proj_field(FieldData,ObjectData,FieldName)
    8383errormsg='';%default
    8484%% case of no projection (object is used only as graph display)
     
    913913%project on a plane
    914914% AJOUTER flux,circul,error
    915  function  [ProjData,errormsg] = proj_plane(FieldData, ObjectData)
     915 function  [ProjData,errormsg] = proj_plane(FieldData, ObjectData,FieldName)
    916916%-----------------------------------------------------------------
    917917
     
    11641164            coord_x_proj=XMin:DX:XMax;
    11651165            coord_y_proj=YMin:DY:YMax;
     1166            if isfield(FieldData,[VarName '_tps'])
     1167                [XI,YI]=meshgrid(coord_x_proj,coord_y_proj');
     1168                XI=reshape(XI,[],1);
     1169                YI=reshape(YI,[],1);         
     1170            end
    11661171            DimCell={'coord_y','coord_x'};
    11671172            ProjData.ListVarName={'coord_y','coord_x'};
     
    11861191            FF=zeros(1,length(coord_y_proj)*length(coord_x_proj));
    11871192            testFF=0;
     1193            if ~isempty(FieldName)
     1194                FieldData=calc_field(FieldName,FieldData,XI,YI);
     1195            end
    11881196            for ivar=VarIndex
    11891197                VarName=FieldData.ListVarName{ivar};
     
    11961204                    end
    11971205                    if  ~isequal(ivar_FF,0)
    1198                         eval(['FieldData.' VarName '=FieldData.' VarName '(indsel);'])
    1199                     end
    1200                     eval(['ProjData.' VarName '=griddata_uvmat(double(coord_X),double(coord_Y),double(FieldData.' VarName '),coord_x_proj,coord_y_proj'',rho);'])
    1201                     eval(['varline=reshape(ProjData.' VarName ',1,length(coord_y_proj)*length(coord_x_proj));'])
     1206                        FieldData.(VarName)=FieldData.(VarName)(indsel);
     1207                    end
     1208%                     if isfield(FieldData,[VarName '_tps'])
     1209%                         [XI,YI]=meshgrid(coord_x_proj,coord_y_proj');
     1210%                         XI=reshape(XI,[],1);
     1211%                         YI=reshape(YI,[],1);
     1212%                         
     1213                   if ~isempty(FieldName)
     1214                        ProjData.(VarName)=griddata_uvmat(double(coord_X),double(coord_Y),double(FieldData.(VarName)),coord_x_proj,coord_y_proj',rho);
     1215                    end
     1216                    varline=reshape(ProjData.(VarName),1,length(coord_y_proj)*length(coord_x_proj));
    12021217                    FFlag= isnan(varline); %detect undefined values NaN
    12031218                    indnan=find(FFlag);
    12041219                    if~isempty(indnan)
    12051220                        varline(indnan)=zeros(size(indnan));
    1206                         eval(['ProjData.' VarName '=reshape(varline,length(coord_y_proj),length(coord_x_proj));'])
     1221                        ProjData.(VarName)=reshape(varline,length(coord_y_proj),length(coord_x_proj));
    12071222                        FF(indnan)=ones(size(indnan));
    12081223                        testFF=1;
  • trunk/src/read_civdata.m

    r380 r382  
    148148if strcmp(vel_type,'civ2') && testder
    149149    vel_type='filter2';
    150 elseif stcmp(vel_type,'civ1') && testder
     150elseif strcmp(vel_type,'civ1') && testder
    151151    vel_type='filter1';
    152152end
    153153
    154154switch vel_type
    155     case {'civ1'}
    156         var={'X','Y','Z','U','V','W','C','F','FF','X_tps','Y_tps','Z_tps','U_tps','V_tps','W_tps','X_SubRange','Y_SubRange','NbSites';...
     155    case {'civ1','filter1'}
     156        var={'X','Y','Z','U','V','W','C','F','FF','X_tps','Y_tps','Z_tps','U_tps','V_tps','W_tps','X_SubRange','Y_SubRange','NbSites','Indices_tps';...
    157157            'Civ1_X','Civ1_Y','Civ1_Z','Civ1_U','Civ1_V','Civ1_W','Civ1_C','Civ1_F','Civ1_FF',...
    158             'Civ1_X_tps','Civ1_Y_tps','','Civ1_U_tps','Civ1_V_tps','','Civ1_X_SubRange','Civ1_Y_SubRange','Civ1_NbSites'};
    159         role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','warnflag','errorflag','','','','','','','','',''};
    160         units={'pixel','pixel','pixel','pixel','pixel','pixel','','','','pixel','pixel','pixel','pixel','pixel','pixel','pixel','pixel',''};
     158            'Civ1_X_tps','Civ1_Y_tps','','Civ1_U_tps','Civ1_V_tps','','Civ1_X_SubRange','Civ1_Y_SubRange','Civ1_NbSites','Civ1_Indices_tps'};
     159        role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','warnflag','errorflag','','','','','','','','','',''};
     160        units={'pixel','pixel','pixel','pixel','pixel','pixel','','','','pixel','pixel','pixel','pixel','pixel','pixel','pixel','pixel','',''};
    161161    case 'civ-filter1'
    162162        var={'X','Y','Z','U','V','W','FF';...
     
    164164        role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','errorflag'};
    165165        units={'pixel','pixel','pixel','pixel','pixel','pixel',[]};
    166     case 'filter1'
    167         var={'X_tps','Y_tps','Z_tps','U_tps','V_tps','W_tps','X_SubRange','Y_SubRange','NbSites';...
    168             'Civ1_X_tps','Civ1_Y_tps','','Civ1_U_tps','Civ1_V_tps','','Civ1_X_SubRange','Civ1_Y_SubRange','Civ1_NbSites'};
    169         role={'','','','','','','','',''};
    170         units={'pixel','pixel','pixel','pixel','pixel','pixel','pixel','pixel',''};
    171     case 'civ2'
    172         var={'X','Y','Z','U','V','W','C','F','FF','X_tps','Y_tps','Z_tps','U_tps','V_tps','W_tps','X_SubRange','Y_SubRange','NbSites';...
     166%     case 'filter1'
     167%         var={'X_tps','Y_tps','Z_tps','U_tps','V_tps','W_tps','X_SubRange','Y_SubRange','NbSites','Indices_tps';...
     168%             'Civ1_X_tps','Civ1_Y_tps','','Civ1_U_tps','Civ1_V_tps','','Civ1_X_SubRange','Civ1_Y_SubRange','Civ1_NbSites','Civ1_Indices_tps'};
     169%         role={'','','','','','','','','',''};
     170%         units={'pixel','pixel','pixel','pixel','pixel','pixel','pixel','pixel','',''};
     171    case {'civ2','filter2'}
     172        var={'X','Y','Z','U','V','W','C','F','FF','X_tps','Y_tps','Z_tps','U_tps','V_tps','W_tps','X_SubRange','Y_SubRange','NbSites','Indices_tps';...
    173173            'Civ2_X','Civ2_Y','Civ2_Z','Civ2_U','Civ2_V','Civ2_W','Civ2_C','Civ2_F','Civ2_FF',...
    174             'Civ2_X_tps','Civ2_Y_tps','','Civ2_U_tps','Civ2_V_tps','','Civ2_X_SubRange','Civ2_Y_SubRange','Civ2_NbSites'};
    175         role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','warnflag','errorflag','','','','','','','','',''};
    176         units={'pixel','pixel','pixel','pixel','pixel','pixel','','','','pixel','pixel','pixel','pixel','pixel','pixel','pixel','pixel',''};
     174            'Civ2_X_tps','Civ2_Y_tps','','Civ2_U_tps','Civ2_V_tps','','Civ2_X_SubRange','Civ2_Y_SubRange','Civ2_NbSites','Civ2_Indices_tps'};
     175        role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','warnflag','errorflag','','','','','','','','','',''};
     176        units={'pixel','pixel','pixel','pixel','pixel','pixel','','','','pixel','pixel','pixel','pixel','pixel','pixel','pixel','pixel','',''};
    177177%         var={'X','Y','Z','U','V','W','C','F','FF';...
    178178%             'Civ2_X','Civ2_Y','Civ2_Z','Civ2_U','Civ2_V','Civ2_W','Civ2_C','Civ2_F','Civ2_FF'};
     
    184184        role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','errorflag'};
    185185        units={'pixel','pixel','pixel','pixel','pixel','pixel',[]};
    186     case 'filter2'
    187         var={'X_tps','Y_tps','Z_tps','U_tps','V_tps','W_tps','X_SubRange','Y_SubRange','NbSites';...
    188             'Civ2_X_tps','Civ2_Y_tps','','Civ2_U_tps','Civ2_V_tps','','Civ2_X_SubRange','Civ2_Y_SubRange','Civ2_NbSites'};
    189         role={'','','','','','','','',''};
    190         units={'pixel','pixel','pixel','pixel','pixel','pixel','pixel','pixel',''};
     186%     case 'filter2'
     187%         var={'X_tps','Y_tps','Z_tps','U_tps','V_tps','W_tps','X_SubRange','Y_SubRange','NbSites','Indices_tps';...
     188%             'Civ2_X_tps','Civ2_Y_tps','','Civ2_U_tps','Civ2_V_tps','','Civ2_X_SubRange','Civ2_Y_SubRange','Civ2_NbSites','Civ2_Indices_tps'};
     189%         role={'','','','','','','','','',''};
     190%         units={'pixel','pixel','pixel','pixel','pixel','pixel','pixel','pixel','',''};
    191191end
    192192vel_type_out=vel_type;
  • trunk/src/struct2nc.m

    r246 r382  
    5353    [Data,errormsg]=check_field_structure(Data);%check the validity of the input field structure
    5454    if ~isempty(errormsg)
    55         errormsg=['invalid input structure:' errormsg];
     55        errormsg=['error in struct2nc:invalid input structure_' errormsg];
    5656        return
    5757    end
     
    112112    for ivar=1:length(ListVarName)
    113113        if isfield(Data,ListVarName{ivar})
    114             eval(['VarVal=Data.' ListVarName{ivar} ';'])%varval=values of the current variable
     114            VarVal=Data.(ListVarName{ivar});
     115            %varval=values of the current variable
    115116            VarDimIndex=Data.VarDimIndex{ivar}; %indices of the variable dimensions in the list of dimensions
    116117            VarDimName=Data.VarDimName{ivar};
     
    122123            testline=isequal(length(siz),2) && isequal(siz(1),1)&& isequal(siz(2), Data.DimValue(VarDimIndex));%matlab vector
    123124            testcolumn=isequal(length(siz),2) && isequal(siz(1), Data.DimValue(VarDimIndex))&& isequal(siz(2),1);%matlab column vector
    124             if ~testrange && ~testline && ~testcolumn && ~isequal(siz,Data.DimValue(VarDimIndex))
    125                 errormsg=['wrong dimensions declared for ' ListVarName{ivar} ' in struct2nc.m'];
    126                 break
    127             end
     125%             if ~testrange && ~testline && ~testcolumn && ~isequal(siz,Data.DimValue(VarDimIndex))
     126%                 errormsg=['wrong dimensions declared for ' ListVarName{ivar} ' in struct2nc.m'];
     127%                 break
     128%             end
    128129            if testline || testrange
    129130                if testrange
  • trunk/src/uvmat.m

    r380 r382  
    16751675    if ~isempty(UvData.j1_series{1})
    16761676        if get(handles.scan_i,'Value')==1% case of scanning along index i
    1677             j1_subseries=UvData.j1_series{1}(ref_i+1,:,:)
     1677            j1_subseries=UvData.j1_series{1}(ref_i+1,:,:);
    16781678        else
    1679             j1_subseries=UvData.j1_series{1}(:,ref_j+1,:)
     1679            j1_subseries=UvData.j1_series{1}(:,ref_j+1,:);
    16801680        end
    16811681        j1_subseries=j1_subseries(j1_subseries>0);
     
    16841684    if ~isempty(UvData.j2_series{1})
    16851685        if get(handles.scan_i,'Value')==1% case of scanning along index i
    1686             j2_subseries=UvData.j2_series{1}(ref_i+1,:,:)
     1686            j2_subseries=UvData.j2_series{1}(ref_i+1,:,:);
    16871687        else
    1688             j2_subseries=UvData.j2_series{1}(:,ref_j+1,:)
     1688            j2_subseries=UvData.j2_series{1}(:,ref_j+1,:);
    16891689        end
    16901690        j2_subseries=j2_subseries(j2_subseries>0);
     
    19961996                ParamIn.Npx=UvData.XmlData.Npx;
    19971997            else
     1998               
    19981999                errormsg='Npx and Npy need to be defined in the xml file for volume images .vol';
    19992000                return
     
    20072008        errormsg=['error in reading ' filename ': ' errormsg];
    20082009        return
    2009     end       
     2010    end 
    20102011    if isfield(ParamOut,'Npx')&& isfield(ParamOut,'Npy')
    20112012        set(handles.num_Npx,'String',num2str(ParamOut.Npx));% display image size on the interface
     
    22132214end
    22142215
     2216
     2217%% update tps in phys coordinates if needed
     2218if (strcmp(VelType,'filter1')||strcmp(VelType,'filter2'))&& isfield(Field{1},'U')&& isfield(Field{1},'V')
     2219    [Field{1}.SubRange,Field{1}.NbSites,Field{1}.Coord_tps,Field{1}.U_tps,Field{1}.V_tps]=filter_tps([Field{1}.X Field{1}.Y],Field{1}.U,Field{1}.V,[],1500,0);
     2220end
     2221
    22152222%% calculate scalar
    22162223if strcmp(FileType(1:3),'civ') && ~isequal(ParamOut.CivStage,0)%&&~isempty(FieldName)%
    2217     Field{1}=calc_field([{ParamOut.FieldName} {ParamOut.ColorVar}],Field{1});
     2224    Field{1}=calc_field([{ParamOut.FieldName} {ParamOut.ColorVar}],Field{1},VelType);
    22182225end
    22192226if numel(Field)==2 && ~test_keepdata_1 && isequal(FileType_1(1:3),'civ') && ~isequal(ParamOut_1.FieldName,'get_field...')%&&~isempty(FieldName_1)
    2220     Field{2}=calc_field([{ParamOut_1.FieldName} {ParamOut_1.ColorVar}],Field{2});
     2227    Field{2}=calc_field([{ParamOut_1.FieldName} {ParamOut_1.ColorVar}],Field{2},VelType_1);
    22212228end
    22222229
Note: See TracChangeset for help on using the changeset viewer.