Changeset 93


Ignore:
Timestamp:
May 27, 2010, 7:25:58 PM (14 years ago)
Author:
sommeria
Message:

FFT: improved to deal with NaN data
merge_proj: corrected to reproduce dt if unique
uvmat.fig: tooltip corrected
plot_field: bug for isocontour corrected,
im_filter: cleaning
phys_polar: spatial derivative included (still to check)
set_obeject.fig: minor correction
struct2nc: comments improved
uvmat: button NB implemented
read_civxdata: error message improved

Location:
trunk/src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/get_field/FFT.m

    r89 r93  
    66    return %exit the function
    77end
    8 
     8GUI_input=[];
    99%initiation
    1010hhget_field=guidata(hget_field);
     
    2929% get variable
    3030eval(['Var= Field.' ordinate_name ';']);
    31 np=size(Var);
     31np=size(Var)
    3232np_freq=floor(np(1)/2);
    3333dx=1;%default
    3434dfreq=1/np(1);%default frequency interval (abscissa= array index)
     35sum_data=sum(Var,2);
    3536if ~isequal(abscissa_name,'')
    3637    eval(['Coord_x= Field.' abscissa_name ';']);
    37     ind_select=find(~isinf(Coord_x));%detect infinite values
     38    ind_select=find(~isinf(Coord_x)&~isnan(sum_data));%detect infinite values
    3839    Coord_x=Coord_x(ind_select);
    3940    Var=Var(ind_select,:);
  • trunk/src/plot_field.m

    r92 r93  
    172172% check the cells of fields :
    173173% testnbdim=1;
    174 [CellVarIndex,NbDim,VarType,errormsg]=find_field_indices(Data);
     174[CellVarIndex,NbDim,VarType,errormsg]=find_field_indices(Data)
    175175
    176176if ~isempty(errormsg)
     
    324324coord_x_index=[];
    325325test_newplot=1;
    326 hh=findobj(haxes,'tag','plot_line');
     326% hh=findobj(haxes,'tag','plot_line');
    327327% num_curve=numel(hh);
    328 icurve=0;
     328% icurve=0;
    329329for icell=1:length(CellVarIndex)
    330330    testfalse=0;
     
    362362    end
    363363    eval(['coord_x{icell}=data.' data.ListVarName{coord_x_index} ';']);%coordinate variable set as coord_x
    364     testcoordvar=1;
     364%     testcoordvar=1;
    365365    testplot(coord_x_index)=0;
    366366    if ~isempty(VarType{icell}.ancillary')
     
    425425                eval(['varmean=mean(double(data.' VarName '));']);%mean value
    426426                textmean=[textmean; {[VarName 'mean= ' num2str(varmean,4)]}];
    427                 if nbcomponent1==1| nbcomponent2==1
     427                if nbcomponent1==1|| nbcomponent2==1
    428428                    legend_str=[legend_str {VarName}]; %variable with one component
    429429                else  %variable with severals  components
     
    553553        VarType.coord=VarType.coord(ind_coord);
    554554    end
    555     idim_Y=[]; 
     555%     idim_Y=[]; 
    556556    test_grid=0;
    557557    if ~isempty(ivar_U) && ~isempty(ivar_V)% vector components detected
     
    563563            eval(['vec_U=Data.' Data.ListVarName{ivar_U} ';'])
    564564            eval(['vec_V=Data.' Data.ListVarName{ivar_V} ';'])
    565             'TESTplot'
    566             VarType.coord
    567565            if ~isempty(ivar_X) && ~isempty(ivar_Y)% 2D field (with unstructured coordinates or structured ones (then ivar_X and ivar_Y empty)     
    568566                eval(['vec_X=Data.' Data.ListVarName{ivar_X} ';'])
     
    748746            end
    749747            if ~isfield(PlotParam.Scalar,'IncrA')
    750                 PlotParam.Scalar.IncrA=[];
    751             end
    752             if isempty(PlotParam.Scalar.IncrA)% | PlotParam.Scalar.AutoScal==0
     748                PlotParam.Scalar.IncrA=NaN;
     749            end
     750            if isnan(PlotParam.Scalar.IncrA)% | PlotParam.Scalar.AutoScal==0
    753751                cont=colbartick(MinA,MaxA);
    754752                intercont=cont(2)-cont(1);%default
     
    767765            sizpx=(AX(end)-AX(1))/(np(2)-1);
    768766            sizpy=(AY(1)-AY(end))/(np(1)-1);
    769             x_cont=[AX(1):sizpx:AX(end)]; % pixel x coordinates for image display
     767            x_cont=AX(1):sizpx:AX(end); % pixel x coordinates for image display
    770768            y_cont=AY(1):-sizpy:AY(end); % pixel x coordinates for image display
    771769            txt=ver;%version of Matlab
     
    857855    %display the colorbar code for B/W images if Poscolorbar not empty
    858856    if siz==2 && exist('PosColorbar','var')&& ~isempty(PosColorbar)
    859         if isempty(hcol)|~ishandle(hcol)
     857        if isempty(hcol)||~ishandle(hcol)
    860858             hcol=colorbar;%create new colorbar
    861859        end
     
    981979        end
    982980        nb_sel=length(ind_sel);
    983         ind_sel=ind_sel([1:2:nb_sel]);% take half the points on a line
     981        ind_sel=ind_sel(1:2:nb_sel);% take half the points on a line
    984982        vec_X=vec_X(ind_sel);
    985983        vec_Y=vec_Y(ind_sel);
  • trunk/src/read_civxdata.m

    r19 r93  
    11%'read_civxdata': reads civx data from netcdf files
    2 %------------------------------------------------------------------
    3 % COMBINE ET REMPLACE read_ncfield, read_vel et read_scalar_new
    42%------------------------------------------------------------------
    53% OUTPUT:
     
    2018%            .CoordType: expresses the type of coordinate ('px' for image, 'sig' for instruments, or 'phys')
    2119%            .dt: time interval for the corresponding image pair
    22 %            .CivStage: =0, ??? A UTILISER POUR REMPLACER civ
    23         %           =1, civ1 has been performed only
    24         %           =2, fix1 has been performed
    25         %           =3, pacth1 has been performed
    26         %           =4, civ2 has been performed
    27         %           =5, fix2 has been performed
    28         %           =6, pacth2 has been performed
     20%            .CivStage: =0,
     21%                   =1, civ1 has been performed only
     22%                   =2, fix1 has been performed
     23%                   =3, pacth1 has been performed
     24%                   =4, civ2 has been performed
     25%                   =5, fix2 has been performed
     26%                   =6, pacth2 has been performed
    2927%            .X, .Y, .Z: set of vector coordinates
    3028%            .U,.V,.W: corresponding set of vector components
     
    3735%            .A, .AX, .AY: additional scalar
    3836% dt:time interval of the image pair red from a single file, or vector with
    39  
    4037% pixcmx,pixcmy: scaling factors (from the first file)
    4138% vel_type_out: string representing the selected velocity type (civ1,civ2,filter1...)
     
    6865    FieldNames=[]; %default
    6966end
    70 
    7167VelTypeOut=VelType;%default
    7268[var,role,units,vel_type_out_cell]=varcivx_generator(FieldNames,VelType);%determine the names of constants and variables to read
     
    7672end
    7773if isequal(vardetect,0)
    78      Field.Txt=[FieldNames ' not accessible in ' filename '/' VelType];
     74     Field.Txt=[reshape(FieldNames,1,numel(FieldNames)) ' not accessible in ' filename '/' VelType];
    7975     return
    8076end
  • trunk/src/series/merge_proj.m

    r89 r93  
    267267                    Field{iview}.VarAttribute=SubField.VarAttribute;
    268268                end
     269                if isfield(Field{iview},'Txt')
     270                    msgbox_uvmat('ERROR',Field{iview}.Txt)
     271                    return
     272                end
    269273                if isfield(Field{iview},'Time')
    270274                    timeread(iview)=Field{iview}.Time;
     
    280284                Field{iview}=transform_fct(Field{iview},XmlData{iview});%transform to phys if requested
    281285            end
    282             min(Field{iview}.X)
    283286            if testcivx
    284287                    Field{iview}=calc_field(FieldName,Field{iview});
    285288            end
    286             min(Field{iview}.X)
    287289
    288290            %projection on object (gridded plane)
     
    350352            MergeData.nb_coord=2;
    351353            MergeData.nb_dim=2;
    352             MergeData.dt=1;
     354            dt=[];
     355            if isfield(Field{1},'dt')&& isnumeric(Field{1}.dt)
     356                dt=Field{1}.dt;
     357            end
     358            for iview =2:numel(Field)
     359                if ~(isfield(Field{iview},'dt')&& isequal(Field{iview}.dt,dt))
     360                    dt=[];%dt not the same for all fields
     361                end
     362            end
     363            if isempty(dt)
     364                MergeData.ListGlobalAttribute(6)=[];
     365            else
     366               MergeData.dt=dt;
     367            end
     368            %MergeData.dt=1;
    353369            MergeData.Time=time_i;
    354370            error=struct2nc(mergename,MergeData); %save result file
     
    387403    return
    388404end
     405
     406
     407
    389408
    390409%group the variables (fields of 'FieldData') in cells of variables with the same dimensions
     
    412431        test_grid=0;
    413432    end
    414 %    DimIndices=Data{1}.VarDimIndex{VarIndex(1)};%indices of the dimensions of the first variable (common to all variables in the cell)
    415433    %case of input fields with unstructured coordinates
    416434    if ~test_grid
     
    423441    %case of fields defined on a structured  grid
    424442    else 
    425 %        DimValue=MergeData.DimValue(DimIndices);%set of dimension values
    426443        testFF=0;
    427444        for iview=2:nbview
    428 %             if ~isequal(DimValue,Data{iview}.DimValue(DimIndices))
    429 %                 MergeData.Txt='ERROR: attempt at merging structured fields with different sizes';
    430 %                 return
    431 %             end
    432445            for ivar=VarIndex
    433446                VarName=MergeData.ListVarName{ivar};
  • trunk/src/struct2nc.m

    r55 r93  
    1 %'struct2nc': create a netcdf file from a Matlab structure
     1% 'struct2nc': create a netcdf file from a Matlab structure
    22%---------------------------------------------------------------------
    33% errormsg=struct2nc(flname,Data)
    44%
    5 %OUPUT:
    6 %errormsg=error message, =[]: default, no error
     5% OUPUT:
     6% errormsg=error message, =[]: default, no error
    77%
    8 %INPUT:
    9 %flname: name of the netcdf file to create (must end with the extension '.nc')
     8% INPUT:
     9% flname: name of the netcdf file to create (must end with the extension '.nc')
    1010%  Data: structure containing all the information of the netcdf file (or netcdf object)
    1111%           with fields:
    12 %         (optional) .ListGlobalAttribute: cell listing the names of the global attributes
    13 %                    .Att_1,Att_2... : values of the global attributes
    14 %         (requested)  .ListVarName: list of variable names to select (cell array of  char strings {'VarName1', 'VarName2',...} )
    15 %         (requested)  .VarDimName: list of dimension names for each element of .ListVarName (cell array of string cells)                         
    16 %         (requested) .Var1, .Var2....: variables (Matlab arrays) with names listed in .ListVarName
    17 %
     12%       (optional) .ListGlobalAttribute: list (cell array of character strings) of the names of the global attributes Att_1, Att_2...
     13%                  .Att_1,Att_2...: values of the global attributes
     14%      (requested) .ListVarName: list of the variable names Var_1, Var_2....(cell array of character strings).
     15%      (requested) .VarDimName: list of dimension names for each element of .ListVarName (cell array of string cells)
     16%       (optional) .VarAttribute: cell array of structures of the form .VarAttribute{ivar}.key=value, defining an attribute key name and value for the variable #ivar
     17%      (requested) .Var1, .Var2....: variables (Matlab arrays) with names listed in .ListVarName
     18
    1819%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    1920%  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
  • trunk/src/transform_field/im_filter.m

    r40 r93  
    1111
    1212DataOut=DataIn; %default
    13 
    1413Atype=class(DataIn.A)% detect integer 8 or 16 bits
    15 DataOut.A=filter2(Mfiltre,DataIn.A);
    16 DataOut.A=feval(Atype,DataOut.A);
     14if numel(size(DataIn.A))==3
     15    DataOut.A=filter2(Mfiltre,sum(DataIn.A,3));%filter the input image, after summation on the color component (for color images)
     16    DataOut.A=uint16(DataOut.A); %transform to 16 bit images
     17else
     18    DataOut.A=filter2(Mfiltre,DataIn.A)
     19    DataOut.A=feval(Atype,DataOut.A);%transform to the initial image format
     20end
    1721 
  • trunk/src/transform_field/phys_polar.m

    r40 r93  
    2828end
    2929test_1=0;
    30 if nargin==4
     30if nargin==4% case of two input fields
    3131    test_1=1;
    3232    Data_1=varargin{3};
     
    6565
    6666iscalar=0;
     67%transform first field to cartesian phys coordiantes
    6768if  ~isempty(Calib{1})
    6869    DataOut=phys_1(Data,Calib{1},origin_xy,radius_offset,angle_offset,angle_scale);
     
    8081    end
    8182end
    82 
     83%transform second field (if exists) to cartesian phys coordiantes
    8384if test_1
    8485    DataOut_1=phys_1(Data_1,Calib{2},origin_xy,radius_offset,angle_offset,angle_scale);
     
    153154            DataOut.V=(-UX.*sin(theta)+VY.*cos(theta));%./(DataOut.X)%+radius_ref);%angular velocity calculated
    154155            %shift and renormalize the angular velocity
     156            end
     157        end
     158        %transform of spatial derivatives
     159        if isfield(Data,'X') && ~isempty(Data.X) && isfield(Data,'DjUi') && ~isempty(Data.DjUi)...
     160                && isfield(Data,'dt')
     161            if ~isempty(Data.dt)
     162                % estimate the Jacobian matrix DXpx/DXphys
     163                for ip=1:length(Data.X)
     164                    [Xp1,Yp1]=phys_XYZ(Calib,Data.X(ip)+0.5,Data.Y(ip),Z);
     165                    [Xm1,Ym1]=phys_XYZ(Calib,Data.X(ip)-0.5,Data.Y(ip),Z);
     166                    [Xp2,Yp2]=phys_XYZ(Calib,Data.X(ip),Data.Y(ip)+0.5,Z);
     167                    [Xm2,Ym2]=phys_XYZ(Calib,Data.X(ip),Data.Y(ip)-0.5,Z);
     168                    %Jacobian matrix DXpphys/DXpx
     169                    DjXi(1,1)=(Xp1-Xm1);
     170                    DjXi(2,1)=(Yp1-Ym1);
     171                    DjXi(1,2)=(Xp2-Xm2);
     172                    DjXi(2,2)=(Yp2-Ym2);
     173                    DjUi(:,:)=Data.DjUi(ip,:,:);
     174                    DjUi=(DjXi*DjUi')/DjXi;% =J-1*M*J , curvature effects (derivatives of J) neglected
     175                    DataOut.DjUi(ip,:,:)=DjUi';
     176                end
     177                DataOut.DjUi =  DataOut.DjUi/Data.dt;   %     min(Data.DjUi(:,1,1))=DUDX
    155178            end
    156179        end
  • trunk/src/uvmat.m

    r89 r93  
    11671167UvData.NewSeries=1; %flag for run0: begin a new series
    11681168
    1169 [FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes_1(handles);
     1169[FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes_1(handles);
    11701170if ~exist(FileName,'file')
    11711171    msgbox_uvmat('ERROR',['input file ' FileName ' not found']);
Note: See TracChangeset for help on using the changeset viewer.