Changeset 55 for trunk/src/uvmat.m


Ignore:
Timestamp:
Mar 17, 2010, 10:26:41 AM (14 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.