Changeset 56


Ignore:
Timestamp:
Mar 17, 2010, 1:30:15 PM (14 years ago)
Author:
sommeria
Message:

uvmat: edit vector button activated
debugging and cleaning after modifications made with the windows version

Location:
trunk/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/RUN_FIX.m

    r47 r56  
    153153    netcdf.close(nc)
    154154else %old netcdf library
    155     nc=netcdf(filename,'write'); %open netcdf file for writing
    156     result=redef(nc);
    157     if isempty(result), msgbox_uvmat('ERROR','##Bad redef operation.'),end 
    158     if iter==1
    159         nc.fix=1;
    160     elseif iter==2
    161         nc.fix2=1;
    162     end
    163     nc{field.fixflag}=ncfloat(field.nb);
    164     fixflag_unit=Field.FF-10*floor(Field.FF/10); %unity term of fix_flag
    165     nc{field.fixflag}(:)=fixflag_unit+10*flagmagenta;
    166     close(nc);
     155    netcdf_toolbox(filename,Field,flagmagenta,iter,field)
    167156end
     157
     158function netcdf_toolbox(filename,Field,flagmagenta,iter,field)
     159nc=netcdf(filename,'write'); %open netcdf file for writing
     160result=redef(nc);
     161if isempty(result), msgbox_uvmat('ERROR','##Bad redef operation.'),end 
     162if iter==1
     163    nc.fix=1;
     164elseif iter==2
     165    nc.fix2=1;
     166end
     167nc{field.fixflag}=ncfloat(field.nb);
     168fixflag_unit=Field.FF-10*floor(Field.FF/10); %unity term of fix_flag
     169nc{field.fixflag}(:)=fixflag_unit+10*flagmagenta;
     170close(nc);
  • trunk/src/get_field.m

    r55 r56  
    134134%------------------------------------------------------------------------
    135135inputfile=get(handles.inputfile,'String');
    136 Field=nc2struct(inputfile,[]);% reads only the lists of fields, dimensions and attributes
     136Field=nc2struct(inputfile);% reads the whole field
    137137hfig=get(handles.inputfile,'parent');
    138138set(hfig,'UserData',Field);
     
    171171set(handles.scalar,'Value',1)
    172172set(handles.scalar,'String', Txt )
    173 
     173'TESTget'
     174Field
    174175[CellVarIndex,NbDim,VarType,errormsg]=find_field_indices(Field);
    175176if ~isempty(errormsg) 
  • trunk/src/nc2struct.m

    r55 r56  
    33% The corresponding dimensions and variable attributes are then extracted
    44%----------------------------------------------------------------------
    5 % function [Data,var_detect,ichoice]=nc2struct(nc,ListVarName)
     5% function [Data,var_detect,ichoice]=nc2struct(nc,varargin)
    66%
    77% OUTPUT:
     
    1919%INPUT:
    2020%     nc:      name of a netcdf file (char string) or netcdf object   
    21 % ListVarName: optional list of variable names to select (cell array of  char strings {'VarName1', 'VarName2',...} )
    22 %         if ListVarName=[] or {}, no variables is read (only global attributes and lists of dimensions, variables and attriburtes)
     21%    additional arguments:
     22%         -in the absence of other arguments, all the fields are read
     23%         -a cell array, ListVarName, of  char strings {'VarName1', 'VarName2',...} )
     24%         if ListVarName=[] or {}, no variables is read (only global attributes)
    2325%         if ListVarName is absent, or = '*', ALL the variables are read.
    2426%        if ListVarName is a cell array with n lines, the set of variables
    2527%                        will be sought by order of priority in the list, while output names will be set by the first line
     28%        - the string 'ListGlobalAttribute' followed by a list of attribute  names: reads only these attributes (fast reading)
    2629%
    2730%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
     
    4245   
    4346function [Data,var_detect,ichoice]=nc2struct(nc,varargin)
    44 List=varargin;
     47
    4548if isempty(varargin)
    46     List{1}='*';
     49    varargin{1}='*';
    4750end
    48 % if ~exist('ListVarName','var')
    49 %     ListVarName='*';
    50 % end
    5151hhh=which('netcdf.open');% look for built-in matlab netcdf library
    5252
     
    6969    end
    7070    % short reading of global attributes
    71     if isequal(List{1},'ListGlobalAttribute')
    72         for ilist=2:numel(List)
     71    if isequal(varargin{1},'ListGlobalAttribute')
     72        for ilist=2:numel(varargin)
    7373            try
    74             valuestr = netcdf.getAtt(nc,netcdf.getConstant('NC_GLOBAL'),List{ilist});
     74            valuestr = netcdf.getAtt(nc,netcdf.getConstant('NC_GLOBAL'),varargin{ilist});
    7575            catch
    7676                valuestr=[];
    7777            end
    78             eval(['Data.' List{ilist} '=valuestr;'])
     78            eval(['Data.' varargin{ilist} '=valuestr;'])
    7979        end
    8080        netcdf.close(nc)
     
    8383
    8484    % reading of variables, including attributes
    85     ListVarName=List{1}; 
     85    ListVarName=varargin{1}; 
    8686    [ndims,nvars,ngatts]=netcdf.inq(nc);%nbre of dimensions, variables, attributes
    8787   
  • trunk/src/nc2struct_toolbox.m

    r19 r56  
    7979   ListVarName='*';
    8080else
    81 if isempty(List{1})
    82     ListVarName='*';
    83 else
    84     ListVarName=List{1}; 
    85 end
     81%     if isempty(List{1})
     82%         ListVarName='*';
     83%     else
     84        ListVarName=List{1}; 
     85%     end
    8686end
    8787%  -------- read global attributes -----------             
  • trunk/src/read_get_field.m

    r55 r56  
    532532        if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=field_var_index
    533533            if isfield(Field.VarAttribute{field_var_index},'Coord_2')&& isfield(Field.VarAttribute{field_var_index},'Coord_1')
    534 %                 Coord_2=Field.VarAttribute{field_var_index}.Coord_2;
    535 %                 Coord_1=Field.VarAttribute{field_var_index}.Coord_1;
     534                 Coord_2=Field.VarAttribute{field_var_index}.Coord_2;
     535                 Coord_1=Field.VarAttribute{field_var_index}.Coord_1;
    536536                testold=1;
    537537            end
     
    659659        if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=field_var_index
    660660            if isfield(Field.VarAttribute{field_var_index},'Coord_2')&& isfield(Field.VarAttribute{field_var_index},'Coord_1')
    661 %                 Coord_2=Field.VarAttribute{field_var_index}.Coord_2;
    662 %                 Coord_1=Field.VarAttribute{field_var_index}.Coord_1;
     661                 Coord_2=Field.VarAttribute{field_var_index}.Coord_2;
     662                 Coord_1=Field.VarAttribute{field_var_index}.Coord_1;
    663663                testold=1;
    664664            end
  • trunk/src/uvmat.m

    r55 r56  
    822822   set(handles.Fields,'String',{'image';'get_field...';'velocity';'vort';'div';'more...'})
    823823elseif isequal(FileExt,'.nc')||isequal(FileExt,'.cdf')
    824    Data=nc2struct(FileName,[]);
     824   Data=nc2struct(FileName,'ListGlobalAttribute','absolut_time_T0','civ');
    825825   col_vec=get(handles.col_vec,'String');
    826    if isfield(Data,'absolut_time_T0')%&& (isfield(Data,'civ1')||isfield(Data,'civ'))
     826   if isfield(Data,'absolut_time_T0')&& ~(isfield(Data,'civ') && isequal(Data.civ,0))
    827827       set(handles.Fields,'String',{'image';'get_field...';'velocity';'vort';'div';'more...'})
    828828       set(handles.Fields,'Value',3) % set menu to 'velocity'
     
    19861986    Field{1}.CoordUnit='pixel'; %used for mouse_motion
    19871987end
     1988
     1989%read a second image
    19881990if ~isfield(UvData,'Txt')&& ~isempty(filename_1) && isequal(FieldName_1,'image')
    19891991    switch FileType_1
     
    27302732    netcdf.close(nc) 
    27312733else %old netcdf library
    2732     nc=netcdf(filename,'write'); %open netcdf file
    2733     result=redef(nc);
    2734     eval(['nc.' attrname '=1;']);
    2735     theDim=nc(nbname) ;% get the number of velocity vectors
    2736     nb_vectors=size(theDim);
    2737     var_FixFlag=ncvar(flagname,nc);% var_FixFlag will be written as the netcdf variable vec_FixFlag
    2738     var_FixFlag(1:nb_vectors)=AxeData.FF;%
    2739     fin=close(nc);
    2740 end
    2741 
    2742 
    2743 
    2744 
    2745 
    2746 
    2747 
     2734    netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
     2735end
     2736
     2737function netcdf_toolbox(filename,AxeData,attrname,nbname,flagname)
     2738nc=netcdf(filename,'write'); %open netcdf file
     2739result=redef(nc);
     2740eval(['nc.' attrname '=1;']);
     2741theDim=nc(nbname) ;% get the number of velocity vectors
     2742nb_vectors=size(theDim);
     2743var_FixFlag=ncvar(flagname,nc);% var_FixFlag will be written as the netcdf variable vec_FixFlag
     2744var_FixFlag(1:nb_vectors)=AxeData.FF;%
     2745fin=close(nc);
    27482746
    27492747
Note: See TracChangeset for help on using the changeset viewer.