Changeset 530 for trunk/src/uvmat.m
- Timestamp:
- Aug 27, 2012, 4:38:41 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/uvmat.m
r528 r530 347 347 end 348 348 [FileName, PathName] = uigetfile({'*.*','All Files(*.*)'},'Pick a file',oldfile); 349 if ~ischar(FileName),return,end %abandon if the browser is cancelled 349 350 fileinput=[PathName FileName];%complete file name 350 if ~exist(fileinput,'file')351 return %abandon if the browser is cancelled352 end353 351 354 352 %% display the selected field and related information … … 397 395 RootPath=get(handles.RootPath,'String'); 398 396 [FileName, PathName] = uigetfile({'*.*','All Files(*.*)'},'Pick a file',RootPath); 397 if ~ischar(FileName),return,end %abandon if the browser is cancelled 399 398 fileinput_1=[PathName FileName];%complete file name 400 if ~exist(fileinput_1,'file')401 return %abandon of the browser is cancelled402 end403 399 404 400 % refresh the current displayed field … … 1286 1282 '*.*', 'All Files (*.*)'}, ... 1287 1283 'Pick a mask file *.png',FileBase); 1284 if ~ischar(FileName),return,end %abandon if the browser is cancelled 1288 1285 maskname=fullfile(PathName,FileName); 1289 if ~exist(maskname,'file')1290 errormsg='no file browsed';1291 end1292 1286 [RootDir,SubDir,RootFile,tild,tild,tild,tild,tild,Mask.NomType]=fileparts_uvmat(maskname); 1293 1287 Mask.Base=fullfile(RootDir,SubDir,RootFile); … … 2388 2382 2389 2383 %% analyse input field 2390 test_x=0;2391 test_z=0;% test for unstructured z coordinate2392 [errormsg,ListDimName,DimValue,VarDimIndex]=check_field_structure(UvData.Field);% check the input field structure2393 if ~isempty(errormsg)2394 errormsg=['error in uvmat/refresh_field/check_field_structure: ' errormsg];% display error2395 return2396 end2397 [Cell VarIndex,NbDim,VarType,errormsg]=find_field_cells(UvData.Field);% analyse the input field structure2384 %test_x=0; 2385 %test_z=0;% test for unstructured z coordinate 2386 %[errormsg,ListDimName,DimValue,VarDimIndex]=check_field_structure(UvData.Field);% check the input field structure 2387 % if ~isempty(errormsg) 2388 % errormsg=['error in uvmat/refresh_field/check_field_structure: ' errormsg];% display error 2389 % return 2390 % end 2391 [CellInfo,NbDimArray,errormsg]=find_field_cells(UvData.Field);% analyse the input field structure 2398 2392 if ~isempty(errormsg) 2399 2393 errormsg=['uvmat /refresh_field / find_field_cells / ' errormsg];% display error 2400 2394 return 2401 2395 end 2402 [NbDim,imax]=max(NbDim);% spatial dimension of the input field 2396 2397 NbDim=max(NbDimArray);% spatial dimension of the input field 2398 imax=find(NbDimArray==NbDim);% indices of field cells to consider 2403 2399 if isfield(UvData.Field,'NbDim') 2404 NbDim=UvData.Field.NbDim;% deal with plane fields containing z coordinates 2405 end 2400 NbDim=double(UvData.Field.NbDim);% deal with plane fields containing z coordinates 2401 end 2402 2406 2403 2407 2404 %% get bounds and mesh (needed to propose default options for projection objects) 2408 2405 if NbDim>1 2409 XName=''; %default 2410 YName=''; 2411 %unstructured coordinates 2412 if ~isempty(VarType{imax}.coord_x)&&~isempty(VarType{imax}.coord_y) 2413 XName=UvData.Field.ListVarName{VarType{imax}.coord_x}; 2414 YName=UvData.Field.ListVarName{VarType{imax}.coord_y}; 2415 test_x=1;%test for unstructured coordinates 2416 if ~isempty(VarType{imax}.coord_z) 2417 ZName=UvData.Field.ListVarName{VarType{imax}.coord_z}; 2418 else 2419 NbDim=2; 2420 end 2421 %structured coordinate 2422 elseif numel(VarType)>=imax && numel(VarType{imax}.coord)>=NbDim && VarType{imax}.coord(NbDim)>0 2423 XName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim)}; 2424 if NbDim> 1 && VarType{imax}.coord(NbDim-1)>0 2425 YName=UvData.Field.ListVarName{VarType{imax}.coord(NbDim-1)}; %structured coordinates 2426 end 2427 DimIndex=VarDimIndex{CellVarIndex{imax}(1)}; %list of dim indices for the variable 2428 nbpoints_x=DimValue(DimIndex(NbDim)); 2429 XMax=nbpoints_x;%default 2430 XMin=1;%default 2431 end 2432 2406 CoordMax=zeros(1,numel(imax)); 2407 CoordMin=zeros(1,numel(imax)); 2408 for ind=1:numel(imax) 2409 XName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(end)}; 2410 YName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(end-1)}; 2411 CoordMax(ind,1)=max(max(UvData.Field.(XName))); 2412 CoordMin(ind,1)=min(min(UvData.Field.(XName))); 2413 CoordMax(ind,2)=max(max(UvData.Field.(YName))); 2414 CoordMin(ind,2)=min(min(UvData.Field.(YName))); 2415 % test_x=1;%test for unstructured coordinates 2416 if NbDim==3 2417 ZName=UvData.Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(1)}; 2418 CoordMax(imax(ind),3)=max(max(UvData.Field.(ZName))); 2419 CoordMin(ind,3)=min(min(UvData.Field.(ZName))); 2420 end 2421 2422 switch CellInfo{imax(ind)}.CoordType 2423 2424 case 'scattered' %unstructured coordinates 2425 NbPoints(ind)=CellInfo{imax(ind)}.CoordSize;% nbre of points 2426 Mesh(ind)=(prod(CoordMax(ind,:)-CoordMin(ind,:))/NbPoints)^(1/NbDim); %(volume or area per point)^(1/NbDim) 2427 case 'grid'%structured coordinate 2428 NbPoints=CellInfo{imax(ind)}.CoordSize;% nbre of points 2429 Mesh(ind)=min((CoordMax(ind,:)-CoordMin(ind,:))./NbPoints); 2430 2431 end 2432 end 2433 UvData.Field.Mesh=min(Mesh); 2434 UvData.Field.XMax=max(CoordMax(ind,1)); 2435 UvData.Field.XMin=min(CoordMin(ind,1)); 2436 UvData.Field.YMax=max(CoordMax(ind,2)); 2437 UvData.Field.YMin=max(CoordMin(ind,2)); 2433 2438 if NbDim==3 2434 if ~test_x 2435 ZName=UvData.Field.ListVarName{VarType{imax}.coord(1)};%structured coordinates in 3D 2436 end 2437 ZMax=max(UvData.Field.(ZName)); 2438 ZMin=min(UvData.Field.(ZName)); 2439 UvData.Field.ZMax=ZMax; 2440 UvData.Field.ZMin=ZMin; 2441 test_z=1; 2442 if isequal(ZMin,ZMax)%no z dependency 2443 NbDim=2; 2444 test_z=0; 2445 end 2446 end 2447 if ~isempty (XName) 2448 XMax=max(max(UvData.Field.(XName))); 2449 XMin=min(min(UvData.Field.(XName))); 2450 UvData.Field.NbDim=NbDim; 2451 UvData.Field.XMax=XMax; 2452 UvData.Field.XMin=XMin; 2453 if NbDim >1&& ~isempty(YName) 2454 YMax=max(max(UvData.Field.(YName))); 2455 YMin=min(min(UvData.Field.(YName))); 2456 UvData.Field.YMax=YMax; 2457 UvData.Field.YMin=YMin; 2458 end 2459 nbvec=length(UvData.Field.(XName)); 2460 if test_x %unstructured coordinates 2461 if test_z 2462 UvData.Field.Mesh=((XMax-XMin)*(YMax-YMin)*(ZMax-ZMin))/nbvec;% volume per vector 2463 UvData.Field.Mesh=(UvData.Field.Mesh)^(1/3); 2464 else 2465 UvData.Field.Mesh=sqrt((XMax-XMin)*(YMax-YMin)/nbvec);%2D 2466 end 2467 end 2468 end 2469 % case of structured coordinates 2470 if ~test_x 2471 DX=(XMax-XMin)/(nbpoints_x-1); 2472 if NbDim >1 2473 nbpoints_y=DimValue(DimIndex(NbDim-1)); 2474 if isempty(YName)% if the y coordinate is not expressed, it is taken as the matrix index 2475 DY=1; 2476 UvData.Field.YMax=nbpoints_y; 2477 UvData.Field.YMin=1; 2478 else 2479 DY=(YMax-YMin)/(nbpoints_y-1); 2480 end 2481 end 2482 if NbDim==3 2483 nbpoints_z=DimValue(DimIndex(1)); 2484 DZ=(ZMax-ZMin)/(nbpoints_z-1); 2485 UvData.Field.Mesh=(DX*DY*DZ)^(1/3); 2486 UvData.Field.ZMax=ZMax; 2487 UvData.Field.ZMin=ZMin; 2488 else 2489 UvData.Field.Mesh=DX;%sqrt(DX*DY); 2490 end 2439 UvData.Field.ZMax=max(CoordMax(ind,3)); 2440 UvData.Field.ZMin=max(CoordMin(ind,3)); 2491 2441 end 2492 2442 % adjust the mesh to a value 1, 2 , 5 *10^n … … 2664 2614 ObjectData.A=flag_mask.*double(ObjectData.A); 2665 2615 ObjectData.A=feval(AClass,ObjectData.A); 2666 ind_off=[]; 2667 if isfield(ObjectData,'ListVarName') 2668 for ilist=1:length(ObjectData.ListVarName) 2669 if isequal(ObjectData.ListVarName{ilist},'Mask')||isequal(ObjectData.ListVarName{ilist},'MaskX')||isequal(ObjectData.ListVarName{ilist},'MaskY') 2670 ind_off=[ind_off ilist]; 2671 end 2672 end 2673 ObjectData.ListVarName(ind_off)=[]; 2674 VarDimIndex(ind_off)=[]; 2675 ind_off=[]; 2676 for ilist=1:length(ListDimName) 2677 if isequal(ListDimName{ilist},'MaskX') || isequal(ListDimName{ilist},'MaskY') 2678 ind_off=[ind_off ilist]; 2679 end 2680 end 2681 ListDimName(ind_off)=[]; 2682 DimValue(ind_off)=[]; 2683 end 2616 % ind_off=[]; 2617 % if isfield(ObjectData,'ListVarName') 2618 % for ilist=1:length(ObjectData.ListVarName) 2619 % if isequal(ObjectData.ListVarName{ilist},'Mask')||isequal(ObjectData.ListVarName{ilist},'MaskX')||isequal(ObjectData.ListVarName{ilist},'MaskY') 2620 % ind_off=[ind_off ilist]; 2621 % end 2622 % end 2623 % ObjectData.ListVarName(ind_off)=[]; 2624 % VarDimIndex(ind_off)=[]; 2625 % ind_off=[]; 2626 % 2627 % end 2684 2628 end 2685 2629 if ~isempty(ObjectData) … … 2752 2696 function histo1_menu_Callback(hObject, eventdata, handles) 2753 2697 %-------------------------------------------- 2754 %plot first histo2755 %huvmat=get(handles.histo1_menu,'parent');2756 2698 histo_menu=get(handles.histo1_menu,'String'); 2757 2699 histo_value=get(handles.histo1_menu,'Value'); 2758 2700 FieldName=histo_menu{histo_value}; 2759 % update_histo(handles.HistoAxes,handles.uvmat,FieldName) 2760 % 2761 % %------------------------------------------------------------------------ 2762 % function histo2_menu_Callback(hObject, eventdata, handles) 2763 % %------------------------------------------------------------------------ 2764 % %plot second histo 2765 % %huvmat=get(handles.histo2_menu,'parent'); 2766 % histo_menu=get(handles.histo2_menu,'String'); 2767 % histo_value=get(handles.histo2_menu,'Value'); 2768 % FieldName=histo_menu{histo_value}; 2769 % update_histo(handles.histo_v,handles.uvmat,FieldName) 2770 % 2771 % %------------------------------------------------------------------------ 2772 % %read the field .Fieldname stored in UvData and plot its histogram 2773 % function update_histo(haxes,huvmat,FieldName) 2774 %------------------------------------------------------------------------ 2701 2775 2702 UvData=get(handles.uvmat,'UserData'); 2776 2703 Field=UvData.Field; … … 2845 2772 set(hlegend,'String',{FieldName;FieldName_2}) 2846 2773 end 2847 % hh=get(handles.HistoAxes,'children');2848 % get(hh(1))2849 % get(hh(2))2850 2774 end 2851 2775 end … … 3097 3021 '*.vol','.volume images (png)'; ... 3098 3022 '*.*', 'All Files (*.*)'}, ... 3099 'Pick an image',imagename); 3023 'Pick an image',imagename); 3024 if ~ischar(FileName),return,end %abandon if the browser is cancelled 3100 3025 imagename=[PathName FileName]; 3101 3026 end … … 3111 3036 '*.*', 'All Files (*.*)'}, ... 3112 3037 'Pick a netcdf file',FileBase); 3038 if ~ischar(FileName),return,end %abandon if the browser is cancelled 3113 3039 FullFileName=[PathName FileName]; 3114 3040 % display the selected field and related information … … 3209 3135 '*.*', 'All Files (*.*)'}, ... 3210 3136 'Pick an image',imagename); 3137 if ~ischar(FileName),return,end %abandon if the browser is cancelled 3211 3138 imagename=[PathName FileName]; 3212 3139 end … … 3545 3472 '*.*', 'All Files (*.*)'}, ... 3546 3473 'Pick the transform function', prev_path); 3474 if ~ischar(FileName),return,end %abandon if the browser is cancelled 3547 3475 path_transform_fct =fullfile(PathName,FileName); 3548 if ~exist(path_transform_fct,'file')% cancel has been activated3549 return3550 end3551 3476 if isempty(regexp(FileName,'.m$'))% detect file extension .m 3552 3477 msgbox_uvmat('ERROR','a Matlab function .m must be introduced');
Note: See TracChangeset
for help on using the changeset viewer.