Changeset 404


Ignore:
Timestamp:
Apr 30, 2012, 6:46:45 PM (12 years ago)
Author:
sommeria
Message:

various bugs corrected. nc2struct_toolbox suppressed (correspond to obsolete versions of Matlab)

Location:
trunk/src
Files:
1 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/calc_field.m

    r399 r404  
     1
     2
    13%'calc_field': defines fields (velocity, vort, div...) from civx data and calculate them
    24%---------------------------------------------------------------------
     
    3537% the scalar is calculated from other fields, as explicited below
    3638
    37 list_field={'velocity';...%image correlation corresponding to a vel vector
     39%% list of field options implemented
     40FieldOptions={'velocity';...%image correlation corresponding to a vel vector
    3841    'ima_cor';...%image correlation corresponding to a vel vector
    3942    'norm_vel';...%norm of the velocity
     
    4851errormsg=[]; %default error message
    4952if ~exist('FieldList','var')
    50     DataOut=list_field;% gives the list of possible fields in the absence of input
     53    DataOut=FieldOptions;% gives the list of possible field inputs in the absence of input
     54    return
     55end
     56
     57%% check input
     58if ~exist('DataIn','var')
     59    DataIn=[];
     60end
     61if ischar(FieldList)
     62    FieldList={FieldList};%convert a string input to a cell with one string element
     63end
     64check_grid=0;
     65check_der=0;
     66check_calc=ones(size(FieldList));
     67for ilist=1:length(FieldList)
     68    switch FieldList{ilist}
     69        case {'u','v'}
     70            check_grid=1;% needs a regular grid
     71        case{'vort','div','strain'}% needs spatial derivatives spatial derivatives
     72            check_der=1;
     73        case {'velocity','norm_vel'};
     74        otherwise
     75            check_calc(ilist)=0;
     76    end
     77end
     78FieldList=FieldList(check_calc==1);
     79if isempty(FieldList)
     80    DataOut=DataIn;
     81    return
     82end
     83if isfield(DataIn,'Z')&& isequal(size(DataIn.Z),size(DataIn.X))
     84    nbcoord=3;
    5185else
    52     if ~exist('DataIn','var')
    53         DataIn=[];
    54     end
    55     if ischar(FieldList)
    56         FieldList={FieldList};%convert a string input to a cell with one string element
    57     end
    58     if isfield(DataIn,'Z')&& isequal(size(DataIn.Z),size(DataIn.X))
    59         nbcoord=3;
    60     else
    61         nbcoord=2;
    62     end
    63     ListVarName={};
    64     ValueList={};
    65     RoleList={};
    66     units_cell={};
    67    
    68     %% interpolation with new civ data
    69     if isfield(DataIn,'SubRange') && isfield(DataIn,'Coord_tps')&& exist('Coord_interp','var')
    70         DataOut.ListGlobalAttribute=DataIn.ListGlobalAttribute; %reproduce global attribute
    71         for ilist=1:numel(DataOut.ListGlobalAttribute)
    72             DataOut.(DataOut.ListGlobalAttribute{ilist})=DataIn.(DataIn.ListGlobalAttribute{ilist});
    73         end
    74         DataOut.ListVarName={'coord_y','coord_x','FF'};
    75         DataOut.VarDimName{1}='coord_y';
    76         DataOut.VarDimName{2}='coord_x';
    77         XMax=max(max(DataIn.SubRange(1,:,:)));% extrema of the coordinates
    78         YMax=max(max(DataIn.SubRange(2,:,:)));
    79         XMin=min(min(DataIn.SubRange(1,:,:)));
    80         YMin=min(min(DataIn.SubRange(2,:,:)));
    81         check_der=0;
    82         check_val=0;
    83         nb_sites=size(Coord_interp,1);
    84         nb_coord=size(Coord_interp,2);
     86    nbcoord=2;
     87end
     88ListVarName={};
     89ValueList={};
     90RoleList={};
     91units_cell={};
     92
     93%% interpolation with new civ data
     94if isfield(DataIn,'SubRange') && isfield(DataIn,'Coord_tps') && (exist('Coord_interp','var') || check_grid ||check_der)
     95    %create a default grid if needed
     96    if  ~exist('Coord_interp','var')
     97        coord_x=DataIn.XMin:DataIn.Mesh:DataIn.XMax;
     98        coord_y=DataIn.XMin:DataIn.Mesh:DataIn.YMax;
     99        [XI,YI]=meshgrid(coord_x,coord_y);
     100        XI=reshape(XI,[],1);
     101        YI=reshape(YI,[],1);
     102        Coord_interp=[XI YI];
     103    end
     104    DataOut.ListGlobalAttribute=DataIn.ListGlobalAttribute; %reproduce global attribute
     105    for ilist=1:numel(DataOut.ListGlobalAttribute)
     106        DataOut.(DataOut.ListGlobalAttribute{ilist})=DataIn.(DataIn.ListGlobalAttribute{ilist});
     107    end
     108    DataOut.ListVarName={'coord_y','coord_x','FF'};
     109    DataOut.VarDimName{1}='coord_y';
     110    DataOut.VarDimName{2}='coord_x';
     111    XMax=max(max(DataIn.SubRange(1,:,:)));% extrema of the coordinates
     112    YMax=max(max(DataIn.SubRange(2,:,:)));
     113    XMin=min(min(DataIn.SubRange(1,:,:)));
     114    YMin=min(min(DataIn.SubRange(2,:,:)));
     115%     check_der=0;
     116%     check_val=0;
     117    nb_sites=size(Coord_interp,1);
     118    nb_coord=size(Coord_interp,2);
     119    %initialise output
     120    for ilist=1:length(FieldList)
     121        switch FieldList{ilist}
     122            case 'velocity'
     123                DataOut.U=zeros(nb_sites,1);
     124                DataOut.V=zeros(nb_sites,1);
     125            otherwise
     126  %          case{'vort','div','strain'}% case of spatial derivatives
     127                DataOut.(FieldList{ilist})=zeros(nb_sites,1);
     128%                 otherwise % case of a scalar
     129%                     check_val=1;
     130%                     DataOut.(FieldList{ilist})=zeros(size(Coord_interp,1));
     131        end
     132    end
     133    nbval=zeros(nb_sites,1);
     134    NbSubDomain=size(DataIn.SubRange,3);
     135    %DataIn.Coord_tps=DataIn.Coord_tps(1:end-3,:,:);% suppress the 3 zeros used to fit with the dimensions of variables
     136    for isub=1:NbSubDomain
     137        nbvec_sub=DataIn.NbSites(isub);
     138        check_range=(Coord_interp >=ones(nb_sites,1)*DataIn.SubRange(:,1,isub)' & Coord_interp<=ones(nb_sites,1)*DataIn.SubRange(:,2,isub)');
     139        ind_sel=find(sum(check_range,2)==nb_coord);
     140        %rho smoothing parameter
     141        %                 epoints = Coord_interp(ind_sel) ;% coordinates of interpolation sites
     142        %                 ctrs=DataIn.Coord_tps(1:nbvec_sub,:,isub);%(=initial points) ctrs
     143        nbval(ind_sel)=nbval(ind_sel)+1;% records the number of values for eacn interpolation point (in case of subdomain overlap)
     144        if check_val
     145            EM = tps_eval(Coord_interp(ind_sel,:),DataIn.Coord_tps(1:nbvec_sub,:,isub));%kernels for calculating the velocity from tps 'sources'
     146        end
     147        if check_der
     148            [EMDX,EMDY] = tps_eval_dxy(Coord_interp(ind_sel,:),DataIn.Coord_tps(1:nbvec_sub,:,isub));%kernels for calculating the spatial derivatives from tps 'sources'
     149        end
    85150        for ilist=1:length(FieldList)
    86151            switch FieldList{ilist}
    87152                case 'velocity'
    88                     check_val=1;
    89                     DataOut.U=zeros(nb_sites,1);
    90                     DataOut.V=zeros(nb_sites,1);
    91                 case{'vort','div','strain'}% case of spatial derivatives
    92                     check_der=1;
    93                     DataOut.(FieldList{ilist})=zeros(nb_sites,1);
    94 %                 otherwise % case of a scalar
    95 %                     check_val=1;
    96 %                     DataOut.(FieldList{ilist})=zeros(size(Coord_interp,1));
     153                    ListFields={'U', 'V'};
     154                    VarAttributes{1}.Role='vector_x';
     155                    VarAttributes{2}.Role='vector_y';
     156                    DataOut.U(ind_sel)=DataOut.U(ind_sel)+EM *DataIn.U_tps(1:nbvec_sub+3,isub);
     157                    DataOut.V(ind_sel)=DataOut.V(ind_sel)+EM *DataIn.V_tps(1:nbvec_sub+3,isub);
     158                case 'u'
     159                    ListFields={'U'};
     160                    VarAttributes{1}.Role='scalar';
     161                    DataOut.U(ind_sel)=DataOut.U(ind_sel)+EM *DataIn.U_tps(1:nbvec_sub+3,isub);
     162                case 'v'
     163                    ListFields={'V'};
     164                    VarAttributes{1}.Role='scalar';
     165                    DataOut.V(ind_sel)=DataOut.V(ind_sel)+EM *DataIn.V_tps(1:nbvec_sub+3,isub);
     166                case 'norm_vel'
     167                    ListFields={'norm_vel'};
     168                    VarAttributes{1}.Role='scalar';
     169                    V=DataOut.U(ind_sel)+EM *DataIn.U_tps(1:nbvec_sub+3,isub);
     170                    V=DataOut.V(ind_sel)+EM *DataIn.V_tps(1:nbvec_sub+3,isub);
     171                    DataOut.norm_vel(ind_sel)=sqrt(U.*U+V.*V);
     172                case 'vort'
     173                    ListFields={'vort'};
     174                    VarAttributes{1}.Role='scalar';
     175                    DataOut.vort(ind_sel)=DataOut.vort(ind_sel)+EMDY *DataIn.U_tps(1:nbvec_sub+3,isub)-EMDX *DataIn.V_tps(1:nbvec_sub+3,isub);
     176                case 'div'
     177                    ListFields={'div'};
     178                    VarAttributes{1}.Role='scalar';
     179                    DataOut.div(ind_sel)=DataOut.div(ind_sel)+EMDX*DataIn.U_tps(1:nbvec_sub+3,isub)+EMDY *DataIn.V_tps(1:nbvec_sub+3,isub);
     180                case 'strain'
     181                    ListFields={'strain'};
     182                    VarAttributes{1}.Role='scalar';
     183                    DataOut.strain(ind_sel)=DataOut.strain(ind_sel)+EMDY*DataIn.U_tps(1:nbvec_sub+3,isub)+EMDX *DataIn.V_tps(1:nbvec_sub+3,isub);
    97184            end
    98185        end
    99         nbval=zeros(nb_sites,1);
    100         NbSubDomain=size(DataIn.SubRange,3);
    101         %DataIn.Coord_tps=DataIn.Coord_tps(1:end-3,:,:);% suppress the 3 zeros used to fit with the dimensions of variables
    102         for isub=1:NbSubDomain
    103             nbvec_sub=DataIn.NbSites(isub);
    104             check_range=(Coord_interp >=ones(nb_sites,1)*DataIn.SubRange(:,1,isub)' & Coord_interp<=ones(nb_sites,1)*DataIn.SubRange(:,2,isub)');
    105             ind_sel=find(sum(check_range,2)==nb_coord);
    106             %rho smoothing parameter
    107             %                 epoints = Coord_interp(ind_sel) ;% coordinates of interpolation sites
    108             %                 ctrs=DataIn.Coord_tps(1:nbvec_sub,:,isub);%(=initial points) ctrs
    109             nbval(ind_sel)=nbval(ind_sel)+1;% records the number of values for eacn interpolation point (in case of subdomain overlap)
    110             if check_val
    111                 EM = tps_eval(Coord_interp(ind_sel,:),DataIn.Coord_tps(1:nbvec_sub,:,isub));%kernels for calculating the velocity from tps 'sources'
    112             end
    113             if check_der
    114                 [EMDX,EMDY] = tps_eval_dxy(Coord_interp(ind_sel,:),DataIn.Coord_tps(1:nbvec_sub,:,isub));%kernels for calculating the spatial derivatives from tps 'sources'
    115             end
    116             for ilist=1:length(FieldList)
    117                 switch FieldList{ilist}
    118                     case 'velocity'
    119                         ListFields={'U', 'V'};
    120                         VarAttributes{1}.Role='vector_x';
    121                         VarAttributes{2}.Role='vector_y';
    122                         DataOut.U(ind_sel)=DataOut.U(ind_sel)+EM *DataIn.U_tps(1:nbvec_sub+3,isub);
    123                         DataOut.V(ind_sel)=DataOut.V(ind_sel)+EM *DataIn.V_tps(1:nbvec_sub+3,isub);
    124                     case 'u'
    125                         ListFields={'U'};
    126                         VarAttributes{1}.Role='scalar';
    127                         DataOut.U(ind_sel)=DataOut.U(ind_sel)+EM *DataIn.U_tps(1:nbvec_sub+3,isub);
    128                     case 'v'
    129                         ListFields={'V'};
    130                         VarAttributes{1}.Role='scalar';
    131                         DataOut.V(ind_sel)=DataOut.V(ind_sel)+EM *DataIn.V_tps(1:nbvec_sub+3,isub);
    132                     case 'vort'
    133                         ListFields={'vort'};
    134                         VarAttributes{1}.Role='scalar';
    135                         DataOut.vort(ind_sel)=DataOut.vort(ind_sel)+EMDY *DataIn.U_tps(1:nbvec_sub+3,isub)-EMDX *DataIn.V_tps(1:nbvec_sub+3,isub);
    136                     case 'div'
    137                         ListFields={'div'};
    138                         VarAttributes{1}.Role='scalar';
    139                         DataOut.div(ind_sel)=DataOut.div(ind_sel)+EMDX*DataIn.U_tps(1:nbvec_sub+3,isub)+EMDY *DataIn.V_tps(1:nbvec_sub+3,isub);
    140                     case 'strain'
    141                         ListFields={'strain'};
    142                         VarAttributes{1}.Role='scalar';
    143                         DataOut.strain(ind_sel)=DataOut.strain(ind_sel)+EMDY*DataIn.U_tps(1:nbvec_sub+3,isub)+EMDX *DataIn.V_tps(1:nbvec_sub+3,isub);
    144                 end
    145             end
    146             DataOut.FF=nbval==0; %put errorflag to 1 for points outside the interpolation rang
    147 %            DataOut.FF=reshape(DataOut.FF,numel(yI),numel(xI));
    148             nbval(nbval==0)=1;
    149 %             switch FieldList{1}
    150 %                 case {'velocity','u','v'}
    151 %                     DataOut.U=reshape(DataOut.U./nbval,numel(yI),numel(xI));
    152 %                     DataOut.V=reshape(DataOut.V./nbval,numel(yI),numel(xI));
    153 %                 case 'vort'
    154 %                     DataOut.vort=reshape(DataOut.vort,numel(yI),numel(xI));
    155 %                 case 'div'
    156 %                     DataOut.div=reshape(DataOut.div,numel(yI),numel(xI));
    157 %                 case 'strain'
    158 %                     DataOut.strain=reshape(DataOut.strain,numel(yI),numel(xI));
    159 %             end
    160             DataOut.ListVarName=[DataOut.ListVarName ListFields];
    161             for ilist=3:numel(DataOut.ListVarName)
    162                 DataOut.VarDimName{ilist}={'coord_y','coord_x'};
    163             end
    164             DataOut.VarAttribute={[],[]};
    165             DataOut.VarAttribute{3}.Role='errorflag';
    166             DataOut.VarAttribute=[DataOut.VarAttribute VarAttributes];
    167         end
    168     else
    169        
    170         %% civx data
    171         DataOut=DataIn;
    172         for ilist=1:length(FieldList)
    173             if ~isempty(FieldList{ilist})
    174                 [VarName,Value,Role,units]=feval(FieldList{ilist},DataIn);%calculate field with appropriate function named FieldList{ilist}
    175                 ListVarName=[ListVarName VarName];
    176                 ValueList=[ValueList Value];
    177                 RoleList=[RoleList Role];
    178                 units_cell=[units_cell units];
    179             end
    180         end
    181         %erase previous data (except coordinates)
    182         for ivar=nbcoord+1:length(DataOut.ListVarName)
    183             VarName=DataOut.ListVarName{ivar};
    184             DataOut=rmfield(DataOut,VarName);
    185         end
    186         DataOut.ListVarName=DataOut.ListVarName(1:nbcoord);
    187         if isfield(DataOut,'VarDimName')
    188             DataOut.VarDimName=DataOut.VarDimName(1:nbcoord);
    189         else
    190             errormsg='element .VarDimName missing in input data';
    191             return
    192         end
    193         DataOut.VarAttribute=DataOut.VarAttribute(1:nbcoord);
    194         %append new data
    195         DataOut.ListVarName=[DataOut.ListVarName ListVarName];
    196         for ivar=1:length(ListVarName)
    197             DataOut.VarDimName{nbcoord+ivar}=DataOut.VarDimName{1};
    198             DataOut.VarAttribute{nbcoord+ivar}.Role=RoleList{ivar};
    199             DataOut.VarAttribute{nbcoord+ivar}.units=units_cell{ivar};
    200             DataOut.(ListVarName{ivar})=ValueList{ivar};
    201         end
    202     end
    203 end
     186        DataOut.FF=nbval==0; %put errorflag to 1 for points outside the interpolation rang
     187        nbval(nbval==0)=1;
     188        DataOut.ListVarName=[DataOut.ListVarName ListFields];
     189        for ilist=3:numel(DataOut.ListVarName)
     190            DataOut.VarDimName{ilist}={'coord_y','coord_x'};
     191        end
     192        DataOut.VarAttribute={[],[]};
     193        DataOut.VarAttribute{3}.Role='errorflag';
     194        DataOut.VarAttribute=[DataOut.VarAttribute VarAttributes];
     195    end
     196else
     197
     198    %% civx data
     199    DataOut=DataIn;
     200    for ilist=1:length(FieldList)
     201        if ~isempty(FieldList{ilist})
     202            [VarName,Value,Role,units]=feval(FieldList{ilist},DataIn);%calculate field with appropriate function named FieldList{ilist}
     203            ListVarName=[ListVarName VarName];
     204            ValueList=[ValueList Value];
     205            RoleList=[RoleList Role];
     206            units_cell=[units_cell units];
     207        end
     208    end
     209    %erase previous data (except coordinates)
     210    for ivar=nbcoord+1:length(DataOut.ListVarName)
     211        VarName=DataOut.ListVarName{ivar};
     212        DataOut=rmfield(DataOut,VarName);
     213    end
     214    DataOut.ListVarName=DataOut.ListVarName(1:nbcoord);
     215    if isfield(DataOut,'VarDimName')
     216        DataOut.VarDimName=DataOut.VarDimName(1:nbcoord);
     217    else
     218        errormsg='element .VarDimName missing in input data';
     219        return
     220    end
     221    DataOut.VarAttribute=DataOut.VarAttribute(1:nbcoord);
     222    %append new data
     223    DataOut.ListVarName=[DataOut.ListVarName ListVarName];
     224    for ivar=1:length(ListVarName)
     225        DataOut.VarDimName{nbcoord+ivar}=DataOut.VarDimName{1};
     226        DataOut.VarAttribute{nbcoord+ivar}.Role=RoleList{ivar};
     227        DataOut.VarAttribute{nbcoord+ivar}.units=units_cell{ivar};
     228        DataOut.(ListVarName{ivar})=ValueList{ivar};
     229    end
     230end
     231
    204232
    205233
  • trunk/src/check_field_structure.m

    r385 r404  
    44%
    55% OUTPUT:
    6 % DataOut: structure reproducing the input structure Data, with the additional elements:
    7 %           with fields:
    8 %
    9 %            .ListDimName: cell listing the names of the array dimensions
    10 %             .DimValue: array dimension values (Matlab vector with the same length as .ListDimName
    11 %            .VarDimIndex: cell containing the set of dimension indices (in list .ListDimName) for each variable of .ListVarName
    12 %            .VarDimName: cell containing a cell of dimension names (in list .ListDimName) for each variable of .ListVarName
     6% DataOut: structure reproducing the input structure Data (TODO: suppress this output)
    137% errormsg: error message which is not empty when the input structure does not have the right form
    148%
     
    2216
    2317
    24 function [DataOut,errormsg]=check_field_structure(Data)
     18function [errormsg,ListDimName,DimValue,VarDimIndex]=check_field_structure(Data)
    2519DataOut=[]; %default
    2620errormsg=[];
     
    4539    return
    4640end
    47 if isfield(Data,'DimValue')
    48     Data=rmfield(Data,'DimValue');
    49 end
     41% if isfield(Data,'DimValue')
     42%     Data=rmfield(Data,'DimValue');
     43% end
    5044nbdim=0;
    51 Data.ListDimName={};
     45ListDimName={};
    5246
    5347%% main loop on the list of variables
     
    10397    for idim=1:numel(DimCell) %loop on the coordinates of variable #ivar
    10498        DimName=DimCell{idim};
    105         iprev=find(strcmp(DimName,Data.ListDimName),1);%look for dimension name DimName in the current list
     99        iprev=find(strcmp(DimName,ListDimName),1);%look for dimension name DimName in the current list
    106100        if isempty(iprev)% append the dimension name to the current list
    107101            nbdim=nbdim+1;
     
    110104                RangeTest(nbdim)=1; %to be updated for a later variable 
    111105            end
    112             Data.DimValue(nbdim)=sizvar(idim);
    113             Data.ListDimName{nbdim}=DimName;
     106            DimValue(nbdim)=sizvar(idim);
     107            ListDimName{nbdim}=DimName;
    114108            DimIndex=[DimIndex nbdim];
    115109        else % DimName is detected in the current list of dimension names
    116             if ~isequal(Data.DimValue(iprev),sizvar(idim))
    117                 if isequal(Data.DimValue(iprev),2)&& RangeTest(iprev)  % the dimension has been already detected as a range [min max]
    118                     Data.DimValue(iprev)=sizvar(idim); %update with actual value
     110            if ~isequal(DimValue(iprev),sizvar(idim))
     111                if isequal(DimValue(iprev),2)&& RangeTest(iprev)  % the dimension has been already detected as a range [min max]
     112                    DimValue(iprev)=sizvar(idim); %update with actual value
    119113                elseif ~testrange               
    120114                    errormsg=['dimension declaration inconsistent with the size =[' num2str(sizvar) '] for ' VarName];
     
    125119        end
    126120    end
    127     Data.VarDimIndex{ivar}=DimIndex;
     121    VarDimIndex{ivar}=DimIndex;
    128122end
    129123DataOut=Data;
  • trunk/src/find_field_indices.m

    r399 r404  
    2323% INPUT:
    2424% Data: structure representing fields, output of check_field_structure
    25 %            .ListDimName: cell listing the names of the array dimensions
    26 %            .ListVarName: cell listing the names of the variables
    27 %            .VarDimIndex: cell containing the set of dimension indices (in list .ListDimName) for each variable of .ListVarName
     25%            .ListVarName: cell array listing the names (cahr strings) of the variables
     26%            .VarDimName: cell array of cells containing the set of dimension names for each variable of .ListVarName
     27%            .VarAttribute: cell array of structures containing the variable attributes:
     28%                     .VarAttribute{ilist}.key=value, where ilist is the variable
     29%                     index, key is the name of the attribute, value its value (char string or number)
    2830%
    2931% HELP:
  • trunk/src/nc2struct.m

    r236 r404  
    1313%                    .VarDimName: list of dimension names for each element of .ListVarName (cell array of string cells)                         
    1414%                    .Var1, .Var2....: variables (Matlab arrays) with names listed in .ListVarName
    15 %                    .ListDimName=list of dimension (added information, not requested for field description)
    16 %                    .DimValue= vlalues of dimensions (added information, not requested for field description)
     15%                  ListDimName=list of dimension (added information, not requested for field description)
     16%                  DimValue= vlalues of dimensions (added information, not requested for field description)
    1717%  var_detect: vector with same length as the cell array ListVarName, = 1 for each detected variable and 0 else.
    1818%            var_detect=[] in the absence of input cell array
     
    108108        try
    109109            if ischar(valuestr) %& length(valuestr)<200 & double(valuestr)<=122 & double(valuestr)>=48 %usual characters
    110                % valuestr=regexprep(valuestr,{'\\','\/','\.','\-',' '},{'_','_','_','_','_'})%remove  '\','.' or '-' if exists
    111110                eval(['Data.' keystr '=''' valuestr ''';'])
    112 %             elseif isempty(valuestr)
    113 %                 eval(['Data.' keystr '=[];'])
    114111            elseif isnumeric(valuestr)
    115112                eval(['Data.' keystr '=valuestr;'])
     
    207204    if ~isempty(var_index)     
    208205        dim_index=find(flag_used);%list of netcdf dimensions indices corresponding to used dimensions
    209         Data.ListDimName=ListDimNameNetcdf(dim_index);
    210         Data.DimValue=dim_value(dim_index);
     206        ListDimName=ListDimNameNetcdf(dim_index);
     207        DimValue=dim_value(dim_index);
    211208    end
    212209   
  • trunk/src/plot_field.m

    r402 r404  
    109109index_1D=[];
    110110index_0D=[];
    111 [Data,errormsg]=check_field_structure(Data);
     111errormsg=check_field_structure(Data);
    112112if ~isempty(errormsg)
    113113    msgbox_uvmat('ERROR',['input of plot_field/check_field_structure: ' errormsg])
  • trunk/src/read_civdata.m

    r397 r404  
    4949function [Field,VelTypeOut,errormsg]=read_civdata(filename,FieldNames,VelType,CivStage)
    5050errormsg='';
    51 VelTypeOut=VelType;%default
    5251%% default input
    5352if ~exist('VelType','var')
  • trunk/src/read_civxdata.m

    r380 r404  
    9696%% adjust for Djui:
    9797if isfield(Field,'DjUi')
     98    Field.ListVarName{end-3}='DjUi';
     99    Field.VarDimName{end-3}=[Field.VarDimName{end-3} {'nb_coord'} {'nb-coord'}];
    98100    Field.ListVarName(end-2:end)=[];
    99     Field.ListVarName{end}='DjUi';
    100101    Field.VarDimName(end-2:end)=[];
    101102    Field.VarAttribute(end-2:end)=[];
  • trunk/src/read_field.m

    r397 r404  
    5050            GUIName=ParamIn.GUIName;
    5151        end
    52         test_civx=0;
     52        CivStage=0;
    5353        if ~strcmp(ParamIn.FieldName,'get_field...')% if get_field is not requested, look for Civx data
    5454            FieldList=calc_field;%list of possible fields for Civx data
     
    6363                    InputField=[{ParamOut.FieldName} {ParamOut.ColorVar}];
    6464                    [Field,ParamOut.VelType,errormsg]=read_civdata(ObjectName,InputField,ParamIn.VelType,Data.CivStage);
    65                     test_civx=Field.CivStage;
     65                    CivStage=Field.CivStage;
    6666                    %case of old civx conventions
    6767                elseif ~isempty(Data.absolut_time_T0)&& ~isequal(Data.civ,0)
     
    7070                    InputField=[{ParamOut.FieldName} {ParamOut.ColorVar}];
    7171                    [Field,ParamOut.VelType]=read_civxdata(ObjectName,InputField,ParamIn.VelType);
    72                     test_civx=Field.CivStage;
     72                    CivStage=Field.CivStage;
    7373                    ParamOut.CivStage=Field.CivStage;
    7474                    % not cvix file, fields will be chosen through the GUI get_field
     
    9090                    return
    9191                end
    92                 test_civx=Field.CivStage;
     92                CivStage=Field.CivStage;
    9393                ParamOut.CivStage=Field.CivStage;
    9494            end
    9595        end
    96         if ~test_civx% read the field names on the interface get_field.
     96        ParamOut.FieldList=[{'image'};FieldList;{'get_field...'}];
     97        if CivStage==0% read the field names on the interface get_field.
    9798            hget_field=findobj(allchild(0),'Name',GUIName);%find the get_field... GUI
    9899            if isempty(hget_field)% open the GUI get_field if it is not found
     
    140141                ParamOut.TimeValue=Field.TimeValue;
    141142            end
    142         end
    143         if test_civx
    144             ParamOut.FieldList=[{'image'};FieldList;{'get_field...'}];
    145         else
    146143            ParamOut.FieldList={'get_field...'};
    147144        end
    148        
     145%         if CivStage~=0
     146%             ParamOut.FieldList=[{'image'};FieldList;{'get_field...'}];
     147%         else
     148% %             ParamOut.FieldList={'get_field...'};
     149%         end   
    149150    case 'video'
    150151        try
  • trunk/src/read_get_field.m

    r402 r404  
    3131empty_coord_x=0;
    3232empty_coord_y=0;
     33empty_coord_z=0;
    3334%dimname_y={};
    3435ListVarName={};
  • trunk/src/struct2nc.m

    r382 r404  
    4242    return
    4343end
    44 hhh=which('netcdf.create');% look for built-in matlab netcdf library
    45 
    46 %USE OF built-in matlab netcdf library
    47 if ~isequal(hhh,'')
    48     FilePath=fileparts(flname);
    49     if ~strcmp(FilePath,'') && ~exist(FilePath,'dir')
    50         errormsg=['directory ' FilePath ' needs to be created'];
    51         return
    52     end
    53     [Data,errormsg]=check_field_structure(Data);%check the validity of the input field structure
    54     if ~isempty(errormsg)
    55         errormsg=['error in struct2nc:invalid input structure_' errormsg];
    56         return
    57     end
    58     ListVarName=Data.ListVarName;
    59     nc=netcdf.create(flname,'NC_CLOBBER');%,'clobber'); %create the netcdf file with name flname   
    60     %write global constants
    61     if isfield(Data,'ListGlobalAttribute')
    62         keys=Data.ListGlobalAttribute;
    63         for iattr=1:length(keys)
    64             if isfield(Data,keys{iattr})
    65                  testvar=0;
    66                 for ivar=1:length(ListVarName)% eliminate possible global attributes with the same name as a variable
    67                     if isequal(ListVarName{ivar}, keys{iattr})
    68                         testvar=1;
    69                         break
    70                     end
     44FilePath=fileparts(flname);
     45if ~strcmp(FilePath,'') && ~exist(FilePath,'dir')
     46    errormsg=['directory ' FilePath ' needs to be created'];
     47    return
     48end
     49%  [Data,errormsg]=check_field_structure(Data);%check the validity of the input field structure
     50[errormsg,ListDimName,DimValue,VarDimIndex]=check_field_structure(Data);
     51if ~isempty(errormsg)
     52    errormsg=['error in struct2nc:invalid input structure_' errormsg];
     53    return
     54end
     55ListVarName=Data.ListVarName;
     56nc=netcdf.create(flname,'NC_CLOBBER');%,'clobber'); %create the netcdf file with name flname   
     57%write global constants
     58if isfield(Data,'ListGlobalAttribute')
     59    keys=Data.ListGlobalAttribute;
     60    for iattr=1:length(keys)
     61        if isfield(Data,keys{iattr})
     62             testvar=0;
     63            for ivar=1:length(ListVarName)% eliminate possible global attributes with the same name as a variable
     64                if isequal(ListVarName{ivar}, keys{iattr})
     65                    testvar=1;
     66                    break
    7167                end
    72                 if ~testvar               
    73                     eval(['cte=Data.' keys{iattr} ';'])
    74                     if (ischar(cte) ||isnumeric(cte)) &&  ~isempty(cte)%&& ~isequal(cte,'')
    75                         %write constant only if it is numeric or char string, and not empty
    76                         netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),keys{iattr},cte)
    77                     end
     68            end
     69            if ~testvar               
     70                eval(['cte=Data.' keys{iattr} ';'])
     71                if (ischar(cte) ||isnumeric(cte)) &&  ~isempty(cte)%&& ~isequal(cte,'')
     72                    %write constant only if it is numeric or char string, and not empty
     73                    netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),keys{iattr},cte)
    7874                end
    7975            end
    8076        end
    8177    end
    82     %create dimensions
    83     dimid=zeros(1,length(Data.ListDimName));
    84     for idim=1:length(Data.ListDimName)
    85          dimid(idim) = netcdf.defDim(nc,Data.ListDimName{idim},Data.DimValue(idim));
    86     end
    87     VarAttribute={}; %default
    88     testattr=0;
    89     if isfield(Data,'VarAttribute')
    90         VarAttribute=Data.VarAttribute;
    91         testattr=1;
    92     end
    93     varid=zeros(1,length(Data.ListVarName));
    94     for ivar=1:length(ListVarName)
    95         varid(ivar)=netcdf.defVar(nc,ListVarName{ivar},'nc_double',dimid(Data.VarDimIndex{ivar}));%define variable 
    96     end
    97      %write variable attributes
    98     if testattr
    99         for ivar=1:min(numel(VarAttribute),numel(ListVarName)) 
    100             if isstruct(VarAttribute{ivar})
    101                 attr_names=fields(VarAttribute{ivar});
    102                 for iattr=1:length(attr_names)
    103                     eval(['attr_val=VarAttribute{ivar}.' attr_names{iattr} ';']);
    104                     if ~isempty(attr_names{iattr})&& ~isempty(attr_val)
    105                         netcdf.putAtt(nc,varid(ivar),attr_names{iattr},attr_val);
    106                     end
     78end
     79%create dimensions
     80dimid=zeros(1,length(ListDimName));
     81for idim=1:length(ListDimName)
     82     dimid(idim) = netcdf.defDim(nc,ListDimName{idim},DimValue(idim));
     83end
     84VarAttribute={}; %default
     85testattr=0;
     86if isfield(Data,'VarAttribute')
     87    VarAttribute=Data.VarAttribute;
     88    testattr=1;
     89end
     90varid=zeros(1,length(Data.ListVarName));
     91for ivar=1:length(ListVarName)
     92    varid(ivar)=netcdf.defVar(nc,ListVarName{ivar},'nc_double',dimid(VarDimIndex{ivar}));%define variable 
     93end
     94 %write variable attributes
     95if testattr
     96    for ivar=1:min(numel(VarAttribute),numel(ListVarName)) 
     97        if isstruct(VarAttribute{ivar})
     98            attr_names=fields(VarAttribute{ivar});
     99            for iattr=1:length(attr_names)
     100                eval(['attr_val=VarAttribute{ivar}.' attr_names{iattr} ';']);
     101                if ~isempty(attr_names{iattr})&& ~isempty(attr_val)
     102                    netcdf.putAtt(nc,varid(ivar),attr_names{iattr},attr_val);
    107103                end
    108104            end
    109105        end
    110106    end
    111     netcdf.endDef(nc); %put in data mode
    112     for ivar=1:length(ListVarName)
    113         if isfield(Data,ListVarName{ivar})
    114             VarVal=Data.(ListVarName{ivar});
    115             %varval=values of the current variable
    116             VarDimIndex=Data.VarDimIndex{ivar}; %indices of the variable dimensions in the list of dimensions
    117             VarDimName=Data.VarDimName{ivar};
    118             if ischar(VarDimName)
    119                 VarDimName={VarDimName};
    120             end
    121             siz=size(VarVal);
    122             testrange=(numel(VarDimName)==1 && strcmp(VarDimName{1},ListVarName{ivar}) && numel(VarVal)==2);% case of a coordinate defined on a regular mesh by the first and last values.
    123             testline=isequal(length(siz),2) && isequal(siz(1),1)&& isequal(siz(2), Data.DimValue(VarDimIndex));%matlab vector
    124             testcolumn=isequal(length(siz),2) && isequal(siz(1), Data.DimValue(VarDimIndex))&& isequal(siz(2),1);%matlab column vector
    125 %             if ~testrange && ~testline && ~testcolumn && ~isequal(siz,Data.DimValue(VarDimIndex))
     107end
     108netcdf.endDef(nc); %put in data mode
     109for ivar=1:length(ListVarName)
     110    if isfield(Data,ListVarName{ivar})
     111        VarVal=Data.(ListVarName{ivar});
     112        %varval=values of the current variable
     113%        VarDimIndex=Data.VarDimIndex{ivar}; %indices of the variable dimensions in the list of dimensions
     114        VarDimName=Data.VarDimName{ivar};
     115        if ischar(VarDimName)
     116            VarDimName={VarDimName};
     117        end
     118        siz=size(VarVal);
     119        testrange=(numel(VarDimName)==1 && strcmp(VarDimName{1},ListVarName{ivar}) && numel(VarVal)==2);% case of a coordinate defined on a regular mesh by the first and last values.
     120        testline=isequal(length(siz),2) && isequal(siz(1),1)&& isequal(siz(2), DimValue(VarDimIndex{ivar}));%matlab vector
     121        testcolumn=isequal(length(siz),2) && isequal(siz(1), DimValue(VarDimIndex{ivar}))&& isequal(siz(2),1);%matlab column vector
     122%             if ~testrange && ~testline && ~testcolumn && ~isequal(siz,DimValue(VarDimIndex))
    126123%                 errormsg=['wrong dimensions declared for ' ListVarName{ivar} ' in struct2nc.m'];
    127124%                 break
    128125%             end
    129             if testline || testrange
    130                 if testrange
    131                     VarVal=linspace(VarVal(1),VarVal(2),Data.DimValue(VarDimIndex));% restitute the whole array of coordinate values
    132                 end
    133                 netcdf.putVar(nc,varid(ivar), double(VarVal'));
    134             else
    135                 netcdf.putVar(nc,varid(ivar), double(VarVal));
    136             end     
    137         end
     126        if testline || testrange
     127            if testrange
     128                VarVal=linspace(VarVal(1),VarVal(2),DimValue(VarDimIndex{ivar}));% restitute the whole array of coordinate values
     129            end
     130            netcdf.putVar(nc,varid(ivar), double(VarVal'));
     131        else
     132            netcdf.putVar(nc,varid(ivar), double(VarVal));
     133        end     
    138134    end
    139     netcdf.close(nc)
    140 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    141 %OLD netcdf toolbox
    142 else
    143     errormsg=struct2nc_toolbox(flname,Data);
    144135end
     136netcdf.close(nc)
    145137
     138
  • trunk/src/uvmat.m

    r403 r404  
    19891989if ~isempty(filename)
    19901990    ObjectName=filename;
    1991     FieldName=[];%default
    1992     VelType=[];%default
    1993    % FileExt=get(handles.FileExt,'String');
    1994     FileType=UvData.FileType{1};
    1995     switch FileType
    1996         %     if strcmp(Ext,'.nc')||strcmp(Ext,'.cdf')
     1991    FieldName='';%default
     1992    VelType='';%default
     1993%     FileType=UvData.FileType{1};
     1994    switch UvData.FileType{1}
    19971995        case {'civx','civdata','netcdf'};
    19981996            list_fields=get(handles.Fields,'String');% list menu fields
    1999             index_fields=get(handles.Fields,'Value');% selected string index
    2000             FieldName= list_fields{index_fields}; % selected field
     1997  %          index_fields=get(handles.Fields,'Value');% selected string index
     1998            FieldName= list_fields{get(handles.Fields,'Value')}; % selected field
    20011999            if ~strcmp(FieldName,'get_field...')
    20022000                if get(handles.FixVelType,'Value')
    20032001                    VelTypeList=get(handles.VelType,'String');
    20042002                    VelType=VelTypeList{get(handles.VelType,'Value')};
    2005 %                     VelType=setfield(handles);% read the velocity type.
    20062003                end
    20072004            end
     
    20292026    ParamIn.VelType=VelType;
    20302027    ParamIn.GUIName='get_field';
    2031     [Field{1},ParamOut,errormsg] = read_field(ObjectName,FileType,ParamIn,num_i1);
     2028    [Field{1},ParamOut,errormsg] = read_field(ObjectName,UvData.FileType{1},ParamIn,num_i1);
    20322029    if ~isempty(errormsg)
    20332030        errormsg=['error in reading ' filename ': ' errormsg];
     
    20562053    end
    20572054    Name=filename_1;
    2058     FileType_1=UvData.FileType{2};
    2059     switch FileType_1
    2060         %     if strcmp(Ext,'.nc')||strcmp(Ext,'.cdf')
     2055%     FileType_1=UvData.FileType{2};
     2056    switch UvData.FileType{2}
    20612057        case {'civx','civdata','netcdf'};
    20622058            list_fields=get(handles.Fields_1,'String');% list menu fields
     
    20662062                    VelTypeList=get(handles.VelType_1,'String');
    20672063                    VelType_1=VelTypeList{get(handles.VelType_1,'Value')};% read the velocity type.
    2068 %                     VelType_1=setfield(handles);% read the velocity type.
    20692064                end
    20702065            end
     
    21022097        ParamIn.VelType=VelType_1;
    21032098        ParamIn.GUIName='get_field_1';
    2104         [Field{2},ParamOut_1,errormsg] = read_field(Name,FileType_1,ParamIn,num_i1);
     2099        [Field{2},ParamOut_1,errormsg] = read_field(Name,UvData.FileType{2},ParamIn,num_i1);
    21052100        if ~isempty(errormsg)
    21062101            errormsg=['error in reading ' FieldName_1 ' in ' filename_1 ': ' errormsg];
     
    21242119test_veltype=0;
    21252120% if ~isequal(FileType,'netcdf')|| isequal(FieldName,'get_field...')
    2126 if (strcmp(FileType,'civx')||strcmp(FileType,'civdata'))&& ~strcmp(FieldName,'get_field...')
     2121if (strcmp(UvData.FileType{1},'civx')||strcmp(UvData.FileType{1},'civdata'))&& ~strcmp(FieldName,'get_field...')
    21272122    test_veltype=1;
    21282123    set(handles.VelType,'Visible','on')
    21292124    set(handles.VelType_1,'Visible','on')
    21302125    set(handles.FixVelType,'Visible','on')
    2131     menu=set_veltype_display(ParamOut.CivStage,FileType);
     2126    menu=set_veltype_display(ParamOut.CivStage,UvData.FileType{1});
    21322127    index_menu=strcmp(ParamOut.VelType,menu);%look for VelType in  the menu
    21332128    index_val=find(index_menu,1);
     
    21542149    set(handles.Fields_1,'String',[{''};ParamOut.FieldList]); %update the field menu
    21552150else
    2156     if (~strcmp(FileType_1,'netcdf')&&~strcmp(FileType_1,'civdata')&&~strcmp(FileType_1,'civx'))|| isequal(FieldName_1,'get_field...')
     2151    if (~strcmp(UvData.FileType{2},'netcdf')&&~strcmp(UvData.FileType{2},'civdata')&&~strcmp(UvData.FileType{2},'civx'))|| isequal(FieldName_1,'get_field...')
    21572152        set(handles.VelType_1,'Visible','off')
    21582153    else
     
    22282223    end
    22292224    %% update tps in phys coordinates if needed
    2230     if (strcmp(VelType,'filter1')||strcmp(VelType,'filter2'))&& strcmp(FileType,'civdata')&&isfield(Field{1},'U')&& isfield(Field{1},'V')
     2225    if (strcmp(VelType,'filter1')||strcmp(VelType,'filter2'))&& strcmp(UvData.FileType{1},'civdata')&&isfield(Field{1},'U')&& isfield(Field{1},'V')
    22312226        Field{1}.X=Field{1}.X(Field{1}.FF==0);
    22322227        Field{1}.Y=Field{1}.Y(Field{1}.FF==0);
     
    22352230        [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,[],Field{1}.Patch1_SubDomain,0);
    22362231    end
    2237     if numel(Field)==2 && ~test_keepdata_1 && isequal(FileType_1(1:3),'civ') && ~isequal(ParamOut_1.FieldName,'get_field...')%&&~isempty(FieldName_1)
     2232    if numel(Field)==2 && ~test_keepdata_1 && isequal(UvData.FileType{2}(1:3),'civ') && ~isequal(ParamOut_1.FieldName,'get_field...')%&&~isempty(FieldName_1)
    22382233        %update tps in phys coordinates if needed
    2239         if (strcmp(VelType_1,'filter1')||strcmp(VelType_1,'filter2'))&& strcmp(FileType_1,'civdata')&&isfield(Field{2},'U')&& isfield(Field{2},'V')
     2234        if (strcmp(VelType_1,'filter1')||strcmp(VelType_1,'filter2'))&& strcmp(UvData.FileType{2},'civdata')&&isfield(Field{2},'U')&& isfield(Field{2},'V')
    22402235            Field{2}.X=Field{2}.X(Field{2}.FF==0);
    22412236            Field{2}.Y=Field{1}.Y(Field{2}.FF==0);
     
    22562251
    22572252%% combine the two input fields (e.g. substract velocity fields)
     2253Field{1}.FieldList=[{ParamOut.FieldName} {ParamOut.ColorVar}];
    22582254if numel(Field)==2
     2255    Field{2}.FieldList=[{ParamOut_1.FieldName} {ParamOut_1.ColorVar}];
    22592256   [UvData.Field,errormsg]=sub_field(Field{1},Field{2}); 
    22602257else
     
    22652262    return
    22662263end
    2267 UvData.Field.FieldList={FieldName}; % TODO: to generalise, used for proj_field with tps interpolation
     2264%UvData.Field.FieldList={FieldName}; % TODO: to generalise, used for proj_field with tps interpolation
     2265
    22682266
    22692267%% get bounds and mesh (needed for mouse action and to open set_object)
    22702268test_x=0;
    22712269test_z=0;% test for unstructured z coordinate
    2272 [UvData.Field,errormsg]=check_field_structure(UvData.Field);
     2270[errormsg,ListDimName,DimValue,VarDimIndex]=check_field_structure(UvData.Field);
    22732271if ~isempty(errormsg)
    22742272    errormsg=['error in uvmat/refresh_field/check_field_structure: ' errormsg];
     
    23362334    else
    23372335        VarIndex=CellVarIndex{imax}; % list of variable indices
    2338         DimIndex=UvData.Field.VarDimIndex{VarIndex(1)}; %list of dim indices for the variable
    2339         nbpoints_x=UvData.Field.DimValue(DimIndex(NbDim));
     2336        DimIndex=VarDimIndex{VarIndex(1)}; %list of dim indices for the variable
     2337        nbpoints_x=DimValue(DimIndex(NbDim));
    23402338        DX=(XMax-XMin)/(nbpoints_x-1);
    23412339        if NbDim >1
    2342             nbpoints_y=UvData.Field.DimValue(DimIndex(NbDim-1));
     2340            nbpoints_y=DimValue(DimIndex(NbDim-1));
    23432341            DY=(YMax-YMin)/(nbpoints_y-1);
    23442342        end
    23452343        if NbDim==3
    2346             nbpoints_z=UvData.Field.DimValue(DimIndex(1));
     2344            nbpoints_z=DimValue(DimIndex(1));
    23472345            DZ=(ZMax-ZMin)/(nbpoints_z-1);
    23482346            UvData.Field.Mesh=(DX*DY*DZ)^(1/3);
     
    23522350            UvData.Field.Mesh=DX;%sqrt(DX*DY);
    23532351        end
     2352    end
     2353    % adjust the mesh to a value 1, 2 , 5 *10^n
     2354    ord=10^(floor(log10(UvData.Field.Mesh)));%order of magnitude
     2355    if UvData.Field.Mesh/ord>=5
     2356        UvData.Field.Mesh=5*ord;
     2357    elseif UvData.Field.Mesh/ord>=2
     2358        UvData.Field.Mesh=2*ord;
     2359    else
     2360        UvData.Field.Mesh=ord;
    23542361    end
    23552362end
     
    23622369    ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider
    23632370    if ~isempty(hset_object) %if set_object is detected
    2364 %         hhset_object=guidata(hset_object);
    2365 % %         ZBounds_old(1)=get(hhset_object.z_slider,'Min');
    2366 % %         ZBounds_old(2)=get(hhset_object.z_slider,'Max');
    2367 % %         if isequal(ZBounds_old,ZBounds)
    2368 %             test_set_object=0;% do not refresh the GUI set_object
    2369 %         else
    2370             delete(hset_object);% delete the GUI set_object if it does not fit
    2371 %         end
     2371          delete(hset_object);% delete the GUI set_object if it does not fit
    23722372    end
    23732373    if test_set_object% reinitiate the GUI set_object
     
    23802380        UvData.Object{1}.Coord(1,3)=(UvData.Field.ZMin+UvData.Field.ZMax)/2;%section at a middle plane chosen
    23812381        UvData.Object{1}.Angle=[0 0 0];
    2382 %         UvData.Object{1}.Theta=0;
    2383 %         UvData.Object{1}.Psi=0;
    23842382        UvData.Object{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR
    2385 %         PlotHandles=get_plot_handles(handles);
    23862383        UvData.Object{1}.Name='1-PLANE';
    23872384        UvData.Object{1}.enable_plot=1;
     
    24602457     PlotParam{1}.Vectors.ListColorCode= {'rgb'};
    24612458end
    2462 keeplim(1)=get(handles.CheckFixLimits,'Value');% test for fixed graph limits
     2459%keeplim(1)=get(handles.CheckFixLimits,'Value');% test for fixed graph limits
    24632460PosColorbar{1}=UvData.OpenParam.PosColorbar;%prescribe the colorbar position on the uvmat interface
    24642461
     
    24712468        %PlotParam{2}=read_plot_param(plot_handles{2});%read plotting parameters on the viewinterface
    24722469        PlotParam{2}=read_GUI(handles.uvmat);%read plotting parameters on the uvmat interface
    2473         keeplim(2)=get(plot_handles{2}.CheckFixLimits,'Value');
     2470       % keeplim(2)=get(plot_handles{2}.CheckFixLimits,'Value');
    24742471        PosColorbar{2}='*'; %TODO: deal with colorbar position on view_field
    24752472    end
     
    24792476for imap=1:numel(IndexObj)
    24802477    iobj=IndexObj(imap);
    2481 %     if iobj==1 && ~isfield(UvData.Object{iobj},'Type')% case with no projection (only for the first empty object)
    2482 %         ord=10^(floor(log10(UvData.Field.Mesh)));%order of magnitude
    2483 %         if UvData.Field.Mesh/ord>=5
    2484 %             mesh=5*ord;
    2485 %         elseif UvData.Field.Mesh/ord>=2
    2486 %             mesh=2*ord;
    2487 %         else
    2488 %             mesh=ord;
    2489 %         end
    2490 %         coord_x=UvData.Field.XMin:mesh:UvData.Field.XMax;
    2491 %         coord_y=UvData.Field.YMin:mesh:UvData.Field.YMax;
    2492 %         [XI,YI]=meshgrid(coord_x,coord_y);
    2493 %         XI=reshape(XI,[],1);
    2494 %         YI=reshape(YI,[],1);
    2495 %         [ObjectData,errormsg]=calc_field({FieldName},UvData.Field,[XI YI]);
    2496 %     else
     2478     if iobj==1 && ~isfield(UvData.Object{iobj},'Type')% case with no projection (only for the first empty object)
     2479         [ObjectData,errormsg]=calc_field(UvData.Field.FieldList,UvData.Field);
     2480     else
    24972481        [ObjectData,errormsg]=proj_field(UvData.Field,UvData.Object{iobj});% project field on the object
    2498 %     end
     2482     end
    24992483    if ~isempty(errormsg)
    25002484        return
     
    25392523            end
    25402524            ObjectData.ListVarName(ind_off)=[];
    2541             ObjectData.VarDimIndex(ind_off)=[];
     2525            VarDimIndex(ind_off)=[];
    25422526            ind_off=[];
    2543             for ilist=1:length(ObjectData.ListDimName)
    2544                 if isequal(ObjectData.ListDimName{ilist},'MaskX') || isequal(ObjectData.ListDimName{ilist},'MaskY')
     2527            for ilist=1:length(ListDimName)
     2528                if isequal(ListDimName{ilist},'MaskX') || isequal(ListDimName{ilist},'MaskY')
    25452529                    ind_off=[ind_off ilist];
    25462530                end
    25472531            end
    2548             ObjectData.ListDimName(ind_off)=[];
    2549             ObjectData.DimValue(ind_off)=[];
     2532            ListDimName(ind_off)=[];
     2533            DimValue(ind_off)=[];
    25502534        end
    25512535    end
    25522536    if ~isempty(ObjectData)
     2537       
    25532538        PlotType='none'; %default
    25542539        if imap==2 && isempty(view_field_handle)
     
    32373222        data.CoordType=UvData.CoordType;
    32383223    end
    3239     if isfield(UvData,'Mesh')&~isempty(UvData.Mesh)
    3240         data.RangeY=UvData.Mesh;
    3241         data.RangeX=UvData.Mesh;
    3242         data.DX=UvData.Mesh;
    3243         data.DY=UvData.Mesh;
     3224    if isfield(UvData.Field,'Mesh')&~isempty(UvData.Field.Mesh)
     3225        data.RangeX=[UvData.Field.XMin UvData.Field.XMax];
     3226        data.RangeY=[UvData.Field.YMin UvData.Field.YMax];
     3227        data.DX=UvData.Field.Mesh;
     3228        data.DY=UvData.Field.Mesh;
    32443229    elseif isfield(UvData.Field,'AX')&isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')%only image
    32453230        np=size(UvData.Field.A);
     
    43284313if isfield(UvData,'Field')
    43294314    Field=UvData.Field;
    4330     if isfield(Field,'Mesh')&&~isempty(Field.Mesh)
    4331         ord=10^(floor(log10(Field.Mesh)));%order of magnitude
    4332         if Field.Mesh/ord>=5
    4333             mesh=5*ord;
    4334         elseif Field.Mesh/ord>=2
    4335             mesh=2*ord;
    4336         else
    4337             mesh=ord;
    4338         end
    4339         data.RangeX=mesh;
    4340         data.RangeY=mesh;
    4341         data.DX=mesh;
    4342         data.DY=mesh;
    4343     elseif isfield(Field,'AX')&& isfield(Field,'AY')&& isfield(Field,'A')%only image
    4344         np=size(Field.A);
    4345         meshx=(Field.AX(end)-Field.AX(1))/np(2);
    4346         meshy=abs(Field.AY(end)-Field.AY(1))/np(1);
    4347         data.RangeY=max(meshx,meshy);
    4348         data.RangeX=max(meshx,meshy);
    4349         data.DX=max(meshx,meshy);
     4315    if isfield(UvData.Field,'Mesh')&&~isempty(UvData.Field.Mesh)
     4316        data.RangeX=[UvData.Field.XMin UvData.Field.XMax];
     4317        data.RangeY=[UvData.Field.YMin UvData.Field.YMax];
     4318        data.DX=UvData.Field.Mesh;
     4319        data.DY=UvData.Field.Mesh;
     4320%     elseif isfield(Field,'AX')&& isfield(Field,'AY')&& isfield(Field,'A')%only image
     4321%         np=size(Field.A);
     4322%         meshx=(Field.AX(end)-Field.AX(1))/np(2);
     4323%         meshy=abs(Field.AY(end)-Field.AY(1))/np(1);
     4324%         data.RangeY=max(meshx,meshy);
     4325%         data.RangeX=max(meshx,meshy);
     4326%         data.DX=max(meshx,meshy);
    43504327    end
    43514328    if isfield(Field,'NbDim')&& isequal(Field.NbDim,3)
     
    43604337end
    43614338hset_object=findobj(allchild(0),'tag','set_object');
    4362 IndexObj=get(handles.ListObject,'Value')
     4339IndexObj=get(handles.ListObject,'Value');
    43634340if ~isempty(hset_object)
    43644341    delete(hset_object)% delete existing version of set_object
Note: See TracChangeset for help on using the changeset viewer.