- Timestamp:
- Oct 29, 2013, 12:28:57 PM (11 years ago)
- Location:
- trunk/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/geometry_calib.m
r682 r693 50 50 % Edit the above text to modify the response to help geometry_calib 51 51 52 % Last Modified by GUIDE v2.5 02-Sep-2013 16:47:2752 % Last Modified by GUIDE v2.5 29-Oct-2013 06:46:10 53 53 54 54 % Begin initialization code - DO NOT edit … … 114 114 set(handles.Copy,'Position',[151 Height-394 120 30])% rank 6 115 115 set(handles.CLEAR_PTS,'Position',[297 Height-394 120 30])% rank 6 116 set(handles.ClearLine,'Position',[297 Height-364 120 30])% rank 6 116 117 set(handles.phys_title,'Position',[38 Height-426 125 20])% rank 7 117 118 set(handles.CoordUnit,'Position',[151 Height-426 120 30])% rank 7 … … 230 231 Data=get(handles.ListCoord,'Data'); 231 232 Data(:,6)=zeros(size(Data,1),1); 232 Data(index,6)= 1;% indicate in the list the point with max deviation (possible mistake)233 Data(index,6)=-1;% indicate in the list the point with max deviation (possible mistake) 233 234 set(handles.ListCoord,'Data',Data)% indicate in the list the point with max deviation (possible mistake) 234 235 figure(handles.geometry_calib) … … 881 882 huvmat=findobj(allchild(0),'Name','uvmat'); 882 883 UvData=get(huvmat,'UserData'); 883 A=UvData.Field.A; 884 A=UvData.Field.A;%currently displayed image 884 885 npxy=size(A); 885 886 X=[CalibData.grid.x_0 CalibData.grid.x_1 CalibData.grid.x_0 CalibData.grid.x_1]';%corner absissa in the phys coordinates (cm) 886 887 Y=[CalibData.grid.y_0 CalibData.grid.y_0 CalibData.grid.y_1 CalibData.grid.y_1]';%corner ordinates in the phys coordinates (cm) 887 888 888 %calculate transform matrices for plane projection 889 %calculate transform matrices for plane projection: rectangle assumed to be viewed in perspective 889 890 % reference: http://alumni.media.mit.edu/~cwren/interpolator/ by Christopher R. Wren 890 891 B = [ X Y ones(size(X)) zeros(4,3) -X.*corners_X -Y.*corners_X ... … … 898 899 899 900 % transform grid image into 'phys' coordinates 900 GeometryCalib.CalibrationType=' linear';901 GeometryCalib.CalibrationType='3D_linear'; 901 902 GeometryCalib.fx_fy=[1 1]; 902 903 GeometryCalib.Tx_Ty_Tz=[Amat(1,3) Amat(2,3) 1]; … … 918 919 DataOut=phys(Data,Calib); 919 920 rmpath(fullfile(path_UVMAT,'transform_field')) 920 Amod=DataOut.A; 921 Amod=DataOut.A;% current imgage expressed in 'phys' coord 921 922 Rangx=DataOut.AX; 922 923 Rangy=DataOut.AY; … … 936 937 ind_range_y=ceil(abs(GeometryCalib.R(2,2)*CalibData.grid.Dy/3));% range of search of image ma around each point obtained by linear interpolation from the marked points 937 938 nbpoints=size(T,1); 939 %lokk for image maxima around each expected pgrid point 938 940 for ipoint=1:nbpoints 939 941 i0=1+round((T(ipoint,1)-Rangx(1))/Dx);%round(Xpx(ipoint)); … … 962 964 Delta(ipoint,2)=(y_shift+ind_y_max+j0min-j0-1)*Dy; 963 965 end 964 Tmod=T(:,(1:2))+Delta; 965 [Xpx,Ypx]=px_XYZ(GeometryCalib,Tmod(:,1),Tmod(:,2)); 966 % for ipoint=1:nbpoints 967 % Coord{ipoint,1}=num2str(T(ipoint,1),4);%display coordiantes with 4 digits 968 % Coord{ipoint,2}=num2str(T(ipoint,2),4);%display coordiantes with 4 digits 969 % Coord{ipoint,3}=num2str(T(ipoint,3),4);%display coordiantes with 4 digits; 970 % Coord{ipoint,4}=num2str(Xpx(ipoint),4);%display coordiantes with 4 digits 971 % Coord{ipoint,5}=num2str(Ypx(ipoint),4);%display coordiantes with 4 digits 972 % end 966 Tmod=T(:,(1:2))+Delta;% 'phys' coordinates of the detected points 967 Tmod(:,2)=flipdim(Tmod(:,2),1);% inverse the order of y coordinates 968 [Xpx,Ypx]=px_XYZ(GeometryCalib,Tmod(:,1),Tmod(:,2));% image coordinates of the detected points 973 969 Coord=[T Xpx Ypx zeros(size(T,1),1)]; 974 970 set(handles.ListCoord,'Data',Coord) … … 1250 1246 Data=get(handles.ListCoord,'Data'); 1251 1247 Data(:,6)=zeros(size(Data,1),1); 1252 Data(iline,6)= 1;% mark the selected line1248 Data(iline,6)=-1;% mark the selected line 1253 1249 set(handles.ListCoord,'Data',Data) 1254 1250 update_calib_marker(Data(iline,:)) … … 1340 1336 set(hhh,'Position',[XCoord-ind_range/2 YCoord-ind_range/2 ind_range ind_range]) 1341 1337 end 1338 1339 %------------------------------------------------------------------------ 1340 % --- Executes on button press in ClearLine: remove the selected line in the table Coord 1341 %------------------------------------------------------------------------ 1342 function ClearLine_Callback(hObject, eventdata, handles) 1343 1344 Coord=get(handles.ListCoord,'Data'); 1345 ind=find(Coord(:,6));%find the marker '-' for line selection 1346 if isempty(ind) 1347 msgbox_uvmat('WARNING','no line suppressed, select a line in the table') 1348 else 1349 answer=msgbox_uvmat('INPUT_Y-N',['suppress line ' num2str(ind) '?']); 1350 if isequal(answer,'Yes') 1351 Coord(:,6)=zeros(size(Coord,1),1);% desactivate the current line mark 1352 Coord(ind,:)=[]; 1353 PLOT_Callback(hObject,eventdata,handles) 1354 set(handles.APPLY,'BackgroundColor',[1 0 1]) 1355 set(handles.ListCoord,'Data',Coord); 1356 end 1357 end -
trunk/src/get_field.m
r675 r693 34 34 function varargout = get_field(varargin) 35 35 36 % Last Modified by GUIDE v2.5 09-Jun-2013 11:15:5436 % Last Modified by GUIDE v2.5 23-Oct-2013 23:44:17 37 37 38 38 % Begin initialization code - DO NOT EDIT … … 97 97 check_singleton(idim)=isequal(Field.DimValue(dim_index),1);%check_singleton=1 for singleton 98 98 end 99 Field.Check0D(ilist)=(isequal(check_singleton,ones(1,NbDim))) ;% =1 if the variable reduces to a single value99 Field.Check0D(ilist)=(isequal(check_singleton,ones(1,NbDim)))||(~isequal(Field.VarType(ilist),4)&&~isequal(Field.VarType(ilist),5));% =1 if the variable reduces to a single value 100 100 if ~Field.Check0D(ilist) 101 101 Field.Display.VarDimName{ilist}=Field.VarDimName{ilist}(~check_singleton);% eliminate singletons in the list of variable dimensions … … 137 137 end 138 138 if Field.MaxDim>=2 139 ListSwitchVarIndexTime=[ListSwitchVarIndexTime;{'variable'};{' dimindex'}];% the time can be chosen as a dim index139 ListSwitchVarIndexTime=[ListSwitchVarIndexTime;{'variable'};{'matrix index'}];% the time can be chosen as a dim index 140 140 end 141 141 … … 144 144 time_index=find(strcmp(ParamIn.TimeAttrName,Field.Display.ListGlobalAttribute),1); 145 145 else 146 time_index=find(~cellfun('isempty',regexp(Field.Display.ListGlobalAttribute,'Time')),1); 146 time_index=find(~cellfun('isempty',regexp(Field.Display.ListGlobalAttribute,'Time')),1);% look for global attribute containing name 'Time' 147 147 end 148 148 if ~isempty(time_index) … … 517 517 %% set default coord selection 518 518 if numel(find(test_coord))>3 519 SwitchVarIndexTime=get(handles.SwitchVarIndexTime,'String'); 520 if numel(SwitchVarIndexTime)<3 521 SwitchVarIndexTime=[SwitchVarIndexTime;'matrix_index']; 522 set(handles.SwitchVarIndexTime,'String',SwitchVarIndexTime) 523 end 519 524 set(handles.SwitchVarIndexTime,'Value',3)% the last dim must be considered as time 525 SwitchVarIndexTime_Callback([], [], handles) 520 526 end 521 527 if numel(var_component)<2 … … 554 560 set(handles.TimeName,'Value',1) 555 561 set(handles.TimeName,'String',ListTime) 556 case ' dimindex'562 case 'matrix index' 557 563 if numel(find(test_coord))<3 558 564 ListTime={''}; … … 579 585 test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordiante 580 586 dim_var=Field.Display.VarDimName{scalar_index};%list of dimensions of the selected variable 581 for ilist=1:numel(Field.Display.VarDimName) 582 dimnames=Field.Display.VarDimName{ilist}; %list of dimensions for variable #ilist 583 if isequal(dimnames,dim_var) 584 test_component(ilist)=1; 585 elseif numel(dimnames)==1 && ~isempty(find(strcmp(dimnames{1},dim_var)))%variable ilist is a 1D array which can be coordinate variable 586 test_coord(ilist)=1; 587 CheckDimensionX=get(handles.CheckDimensionX,'Value'); 588 CheckDimensionY=get(handles.CheckDimensionY,'Value'); 589 if ~CheckDimensionX || ~CheckDimensionY 590 %look for coordinate variables among the other variables 591 for ilist=1:numel(Field.Display.VarDimName) 592 dimnames=Field.Display.VarDimName{ilist}; %list of dimensions for variable #ilist 593 if isequal(dimnames,dim_var) 594 test_component(ilist)=1;% the listed variable has the same dimension as the selected scalar-> possibly chosen as unstructured coordinate 595 elseif numel(dimnames)==1 && ~isempty(find(strcmp(dimnames{1},dim_var), 1))%variable ilist is a 1D array which can be coordinate variable 596 test_coord(ilist)=1; 597 end 587 598 end 588 599 end … … 593 604 %% set default coord selection 594 605 if numel(find(test_coord))>3 606 SwitchVarIndexTime=get(handles.SwitchVarIndexTime,'String'); 607 if numel(SwitchVarIndexTime)<3 608 SwitchVarIndexTime=[SwitchVarIndexTime;'matrix_index']; 609 set(handles.SwitchVarIndexTime,'String',SwitchVarIndexTime) 610 end 595 611 set(handles.SwitchVarIndexTime,'Value',3)% the last dim must be considered as time 612 SwitchVarIndexTime_Callback([], [], handles) 596 613 end 597 614 % if numel(var_component)<2 … … 623 640 end 624 641 end 625 set(handles.Coord_x,'Value',coord_val(1)) 626 set(handles.Coord_y,'Value',coord_val(2)) 627 set(handles.Coord_y,'String',ListCoord) 628 set(handles.Coord_x,'String',ListCoord) 629 642 if CheckDimensionX 643 set(handles.Coord_x,'Value',2) 644 set(handles.Coord_x,'String',dim_var') 645 else 646 set(handles.Coord_x,'Value',coord_val(1)) 647 set(handles.Coord_x,'String',ListCoord) 648 end 649 if CheckDimensionY 650 set(handles.Coord_y,'Value',1) 651 set(handles.Coord_y,'String',dim_var') 652 else 653 set(handles.Coord_y,'Value',coord_val(2)) 654 set(handles.Coord_y,'String',ListCoord) 655 end 630 656 631 657 %% set list of time coordinates … … 871 897 end 872 898 set(handles.TimeName, 'String',TimeVarName) 873 case 'dim index'% TimeName menu represents the available dimensions 874 set(handles.TimeName, 'Visible','on') 875 TimeVarName=Field.Display.SingleDimName; 876 List=get(handles.TimeName,'String'); 877 option=List{get(handles.TimeName,'Value')}; 878 ind=find(strcmp(option,TimeVarName)); 879 if isempty(ind) 880 set(handles.TimeName, 'Value',1); 881 else 882 set(handles.TimeName, 'Value',ind); 883 end 884 set(handles.TimeName, 'String',TimeVarName) 899 case 'matrix_index'% TimeName menu represents the available dimensions 900 set(handles.TimeName, 'Visible','on') 901 set(handles.TimeName, 'Value',1); 902 set(handles.TimeName, 'String',Field.Display.ListDimName) 885 903 end 886 904 … … 920 938 end 921 939 end 940 941 % --- Executes on button press in CheckDimensionY. 942 function CheckDimensionX_Callback(hObject, eventdata, handles) 943 FieldList=get(handles.FieldOption,'String'); 944 FieldOption=FieldList{get(handles.FieldOption,'Value')}; 945 switch FieldOption 946 case '1D plot' 947 948 case 'scalar' 949 scalar_Callback(hObject, eventdata, handles) 950 case 'vectors' 951 end 952 953 % --- Executes on button press in CheckDimensionY. 954 function CheckDimensionY_Callback(hObject, eventdata, handles) 955 FieldList=get(handles.FieldOption,'String'); 956 FieldOption=FieldList{get(handles.FieldOption,'Value')}; 957 switch FieldOption 958 case '1D plot' 959 960 case 'scalar' 961 scalar_Callback(hObject, eventdata, handles) 962 case 'vectors' 963 end 964 % hObject handle to CheckDimensionY (see GCBO) 965 % eventdata reserved - to be defined in a future version of MATLAB 966 % handles structure with handles and user data (see GUIDATA) 967 968 % Hint: get(hObject,'Value') returns toggle state of CheckDimensionY -
trunk/src/mouse_motion.m
r682 r693 418 418 Data=get(h_ListCoord,'Data'); 419 419 Data(:,6)=zeros(size(Data,1),1); 420 Data(index_point,6)= 1;%mrk the point on the GUI geometry_calib420 Data(index_point,6)=-1;%mrk the point on the GUI geometry_calib 421 421 set(h_ListCoord,'Data',Data); 422 422 hhh=findobj('Tag','calib_marker');%look for handle of point marker (circle) -
trunk/src/nc2struct.m
r648 r693 13 13 % .VarDimName: list of dimension names for each element of .ListVarName (cell array of string cells) 14 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) 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 % .VarType= integers giving the type of variable as coded by netcdf= 2 for char, =4 for single,=( for double 17 18 % .Txt: error message 18 19 % var_detect: vector with same length as the cell array ListVarName, = 1 for each detected variable and 0 else. … … 166 167 for ncvar=1:nvars %loop on the variables of the netcdf file 167 168 %get name, type, dimensions and attribute numbers of each variable 168 [ListVarNameNetcdf{ncvar},xtype ,dimids{ncvar},nbatt(ncvar)] = netcdf.inqVar(nc,ncvar-1);169 [ListVarNameNetcdf{ncvar},xtype(ncvar),dimids{ncvar},nbatt(ncvar)] = netcdf.inqVar(nc,ncvar-1); 169 170 end 170 171 testmulti=0; … … 221 222 end 222 223 try 223 if ischar(valuestr) 224 % valuestr=regexprep(valuestr,{'\\','\/','\.','\-',' '},{'_','_','_','_','_'});%remove '\','.' or '-' if exists 225 eval(['Data.VarAttribute{ivar}.' attname '=''' valuestr ''';']) 226 elseif isempty(valuestr) 227 eval(['Data.VarAttribute{ivar}.' attname '=[];']) 228 elseif isnumeric(valuestr) 229 eval(['Data.VarAttribute{ivar}.' attname '=valuestr;']) 224 if isempty(valuestr) 225 Data.VarAttribute{ivar}.(attname)=valuestr; 230 226 end 231 227 catch ME … … 233 229 display(valuestr) 234 230 display(ME.message) 235 eval(['Data.VarAttribute{ivar}.atrr_' num2str(iatt) '=''not read'';'])231 Data.VarAttribute{ivar}.(['atrr_' num2str(iatt)])='not read'; 236 232 end 237 233 end … … 255 251 if var_dim{ivar}(end)==TimeDimIndex% if the last dim of the variable is the time 256 252 slice_length=prod(var_dim{ivar}(1:end-1)); 257 Data.(VarName)=double(netcdf.getVar(nc,var_index(ivar)-1 ),TimeIndex*slice_length,slice_length); %read the variable data253 Data.(VarName)=double(netcdf.getVar(nc,var_index(ivar)-1,TimeIndex*slice_length,slice_length)); %read the variable data 258 254 CheckSub=1; 259 255 end 260 256 end 261 257 if ~CheckSub 262 Data.(VarName)=double(netcdf.getVar(nc,var_index(ivar)-1)); %read the whole variable data 263 end 264 end 265 end 258 Data.(VarName)=netcdf.getVar(nc,var_index(ivar)-1); %read the whole variable data 259 if xtype(var_index(ivar))==5 260 Data.(VarName)=double(Data.(VarName)); %transform to double for single pecision 261 end 262 end 263 end 264 end 265 Data.VarType=xtype(var_index); 266 266 267 267 %% -------- close fle----------- -
trunk/src/read_field.m
r684 r693 20 20 % .ColorVar: variable used for vector color 21 21 % .Npx, .Npy: nbre of pixels along x and y (used for .vol input files) 22 % .TimeDimName: name of the dimension considered as 'time', selected index value then set by input 'num' 22 23 % num: frame number for movies 23 24 % -
trunk/src/uvmat.m
r690 r693 2352 2352 if strcmp(TimeName,'civdata')||strcmp(TimeName,'civx') 2353 2353 abstime=Field{1}.Time; 2354 elseif ~isempty(regexp(TimeName,'^att:'))||~isempty(regexp(TimeName,'^ dim:'))||~isempty(regexp(TimeName,'^var:'))2354 elseif ~isempty(regexp(TimeName,'^att:'))||~isempty(regexp(TimeName,'^var:')) 2355 2355 abstime=Field{1}.(TimeName(5:end));%the time is an attribute or variale selected by get_file 2356 elseif ~isempty(regexp(TimeName,'^dim:')) 2357 abstime=str2num(get(handles.i1,'String')); 2356 2358 end 2357 2359 if isfield(Field{1},'Dt') … … 3127 3129 XName=GetFieldData.Coordinates.Coord_x; 3128 3130 TimeNameStr=GetFieldData.Time.SwitchVarIndexTime; 3129 if strcmp(TimeNameStr,'file index') 3130 set(handles.TimeName,'String',''); 3131 else 3132 set(handles.TimeName,'String',[TimeNameStr(1:3) ':' GetFieldData.Time.TimeName]); 3133 end 3134 if strcmp(TimeNameStr,'variable')||strcmp(TimeNameStr,'dim index')% we scan a variable index, not a file index 3135 set(handles.NomType,'String','*') 3136 set(handles.RootFile,FileName) 3137 end 3138 % set(handles.TimeValue,'String' SwitchVarIndexTime 3131 switch TimeNameStr 3132 case 'file index' 3133 set(handles.TimeName,'String',''); 3134 case 'attribute' 3135 set(handles.TimeName,'String',['att:' GetFieldData.Time.TimeName]); 3136 case 'variable' 3137 set(handles.TimeName,'String',['var:' GetFieldData.Time.TimeName]) 3138 set(handles.NomType,'String','*') 3139 set(handles.RootFile,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')]) 3140 set(handles.FileIndex,'String','') 3141 ParamIn.TimeVarName=GetFieldData.Time.TimeName; 3142 case 'matrix_index' 3143 set(handles.TimeName,'String',['dim:' GetFieldData.Time.TimeName]); 3144 set(handles.NomType,'String','*') 3145 set(handles.RootFile,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')]) 3146 set(handles.FileIndex,'String','') 3147 ParamIn.TimeDimName=GetFieldData.Time.TimeName; 3148 end 3139 3149 set(handles.Coord_x,'String',XName) 3140 3150 if ischar(YName)
Note: See TracChangeset
for help on using the changeset viewer.