Changeset 667 for trunk/src/uvmat.m


Ignore:
Timestamp:
Jul 15, 2013, 2:50:08 PM (11 years ago)
Author:
sommeria
Message:

a few bugs corrected.
multimask introduced in series
displ_uvmat transformed into disp_uvmat

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/uvmat.m

    r660 r667  
    985985    end
    986986end
    987 if (isfield(XmlData,'Time')&& ~isempty(XmlData.Time))
     987if (strcmp(FileType,'civdata')||strcmp(FileType,'civx')) && ((isfield(XmlData,'Time')&& ~isempty(XmlData.Time)))
    988988    if index==1
    989989    set(handles.TimeName,'String','xml')
     
    11821182%------------------------------------------------------------------------
    11831183% --- switch file index scanning options scan_i and scan_j in an exclusive way
     1184%------------------------------------------------------------------------
    11841185function scan_i_Callback(hObject, eventdata, handles)
    1185 %------------------------------------------------------------------------
     1186
    11861187if get(handles.scan_i,'Value')==1
    1187 %     set(handles.scan_i,'BackgroundColor',[1 1 0])
    11881188    set(handles.scan_j,'Value',0)
    11891189else
    1190 %     set(handles.scan_i,'BackgroundColor',[0.831 0.816 0.784])
    11911190    set(handles.scan_j,'Value',1)
    11921191end
     
    11951194%------------------------------------------------------------------------
    11961195% --- switch file index scanning options scan_i and scan_j in an exclusive way
     1196%------------------------------------------------------------------------
    11971197function scan_j_Callback(hObject, eventdata, handles)
    1198 %------------------------------------------------------------------------
     1198
    11991199if get(handles.scan_j,'Value')==1
    1200 %     set(handles.scan_j,'BackgroundColor',[1 1 0])
    12011200    set(handles.scan_i,'Value',0)
    1202 %     set(handles.scan_i,'BackgroundColor',[0.831 0.816 0.784])
    1203 %     NomType=get(handles.NomType,'String');
    1204 %     switch NomType
    1205 %     case {'_1_1-2','#_ab','%3dab'},% pair with j index
    1206 %         set(handles.CheckFixPair,'Visible','on')% option fixed pair on/off made visible (choice of avaible pair with buttons + and - if ='off')
    1207 %     otherwise
    1208 %         set(handles.CheckFixPair,'Visible','off')
    1209 %     end
    12101201else
    1211 %     set(handles.scan_j,'BackgroundColor',[0.831 0.816 0.784])
    12121202    set(handles.scan_i,'Value',1)
    1213 %     set(handles.scan_i,'BackgroundColor',[1 1 0])
    12141203    set(handles.CheckFixPair,'Visible','off')
    12151204end
     
    13451334        ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray
    13461335        check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files
    1347         ListFiles=ListCells(1,:);%list of file names
    1348         ListFiles=ListFiles(~check_dir);
     1336        ListFiles=ListCells(1,:);%list of file and dri names
     1337        ListFiles=ListFiles(~check_dir);%list of file names (excluding dir)
    13491338        if ~isempty(ListFiles)
    13501339            [tild,tild,MaskExt]=fileparts(ListFiles{1});
    1351             [tild,tild,MaskFile,i1_series,i2_series,j1_series,j2_series,MaskNomType,MaskFileType]=find_file_series(MaskPath,ListFiles{1});
     1340            [tild,tild,MaskFile,i1_series,i2_series,j1_series,j2_series,MaskNomType,MaskFileType]=find_file_series(MaskPath,ListFiles{1},0);
    13521341            if strcmp(MaskFileType,'image') && isempty(i2_series) && isempty(j2_series)
    13531342                mdetect=1;
     
    13561345    end
    13571346    if mdetect==0
    1358         MaskFullName=uigetfile_uvmat('pick a mask image file:',fullfile(RootPath,SubDir),'image');
     1347        MaskFullName=uigetfile_uvmat('pick a mask image file:',RootPath,'image');
    13591348        if isempty(MaskFullName)
    13601349            set(handles.CheckMask,'Value',0)
    13611350        end
    13621351        [MaskPath,MaskName,MaskExt]=fileparts(MaskFullName);
    1363         [tild,tild,MaskFile,i1_series,i2_series,j1_series,j2_series,MaskNomType]=find_file_series(MaskPath,[MaskName MaskExt]);
     1352        [tild,tild,MaskFile,i1_series,i2_series,j1_series,j2_series,MaskNomType]=find_file_series(MaskPath,[MaskName MaskExt],0);
    13641353        if ~(isempty(i2_series) && isempty(j2_series))
    13651354            MaskNomType='*';
     
    21492138    set(handles.num_Npy,'String',num2str(ParamOut.Npy));
    21502139end
    2151 %
    2152 % if isfield(ParamOut,'TimeIndex')% case of time obtained from get_field
    2153 %     set(handles.i1,'String',num2str(ParamOut.TimeIndex))
    2154 % end
    2155 % if isfield(ParamOut,'TimeValue')
    2156 %     Field{1}.Time=ParamOut.TimeValue;% case of time obtained from get_field
    2157 % end
    21582140Field{1}.ZIndex=z_index; %used for multiplane 3D calibration
    2159 
    21602141
    21612142%% choose and read a second field FileName_1 if defined
     
    22752256    set(handles.VelType,'Visible','off')
    22762257end
    2277 % display the FieldName menu from the input file and pick the selected one:
    2278 % if isstruct(ParamOut)
    2279 %     field_index=strcmp(ParamOut.FieldName,ParamOut.FieldList);
    2280 %     set(handles.FieldName,'String',ParamOut.FieldList); %update the field menu
    2281 %     set(handles.FieldName,'Value',find(field_index,1))
    2282 % end
    22832258
    22842259%% update the display menu for the second velocity type (second menuline)
     
    23022277    % update the second field menu: the same quantity
    23032278    if isstruct(ParamOut_1)
    2304 %        set(handles.FieldName_1,'String',[{''};ParamOut_1.FieldList]); %update the field menu
    23052279        % display the FieldName menu from the input file and pick the selected one:
    23062280        FieldList=get(handles.FieldName_1,'String');
     
    23162290    set(handles.FixVelType,'Visible','off')
    23172291end
    2318 
    2319 % field_index=strcmp(ParamOut_1.FieldName,ParamOut_1.FieldList);
    2320 % set(handles.FieldName,'String',ParamOut.FieldList); %update the field menu
    2321 % set(handles.FieldName,'Value',find(field_index,1))
    23222292   
    23232293%% introduce w as background image by default for a new series (only for nbdim=2)
     
    23872357    end
    23882358end
    2389 % if isfield(Field{1},'Time')
    2390 %     abstime=Field{1}.Time;%time read from the netcdf input file
    2391 % end
    2392 % if numel(Field)==2 && isfield(Field{2},'Time')
    2393 %     abstime_1=Field{2}.Time;%time read from the netcdf input file
    2394 % end
    2395 
    2396 % look for timing in the input file if not defined in a xml file or movie
     2359
     2360%% look for timing in the input file if not defined in a xml file or movie
    23972361if isempty(abstime)
    23982362    TimeName=get(handles.TimeName,'String');
     
    24112375        end
    24122376    end
    2413 end
    2414 % if ~isequal(numel(abstime),1)
    2415 %     abstime=[];
    2416 % end
    2417 % if ~isequal(numel(abstime_1),1)
    2418 %       abstime_1=[];
    2419 % end 
     2377end
    24202378set(handles.TimeValue,'String',num2str(abstime))
    24212379abstime_1=[];
     
    24342392    end
    24352393end
    2436 
    24372394
    24382395%% store the current open names, fieldname and vel types in uvmat interface
     
    24802437UvData.Field=tps_coeff_field(UvData.Field,check_proj_tps);
    24812438
    2482 %% analyse input field
    2483 % [CellInfo,NbDimArray,errormsg]=find_field_cells(UvData.Field);% analyse  the input field structure
    2484 % if ~isempty(errormsg)
    2485 %     errormsg=['uvmat /refresh_field / find_field_cells / ' errormsg];% display error
    2486 %     return
    2487 % end
    2488 %
    2489 % NbDim=max(NbDimArray);% spatial dimension of the input field
    2490 % imax=find(NbDimArray==NbDim);% indices of field cells to consider
    2491 % if isfield(UvData.Field,'NbDim')
    2492 %     NbDim=double(UvData.Field.NbDim);% deal with plane fields containing z coordinates
    2493 % end
    2494 %
    2495 % %% get bounds and mesh (needed  to propose default options for projection objects)
    2496 % if NbDim>1
    2497 %     CoordMax=zeros(numel(imax),NbDim);
    2498 %     CoordMin=zeros(numel(imax),NbDim);
    2499 %     Mesh=zeros(1,numel(imax));
    2500 %     for ind=1:numel(imax)
    2501 %         if strcmp(CellInfo{imax(ind)}.CoordType,'tps')
    2502 %             CoordName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex};% X,Y coordinates in a single variable
    2503 %             CoordMax(ind,NbDim)=max(max(UvData.Field.(CoordName)(1:end-3,1,:),[],1),[],3);% max of x component (2D case)
    2504 %             CoordMax(ind,NbDim-1)=max(max(UvData.Field.(CoordName)(1:end-3,2,:),[],1),[],3);% max of y component (2D case)
    2505 %             CoordMin(ind,NbDim)=min(min(UvData.Field.(CoordName)(1:end-3,1,:),[],1),[],3);
    2506 %             CoordMin(ind,NbDim-1)=min(min(UvData.Field.(CoordName)(1:end-3,2,:),[],1),[],3);% min of y component (2D case)
    2507 %         else
    2508 %             XName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(end)};
    2509 %             YName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(end-1)};
    2510 %             CoordMax(ind,NbDim)=max(max(UvData.Field.(XName)));
    2511 %             CoordMin(ind,NbDim)=min(min(UvData.Field.(XName)));
    2512 %             CoordMax(ind,NbDim-1)=max(max(UvData.Field.(YName)));
    2513 %             CoordMin(ind,NbDim-1)=min(min(UvData.Field.(YName)));
    2514 %             %         test_x=1;%test for unstructured coordinates
    2515 %             if NbDim==3
    2516 %                 ZName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(1)};
    2517 %                 CoordMax(imax(ind),1)=max(max(UvData.Field.(ZName)));
    2518 %                 CoordMin(ind,1)=min(min(UvData.Field.(ZName)));
    2519 %             end
    2520 %         end
    2521 %         switch CellInfo{imax(ind)}.CoordType
    2522 %             
    2523 %             case {'scattered','tps'} %unstructured coordinates
    2524 %                 NbPoints=CellInfo{imax(ind)}.CoordSize;% total nbre of points
    2525 %                 Mesh(ind)=(prod(CoordMax(ind,:)-CoordMin(ind,:))/NbPoints)^(1/NbDim); %(volume or area per point)^(1/NbDim)
    2526 %             case 'grid'%structured coordinate
    2527 %                 NbPoints=CellInfo{imax(ind)}.CoordSize;% nbre of points in each direction
    2528 %                 Mesh(ind)=min((CoordMax(ind,:)-CoordMin(ind,:))./(NbPoints-1));               
    2529 %         end
    2530 %     end
    2531 %     UvData.Field.CoordMesh=min(Mesh);
    2532 %     UvData.Field.XMax=max(CoordMax(:,end));
    2533 %     UvData.Field.XMin=min(CoordMin(:,end));
    2534 %     UvData.Field.YMax=max(CoordMax(:,end-1));
    2535 %     UvData.Field.YMin=min(CoordMin(:,end-1));
    2536 %     if NbDim==3
    2537 %         UvData.Field.ZMax=max(CoordMax(ind,1));
    2538 %         UvData.Field.ZMin=max(CoordMin(ind,1));
    2539 %     end
    2540 %     % adjust the mesh to a value 1, 2 , 5 *10^n
    2541 %     ord=10^(floor(log10(UvData.Field.CoordMesh)));%order of magnitude
    2542 %     if UvData.Field.CoordMesh/ord>=5
    2543 %         UvData.Field.CoordMesh=5*ord;
    2544 %     elseif UvData.Field.CoordMesh/ord>=2
    2545 %         UvData.Field.CoordMesh=2*ord;
    2546 %     else
    2547 %         UvData.Field.CoordMesh=ord;
    2548 %     end
    2549 if ~isfield(UvData.Field,'NbDim')
    2550     UvData.Field.NbDim=1;
    2551 end
     2439%% get bounds and dimensions of the input field
     2440UvData.Field=find_field_bounds(UvData.Field);
     2441
    25522442if UvData.Field.NbDim>1
    2553     UvData.Field=find_field_bounds(UvData.Field);
    25542443    % default projection plane
    25552444    if isempty(UvData.ProjObject{1})
     
    48364725%------------------------------------------------------------------------
    48374726%get the object file
    4838 [FileName, PathName, filterindex] = uigetfile( ...
    4839        {'*.xml;*.mat', ' (*.xml,*.mat)';
    4840        '*.xml',  '.xml files '; ...
    4841         '*.mat',  '.mat matlab files '}, ...
    4842         'Pick an xml Object file',get(handles.RootPath,'String'));
    4843 fileinput=[PathName FileName];%complete file name
    4844 sizf=size(fileinput);
    4845 if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end
    4846 
    4847 %read the file
    4848 [data,heading]=xml2struct(fileinput);
    4849 if ~strcmp(heading,'ProjObject')
    4850     msgbox_uvmat('WARNING','The xml file does not have the heading ProjObject for projection objects')
    4851 end
    4852 [tild,data.Name]=fileparts(FileName);% object name set as file name
    4853 ListObject=get(handles.ListObject,'String');
    4854 if ~strcmp(ListObject{end},'')
    4855     ListObject=[ListObject;{''}]; %append a blank to the list (if not already done) to indicate the creation of a new object
    4856     set(handles.ListObject,'String',ListObject)
    4857 end
    4858 IndexObj=length(ListObject);
    4859 
    4860 UvData=get(handles.uvmat,'UserData');
    4861 UvData.ProjObject{IndexObj}=[]; %create a new empty object
    4862 UvData.ProjObject{IndexObj}.DisplayHandle.uvmat=[]; %no plot handle before plot_field operation
    4863 UvData.ProjObject{IndexObj}.DisplayHandle.view_field=[]; %no plot handle before plot_field operation
    4864 set(handles.uvmat,'UserData',UvData)
    4865 set(handles.ListObject,'Value',IndexObj)
    4866 hset_object=set_object(data);% call the set_object interface
    4867 set(get(hset_object,'children'),'enable','on')% enable edit action on elements on GUI set_object
    4868 set(handles.CheckEditObject,'Value',0); %suppress the object edit mode
    4869 CheckEditObject_Callback([],[],handles)
    4870 % set(handles.CheckEditObject,'BackgroundColor',[0.7,0.7,0.7]) 
    4871 set(handles.DeleteObject,'Visible','on')
    4872 
     4727fileinput=uigetfile_uvmat('pick an xml object file:',get(handles.RootPath,'String'),'.xml');
     4728
     4729if ~isempty(fileinput)
     4730    %read the file
     4731    [data,heading]=xml2struct(fileinput);
     4732    if ~strcmp(heading,'ProjObject')
     4733        msgbox_uvmat('WARNING','The xml file does not have the heading ProjObject for projection objects')
     4734    end
     4735   % [tild,data.Name]=fileparts(fileinput);% object name set as file name
     4736    ListObject=get(handles.ListObject,'String');
     4737   
     4738%     if ~strcmp(ListObject{end},'')
     4739%         ListObject=[ListObject;{''}]; %append a blank to the list (if not already done) to indicate the creation of a new object
     4740%         set(handles.ListObject,'String',ListObject)
     4741%     end
     4742ListObject=[ListObject;{data.Name}];
     4743    IndexObj=length(ListObject); 
     4744    UvData=get(handles.uvmat,'UserData');
     4745    UvData.ProjObject{IndexObj}=[]; %create a new empty object
     4746    UvData.ProjObject{IndexObj}.DisplayHandle.uvmat=[]; %no plot handle before plot_field operation
     4747    UvData.ProjObject{IndexObj}.DisplayHandle.view_field=[]; %no plot handle before plot_field operation
     4748    set(handles.uvmat,'UserData',UvData)
     4749%     set(handles.ListObject,'String',ListObject)
     4750%     set(handles.ListObject,'Value',IndexObj)
     4751    set(handles.CheckViewObject,'Value',1)
     4752    set(handles.CheckViewField,'Value',1)
     4753    hset_object=set_object(data);% call the set_object interface
     4754    hhset_object=guidata(hset_object);
     4755    set_object('PLOT_Callback',hObject,eventdata,hhset_object);% plot projection
     4756    %set(get(hset_object,'children'),'enable','on')% enable edit action on elements on GUI set_object
     4757    set(handles.CheckEditObject,'Value',0); %suppress the object edit mode
     4758    CheckEditObject_Callback([],[],handles)
     4759    set(handles.DeleteObject,'Visible','on')
     4760end
    48734761
    48744762% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Note: See TracChangeset for help on using the changeset viewer.