Changeset 55 for trunk/src


Ignore:
Timestamp:
Mar 17, 2010, 10:26:41 AM (15 years ago)
Author:
sommeria
Message:

-use of a single parameter file PARAM.xml (instead of PARAM_WIN and PARAM_LINUX).
-correction of a bug for opening an existing projection object
-manual editing of vectors made available with the builtin netcdf tool.
-bug fix for reading netcdf files with the builtin netcdf tool.

Location:
trunk/src
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r54 r55  
    139139    patch_new_exe=sparam.PatchNew_exe;
    140140end
     141
     142if isfield(sparam,'SGE')
     143    sge=str2double(sparam.SGE);
     144end   
     145
     146test_batch=sge;%default
    141147if isfield(sparam,'Todo_path')
    142148    todo_path=sparam.Todo_path;
    143 end
    144 if isfield(sparam,'SGE')
    145     sge=str2num(sparam.SGE);
    146 end   
    147 name_todo=fullfile(todo_path,'TODO.txt');
    148 test_batch=1;
    149 if ~sge
    150     if isequal(todo_path,'') || isequal(todo_path,[])
    151         display(['no batch distributed processing available:file path TODO.txt not defined in UVMAT/PARAM.xml'])
    152         test_batch=0;
    153     end
    154     if exist(name_todo,'file')~=2
    155         msgbox_uvmat('WARNING',['no batch distributed processing available, queue file ' name_todo ' absent']);
    156       %  test_batch=0;  % Problems to detect file on linux/nfs filesystems
     149    name_todo=fullfile(todo_path,'TODO.txt');
     150    if exist(name_todo,'file')
     151        test_batch=1;
    157152    end
    158153end
  • trunk/src/editxml.m

    r54 r55  
    185185    testupfile=0;
    186186    DataIn=get(get(hObject,'parent'),'UserData');
    187     if isfield(DataIn,'UpFile')&~isempty(DataIn.UpFile)
     187    if isfield(DataIn,'UpFile')&&~isempty(DataIn.UpFile)
    188188        [UpPath,UpName,UpExt]=fileparts(DataIn.UpFile{1});
    189189        if isequal(UpExt,'.xml')
     
    283283CurrentFile=fullfile(PathName,FileName);
    284284sizf=size(CurrentFile);
    285 if (~ischar(CurrentFile)|~isequal(sizf(1),1)),return;end% keep only character strings as input file name
     285if (~ischar(CurrentFile)||~isequal(sizf(1),1)),return;end% keep only character strings as input file name
    286286if exist(CurrentFile,'file')
    287287%     set(handles.CurrentAttributes,'UserDataIn',PathName); %store the path to the xml file
    288288    [CurPath,CurName,CurExt]=fileparts(CurrentFile);
    289289    if isequal(CurExt,'.xls')   
    290         if isfield(DataIn,'hfig_xls')&ishandle(DataIn.hfig_xls)
     290        if isfield(DataIn,'hfig_xls') && ishandle(DataIn.hfig_xls)
    291291            [hfig_xls]=read_xls(CurrentFile,DataIn.hfig_xls);
    292292        else
     
    310310t=xmltree(CurrentFile);%open the xml file
    311311head_element=get(t,1);
    312 if ~isfield(head_element,'name') | ~isfield(head_element,'attributes')
     312if ~isfield(head_element,'name') || ~isfield(head_element,'attributes')
    313313    msgbox_uvmat('ERROR','root element of the .xml file not in correct format')
    314314end
     
    317317xstest=0;
    318318for iattr=1:length(head_attr)
    319     if isequal(head_attr{iattr}.key,'xmlns:xsi')& isequal(head_attr{iattr}.val,'none')%no schema to read
     319    if isequal(head_attr{iattr}.key,'xmlns:xsi')&& isequal(head_attr{iattr}.val,'none')%no schema to read
    320320         xs=[];
    321321%          xstest=1;
    322322    end
    323     if isequal(head_attr{iattr}.key,'xsi:noNamespaceSchemaLocation') & exist(head_attr{iattr}.val,'file')
     323    if isequal(head_attr{iattr}.key,'xsi:noNamespaceSchemaLocation') && exist(head_attr{iattr}.val,'file')
    324324        DataIn.Schema=head_attr{iattr}.val;
    325325        xs=xmltree(DataIn.Schema);%open the associated schema file
     
    332332    path_uvmat=which('editxml');% check the path detected for source file uvmat
    333333    path_UVMAT=fileparts(path_uvmat); %path to UVMAT
    334 %     if isunix
    335 xmlparam=fullfile(path_UVMAT,'PARAM.xml');
    336 if exist(xmlparam,'file')
    337     tparam=xmltree(xmlparam);
    338     sparam=convert(tparam);
    339     if isfield(sparam,'SchemaPath')
    340         schemapath=[fullfile(sparam.SchemaPath,head_name) '.xsd']
    341     end
    342     if exist(fullfile(path_UVMAT,schemapath)
    343         schemapath=fullfile(path_UVMAT,schemapath);%look for relative path definition
    344     end
    345     schemapath=fullfile(path_UVMAT,schemapath);
    346 %         schemapath=['/coriolis/papillon/data/civbin/XML_SCHEMAS/' head_name '.xsd']%current dir for schema
    347 %     else
    348 %         xmlparam=fullfile(path_UVMAT,'PARAM_WIN.xml')
    349 %         if exist(xmlparam,'file')
    350 %             tparam=xmltree(xmlparam);
    351 %             sparam=convert(tparam)
    352 %             if isfield(sparam,'SchemaPath')
    353 %                 schemapath=[fullfile(sparam.SchemaPath,head_name) '.xsd']
    354 %             end
    355 %         end
    356 %         schemapath=['\\Papillon\data\civbin\XML_SCHEMAS\' head_name '.xsd']%current dir for schemas
    357 %     end
    358     if exist(schemapath,'file')
    359         xs=xmltree(schemapath);
    360     else
    361         msgbox_uvmat('ERROR',['The xml schema for ' CurrentFile ' is unknown, check the schema path set in the file PARAM.xml'])
    362         [FileName, PathName]=uigetfile( ...
    363        {'*.xsd', '(*.xsd)';
    364         '*.xsd',  '.xsd files '; ...
    365         '*.*',  'All Files (*.*)'}, ...
    366         ['Pick a .xsd schema'] ,schemapath); %file browser
    367         if ischar(PathName)&ischar(FileName)& exist(fullfile(PathName,FileName),'file')
    368             DataIn.Schema=fullfile(PathName,FileName);
    369             xs=xmltree(DataIn.Schema);%open the associated schema file
     334    xmlparam=fullfile(path_UVMAT,'PARAM.xml');
     335    if exist(xmlparam,'file')
     336        tparam=xmltree(xmlparam);
     337        sparam=convert(tparam);
     338        if isfield(sparam,'SchemaPath')
     339            schemafile=[fullfile(sparam.SchemaPath,head_name) '.xsd'];
     340        end
     341        if ~exist(schemafile,'file')
     342            schemafile=fullfile(path_UVMAT,schemafile);%look for relative path definition
     343        end
     344        if exist(schemafile,'file')
     345            xs=xmltree(schemafile);
    370346        else
    371             xs=[];
     347            msgbox_uvmat('ERROR',['The xml schema for ' CurrentFile ' is unknown, check the schema path set in the file PARAM.xml'])
     348            [FileName, PathName]=uigetfile( ...
     349           {'*.xsd', '(*.xsd)';
     350            '*.xsd',  '.xsd files '; ...
     351            '*.*',  'All Files (*.*)'}, ...
     352            'Pick a .xsd schema' ,schemapath); %file browser
     353            if ischar(PathName) && ischar(FileName) && exist(fullfile(PathName,FileName),'file')
     354                DataIn.Schema=fullfile(PathName,FileName);
     355                xs=xmltree(DataIn.Schema);%open the associated schema file
     356            else
     357                xs=[];
     358            end
    372359        end
    373360    end
     
    376363if isempty(xs)
    377364    displ_xml(handles,t,1,DataIn,get(hObject,'parent'));%no associated schema, default  display of the xml file
    378 %    set(handles.inport_file,'Visible','off')
    379 %    set(handles.RefFile,'Visible','off')
    380365else
    381366    DataIn.xs_CurrentUid=find(xs,'/xs:schema/xs:element');%uid of the root element in the schema
     
    383368        [element,subelem]=get_xml(t,path,xs_element,1,xs_subelem);% read the corresponding xml data
    384369        update_list(handles,path,xs_element,element,1,xs_subelem,subelem);%update the display of information on the interface
    385    % set(handles.inport_file,'Visible','on')
    386    % set(handles.RefFile,'Visible','on')
    387370end
    388371set(heditxml,'UserData',DataIn);%store the new input xml file name
     
    890873end
    891874set(handles.element_value,'UserData',node)
    892 if ~testedit && isfield(element,'attrup') & isfield(element.attrup,'source')&& ~isequal(element.attrup.source,'manual')
     875if ~testedit && isfield(element,'attrup') && isfield(element.attrup,'source')&& ~isequal(element.attrup.source,'manual')
    893876     set(handles.element_value,'Enable','inactive')
    894877else
  • trunk/src/get_field.m

    r38 r55  
    228228for icell=1:numel(CellVarIndex)
    229229    VarIndex=CellVarIndex{icell};
    230     if ~isempty(find(VarIndex==yindex)) && (isempty(VarType{icell}.coord_x)||~isequal(VarType{icell}.coord_x,VarIndex))
     230    if ~isempty(find(VarIndex==yindex,1)) && (isempty(VarType{icell}.coord_x)||~isequal(VarType{icell}.coord_x,VarIndex))
    231231        cell_select=icell;
    232232        break
     
    237237set(handles.abscissa,'Value',min(val,2));
    238238coord_x_index=VarType{cell_select}.coord;
    239 coord_x_index=coord_x_index(find(coord_x_index));
     239coord_x_index=coord_x_index(coord_x_index~=0);
    240240set(handles.abscissa,'String',[{''}; (Field.ListVarName(coord_x_index))'; (Field.ListVarName(VarIndex))'])
    241241% Field.VarIndex.y=yindex;
     
    12451245%default setting for the visibility of the GUI elements*
    12461246if ~isequal(ACTION,'PLOT')
    1247     varargout=feval(ACTION)% input list asked by the selected function
     1247    varargout=feval(ACTION);% input list asked by the selected function
    12481248    test_1Dplot=[];
    12491249    test_scalar=[];
     
    12531253                           %RootFile always visible
    12541254            case 'check_1Dplot'   
    1255                  test_1Dplot=isequal(lower(varargout{ilist,2}),'y')
     1255                 test_1Dplot=isequal(lower(varargout{ilist,2}),'y');
    12561256            case 'check_scalar'
    1257                  test_scalar=isequal(lower(varargout{ilist,2}),'y')    
     1257                 test_scalar=isequal(lower(varargout{ilist,2}),'y');   
    12581258            case 'check_vector'   
    1259                  test_vector=isequal(lower(varargout{ilist,2}),'y')
     1259                 test_vector=isequal(lower(varargout{ilist,2}),'y');
    12601260        end
    12611261    end
     
    14491449set(handles.MenuFile_5,'Label',MenuFile_5)
    14501450dir_perso=prefdir;
    1451 profil_perso=fullfile(dir_perso,'uvmat_perso.mat')
     1451profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
     1452display(profil_perso)
    14521453if exist(profil_perso,'file')
    14531454    save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat
  • trunk/src/nc2struct.m

    r45 r55  
    22% it reads all the global attributes and all variables, or a selected list.
    33% The corresponding dimensions and variable attributes are then extracted
    4 %%%%%% TODO: add the possibility to read only attributes, see  nc2struct_toolbox %%%
    54%----------------------------------------------------------------------
    65% function [Data,var_detect,ichoice]=nc2struct(nc,ListVarName)
     
    98%  Data: structure containing all the information of the netcdf file (or netcdf object)
    109%           with fields:
    11 %    .ListGlobalAttribute: cell listing the names of the global attributes
    12 %        .Att_1,Att_2... : values of the global attributes
    13 %            .ListDimName: cell listing the names of the array dimensions
    14 %               .DimValue: array dimension values (Matlab vector with the same length as .ListDimName
    15 %            .ListVarName: cell listing the names of the variables
    16 %            .VarDimIndex: cell containing the set of dimension indices (in list .ListDimName) for each variable of .ListVarName
    17 %            .VarDimName: cell containing a cell of dimension names (in list .ListDimName) for each variable of .ListVarName
    18 %           .VarAttribute: cell of structures s containing names and values of variable attributes (s.name=value) for each variable of .ListVarName
    19 %        .Var1, .Var2....: variables (Matlab arrays) with names listed in .ListVarName
    20 %  var_detect: vector with same length as ListVarName, with 1 for each detected variable and 0 else.
    21 %  ichoice: = line
    22 %
     10%         (optional) .ListGlobalAttribute: cell listing the names of the global attributes
     11%                    .Att_1,Att_2... : values of the global attributes
     12%                    .ListVarName: list of variable names to select (cell array of  char strings {'VarName1', 'VarName2',...} )
     13%                    .VarDimName: list of dimension names for each element of .ListVarName (cell array of string cells)                         
     14%                    .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)
     17%                    .VarDimIndex= list of dimension indices (added information,
     18
    2319%INPUT:
    2420%     nc:      name of a netcdf file (char string) or netcdf object   
     
    4743function [Data,var_detect,ichoice]=nc2struct(nc,varargin)
    4844List=varargin;
    49 if nargin==0
     45if isempty(varargin)
    5046    List{1}='*';
    5147end
     
    122118
    123119    %  -------- read dimensions -----------
    124     dim_name={};
     120    ListDimName={};
    125121    dim_value=[];
    126122    for idim=1:ndims%length(dim_read);
    127         [dim_name{idim},dim_value(idim)] = netcdf.inqDim(nc,idim-1);
    128     end
    129     if ~isempty(dim_name) && ~isempty(dim_value)
    130         Data.ListDimName=dim_name;
    131         Data.DimValue=dim_value;
     123        [ListDimName{idim},dim_value(idim)] = netcdf.inqDim(nc,idim-1);
     124    end
     125    if ~isempty(ListDimName) %&& ~isempty(dim_value)
     126%         Data.DimValue=dim_value;
    132127%         DimIndices=[1:ndims]; %index of the dimension in the netcdf file
    133         dim_used=zeros(1,ndims);%initialize test of used dimensions
     128        flag_used=zeros(1,ndims);%initialize test of used dimensions
    134129    end
    135130 
     
    198193        end
    199194    end
    200    
    201    
     195       
    202196    %select variable attributes and associate dimensions
    203197%     var_dim_index=[]; %default
     
    211205        end
    212206        var_dim=dimids{var_index(ivar)}+1; %dimension indices used by the variable
    213         dim_used(var_dim)=ones(size(var_dim));
     207        flag_used(var_dim)=ones(size(var_dim));%flag_used =1 for the indices of used dimensions
    214208        VarDimIndex{ivar}=var_dim;
    215209
     
    233227
    234228    %select the used dimensions
    235     if isempty(var_read)
    236         if isfield(Data,'ListDimName') && isfield(Data,'DimValue')
    237         Data=rmfield(Data,'ListDimName');
    238         Data=rmfield(Data,'DimValue');
    239         end
    240     else
     229    if ~isempty(var_read)
     230%         if isfield(Data,'ListDimName') %&& isfield(Data,'DimValue')
     231%         Data=rmfield(Data,'ListDimName');
     232%         %Data=rmfield(Data,'DimValue');
     233%         end
     234%     else
    241235%         list_dim=1:ndims;
    242         dim_index=find(dim_used);
     236        dim_index=find(flag_used);
    243237%         list_dim=list_dim(dim_index);
    244         old2new=cumsum(dim_used);
    245         Data.ListDimName=Data.ListDimName(dim_index);
    246         Data.DimValue=Data.DimValue(dim_index);
     238        old2new=cumsum(flag_used);
     239        ListDimName=ListDimName(dim_index);
     240        dim_value=dim_value(dim_index);
    247241    end
    248242    for ivar=1:length(var_read)
    249         Data.VarDimIndex{ivar}=old2new(VarDimIndex{ivar});% ENLEVER Data.VarDimIndex ulterieurement
    250         Data.VarDimName{ivar}=Data.ListDimName(Data.VarDimIndex{ivar});
    251     end
     243        %Data.VarDimIndex{ivar}=old2new(VarDimIndex{ivar});% ENLEVER Data.VarDimIndex ulterieurement
     244        %Data.VarDimName{ivar}=Data.ListDimName(Data.VarDimIndex{ivar});
     245        Data.VarDimName{ivar}=ListDimName(old2new(VarDimIndex{ivar}));
     246    end
     247    Data.ListDimName=ListDimName;
     248    Data.DimValue=dim_value;
     249    Data.VarDimIndex= VarDimIndex;
    252250    %variable values
    253251    if  ~isempty(ListVarName)
     
    259257            end
    260258            eval(['Data.' VarName '=netcdf.getVar(nc,var_index(ivar)-1);'])%read the variable data
    261             eval(['siz=size(Data.' VarName ');'])
    262             if numel(siz)<=2
    263             eval(['Data.' VarName '=Data.' VarName ''';'])%read the variable data
    264             end
     259            %eval(['siz=size(Data.' VarName ');'])
     260           % if numel(siz)<=2
     261            %eval(['Data.' VarName '=Data.' VarName ''';'])%read the variable data
     262            %end
    265263        end
    266264    end
  • trunk/src/plot_field.m

    r46 r55  
    777777            test_interp=0; % no interpolation done
    778778        end
    779         if test_interp==1%if we interpolate             
     779        if test_interp==1%if we interpolate   
    780780            x=linspace(AX(1),AX(2),np(2));
    781781            y=linspace(AY(1),AY(2),np(1));
  • trunk/src/proj_field.m

    r46 r55  
    9090    return
    9191end
    92 FieldData
    9392%introduce default field properties (reading old standards)
    9493if ~isfield(ObjectData,'Style')||~isfield(ObjectData,'Coord')||~isfield(ObjectData,'ProjMode')
  • trunk/src/read_get_field.m

    r47 r55  
    708708        if testpermute(ilist)
    709709            eval(['SubField.' VarName '=permute(SubField.' VarName ',[2 1]);'])
    710             subvarindex(ilist)
    711             SubField.VarDimName{subvarindex(ilist)}
    712710            SubField.VarDimName{subvarindex(ilist)}=SubField.VarDimName{subvarindex(ilist)}([2 1]);
    713711        end
  • trunk/src/series.m

    r46 r55  
    15371537%------------------------------------------------------------------------
    15381538%     hseries=get(handles.last_i,'parent');
    1539 first_i=str2num(get(handles.first_i,'String'));
    1540 last_i=str2num(get(handles.last_i,'String'));
    1541 ref_i=ceil((first_i+last_i)/2);
    1542 set(handles.ref_i,'String', num2str(ref_i))
    1543 ref_i_Callback(hObject, eventdata, handles)
     1539% first_i=str2num(get(handles.first_i,'String'));
     1540% last_i=str2num(get(handles.last_i,'String'));
     1541% ref_i=ceil((first_i+last_i)/2);
     1542% set(handles.ref_i,'String', num2str(ref_i))
     1543% ref_i_Callback(hObject, eventdata, handles)
    15441544SeriesData=get(handles.figure1,'UserData');
    15451545if ~isfield(SeriesData,'Time')
     
    21652165ind_coord=get(handles.transform_fct,'Value');
    21662166coord_option=menu{ind_coord};
    2167 list_transform=get(handles.transform_fct,'UserData')
     2167list_transform=get(handles.transform_fct,'UserData');
    21682168ff=functions(list_transform{end});
    21692169if isequal(coord_option,'more...');
     
    22002200   if exist(profil_perso,'file')
    22012201       for ilist=nb_transform+1:numel(list_transform)
    2202            ff=functions(list_transform{ilist})
     2202           ff=functions(list_transform{ilist});
    22032203           transform_fct{ilist-nb_transform}=ff.file;
    22042204       end
  • trunk/src/series/aver_stat.m

    r43 r55  
    241241%check coincidence in time
    242242multitime=0;
    243 if length(timecell)==0
     243if isempty(timecell)
    244244    time=[];
    245245elseif length(timecell)==1
     
    454454        end
    455455        display([filemean ' written']);
    456     else %determine global attributes
     456    else %case of netcdf input file , determine global attributes
    457457        DataMean.ListGlobalAttribute=[DataMean.ListGlobalAttribute {Series.Action}];
    458458        ActionKey='Action';
     
    493493   end
    494494end
     495
    495496hget_field=findobj(allchild(0),'name','get_field');%find the get_field... GUI
    496497delete(hget_field)
  • trunk/src/set_object.m

    r41 r55  
    77% hset_object: handle of the GUI figure
    88%
    9 % INTPUT:
     9% INPUT:
    1010% data: structure describing the object properties
    11 %  PlotHandles: handles for projection plots
     11%    .Style=...
     12%    .ProjMode
     13%    .CoordType: 'phys' or 'px'
     14%    .DX,.DY,.DZ : mesh along each dirction
     15%    .RangeX, RangeY
     16%    .Coord(j,i), i=1, 2, 3,  components x, y, z of j=1...n position(s) characterizing the object components
     17% PlotHandles: handles for projection plots
    1218% Zbounds: bounds on Z ( 3D case)
    1319%
     
    8692desable_plot=0;%default
    8793SetData.PlotHandles=PlotHandles;
    88 if exist('data','var') & isfield(data,'ParentButton')
     94if exist('data','var') && isfield(data,'ParentButton')
    8995        SetData.ParentButton=data.ParentButton;
    9096        set(hObject,'DeleteFcn',{@closefcn,SetData.ParentButton})%
     
    94100% fill the interface as set in the input data:
    95101if exist('data','var')
    96 %     if isfield(data,'desable_open')
    97 %         desable_open=data.desable_open;%test to desable button OPEN (edit or display mode)
    98 %     end
    99102    if isfield(data,'desable_plot')
    100103        desable_plot=data.desable_plot;%test to desable button PLOT (display mode)
    101104    end
    102     if ~isfield(data,'NbDim')|~isequal(data.NbDim,3)%2D case
     105    if ~isfield(data,'NbDim')||~isequal(data.NbDim,3)%2D case
    103106        set(handles.ZObject,'Visible','off')
    104107        set(handles.z_slider,'Visible','off')
     
    110113        end
    111114    end
    112 %     if isfield(data,'ProjMode') && isfield(data,'Style')
    113 %         data.TITLE=set_title(data.Style,data.ProjMode);% define TITLE in set_object (POINTS, LINE, PATCH,...)
    114 %     end
    115 %     if isfield(data,'TITLE')
    116 %         menutitle=get(handles.TITLE,'String');
    117 %         for iline=1:length(menutitle)
    118 %             strmenu=menutitle{iline};
    119 %             if isequal(data.TITLE,strmenu)
    120 %                 set(handles.TITLE,'Value',iline)
    121 %                 break
    122 %             end
    123 %         end
    124 %         TITLE_Callback(hObject, eventdata, handles)% enable edit boxes depending on TITLE
    125 %     end
    126 %     if isfield(data,'fixedtitle')&isequal(data.fixedtitle,1)
    127 %         set(handles.TITLE,'enable','off')
    128 %     end
    129115    if isfield(data,'Style')
    130116        menu=get(handles.ObjectStyle,'String');
     
    147133    end
    148134    ProjMode_Callback(hObject, eventdata, handles)
    149     if isfield(data,'Coord') & size(data.Coord,2)>=2
    150         sizcoord=size(data.Coord);
    151         for i=1:sizcoord(1)
    152             XObject{i}=num2str(data.Coord(i,1),4);
    153             YObject{i}=num2str(data.Coord(i,2),4);
    154         end
    155         set(handles.XObject,'String',XObject)
    156         set(handles.YObject,'String',YObject)
    157         %set(handles.XObject,'String',mat2cell(data.Coord(:,1),sizcoord(1)))
    158         %set(handles.YObject,'String',mat2cell(data.Coord(:,2),sizcoord(1)))
    159         if sizcoord(2)>3
     135    if isfield(data,'Coord')
     136        if ischar(data.Coord)
     137            data.Coord=str2num(data.Coord);
     138        elseif iscell(data.Coord)
     139            CoordCell=data.Coord;
     140            data.Coord=zeros(numel(CoordCell),3);
     141            for iline=1:numel(CoordCell)
     142                data.Coord(iline,:)=str2num(CoordCell{iline});
     143            end
     144        end
     145        if size(data.Coord,2)>=2
     146            sizcoord=size(data.Coord);
    160147            for i=1:sizcoord(1)
    161                 ZObject{i}=num2str(data.Coord(i,3),4);
     148                XObject{i}=num2str(data.Coord(i,1),4);
     149                YObject{i}=num2str(data.Coord(i,2),4);
    162150            end
    163             set(handles.ZObject,'String',ZObject)
     151            set(handles.XObject,'String',XObject)
     152            set(handles.YObject,'String',YObject)
     153            if sizcoord(2)>3
     154                for i=1:sizcoord(1)
     155                    ZObject{i}=num2str(data.Coord(i,3),4);
     156                end
     157                set(handles.ZObject,'String',ZObject)
     158            end
    164159        end
    165160    end
    166161    if isfield(data,'DX')
    167         set(handles.DX,'String',num2str(data.DX,3))
     162        if ~ischar(handles.DX)
     163            data.DX=num2str(data.DX,3);
     164        end
     165        set(handles.DX,'String',data.DX)
    168166    end
    169167    if isfield(data,'DY')
    170          set(handles.DY,'String',num2str(data.DY,3))
    171     end
    172     %OBSOLETE (replaced by Range)
    173 %     if isfield(data,'XMin')
    174 %          set(handles.XMin,'String',num2str(data.XMin,3))
    175 %     end
    176 %     if isfield(data,'XMax')
    177 %          set(handles.XMax,'String',num2str(data.XMax,3))
    178 %     end
    179 %     if isfield(data,'YMin')
    180 %          set(handles.YMin,'String',num2str(data.YMin,3))
    181 %     end
    182 %     if isfield(data,'YMax')
    183 %          set(handles.YMax,'String',num2str(data.YMax,3))
    184 %     end
     168        if ~ischar(handles.DY)
     169            data.DY=num2str(data.DY,3);
     170        end
     171        set(handles.DY,'String',data.DX)
     172    end
    185173    if isfield(data,'RangeZ') && length(ZBounds) >= 2
    186174        set(handles.ZMax,'String',num2str(max(data.RangeZ),3))
     
    197185    end
    198186    if isfield(data,'RangeX')
    199             set(handles.XMax,'String',num2str(max(data.RangeX),3))
    200             set(handles.XMin,'String',num2str(min(data.RangeX),3))
     187        if ischar(data.RangeX)
     188            data.RangeX=str2num(data.RangeX);
     189        end
     190        set(handles.XMax,'String',num2str(max(data.RangeX),3))
     191        set(handles.XMin,'String',num2str(min(data.RangeX),3))
    201192    end
    202193    if isfield(data,'RangeY')
    203             set(handles.YMax,'String',num2str(max(data.RangeY),3))
    204             set(handles.YMin,'String',num2str(min(data.RangeY),3))
     194        if ischar(data.RangeY)
     195            data.RangeY=str2num(data.RangeY);
     196        end
     197        set(handles.YMax,'String',num2str(max(data.RangeY),3))
     198        set(handles.YMin,'String',num2str(min(data.RangeY),3))
    205199    end
    206200    if isfield(data,'RangeZ')
    207             set(handles.ZMax,'String',num2str(max(data.RangeZ),3))
    208             set(handles.ZMin,'String',num2str(min(data.RangeZ),3))
     201        if ischar(data.RangeZ)
     202            data.RangeZ=str2num(data.RangeZ);
     203        end
     204        set(handles.ZMax,'String',num2str(max(data.RangeZ),3))
     205        set(handles.ZMin,'String',num2str(min(data.RangeZ),3))
    209206    end 
    210207    if isfield(data,'Phi')
    211          set(handles.Phi,'String',num2str(data.Phi,3))
     208        if ~ischar(handles.Phi)
     209            data.DY=num2str(data.Phi,3);
     210        end
     211         set(handles.Phi,'String',data.Phi)
    212212    end
    213213    if isfield(data,'Theta')
    214          set(handles.Theta,'String',num2str(data.Theta,3))
     214        if ~ischar(handles.Theta)
     215            data.DY=num2str(data.Theta,3);
     216        end
     217        set(handles.Theta,'String',data.Theta)
    215218    end
    216219    if isfield(data,'Psi')
    217          set(handles.Psi,'String',num2str(data.Psi,3))
     220         if ~ischar(handles.Psi)
     221            data.DY=num2str(data.Psi,3);
     222        end
     223         set(handles.Psi,'String',data.Psi)
    218224    end 
    219225    if isfield(data,'DZ')
    220         set(handles.DZ,'String',num2str(data.DZ,3))
     226        if ~ischar(handles.DZ)
     227            data.DY=num2str(data.DZ,3);
     228        end
     229        set(handles.DZ,'String',data.DZ)
    221230    end
    222231    if isfield(data,'CoordType')
     
    506515
    507516%-----------------------------------------------------
    508 % --- Executes on button press in OPEN.
     517% --- Executes on button press in OPEN: DESACTIVATED use uvmat browser
    509518function OPEN_Callback(hObject, eventdata, handles)
    510519%get the object file
  • trunk/src/struct2nc.m

    r45 r55  
    1010%  Data: structure containing all the information of the netcdf file (or netcdf object)
    1111%           with fields:
    12 %    .ListGlobalAttribute: cell listing the names of the global attributes (note that a global atribute with the same name as a variable is excluded)
    13 %        .Att_1,Att_2... : values of the global attributes
    14 %            .ListDimName: cell listing the names of the array dimensions
    15 %               .DimValue: array dimension values (Matlab vector with the same length as .ListDimName
    16 %            .ListVarName: cell listing the names of the variables
    17 %            .VarDimIndex: cell containing the set of dimension indices (in list .ListDimName) for each variable of .ListVarName
    18 %           .VarAttribute: cell of structures s containing names and values of variable attributes (s.name=value) for each variable of .ListVarName
    19 %        .Var1, .Var2....: variables (Matlab arrays) with names listed in .ListVarName
     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
    2017%
    2118%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
     
    126123                break
    127124            end
    128             if testline || testrange%NEW
     125            if testline || testrange
    129126                if testrange
    130                     VarVal=linspace(VarVal(1),VarVal(2),Data.DimValue(VarDimIndex));%NEW
     127                    VarVal=linspace(VarVal(1),VarVal(2),Data.DimValue(VarDimIndex));
    131128                end
    132129               %nc{ListVarName{ivar}}=ncfloat(Data.ListDimName(VarDimIndex));%vector of x coordinates
    133                netcdf.putVar(nc,varid(ivar), VarVal');
     130               netcdf.putVar(nc,varid(ivar), double(VarVal'));
    134131            else
    135                 netcdf.putVar(nc,varid(ivar), VarVal);
     132                netcdf.putVar(nc,varid(ivar), double(VarVal));
    136133                %nc{ListVarName{ivar}}(:) = VarVal;
    137134            end
  • trunk/src/uvmat.m

    r45 r55  
    14261426        Mask.Base=[FileBase Name(i:ind_mask+3)];
    14271427        Mask.NbSlice=nbslice;
    1428         num_i1=mod(num_i1-1,nbslice)+1
     1428        num_i1=mod(num_i1-1,nbslice)+1;
    14291429        Mask.NomType=Mask_NomType{1};
    1430         [maskname,mdetect]=name_generator(Mask.Base,num_i1,num_j1,'.png',Mask.NomType)%
    1431         mdetect=exist(maskname,'file')
     1430        [maskname,mdetect]=name_generator(Mask.Base,num_i1,num_j1,'.png',Mask.NomType);%
     1431        mdetect=exist(maskname,'file');
    14321432        if mdetect
    14331433            set(handles.nb_slice,'String',Name(i+1:ind_mask-1));
     
    26952695AxeData=get(gca,'UserData');
    26962696[erread,message]=fileattrib(filename);
    2697 if ~isempty(message) & ~isequal(message.UserWrite,1)
     2697if ~isempty(message) && ~isequal(message.UserWrite,1)
    26982698     msgbox_uvmat('ERROR',['no writting access to ' filename])
    26992699     return
    27002700end
    2701 nc=netcdf(filename,'write'); %open netcdf file
    2702 result=redef(nc);
    2703 if isempty(result), msgbox_uvmat('ERROR','##Bad redef operation.'),end
    27042701test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]);
    2705 if ~test_civ2
    2706     test_civ1=isequal(get(handles.civ1,'BackgroundColor'),[1 1 0]);
    2707 end
    2708 if test_civ2 % for civ2 
    2709    
    2710     theDim=nc('nb_vectors2') ;% get the number of velocity vectors
    2711     nb_vectors2=size(theDim);
    2712     var_FixFlag=ncvar('vec2_FixFlag',nc);% var_FixFlag will be written as the netcdf variable vec_FixFlag
    2713     var_FixFlag(1:nb_vectors2)=AxeData.FF;%
    2714 elseif test_civ1 % for civ1
    2715    
    2716     theDim=nc('nb_vectors') ;% get the number of velocity vectors
    2717     nb_vectors=size(theDim);
    2718      var_FixFlag=ncvar('vec_FixFlag',nc);% var_FixFlag will be written as the netcdf variable vec_FixFlag
    2719     var_FixFlag(1:nb_vectors)=AxeData.FF;%
    2720 else
     2702test_civ1=isequal(get(handles.civ1,'BackgroundColor'),[1 1 0]);
     2703if ~test_civ2 && ~test_civ1
    27212704    msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields')
    27222705end
    2723 fin=close(nc);
     2706if test_civ2
     2707    nbname='nb_vectors2';
     2708   flagname='vec2_FixFlag';
     2709   attrname='fix2';
     2710end
     2711if test_civ1
     2712    nbname='nb_vectors';
     2713   flagname='vec_FixFlag';
     2714   attrname='fix';
     2715end
     2716%write fix flags in the netcdf file
     2717hhh=which('netcdf.open');% look for built-in matlab netcdf library
     2718if ~isequal(hhh,'')% case of new builtin Matlab netcdf library
     2719    nc=netcdf.open(filename,'NC_WRITE');
     2720    netcdf.reDef(nc)
     2721    netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),attrname,1)
     2722    dimid = netcdf.inqDimID(nc,nbname);
     2723    try
     2724        varid = netcdf.inqVarID(nc,flagname);% look for already existing fixflag variable
     2725    catch
     2726        varid=netcdf.defVar(nc,flagname,'double',dimid);%create fixflag variable if it does not exist
     2727    end
     2728    netcdf.endDef(nc)
     2729    netcdf.putVar(nc,varid,AxeData.FF);
     2730    netcdf.close(nc) 
     2731else %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);
     2740end
     2741
     2742
     2743
     2744
     2745
     2746
    27242747
    27252748
     
    36803703function edit_vect_Callback(hObject, eventdata, handles)
    36813704%-------------------------------------------------------
    3682 huvmat=get(handles.edit_vect,'parent');
    3683 UvData=get(huvmat,'UserData');%read UvData properties stored on the uvmat interface
     3705
     3706UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface
    36843707if isequal(get(handles.edit_vect,'Value'),1)
     3708    test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]);
     3709    test_civ1=isequal(get(handles.civ1,'BackgroundColor'),[1 1 0]);
     3710    if ~test_civ2 && ~test_civ1
     3711        msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields')
     3712    end
    36853713    set(handles.record,'Visible','on')
    36863714    set(handles.edit_vect,'BackgroundColor',[1 1 0])
     
    36963724    UvData.MouseAction='none';
    36973725end
    3698 set(huvmat,'UserData',UvData)
     3726set(handles.uvmat,'UserData',UvData)
    36993727
    37003728%----------------------------------------------
     
    48794907% --------------------------------------------------------------------
    48804908function Menupoints_Callback(hObject, eventdata, handles)
    4881 % set(handles.create,'Visible','on')
    4882 % set(handles.create,'Value',1)
    4883 % POINTS_Callback(hObject,eventdata,handles)
    48844909data.Style='points';
    48854910data.ProjMode='projection';%default
    4886 PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
    4887 create_object(data,handles.uvmat,PlotHandles)
     4911create_object(data,handles)
    48884912
    48894913% --------------------------------------------------------------------
     
    48944918data.Style='line';
    48954919data.ProjMode='projection';%default
    4896 PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
    4897 create_object(data,handles.uvmat,PlotHandles)
     4920create_object(data,handles)
    48984921
    48994922%------------------------------------------------------------------------
     
    49024925data.Style='polyline';
    49034926data.ProjMode='projection';%default
    4904 PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
    4905 create_object(data,handles.uvmat,PlotHandles)
    4906 
    4907 % ------------------------------------------------------------------
     4927create_object(data,handles)
     4928
     4929%------------------------------------------------------------------------
    49084930function Menupolygon_Callback(hObject, eventdata, handles)
    4909 % set(handles.create,'Visible','on')
    4910 % set(handles.create,'Value',1)
    4911 % PATCH_Callback(hObject,eventdata,handles)
     4931%------------------------------------------------------------------------
    49124932data.Style='polygon';
    49134933data.ProjMode='inside';%default
    4914 PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
    4915 create_object(data,handles.uvmat,PlotHandles)
     4934create_object(data,handles)
    49164935
    49174936%------------------------------------------------------------------------
     
    49204939data.Style='rectangle';
    49214940data.ProjMode='inside';%default
    4922 PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
    4923 create_object(data,handles.uvmat,PlotHandles)
     4941create_object(data,handles)
    49244942
    49254943%------------------------------------------------------------------------
     
    49284946data.Style='ellipse';
    49294947data.ProjMode='inside';%default
    4930 PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
    4931 create_object(data,handles.uvmat,PlotHandles)
     4948create_object(data,handles)
    49324949
    49334950% ------------------------------------------------------------------
     
    49384955data.Style='plane';
    49394956data.ProjMode='projection';%default
    4940 PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
    4941 create_object(data,handles.uvmat,PlotHandles)
     4957
     4958create_object(data,handles)
    49424959
    49434960% ------------------------------------------------------------------
     
    49664983
    49674984%read the file
    4968  t=xmltree(fileinput);
    4969  data=convert(t);
    4970  if ~isfield(data,'Style')
    4971      data.Style='points';
    4972  end
    4973  if ~isfield(data,'ProjMode')
    4974      data.ProjMode='none';
    4975  end
     4985t=xmltree(fileinput);
     4986data=convert(t);
    49764987PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
    4977 create_object(data,handles.uvmat,PlotHandles)
    4978 
    4979 %------------------------------------------------------------------------
    4980 function create_object(data,huvmat,PlotHandles)
    4981 %------------------------------------------------------------------------
    4982 hset_object=findobj(allchild(0),'Name','set_object')
     4988hset_object=findobj(allchild(0),'Name','set_object');
    49834989if ~isempty(hset_object)
    49844990    delete(hset_object)% delete existing version of set_object
    49854991end
    4986 UvData=get(huvmat,'UserData');
     4992[hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface
     4993UvData.MouseAction='create_object';
     4994set(handles.uvmat,'UserData',UvData)
     4995
     4996%------------------------------------------------------------------------
     4997function create_object(data,handles)
     4998%------------------------------------------------------------------------
     4999hset_object=findobj(allchild(0),'Name','set_object');
     5000if ~isempty(hset_object)
     5001    delete(hset_object)% delete existing version of set_object
     5002end
     5003UvData=get(handles.uvmat,'UserData');
    49875004if isfield(UvData,'CoordType')
    49885005    data.CoordType=UvData.CoordType;
    49895006end
    4990 if isfield(UvData,'Mesh')&~isempty(UvData.Mesh)
     5007if isfield(UvData,'Mesh')&&~isempty(UvData.Mesh)
    49915008    data.RangeX=UvData.Mesh;
    49925009    data.RangeY=UvData.Mesh;
    49935010    data.DX=UvData.Mesh;
    49945011    data.DY=UvData.Mesh;
    4995 elseif isfield(UvData.Field,'AX')&isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')%only image
     5012elseif isfield(UvData.Field,'AX')&& isfield(UvData.Field,'AY')&& isfield(UvData.Field,'A')%only image
    49965013    np=size(UvData.Field.A);
    49975014    meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/np(2);
     
    50015018    data.DX=max(meshx,meshy);
    50025019end
    5003 if isfield(data,'DX')
    5004     data.Coord=[[0 0 0];[data.DX 0 0]]; %default
    5005 else
    5006     data.Coord=[[0 0 0];[1 0 0]]; %default
     5020data.Coord=[0 0 0]; %default
     5021if isfield(data,'Style') && isequal(data.Style,'line')
     5022    if isfield(data,'DX')
     5023        data.Coord=[[0 0 0];[data.DX 0 0]]; %default
     5024    else
     5025        data.Coord=[[0 0 0];[1 0 0]]; %default
     5026    end
    50075027end
    50085028%data.ParentButton=handles.create;
    5009 
     5029if ishandle(handles.UVMAT_title)
     5030    delete(handles.UVMAT_title)%delete the initial display of uvmat if no field has been entered
     5031end
     5032PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
    50105033[hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface
    50115034UvData.MouseAction='create_object';
    5012 set(huvmat,'UserData',UvData)
    5013 
    5014 
     5035set(handles.uvmat,'UserData',UvData)
     5036set(handles.zoom,'Value',0)
     5037zoom_Callback(handles.uvmat, [], handles)
     5038
Note: See TracChangeset for help on using the changeset viewer.