- Timestamp:
- Apr 22, 2014, 9:44:39 AM (11 years ago)
- Location:
- trunk/src
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/compile.m
r746 r747 11 11 return 12 12 else 13 hh=msgbox_uvmat(' INFO',['compilation of ' FctName ' in progress...']);13 hh=msgbox_uvmat('WAITING...',['compilation of ' FctName ' in progress...']); 14 14 end 15 15 disp(['compiling ' FctName ' ...']) -
trunk/src/disp_uvmat.m
r667 r747 10 10 % checkrun: =0: batch mode: text display on log file 11 11 12 function disp_uvmat(title,display_str,checkrun) 12 function hh=disp_uvmat(title,display_str,checkrun) 13 hh=[]; 13 14 if checkrun 14 msgbox_uvmat(title,display_str,'')15 hh=msgbox_uvmat(title,display_str,''); 15 16 else 16 17 disp([title ': ' display_str]) -
trunk/src/fill_GUI.m
r710 r747 38 38 set(handles.(fields{ifield}),'Visible','on') 39 39 errormsg=fill_GUI(Param.(fields{ifield}),handles.(fields{ifield}));% recursively apply the function to the substructure 40 % elseif isfield(UserData,fields{ifield}) && isfield(handles,fields{ifield}) && isfield(Param.(fields{ifield}),'Name')41 % UserData.(fields{ifield})=Param.(fields{ifield});42 % set(handles.(fields{ifield}),'String',Param.(fields{ifield}).Name)43 40 end 44 41 else … … 87 84 if isnumeric(input_data) 88 85 if numel(input_data)>0 89 input_string=num2str(input_data(ibox) );86 input_string=num2str(input_data(ibox),4); 90 87 end 91 88 else … … 95 92 case{'listbox','popupmenu'} 96 93 if isnumeric(input_data) 97 input_data=num2str(input_data );94 input_data=num2str(input_data,4); 98 95 end 99 96 menu=get(hh(ibox),'String'); -
trunk/src/find_field_bounds.m
r667 r747 51 51 if NbDim==3 52 52 ZName=Field.ListVarName{CellInfo{imax(ind)}.CoordIndex(1)}; 53 CoordMax(i max(ind),1)=max(max(Field.(ZName)));53 CoordMax(ind,1)=max(max(Field.(ZName))); 54 54 CoordMin(ind,1)=min(min(Field.(ZName))); 55 55 end … … 72 72 if NbDim==3 73 73 FieldOut.ZMax=max(CoordMax(ind,1)); 74 FieldOut.ZMin=m ax(CoordMin(ind,1));74 FieldOut.ZMin=min(CoordMin(ind,1)); 75 75 end 76 76 % adjust the mesh to a value 1, 2 , 5 *10^n -
trunk/src/find_field_cells.m
r690 r747 257 257 DimIndices=[]; 258 258 for idim=1:numel(DimCell) 259 ind_dim=find(strcmp(DimCell{idim},ListDimName));%find the dim index in the list of coordinate variables259 ind_dim=find(strcmp(DimCell{idim},ListDimName));%find the dim index in the list of dimensions ListDimName 260 260 if ~isempty(ind_dim) 261 DimIndices=[DimIndices ind_dim]; %update the list of coord dimensions included in DimCell262 if check_var && CoordSize(ind_dim)==2 % determine the size of the coordinate in case of coordi ante variablelimited to lower and upper bounds261 DimIndices=[DimIndices ind_dim]; %update the list of dim indices included in DimCell 262 if check_var && CoordSize(ind_dim)==2 % determine the size of the coordinate in case of coordinate definition limited to lower and upper bounds 263 263 if isvector(Data.(ListVarName{ivardim})) 264 264 if numel(Data.(ListVarName{ivardim}))>2 … … 287 287 NewNbDim(nbcell)=numel(DimIndices); 288 288 NewCellInfo{nbcell}.CoordType='grid'; 289 NewCellInfo{nbcell}.CoordSize=CoordSize ;289 NewCellInfo{nbcell}.CoordSize=CoordSize(DimIndices); 290 290 NewCellInfo{nbcell}.CoordIndex=ListCoordIndex(DimIndices); 291 291 end -
trunk/src/get_field.m
r701 r747 34 34 function varargout = get_field(varargin) 35 35 36 % Last Modified by GUIDE v2.5 2 3-Oct-2013 23:44:1736 % Last Modified by GUIDE v2.5 21-Apr-2014 15:03:19 37 37 38 38 % Begin initialization code - DO NOT EDIT … … 86 86 Field.Display=Field; 87 87 Field.Check0D=zeros(size(Field.ListVarName));% =1 for arrays with a single value 88 NbVar=numel(Field.VarDimName); 88 NbVar=numel(Field.VarDimName);%nbre of variables in the input data 89 89 for ilist=1:NbVar 90 90 if ischar(Field.VarDimName{ilist}) … … 92 92 end 93 93 NbDim=numel(Field.VarDimName{ilist}); 94 check_singleton=false(1,NbDim); 94 check_singleton=false(1,NbDim);% check singleton, false by default 95 95 for idim=1:NbDim 96 96 dim_index=strcmp(Field.VarDimName{ilist}{idim},Field.ListDimName);%index in the list of dimensions … … 101 101 Field.Display.VarDimName{ilist}=Field.VarDimName{ilist}(~check_singleton);% eliminate singletons in the list of variable dimensions 102 102 end 103 %Field.NbDim(ilist)=numel(Field.VarDimNameNonSingleton{ilist});%nbre of array dimensions after elimination of singletons104 103 end 105 104 if ~isfield(Field,'VarAttribute') … … 109 108 Field.VarAttribute(numel(Field.VarAttribute)+1:NbVar)=cell(1,NbVar-numel(Field.VarAttribute)); 110 109 end 111 % Field.Display = list of variables and corresponding properties obtained after removal of singletons112 Field.Display.ListVarName=Field.ListVarName(~Field.Check0D); 110 % Field.Display = list of variables and corresponding properties obtained after removal of variables with a single value and singleton dimensions 111 Field.Display.ListVarName=Field.ListVarName(~Field.Check0D); %list of variables available for plots, after eliminating variables with a single value 113 112 Field.Display.VarAttribute=Field.VarAttribute(~Field.Check0D); 114 113 Field.Display.VarDimName=Field.Display.VarDimName(~Field.Check0D); 115 Field.Display.DimValue=Field.DimValue(Field.DimValue~=1); 116 Field.Display.ListDimName=Field.ListDimName(Field.DimValue~=1); 114 Field.Display.ListDimName=Field.ListDimName(Field.DimValue~=1);% list of non singleton dimension names 115 Field.Display.DimValue=Field.DimValue(Field.DimValue~=1);% corresponding list of non singleton dimension values 116 117 117 118 118 %% analyse the input field cells … … 159 159 set(handles.vector_x,'String',Field.Display.ListVarName)% fill the menu of x vector components 160 160 set(handles.vector_y,'String',Field.Display.ListVarName)% fill the menu of y vector components 161 set(handles.vector_z,'String', [{''} Field.Display.ListVarName])% fill the menu of y vector components161 set(handles.vector_z,'String',Field.Display.ListVarName)% fill the menu of y vector components 162 162 set(handles.vec_color,'String',[{''} Field.Display.ListVarName])% fill the menu of y vector components 163 163 set(handles.scalar,'Value',1)% fill the menu of y vector components 164 set(handles.scalar,'String',Field.Display.ListVarName)% fill the menu of y vector components164 set(handles.scalar,'String',Field.Display.ListVarName)% fill the menu for scalar 165 165 set(handles.ordinate,'Value',1)% fill the menu of y vector components 166 set(handles.ordinate,'String',Field.Display.ListVarName)% fill the menu of y vector components166 set(handles.ordinate,'String',Field.Display.ListVarName)% fill the menu of y coordinate for 1D plots 167 167 if isfield(Field,'Conventions')&& strcmp(Field.Conventions,'uvmat/civdata') 168 set(handles.FieldOption,'String',{'1D plot';'scalar';'vectors';'civdata...'}) 168 set(handles.FieldOption,'String',{'1D plot';'scalar';'vectors';'civdata...'})% provides the possibility to come back to civdata 169 169 else 170 170 set(handles.FieldOption,'String',{'1D plot';'scalar';'vectors'}) … … 238 238 set(hObject,'Position',pos_view_field) 239 239 set(handles.get_field,'WindowStyle','modal')% Make the GUI modal 240 241 %% set z coordinate menu if relevant 242 if Field.MaxDim>=3 243 set(handles.Check3D,'Value',1) 244 else 245 set(handles.Check3D,'Value',0) 246 end 247 Check3D_Callback(hObject, eventdata, handles) 240 248 drawnow 241 249 uiwait(handles.get_field); 242 243 return244 245 %% set z coordinate menu if relevant246 if Field.MaxDim>=3247 set(handles.vector_z,'Visible','on')248 set(handles.vector_z,'String',Field.ListVarName(~Field.Check0D))249 set(handles.Coord_z,'Visible','on')250 set(handles.SwitchVarIndexZ,'Visible','on')251 set(handles.Z_title,'Visible','on')252 else253 set(handles.vector_z,'Visible','off')254 set(handles.Coord_z,'Visible','off')255 set(handles.Z_title,'Visible','off')256 end257 258 %% make selections according to ParamIn259 if isfield(ParamIn,'vector_x') && isfield(ParamIn,'vector_y')260 261 end262 250 263 251 %------------------------------------------------------------------------ … … 431 419 end 432 420 end 433 scalar_index=find(~test_coord,1);%get the first variable not a coordi ante421 scalar_index=find(~test_coord,1);%get the first variable not a coordinate 434 422 if isempty(scalar_index) 435 423 set(handles.scalar,'Value',1) … … 589 577 test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordiante 590 578 dim_var=Field.Display.VarDimName{scalar_index};%list of dimensions of the selected variable 591 CheckDimensionX=get(handles.CheckDimensionX,'Value'); 592 CheckDimensionY=get(handles.CheckDimensionY,'Value'); 593 if ~CheckDimensionX || ~CheckDimensionY 579 if ~get(handles.CheckDimensionX,'Value') || ~get(handles.CheckDimensionY,'Value') 594 580 %look for coordinate variables among the other variables 595 581 for ilist=1:numel(Field.Display.VarDimName) … … 616 602 SwitchVarIndexTime_Callback([], [], handles) 617 603 end 618 % if numel(var_component)<2 619 % if numel(test_coord)<2 620 % ListCoord={''}; 621 % else 622 % set(handles.Coord_x,'Value',2) 623 % set(handles.Coord_y,'Value',1) 624 % end 625 % else 604 626 605 coord_val=[0 0]; 627 606 % look for labelled unstructured coordinates … … 644 623 end 645 624 end 646 if CheckDimensionX625 if get(handles.CheckDimensionX,'Value') 647 626 set(handles.Coord_x,'Value',2) 648 627 set(handles.Coord_x,'String',dim_var') … … 651 630 set(handles.Coord_x,'String',ListCoord) 652 631 end 653 if CheckDimensionY632 if get(handles.CheckDimensionY,'Value') 654 633 set(handles.Coord_y,'Value',1) 655 634 set(handles.Coord_y,'String',dim_var') … … 657 636 set(handles.Coord_y,'Value',coord_val(2)) 658 637 set(handles.Coord_y,'String',ListCoord) 638 end 639 if get(handles.CheckDimensionZ,'Value') 640 set(handles.Coord_z,'Value',1) 641 set(handles.Coord_z,'String',dim_var') 642 else 643 set(handles.Coord_z,'Value',coord_val(2)) 644 set(handles.Coord_z,'String',ListCoord) 659 645 end 660 646 … … 860 846 % --- Executes on selection change in SwitchVarIndexTime. 861 847 %------------------------------------------------------------------------ 848 862 849 function SwitchVarIndexTime_Callback(hObject, eventdata, handles) 863 850 … … 891 878 case 'variable'% TimeName menu represents the available variables 892 879 set(handles.TimeName, 'Visible','on') 893 TimeVarName=Field.Display.SingleVarName;% slist of variables with a single dimension (candidate for time) 894 List=get(handles.TimeName,'String'); 895 option=List{get(handles.TimeName,'Value')}; 896 ind=find(strcmp(option,TimeVarName)); 897 if isempty(ind) 898 set(handles.TimeName, 'Value',1); 899 else 900 set(handles.TimeName, 'Value',ind); 901 end 902 set(handles.TimeName, 'String',TimeVarName) 903 case 'matrix_index'% TimeName menu represents the available dimensions 880 VarNbDim=cellfun('length',Field.Display.VarDimName); % check the nbre of dimensions of each input variable 881 TimeVarName=Field.Display.ListVarName(VarNbDim==1);% list of variables with a single dimension (candidate for time) 882 List=get(handles.TimeName,'String');% list of names on the menu for time 883 if isempty(List) 884 ind=1; 885 else 886 option=List{get(handles.TimeName,'Value')};% previous selected option 887 ind=find(strcmp(option,TimeVarName)); %check whether the previous selection is available in the newlist 888 if isempty(ind) 889 ind=1; 890 end 891 end 892 if ~isempty(TimeVarName) 893 set(handles.TimeName, 'Value',ind);% select first value in the menu if the option is not found 894 set(handles.TimeName, 'String',TimeVarName)% update the menu for time name 895 end 896 case 'matrix index'% TimeName menu represents the available dimensions 904 897 set(handles.TimeName, 'Visible','on') 905 898 set(handles.TimeName, 'Value',1); … … 966 959 case 'vectors' 967 960 end 968 % hObject handle to CheckDimensionY (see GCBO) 969 % eventdata reserved - to be defined in a future version of MATLAB 970 % handles structure with handles and user data (see GUIDATA) 971 972 % Hint: get(hObject,'Value') returns toggle state of CheckDimensionY 961 962 963 % --- Executes on button press in CheckDimensionZ. 964 function CheckDimensionZ_Callback(hObject, eventdata, handles) 965 FieldList=get(handles.FieldOption,'String'); 966 FieldOption=FieldList{get(handles.FieldOption,'Value')}; 967 switch FieldOption 968 case '1D plot' 969 970 case 'scalar' 971 scalar_Callback(hObject, eventdata, handles) 972 case 'vectors' 973 end 974 975 % --- Executes on selection change in TimeName. 976 function TimeName_Callback(hObject, eventdata, handles) 977 index=get(handles.SwitchVarIndexTime,'Value'); 978 if index==3 ; % TimeName is used to chose a variable 979 index=get(handles.TimeName,'Value'); 980 string=get(handles.TimeName,'String'); 981 VarName=string{index}; 982 end 983 update_field(handles,VarName) 984 985 986 % --- Executes on button press in Check3D. 987 function Check3D_Callback(hObject, eventdata, handles) 988 if get(handles.Check3D,'Value') 989 status='on'; 990 else 991 status='off'; 992 end 993 set(handles.Coord_z,'Visible',status) 994 set(handles.CheckDimensionZ,'Visible',status) 995 set(handles.Z_title,'Visible',status) 996 set(handles.vector_z,'Visible',status) 997 set(handles.W_title,'Visible',status) 998 999 -
trunk/src/msgbox_uvmat.m
r746 r747 6 6 % OUTPUT: 7 7 % answer (text string)= 'yes', 'No', 'cancel', or the text string introduced as input 8 % for title='WAITING...', the output is the handle of the figure, to allow deletion by the calling program. 8 9 % 9 10 %INPUT: 10 11 % title: string indicating the type of message box: 11 % title= 'INPUT_TXT',' CONFIMATION' ,'ERROR', 'WARNING', 'INPUT_Y-N','INPUT_MENU'default = 'INPUT_TXT' (the title is displayed in the upper bar of the fig).12 % title= 'INPUT_TXT','INPUT_Y-N','INPUT_MENU','ERROR', 'WARNING','CONFIMATION','WAITING...',default = 'INPUT_TXT' (the title is displayed in the upper bar of the fig). 12 13 % if title='INPUT_TXT', input data is asked in an edit box 13 % if title='CONFIMATION'', 'ERROR', 'WARNING', the figure remains opened until a button 'OK' is pressed 14 % if title='CONFIMATION'', 'ERROR', 'WARNING','RULER' the figure remains opened until a button 'OK' is pressed 15 % title='RULER' is used for display of length and angle from the ruler tool. 14 16 % if title='INPUT_Y-N', an answer Yes/No is requested 15 % display, displayed text 17 % if title='WAITING...' the figure remains open until the program deletes it 18 % display: displayed text 16 19 % default_answer: default answer in the edit box (only used with title='INPUT_TXT') 17 20 … … 88 91 testCancel=1; %no cancel button 89 92 testNo=1; % button No activated 90 case {'RULER'}93 case 'RULER' 91 94 icontype=''; 92 95 testinputstring=1; … … 97 100 testinputstring=2; 98 101 testCancel=1; %no cancel button 99 case ' INFO'102 case 'WAITING...' 100 103 icontype=''; 101 104 testOK=0; … … 213 216 if strcmp(get(handles.OK,'Visible'),'on') 214 217 delete(handles.figure1); 215 else %case of INFOdisplay (non modal)218 else %case of WAITING... display (non modal) 216 219 varargout{1}=hObject; 217 220 end -
trunk/src/nc2struct.m
r693 r747 28 28 % if ListVarName=[] or {}, no variable value is read (only global attributes and list of variables and dimensions) 29 29 % if ListVarName is absent, or = '*', ALL the variables of the netcdf file are read. 30 % if ListVarName is a cell array with n lines, the set of variables will be sought by order of priority 31 % in the list, while output names will be set by the first line 32 % - the string 'ListGlobalAttribute' followed by a list of attribute names: reads only these attributes (fast reading) 33 % - the string 'TimeVarName', a string (the variable considered as 34 % time), an integer (the selected time index), the cell of other 35 % input variables limited to the input time index (considered as the last index of arrays) 36 % - the string 'TimeDimName', a string (the dimension considered as time), an integer (the selected time index), the cell of other 37 % input variables limited to the input time index (considered as the last index of arrays) 30 % if ListVarName is a cell array with n lines, the set of variables will be sought by order of priority in the list, 31 % while output names will be set by the first line 32 % - the string 'ListGlobalAttribute' followed by a list of attribute names: reads only these attributes (fast reading) 33 % - the string 'TimeVarName', a string (the variable considered as time), an integer or vector with integer values 34 % representing time indices to select, the cell of other input variable names. 35 % - the string 'TimeDimName', a string (the name of the dimension considered as time), an integer or vector with integer values 36 % representing time indices to select, the cell of other input variable names. 38 37 39 38 %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA … … 53 52 %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 54 53 55 function [Data,var_detect,ichoice ]=nc2struct(nc,varargin)56 54 function [Data,var_detect,ichoice,errormsg]=nc2struct(nc,varargin) 55 errormsg='';%default error message 57 56 if isempty(varargin) 58 57 varargin{1}='*'; … … 67 66 68 67 %% open the netcdf file for reading 69 if ischar(nc) 68 if ischar(nc) 70 69 if exist(nc,'file') 71 70 try 72 nc=netcdf.open(nc,'NC_NOWRITE');73 testfile=1;71 nc=netcdf.open(nc,'NC_NOWRITE'); 72 testfile=1; 74 73 catch ME 75 Data.Txt=['ERROR opening ' nc ': ' ME.message];76 return74 errormsg=['ERROR opening ' nc ': ' ME.message]; 75 return 77 76 end 78 77 else 79 Data.Txt=['ERROR:file ' nc ' does not exist'];80 return78 errormsg=['ERROR:file ' nc ' does not exist']; 79 return 81 80 end 82 81 else … … 89 88 valuestr=[];%default 90 89 try 91 valuestr = netcdf.getAtt(nc,netcdf.getConstant('NC_GLOBAL'),varargin{ilist});90 valuestr = netcdf.getAtt(nc,netcdf.getConstant('NC_GLOBAL'),varargin{ilist}); 92 91 catch ME 93 92 end … … 95 94 end 96 95 netcdf.close(nc) 97 return96 return 98 97 end 99 98 100 99 %% time variable or dimension 101 100 input_index=1; 101 CheckTimeVar=0; 102 TimeVarName=''; 102 103 if isequal(varargin{1},'TimeVarName') 103 104 TimeVarName=varargin{2}; 104 TimeVarIndex=varargin{3}; 105 input_index=4; 105 CheckTimeVar=1; 106 TimeIndex=varargin{3}; 107 input_index=4;% list of varibles to read is at fourth argument 106 108 elseif isequal(varargin{1},'TimeDimName') 107 109 TimeDimName=varargin{2}; 108 Time VarIndex=varargin{3};110 TimeIndex=varargin{3}; 109 111 input_index=4; 110 112 end 111 113 112 114 %% full reading: get the nbre of dimensions, variables, global attributes 113 ListVarName=varargin{input_index}; 115 ListVarName=varargin{input_index}; 114 116 [ndims,nvars,ngatts]=netcdf.inq(nc);%nbre of dimensions, variables, global attributes, in the netcdf file 115 117 … … 130 132 eval(['Data.' keystr '=valuestr;']) 131 133 else 132 eval(['Data.' keystr '='';']) 134 eval(['Data.' keystr '='';']) 133 135 end 134 136 att_key{iatt}=keystr; … … 139 141 end 140 142 Data.ListGlobalAttribute=att_key; 141 143 142 144 %% -------- read dimension names----------- 143 145 ListDimNameNetcdf=cell(1,ndims); … … 146 148 [ListDimNameNetcdf{idim},dim_value(idim)] = netcdf.inqDim(nc,idim-1);%get name and value of each dimension 147 149 end 148 if ~isempty(ListDimNameNetcdf) 150 if ~isempty(ListDimNameNetcdf) 149 151 flag_used=zeros(1,ndims);%initialize the flag indicating the selected dimensions in the list (0=unused) 150 152 end 151 153 if isequal(varargin{1},'TimeDimName')% time dimension introduced 152 TimeDimIndex=find(strcmp( varargin{2},ListDimNameNetcdf));154 TimeDimIndex=find(strcmp(TimeDimName,ListDimNameNetcdf)); 153 155 if isempty(TimeDimIndex) 154 Data.Txt=['requested time dimension ' varargin{2} ' not found'];156 errormsg=['requested time dimension ' varargin{2} ' not found']; 155 157 return 156 158 end 157 159 if dim_value(TimeDimIndex)<varargin{3} 158 Data.Txt=['requested time index ' num2str(varargin{3}) ' exceeds matrix dimension'];160 errormsg=['requested time index ' num2str(varargin{3}) ' exceeds matrix dimension']; 159 161 return 160 162 end 161 end 162 163 end 164 163 165 %% -------- read names of variables ----------- 164 166 ListVarNameNetcdf=cell(1,nvars); %default … … 166 168 nbatt=zeros(1,nvars); 167 169 for ncvar=1:nvars %loop on the variables of the netcdf file 168 %get name, type, dimensions and attribute numbers of each variable 170 %get name, type, dimensions and attribute numbers of each variable 169 171 [ListVarNameNetcdf{ncvar},xtype(ncvar),dimids{ncvar},nbatt(ncvar)] = netcdf.inqVar(nc,ncvar-1); 170 end 171 testmulti=0;172 end 173 % testmulti=0; 172 174 if isequal(ListVarName,'*')||isempty(ListVarName) 173 var_index=1:nvars; %all the variables are selected in the netcdf file 175 var_index=1:nvars; %all the variables are selected in the netcdf file 174 176 Data.ListVarName=ListVarNameNetcdf; 175 177 else %select input variables, if requested by the input ListVarName 176 ind_remove=[];177 178 check_keep=ones(1,size(ListVarName,2)); 178 179 for ivar=1:size(ListVarName,2) % check redondancy of variable names … … 181 182 end 182 183 end 183 ListVarName=ListVarName(:,logical(check_keep)); 184 ListVarName=ListVarName(:,logical(check_keep)); 184 185 sizvar=size(ListVarName); 185 testmulti=(sizvar(1)>1);%test for multiple choice of variable ranked by order of priority186 186 var_index=zeros(1,sizvar(2));%default 187 if testmulti%multiple choice of variable ranked by order of priority187 if sizvar(1)>1 %multiple choice of variable ranked by order of priority 188 188 for iline=1:sizvar(1) 189 189 search_index=find(strcmp(ListVarName{iline,1},ListVarNameNetcdf),1);%look for the first variable name in the list of netcdf variables … … 196 196 iline=1; 197 197 end 198 for ivar=1:sizvar(2) 198 %ListVarName=ListVarName(iline,:);% select the appropriate option for input variable (lin ein the input name matrix) 199 if CheckTimeVar 200 TimeVarIndex=find(strcmp(TimeVarName,ListVarNameNetcdf),1); %look for the index of the time variable in the netcdf list 201 if isempty(TimeVarIndex) 202 errormsg='requested variable for time is missing'; 203 return 204 end 205 TimeDimIndex=dimids{TimeVarIndex}(1)+1; 206 ListVarName=[ListVarName {TimeVarName}]; 207 end 208 for ivar=1:size(ListVarName,2) 199 209 search_index=find(strcmp(ListVarName{iline,ivar},ListVarNameNetcdf),1);%look for the variable name in the list of netcdf file 200 210 if ~isempty(search_index) … … 202 212 end 203 213 end 204 var_detect=(var_index~=0);%=1 for detected variables 214 var_detect=(var_index~=0);%=1 for detected variables 205 215 list_index=find(var_index);% indices in the input list corresponding to a detected variable 206 216 var_index=var_index(list_index);% netcdf variable indices corresponding to the output list of read variable 207 217 Data.ListVarName=ListVarName(1,list_index);%the first line of ListVarName sets the output names of the variables 208 218 end 209 210 %% get the dimensions and attributes associated to variables211 var_dim=cell(size(var_index));% initiate list of dimensions for variables219 220 %% get the dimensions and attributes associated to variables 221 var_dim=cell(size(var_index));% initiate list of dimensions for variables 212 222 for ivar=1:length(var_index) 213 223 var_dim{ivar}=dimids{var_index(ivar)}+1; %netcdf dimension indices used by the variable #ivar … … 222 232 end 223 233 try 224 if isempty(valuestr)225 Data.VarAttribute{ivar}.(attname)=valuestr;226 end234 if isempty(valuestr) 235 Data.VarAttribute{ivar}.(attname)=valuestr; 236 end 227 237 catch ME 228 238 display(attname) 229 239 display(valuestr) 230 display(ME.message) 240 display(ME.message) 231 241 Data.VarAttribute{ivar}.(['atrr_' num2str(iatt)])='not read'; 232 242 end … … 234 244 end 235 245 236 237 246 %% select the dimensions used for the set of input variables 238 if ~isempty(var_index) 239 dim_index=find(flag_used);%list of netcdf dimensions indices corresponding to used dimensions 240 Data.ListDimName=ListDimNameNetcdf(dim_index); 247 if ~isempty(var_index) 248 dim_index=find(flag_used);%list of netcdf dimensions indices corresponding to used dimensions 249 Data.ListDimName=ListDimNameNetcdf(dim_index); 241 250 Data.DimValue=dim_value(dim_index); 251 if input_index==4% if a dimension is selected as time 252 Data.DimValue(TimeDimIndex)=numel(TimeIndex); 253 end 242 254 end 243 255 … … 246 258 for ivar=1:length(var_index) 247 259 VarName=Data.ListVarName{ivar}; 248 VarName=regexprep(VarName,'-',' '); %suppress '-' if it exists in the netcdf variable name249 CheckSub=0;260 VarName=regexprep(VarName,'-','_'); %suppress '-' if it exists in the netcdf variable name (leads to errors in matlab) 261 % CheckSub=0; 250 262 if input_index==4% if a dimension is selected as time 251 if var_dim{ivar}(end)==TimeDimIndex% if the last dim of the variable is the time 252 slice_length=prod(var_dim{ivar}(1:end-1)); 253 Data.(VarName)=double(netcdf.getVar(nc,var_index(ivar)-1,TimeIndex*slice_length,slice_length)); %read the variable data 254 CheckSub=1; 255 end 256 end 257 if ~CheckSub 263 ind_vec=zeros(1,numel(var_dim{ivar}));% vector with zeros corresponding to al the dimensions of the variable VarName 264 ind_size=dim_value(var_dim{ivar});% vector giving the size of the variable VarName 265 index_time=find(var_dim{ivar}==TimeDimIndex); 266 if ~isempty(index_time) 267 ind_vec(index_time)=TimeIndex-1;% selected index(or indices) to read 268 ind_size(index_time)=numel(TimeIndex);%length of the selected set of time indices 269 if numel(TimeIndex)==1 && ~strcmp(VarName,TimeVarName) 270 Data.VarDimName{ivar}(index_time)=[];% for a single selected time remove the time in the list of dimensions (except for tTime itself) 271 end 272 end 273 Data.(VarName)=double(netcdf.getVar(nc,var_index(ivar)-1,ind_vec,ind_size)); %read the variable data 274 Data.(VarName)=squeeze(Data.(VarName));%remove singeton dimension 275 else 258 276 Data.(VarName)=netcdf.getVar(nc,var_index(ivar)-1); %read the whole variable data 259 if xtype(var_index(ivar))==5 277 end 278 if xtype(var_index(ivar))==5 260 279 Data.(VarName)=double(Data.(VarName)); %transform to double for single pecision 261 end262 280 end 263 281 end … … 267 285 %% -------- close fle----------- 268 286 if testfile==1 269 netcdf.close(nc) 270 end 271 272 %% old netcdf library 287 netcdf.close(nc) 288 end 289 290 %% old netcdf library 273 291 else 274 292 [Data,var_detect,ichoice]=nc2struct_toolbox(nc,varargin); -
trunk/src/proj_field.m
r738 r747 1296 1296 Coord{1}=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(1)}); 1297 1297 Coord{2}=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(2)}); 1298 if NbDim==3 1299 Coord{3}=FieldData.(FieldData.ListVarName{CellInfo{icell}.CoordIndex(3)}); 1300 end 1298 1301 if numel(Coord{NbDim-1})==2 1299 1302 DY=(Coord{NbDim-1}(2)-Coord{NbDim-1}(1))/(DimValue(1)-1); … … 1302 1305 DX=(Coord{NbDim}(2)-Coord{NbDim}(1))/(DimValue(2)-1); 1303 1306 end 1304 if testYMin%test_direct(indY) 1305 YIndexMin=(YMin-Coord{NbDim-1}(1))/DY+1;% matrix index corresponding to the min y value for the new field 1306 YIndexMax=(YMax-Coord{NbDim-1}(1))/DY+1;% matrix index corresponding to the max y value for the new field 1307 if testYMax 1308 YIndexMax=(YMax-Coord{NbDim-1}(1))/DY+1;% matrix index corresponding to the max y value for the new field 1309 if testYMin%test_direct(indY) 1310 YIndexMin=(YMin-Coord{NbDim-1}(1))/DY+1;% matrix index corresponding to the min x value for the new field 1311 else 1312 YIndexMin=1; 1313 end 1307 1314 else 1308 YIndexM in=(Coord{NbDim-1}(1)-YMax)/DY+1;1309 YIndexM ax=(Coord{NbDim-1}(1)-YMin)/DY+1;1310 Ybound(2)=Coord{NbDim-1}(1)-DY*(YIndexMax-1);1311 Ybound(1)=Coord{NbDim-1}(1)-DY*(YIndexMin-1);1312 end1313 if testXMin%test_direct(NbDim)==11314 XIndexMin=(XMin-Coord{NbDim}(1))/DX+1;% matrix index corresponding to the min x value for the new field1315 XIndexMax=(XMax-Coord{NbDim}(1))/DX+1;% matrix index corresponding to the max x value for the new field1316 Xbound(1)=Coord{NbDim}(1)+DX*(XIndexMin-1);% x value corresponding to XIndexMin1317 Xbound(2)=Coord{NbDim}(1)+DX*(XIndexMax-1);% x value corresponding to XIndexMax1315 YIndexMax=Coord{NbDim-1}(end)/DY; 1316 YIndexMin=1; 1317 end 1318 if testXMax 1319 XIndexMax=(XMax-Coord{NbDim}(1))/DY+1;% matrix index corresponding to the max y value for the new field 1320 if testYMin%test_direct(indY) 1321 XIndexMin=(XMin-Coord{NbDim}(1))/DX+1;% matrix index corresponding to the min x value for the new field 1322 else 1323 XIndexMin=1; 1324 end 1318 1325 else 1319 XIndexMin=(Coord{NbDim}(1)-XMax)/DX+1; 1320 XIndexMax=(Coord{NbDim}(1)-XMin)/DX+1; 1321 Xbound(2)=Coord{NbDim}(1)+DX*(XIndexMax-1); 1322 Xbound(1)=Coord{NbDim}(1)+DX*(XIndexMin-1); 1323 end 1326 XIndexMax=Coord{NbDim}(end)/DX; 1327 XIndexMin=1; 1328 end 1329 % YIndexMin=(Coord{NbDim-1}(1)-YMax)/DY+1; 1330 % % YIndexMax=(Coord{NbDim-1}(1)-YMin)/DY+1; 1331 % Ybound(2)=Coord{NbDim-1}(1)-DY*(YIndexMax-1); 1332 % Ybound(1)=Coord{NbDim-1}(1)-DY*(YIndexMin-1); 1333 % end 1334 % if testXMin%test_direct(NbDim)==1 1335 % XIndexMin=(XMin-Coord{NbDim}(1))/DX+1;% matrix index corresponding to the min x value for the new field 1336 % XIndexMax=(XMax-Coord{NbDim}(1))/DX+1;% matrix index corresponding to the max x value for the new field 1337 % Xbound(1)=Coord{NbDim}(1)+DX*(XIndexMin-1);% x value corresponding to XIndexMin 1338 % Xbound(2)=Coord{NbDim}(1)+DX*(XIndexMax-1);% x value corresponding to XIndexMax 1339 % else 1340 % XIndexMin=(Coord{NbDim}(1)-XMax)/DX+1; 1341 % XIndexMax=(Coord{NbDim}(1)-XMin)/DX+1; 1342 % Xbound(2)=Coord{NbDim}(1)+DX*(XIndexMax-1); 1343 % Xbound(1)=Coord{NbDim}(1)+DX*(XIndexMin-1); 1344 % end 1324 1345 YIndexRange(1)=ceil(min(YIndexMin,YIndexMax));%first y index to select from the previous field 1325 1346 YIndexRange(1)=max(YIndexRange(1),1);% avoid bound lower than the first index … … 1346 1367 else 1347 1368 if NbDim==3 1369 DZ=(Coord{1}(end)-Coord{1}(1))/(numel(Coord{1})-1); 1348 1370 DimCell(1)=[]; %suppress z variable 1349 1371 DimValue(1)=[]; 1372 test_direct=1;%TOdo; GENERALIZE, SEE CASE OF points 1350 1373 if test_direct(1) 1351 1374 iz=ceil((ObjectData.Coord(1,3)-Coord{1}(1))/DZ)+1; -
trunk/src/read_field.m
r693 r747 36 36 errormsg=''; 37 37 if ~exist(FileName,'file') 38 erro msg=['input file ' FileName ' does not exist'];38 errormsg=['input file ' FileName ' does not exist']; 39 39 return 40 40 end … … 92 92 end 93 93 else % an operator 'vec' or 'norm' is used 94 %Operator=r.Operator;95 94 if ~check_colorvar(ilist) && strcmp(r.Operator,'norm') 96 95 ProjModeRequestVar='interp_lin';%scalar field (requires interpolation for plot) … … 121 120 end 122 121 if isfield(ParamIn,'TimeDimName')% case of reading of a single time index in a multidimensional array 123 [Field,var_detect,ichoice]=nc2struct(FileName,'TimeDimName',ParamIn.TimeDimName,num,[ParamIn.Coord_x (ParamIn.Coord_y) ListVar]); 124 else 125 [Field,var_detect,ichoice]=nc2struct(FileName,[ParamIn.Coord_x (ParamIn.Coord_y) ListVar]); 126 end 127 if isfield(Field,'Txt') 128 errormsg=Field.Txt; 122 [Field,var_detect,ichoice,errormsg]=nc2struct(FileName,'TimeDimName',ParamIn.TimeDimName,num,[ParamIn.Coord_x (ParamIn.Coord_y) ListVar]); 123 elseif isfield(ParamIn,'TimeVarName')% case of reading of a single time in a multidimensional array 124 [Field,var_detect,ichoice,errormsg]=nc2struct(FileName,'TimeVarName',ParamIn.TimeVarName,num,[ParamIn.Coord_x (ParamIn.Coord_y) ListVar]); 125 else 126 [Field,var_detect,ichoice,errormsg]=nc2struct(FileName,[ParamIn.Coord_x (ParamIn.Coord_y) (ParamIn.Coord_z) ListVar]); 127 end 128 if ~isempty(errormsg) 129 129 return 130 130 end -
trunk/src/set_object.m
r745 r747 701 701 norm_plane(3)=OmAxis(3)*coeff+cos_om; 702 702 end 703 Coord=get(handles.Coord,'Data'); 704 Coord(3)=Z_value; 705 set(handles.Coord,'Data',Coord) 703 706 704 707 % update graph -
trunk/src/uvmat.m
r745 r747 195 195 set(handles.PlotAxes,'UserData',AxeData) 196 196 % position of table Coord_y 197 set(handles.Coord_y,'Unit','pixel')198 Pos=get(handles.Coord_y,'Position');199 set(handles.Coord_y,'Unit','normalized')200 set(handles.Coord_y,'ColumnWidth',{Pos(3)})201 set(handles.Coord_y,'ColumnFormat',{'char'})202 set(handles.Coord_y,'ColumnEditable',false)203 set(handles.Coord_y,'ColumnName',{''})197 %set(handles.Coord_y,'Unit','pixel') 198 % Pos=get(handles.Coord_y,'Position'); 199 % set(handles.Coord_y,'Unit','normalized') 200 % set(handles.Coord_y,'ColumnWidth',{Pos(3)}) 201 % set(handles.Coord_y,'ColumnFormat',{'char'}) 202 % set(handles.Coord_y,'ColumnEditable',false) 203 % set(handles.Coord_y,'ColumnName',{''}) 204 204 205 205 %% set functions for the mouse and keyboard … … 994 994 % time not set by the input file: images or civ data: indicate that time is read from the xml file 995 995 if isfield(XmlData,'Time')&& ~isempty(XmlData.Time) && ... 996 (strcmp(FileType,'image')|| strcmp(FileType,'multimage') ||strcmp(FileType,'civdata')||strcmp(FileType,'civx'))996 (strcmp(FileType,'image')|| strcmp(FileType,'multimage'))%||strcmp(FileType,'civdata')||strcmp(FileType,'civx')) 997 997 TimeName='xml'; 998 998 elseif strcmp(FileType,'civdata') … … 1110 1110 set(handles.ColorScalar,'String',ColorList) 1111 1111 set(handles.Vectors,'Visible','on') 1112 set(handles.Coord_x,'Value',1);1112 %set(handles.Coord_x,'Value',1); 1113 1113 set(handles.Coord_x,'String','X'); 1114 % set(handles.Coord_y,'Value',1); 1115 set(handles.Coord_y,'Data',{'Y'}); 1114 set(handles.Coord_y,'String','Y'); 1116 1115 case 'netcdf' 1117 1116 set(handles_Fields,'Value',1) … … 1125 1124 set(handles_Fields,'Value',1) % set menu to 'image' 1126 1125 set(handles_Fields,'String',{'image'}) 1127 set(handles.Coord_x,'Value',1);1126 %set(handles.Coord_x,'Value',1); 1128 1127 set(handles.Coord_x,'String','AX'); 1129 set(handles.Coord_y,' Data',{'AY'});1128 set(handles.Coord_y,'String','AY'); 1130 1129 end 1131 1130 set(handles.uvmat,'UserData',UvData) 1132 1131 1133 %% set index navigation options and inputfilerefresh plots1132 %% set index navigation options 1134 1133 scan_option='i';%default 1135 1134 state_j='off'; %default … … 1623 1622 FileExt=InputFile.FileExt; 1624 1623 NomType=InputFile.NomType; 1625 % i1=str2num(get(handles.i1,'String'));%read the field indices (for movie, it is not given by the file name)1626 % i2=[];%default1627 % if strcmp(get(handles.i2,'Visible'),'on')1628 % i2=str2num(get(handles.i2,'String'));1629 % end1630 % j1=[];1631 % if strcmp(get(handles.j1,'Visible'),'on')1632 % j1=stra2num(get(handles.j1,'String'));1633 % end1634 % j2=j1;1635 % if strcmp(get(handles.j2,'Visible'),'on')1636 % j2=stra2num(get(handles.j2,'String'));1637 % end1638 1624 [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(InputFile.FileIndex);% check back the indices used 1639 1625 if isempty(i1) … … 1700 1686 end 1701 1687 else % free increment 1702 runaction=get(gcbo,'tag');1688 % runaction=get(gcbo,'tag'); 1703 1689 if strcmp(increment,'+')% if runplus or movie is activated 1704 1690 step=1; … … 1817 1803 filename=fullfile_uvmat(InputFile.RootPath,InputFile.SubDir,InputFile.RootFile,FileExt,NomType,i1,i2,j1,j2); 1818 1804 1819 %% inputfilerefresh plots1805 %% refresh plots 1820 1806 if sub_value 1821 1807 filename_1=fullfile_uvmat(InputFile.RootPath_1,InputFile.SubDir_1,InputFile.RootFile_1,InputFile.FileExt_1,InputFile.NomType_1,i1_1,i2_1,j1_1,j2_1); … … 2149 2135 end 2150 2136 case {'video','mmreader'} 2151 ParamIn=UvData.MovieObject{1}; 2137 ParamIn=UvData.MovieObject{1}; % movie object 2152 2138 if strcmp(NomType,'*') 2153 2139 frame_index=num_i1;%frame index from a single movies or multimage … … 2174 2160 ParamIn.VelType=VelType; 2175 2161 ParamIn.Coord_x=get(handles.Coord_x,'String'); 2176 ParamIn.Coord_y=get(handles.Coord_y,'Data'); 2177 end 2178 check_tps = 0; 2179 if strcmp(UvData.FileType{1},'civdata')&&~strcmp(ParamIn.FieldName,'velocity')&&~strcmp(ParamIn.FieldName,'get_field...') 2180 check_tps=1;%tps needed to get the requested field 2181 end 2162 ParamIn.Coord_y=get(handles.Coord_y,'String'); 2163 ParamIn.Coord_z=get(handles.Coord_z,'String'); 2164 TimeName=get(handles.TimeName,'String'); 2165 r=regexp(TimeName,'^(?<type>(dim:)|(var:))','names');%look for 'var:' or 'dim:' at the beginning of time name 2166 if ~isempty(r) 2167 frame_index=num_i1;%time index chosen by i1 2168 if strcmp(r.type,'dim:') 2169 ParamIn.TimeDimName=TimeName(5:end); 2170 elseif strcmp(r.type,'var:') 2171 ParamIn.TimeVarName=TimeName(5:end); 2172 end 2173 end 2174 end 2175 % check_tps = 0; 2176 % if strcmp(UvData.FileType{1},'civdata')&&~strcmp(ParamIn.FieldName,'velocity')&&~strcmp(ParamIn.FieldName,'get_field...') 2177 % check_tps=1;%tps needed to get the requested field 2178 % end 2182 2179 [Field{1},ParamOut,errormsg] = read_field(FileName,UvData.FileType{1},ParamIn,frame_index); 2183 2180 if ~isempty(errormsg) … … 2224 2221 case {'video','mmreader'} 2225 2222 ParamIn_1=UvData.MovieObject{2}; 2226 2223 if ~strcmp(NomType_1,'*') 2227 2224 frame_index_1=j1_1;%frame index for movies or multimage 2228 2225 else … … 2245 2242 end 2246 2243 if isequal(get(handles.NomType_1,'Visible'),'on') 2247 NomType_1=get(handles.NomType_1,'String');2244 NomType_1=get(handles.NomType_1,'String'); 2248 2245 else 2249 2246 NomType_1=get(handles.NomType,'String'); … … 2261 2258 ParamIn_1.VelType=VelType_1; 2262 2259 ParamIn_1.Coord_x=get(handles.Coord_x,'String'); 2263 ParamIn_1.Coord_y=get(handles.Coord_y,' Data');2260 ParamIn_1.Coord_y=get(handles.Coord_y,'String'); 2264 2261 end 2265 2262 [Field{2},ParamOut_1,errormsg] = read_field(FileName_1,UvData.FileType{2},ParamIn_1,frame_index_1); … … 2312 2309 test_veltype_1=0; 2313 2310 if isempty(FileName_1) 2314 % set(handles.FieldName_1,'Value',1); %update the field menu2315 % if isstruct(ParamOut)2316 % set(handles.FieldName_1,'String',[{''};ParamOut.FieldList]); %update the field menu2317 % end2318 2311 elseif ~test_keepdata_1 2319 2312 if (strcmp(UvData.FileType{2},'civx')||strcmp(UvData.FileType{2},'civdata'))&& ~strcmp(FieldName_1,'get_field...') 2320 % if (~strcmp(UvData.FileType{2},'netcdf')&&~strcmp(UvData.FileType{2},'civdata')&&~strcmp(UvData.FileType{2},'civx'))|| isequal(FieldName_1,'get_field...')2321 2313 test_veltype_1=1; 2322 2314 set(handles.VelType_1,'Visible','on') … … 2373 2365 TimeUnit=''; 2374 2366 if isfield(UvData,'TimeUnit') 2375 TimeUnit=UvData.TimeUnit;%retrieve info from update_rootinfo 2376 end 2367 TimeUnit=UvData.TimeUnit;%retrieve info from update_rootinfo 2368 end 2369 TimeName=get(handles.TimeName,'String'); 2370 2377 2371 % time from xml file or video movie 2378 TimeName=get(handles.TimeName,'String');% indicate that time is from xml2379 2372 if strcmp(TimeName,'xml')||strcmp(TimeName,'video') 2380 2373 if isempty(num_i2)||isnan(num_i2) … … 2398 2391 end 2399 2392 2400 % gettime in the input file, not defined in a xml file or movie2393 % time in the input file, not defined in a xml file or movie 2401 2394 if isempty(abstime) 2402 2395 if strcmp(TimeName,'civdata')||strcmp(TimeName,'civx') 2403 2396 abstime=Field{1}.Time; 2404 elseif ~isempty(regexp(TimeName,'^att:'))||~isempty(regexp(TimeName,'^var:')) 2405 abstime=Field{1}.(TimeName(5:end));%the time is an attribute or variale selected by get_file 2397 elseif ~isempty(regexp(TimeName,'^att:', 'once')) 2398 abstime=Field{1}.(TimeName(5:end));%the time is an attribute selected by get_file 2399 if isfield(Field{1},[TimeName(5:end) 'Unit']) 2400 TimeUnit=Field{1}.([TimeName(5:end) 'Unit']); 2401 else 2402 TimeUnit=''; 2403 end 2404 elseif ~isempty(regexp(TimeName,'^var:')) 2405 abstime=Field{1}.(TimeName(5:end));%the time is a variale selected by get_file 2406 % TODO: look for time unit attribute 2406 2407 elseif ~isempty(regexp(TimeName,'^dim:')) 2407 2408 abstime=str2num(get(handles.i1,'String')); 2409 TimeUnit='index'; 2408 2410 end 2409 2411 if isfield(Field{1},'Dt') 2410 2412 dt=Field{1}.Dt;%dt read from the netcdf input file 2411 if isfield(Field{1},'TimeUnit')2412 TimeUnit=Field{1}.TimeUnit;2413 end2414 2413 elseif numel(Field)==2 && isfield(Field{2},'Dt')%dt obtained from the second field if not defined in the first 2415 2414 dt=Field{2}.Dt;%dt read from the netcdf input file 2416 if isfield(Field{2},'TimeUnit')2417 TimeUnit=Field{2}.TimeUnit;2418 end2419 2415 end 2420 2416 end … … 2523 2519 UvData.Field=find_field_bounds(UvData.Field); 2524 2520 2525 if UvData.Field.NbDim>12526 % default projection plane2527 if isempty(UvData.ProjObject{1})2528 UvData.ProjObject{1}.Type='plane';%main plotting plane2529 UvData.ProjObject{1}.ProjMode='projection';%main plotting plane2530 % UvData.ProjObject{1}.Coord=[0 0 0];2531 UvData.ProjObject{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat2532 UvData.ProjObject{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat2533 end2534 %% 3D case (menuvolume)2535 if UvData.Field.NbDim==3% && UvData.NewSeries2536 test_set_object=1;2537 hset_object=findobj(allchild(0),'tag','set_object');% look for the set_object GUI2538 ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider2539 ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider2540 if ~isempty(hset_object) %if set_object is detected2541 delete(hset_object);% delete the GUI set_object if it does not fit2542 end2543 if test_set_object% reinitiate the GUI set_object2544 delete_object(1);% delete the current projection object in the list UvData.ProjObject, delete its graphic representations and update the list displayed in handles.ListObject and 22545 UvData.ProjObject{1}.NbDim=NbDim;%test for 3D objects2546 UvData.ProjObject{1}.RangeZ=UvData.Field.CoordMesh;%main plotting plane2547 UvData.ProjObject{1}.Coord(1,3)=(UvData.Field.ZMin+UvData.Field.ZMax)/2;%section at a middle plane chosen2548 UvData.ProjObject{1}.Angle=[0 0 0];2549 UvData.ProjObject{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR2550 UvData.ProjObject{1}.Name='1-PLANE';2551 UvData.ProjObject{1}.enable_plot=1;2552 set_object(UvData.ProjObject{1},handles,ZBounds);2553 set(hset_object,'name','set_object');% rename if set_object already used with series2554 set(handles.ListObject,'Value',1);2555 set(handles.ListObject,'String',{'1-PLANE'});2556 set(handles.CheckEditObject,'Value',1)% put the plane in edit mode to enable the z cursor2557 CheckEditObject_Callback([],[], handles)2558 end2559 %multilevel case (single menuplane in a 3D space)2560 elseif isfield(UvData,'Z')2561 if isfield(UvData,'CoordType')&& isequal(UvData.CoordType,'phys') && isfield(UvData,'XmlData')2562 XmlData=UvData.XmlData{1};2563 if isfield(XmlData,'PlanePos')2564 UvData.ProjObject{1}.Coord=XmlData.PlanePos(UvData.ZIndex,:);2565 end2566 if isfield(XmlData,'PlaneAngle')2567 siz=size(XmlData.PlaneAngle);2568 indangle=min(siz(1),UvData.ZIndex);%take first angle if a single angle is defined (translating scanning)2569 UvData.ProjObject{1}.PlaneAngle=XmlData.PlaneAngle(indangle,:);2570 end2571 elseif isfield(UvData,'ZIndex')2572 UvData.ProjObject{1}.ZObject=UvData.ZIndex;2573 end2574 end2575 end2576 2577 2521 testnewseries=UvData.NewSeries; 2578 2522 UvData.NewSeries=0;% put to 0 the test for a new field series (set by RootPath_callback) 2579 set(handles.uvmat,'UserData',UvData)2580 2523 2581 2524 %% reset the min and max of scalar if only the mask is displayed(TODO: check the need) … … 2588 2531 if UvData.Field.NbDim<=1 2589 2532 set(handles.Objects,'Visible','off') 2590 % set(handles.ListObject_1_title,'Visible','off')2591 % set(handles.ListObject_1,'Visible','off')2592 2533 [PlotType,PlotParamOut]=plot_field(UvData.Field,handles.PlotAxes,read_GUI(handles.uvmat)); 2593 2534 errormsg=fill_GUI(PlotParamOut,handles.uvmat); … … 2597 2538 end 2598 2539 end 2599 2540 set(handles.uvmat,'UserData',UvData) 2600 2541 %% 2D or 3D fieldname are generally projected 2601 2542 else 2602 2543 set(handles.Objects,'Visible','on') 2603 % set(handles.ListObject_1_title,'Visible','on')2604 % set(handles.ListObject_1,'Visible','on')2605 2544 2606 2545 %% Plot the projections on the selected projection objects 2607 % main projection object (uvmat display) 2608 list_object=get(handles.ListObject_1,'String'); 2609 if isequal(list_object,{''})||isequal(list_object,' ')%refresh list of objects if the menu is empty 2546 %if no projection object exists, create a default one 2547 if isempty(UvData.ProjObject{1}) 2610 2548 set(handles.ListObject,'Value',1) 2611 2549 set(handles.ListObject,'String',{'plane'}) … … 2616 2554 set(handles.ListObject_1,'Value',1) 2617 2555 set(handles.ListObject_1,'String',{'plane'}) 2556 if UvData.Field.NbDim==3 %3D case 2557 % ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider 2558 % ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider 2559 UvData.ProjObject{1}.NbDim=3;%test for 3D objects 2560 UvData.ProjObject{1}.RangeZ=UvData.Field.CoordMesh;%main plotting plane 2561 UvData.ProjObject{1}.Coord(1,3)=(UvData.Field.ZMin+UvData.Field.ZMax)/2;%section at a middle plane chosen 2562 UvData.ProjObject{1}.Angle=[0 0 0]; 2563 elseif isfield(UvData,'Z') 2564 %multilevel case (single menuplane in a 3D space) 2565 if isfield(UvData,'CoordType')&& isequal(UvData.CoordType,'phys') && isfield(UvData,'XmlData') 2566 XmlData=UvData.XmlData{1}; 2567 if isfield(XmlData,'PlanePos') 2568 UvData.ProjObject{1}.Coord=XmlData.PlanePos(UvData.ZIndex,:); 2569 end 2570 if isfield(XmlData,'PlaneAngle') 2571 siz=size(XmlData.PlaneAngle); 2572 indangle=min(siz(1),UvData.ZIndex);%take first angle if a single angle is defined (translating scanning) 2573 UvData.ProjObject{1}.PlaneAngle=XmlData.PlaneAngle(indangle,:); 2574 end 2575 elseif isfield(UvData,'ZIndex') 2576 UvData.ProjObject{1}.ZObject=UvData.ZIndex; 2577 end 2578 end 2618 2579 end 2619 2580 IndexObj=get(handles.ListObject_1,'Value');%selected projection object for main view … … 2648 2609 2649 2610 %% second projection object (view_field display) 2650 if length( IndexObj) >=22611 if length( IndexObj)==2 2651 2612 view_field_handle=findobj(allchild(0),'tag','view_field');%handles of the view_field GUI 2652 2613 if ~isempty(view_field_handle) … … 2654 2615 haxes(2)=plot_handles{2}.PlotAxes; 2655 2616 PlotParam{2}=read_GUI(view_field_handle); 2656 % PlotParam{2}=read_GUI(handles.uvmat);%read plotting parameters on the uvmat interface2657 2617 PosColorbar{2}='*'; %TODO: deal with colorbar position on view_field 2658 2618 end … … 2665 2625 if numel(UvData.ProjObject)<iobj 2666 2626 break 2627 end 2628 if UvData.Field.NbDim==3% TO GENERALISE 2629 UvData.ProjObject{iobj}.NbDim=3;%test for 3D objects 2630 UvData.ProjObject{iobj}.RangeZ=UvData.Field.CoordMesh;%main plotting plane 2631 UvData.ProjObject{iobj}.Coord(1,3)=(UvData.Field.ZMin+UvData.Field.ZMax)/2;%section at a middle plane chosen 2632 UvData.ProjObject{iobj}.Angle=[0 0 0]; 2667 2633 end 2668 2634 [ObjectData,errormsg]=proj_field(UvData.Field,UvData.ProjObject{iobj});% project field on the object … … 2727 2693 end 2728 2694 2695 set(handles.uvmat,'UserData',UvData) 2696 2729 2697 %% update the mask 2730 2698 if isequal(get(handles.CheckMask,'Value'),1)%if the mask option is on … … 2778 2746 end 2779 2747 end 2748 2749 if UvData.Field.NbDim==3 2750 CheckEditObject_Callback(handles.uvmat, [], handles) 2751 end 2780 2752 ResizeFcn(handles.uvmat,[],handles) 2781 2753 set(handles.uvmat,'Pointer',pointer) … … 2784 2756 function histo1_menu_Callback(hObject, eventdata, handles) 2785 2757 %-------------------------------------------- 2758 %% get the current field stored in uvmat user data 2759 UvData=get(handles.uvmat,'UserData'); 2760 Field=UvData.Field; 2761 2762 %% get from the menu 'histo1_menu' the name(s) of the fields to use 2786 2763 histo_menu=get(handles.histo1_menu,'String'); 2787 2764 histo_value=get(handles.histo1_menu,'Value'); 2788 2765 FieldName=histo_menu{histo_value}; 2789 2790 UvData=get(handles.uvmat,'UserData');2791 Field=UvData.Field;2792 2766 r=regexp(FieldName,'(?<var1>.*)(?<sep>,)(?<var2>.*)','names'); 2793 2767 FieldName_2=''; 2794 2768 if ~isempty(r) 2795 FieldName=r.var1; 2796 FieldName_2=r.var2; 2769 FieldName=r.var1;% name of first variable 2770 FieldName_2=r.var2;% name of second variable 2797 2771 end 2798 2772 if ~isfield(UvData.Field,FieldName) … … 2800 2774 return 2801 2775 end 2802 FieldHisto=Field.(FieldName); 2803 if isfield(Field,'FF') && ~isempty(Field.FF) && isequal(size(Field.FF),size(FieldHisto)) 2776 2777 %% extract the fields to use 2778 % eliminate false data if relevant (false flag FF exists) 2779 check_false=0; 2780 if isfield(Field,'FF') && ~isempty(Field.FF) && isequal(size(Field.FF),size(Field.(FieldName))) 2804 2781 indsel=find(Field.FF==0);%find values marked as false 2805 2782 if ~isempty(indsel) 2806 FieldHisto=Field Histo(indsel);2783 FieldHisto=Field.(FieldName)(indsel);%field of the first variable (U) 2807 2784 if ~isempty(FieldName_2) 2808 FieldHisto(:,:,2)=Field.(FieldName_2)(indsel); 2809 end 2810 end 2811 elseif ~isempty(FieldName_2) 2812 FieldHisto(:,:,2)=Field.(FieldName_2); 2813 end 2785 if isfield(Field,'NbDim') && Field.NbDim==3 2786 FieldHisto(:,:,:,2)=Field.(FieldName_2)(indsel);%field of the second variable (U) 2787 else 2788 FieldHisto(:,:,2)=Field.(FieldName_2)(indsel);%field of the second variable (U) 2789 end 2790 end 2791 check_false=1; 2792 end 2793 end 2794 % no false data 2795 if ~check_false 2796 FieldHisto=Field.(FieldName);%field of the first variable (U) 2797 if ~isempty(FieldName_2) 2798 if isfield(Field,'NbDim') && Field.NbDim==3 2799 FieldHisto(:,:,:,2)=Field.(FieldName_2);%field of the second variable (V) 2800 else 2801 FieldHisto(:,:,2)=Field.(FieldName_2);%field of the second variable (V) 2802 end 2803 end 2804 end 2805 2806 %% calculate and plot histogram 2814 2807 if isempty(Field) 2815 2808 msgbox_uvmat('ERROR',['empty field ' FieldName]) … … 2844 2837 Histo.VarAttribute{1}.units=units; 2845 2838 end 2846 eval(['Histo.' FieldName '=linspace(Amin,Amax,50);'])%absissa values for histo2839 Histo.(FieldName)=linspace(Amin,Amax,50); %absissa values for histo 2847 2840 if isfield(Field,'NbDim') && isequal(Field.NbDim,3) 2848 2841 C=reshape(double(FieldHisto),1,[]);% reshape in a vector … … 3102 3095 %------------------------------------------------------------------------ 3103 3096 % --- Executes on menu selection FieldName 3104 function FieldName_Callback(hObject, eventdata, handles) 3097 3098 function FieldName_Callback(hObject, eventdata, handles) 3105 3099 %------------------------------------------------------------------------ 3106 3100 … … 3114 3108 [tild,tild,tild,i1,i2,j1,j2,tild,NomType]=fileparts_uvmat(['xxx' get(handles.FileIndex,'String') FileExt]); 3115 3109 3116 switch field 3117 3110 switch field 3118 3111 case 'get_field...' 3119 3112 %% fill the coordinates and variables from selections in get_field … … 3156 3149 FieldList={}; 3157 3150 VecColorList={''}; 3151 ZName=''; 3158 3152 switch GetFieldData.FieldOption 3159 3153 case 'vectors' 3160 3154 UName=GetFieldData.PanelVectors.vector_x; 3161 3155 VName=GetFieldData.PanelVectors.vector_y; 3162 YName={GetFieldData.Coordinates.Coord_y}; 3156 YName=GetFieldData.Coordinates.Coord_y; 3157 if isfield(GetFieldData.Coordinates,'Coord_z') 3158 ZName=GetFieldData.Coordinates.Coord_z; 3159 end 3163 3160 CName=GetFieldData.PanelVectors.vec_color; 3164 3161 FieldList={['vec(' UName ',' VName ')'];... … … 3172 3169 case 'scalar' 3173 3170 AName=GetFieldData.PanelScalar.scalar; 3174 YName={GetFieldData.Coordinates.Coord_y}; 3171 YName=GetFieldData.Coordinates.Coord_y; 3172 if isfield(GetFieldData.Coordinates,'Coord_z') 3173 ZName=GetFieldData.Coordinates.Coord_z; 3174 end 3175 3175 FieldList={AName}; 3176 3176 case '1D plot' … … 3179 3179 display_file_name(handles,FileName,1) 3180 3180 end 3181 % get time as file index, attribute, variable or matrix index 3181 3182 if ~strcmp(GetFieldData.FieldOption,'civdata...') 3182 3183 XName=GetFieldData.Coordinates.Coord_x; … … 3191 3192 set(handles.NomType,'String','*') 3192 3193 set(handles.RootFile,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')]) 3194 set(handles.i1,'String','1')% set counter to 1 (now the time index in the input matrix) 3193 3195 set(handles.FileIndex,'String','') 3194 3196 ParamIn.TimeVarName=GetFieldData.Time.TimeName; 3195 case 'matrix _index'3197 case 'matrix index' 3196 3198 set(handles.TimeName,'String',['dim:' GetFieldData.Time.TimeName]); 3197 3199 set(handles.NomType,'String','*') 3198 3200 set(handles.RootFile,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')]) 3201 set(handles.i1,'String','1')% set counter to 1 (now the time index in the input matrix) 3199 3202 set(handles.FileIndex,'String','') 3200 3203 ParamIn.TimeDimName=GetFieldData.Time.TimeName; 3201 3204 end 3202 3205 set(handles.Coord_x,'String',XName) 3203 if ischar(YName) 3204 YName={YName}; 3205 end 3206 set(handles.Coord_y,'Data',YName) 3206 % if ischar(YName) 3207 % YName={YName}; 3208 % end 3209 set(handles.Coord_y,'String',YName) 3210 set(handles.Coord_z,'String',ZName) 3207 3211 set(handles.FieldName,'Value',1) 3208 3212 set(handles.FieldName,'String',[FieldList; {'get_field...'}]); … … 3313 3317 UName=GetFieldData.PanelVectors.vector_x; 3314 3318 VName=GetFieldData.PanelVectors.vector_y; 3315 YName= {GetFieldData.Coordinates.Coord_y};3319 YName=GetFieldData.Coordinates.Coord_y; 3316 3320 CName=GetFieldData.PanelVectors.vec_color; 3317 3321 FieldList={['vec(' UName ',' VName ')'];... … … 3325 3329 case 'scalar' 3326 3330 AName=GetFieldData.PanelScalar.scalar; 3327 YName= {GetFieldData.Coordinates.Coord_y};3331 YName=GetFieldData.Coordinates.Coord_y; 3328 3332 FieldList={AName}; 3329 3333 case '1D plot' … … 3354 3358 end 3355 3359 set(handles.Coord_x,'String',XName) 3356 if ischar(YName)3357 YName={YName};3358 end3359 set(handles.Coord_y,' Data',YName)3360 % if ischar(YName) 3361 % YName={YName}; 3362 % end 3363 set(handles.Coord_y,'String',YName) 3360 3364 set(handles.FieldName_1,'Value',1) 3361 3365 set(handles.FieldName_1,'String',[FieldList; {'get_field...'}]); … … 3796 3800 3797 3801 %% adapt the GUI to the input/output conditions of the selected transform fct 3798 DataOut=[];3799 3802 CoordUnit=''; 3800 3803 CoordUnitPrev=''; … … 3804 3807 if ~isempty(list_path{ichoice}) 3805 3808 if nargin(transform_handle)>1 && isfield(UvData,'XmlData')&&~isempty(UvData.XmlData) 3806 %XmlData=UvData.XmlData{1}; 3807 DataOut=feval(transform_handle,'*',UvData.XmlData{1}); 3809 DataOut=feval(transform_handle,'*',UvData.XmlData{1});% execute the transform fct to get the required conditions 3808 3810 if isfield(DataOut,'CoordUnit')% set the requested coord unit (info used to possibly delete the current projection objects) 3809 3811 CoordUnit=DataOut.CoordUnit; … … 3814 3816 if isfield(DataOut,'TransformInput')% used to add transform parameters at selection of the transform fct 3815 3817 UvData.XmlData{1}.TransformInput=DataOut.TransformInput; 3816 % ListFields=fieldnames(DataOut.XmlData); 3817 % for ilist=1:numel(ListFields) 3818 % UvData.XmlData{1}.(ListFields{ilist})=DataOut.XmlData.(ListFields{ilist}); 3819 % end 3820 end 3821 % else 3822 % DataOut=feval(transform_handle,'*'); 3823 end 3824 end 3825 3818 end 3819 end 3820 end 3826 3821 3827 3822 %% delete drawn objects if the output CooordUnit is different from the previous one … … 4306 4301 ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on ObjectData 4307 4302 [PlotType,PlotParam]=plot_field(ProjData,hhview_field.PlotAxes,read_GUI(hview_field));%read plotting parameters on the uvmat interface 4308 4309 %write_plot_param(hhview_field,PlotParam); %update the display of plotting parameters for the current object4310 4303 haxes=findobj(hview_field,'tag','axes3'); 4311 4304 pos=get(hview_field,'Position'); … … 4485 4478 end 4486 4479 end 4487 %write_plot_param(hhview_field,PlotParam); %update the display of plotting parameters for the current object4488 4480 haxes=findobj(hview_field,'tag','axes3'); 4489 4481 pos=get(hview_field,'Position'); … … 4494 4486 else 4495 4487 Data=get(hview_field,'UserData'); 4496 % set(hview_field,'Position',Data.GUISize)% restore the size of view_field for plots4497 4488 end 4498 4489 else … … 5545 5536 Param.TransformName=TransformList{get(handles.TransformName,'Value')}; 5546 5537 Param.Coord_x_str=get(handles.Coord_x,'String'); 5547 Param.Coord_x_val=get(handles.Coord_x,'Value');5548 Param.Coord_y_str=get(handles.Coord_y,' Data');5538 %Param.Coord_x_val=get(handles.Coord_x,'Value'); 5539 Param.Coord_y_str=get(handles.Coord_y,'String'); 5549 5540 5550 5541 % -------------------------------------------------------------------- … … 5562 5553 % end 5563 5554 5564 % --- Executes on selection change in Coord_y.5565 function Coord_y_Callback(hObject, eventdata, handles)5566 5567 % --- Executes on selection change in Coord_x.5568 function Coord_x_Callback(hObject, eventdata, handles)5569 5570 5571 % --- Executes on button press in CheckColorBar.5572 function CheckColorBar_Callback(hObject, eventdata, handles)5573 5574 5575 5576 function TransformPath_Callback(hObject, eventdata, handles)5577 % hObject handle to TransformPath (see GCBO)5578 % eventdata reserved - to be defined in a future version of MATLAB5579 % handles structure with handles and user data (see GUIDATA)5580 5581 % Hints: get(hObject,'String') returns contents of TransformPath as text5582 % str2double(get(hObject,'String')) returns contents of TransformPath as a double5583 5555 5584 5556 … … 5692 5664 set(handles.TableDisplay,'Visible','off') 5693 5665 end 5666 5667 5668 5669 function Coord_z_Callback(hObject, eventdata, handles) 5670 % hObject handle to Coord_z (see GCBO) 5671 % eventdata reserved - to be defined in a future version of MATLAB 5672 % handles structure with handles and user data (see GUIDATA) 5673 5674 % Hints: get(hObject,'String') returns contents of Coord_z as text 5675 % str2double(get(hObject,'String')) returns contents of Coord_z as a double 5676 5677 5678 % --- Executes during object creation, after setting all properties. 5679 function Coord_z_CreateFcn(hObject, eventdata, handles) 5680 % hObject handle to Coord_z (see GCBO) 5681 % eventdata reserved - to be defined in a future version of MATLAB 5682 % handles empty - handles not created until after all CreateFcns called 5683 5684 % Hint: edit controls usually have a white background on Windows. 5685 % See ISPC and COMPUTER. 5686 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 5687 set(hObject,'BackgroundColor','white'); 5688 end
Note: See TracChangeset
for help on using the changeset viewer.