Changeset 1095
- Timestamp:
- Mar 31, 2021, 3:32:03 PM (4 years ago)
- Location:
- trunk/src
- Files:
-
- 1 added
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/@xmltree/xmltree.m
r925 r1095 38 38 % Input argument is an XML string 39 39 if (~exist(varargin{1},'file') && ... 40 ~isempty(xml_findstr(varargin{1},'<',1,1)))40 ~isempty(xml_findstr(varargin{1},'<',1,1))) 41 41 tree.tree = xml_parser(varargin{1}); 42 42 tree.filename = ''; 43 % Input argument is an XML filename43 % Input argument is an XML filename 44 44 else 45 fid = fopen(varargin{1},'rt'); 46 if (fid == -1) 47 error(['[XMLTree] Cannot open ' varargin{1}]); 45 if isempty(regexp(varargin{1},'^http://'))%ordinary file (not OpenDAP) 46 fid = fopen(varargin{1},'rt'); 47 if (fid == -1) 48 error(['[XMLTree] Cannot open ' varargin{1}]); 49 end 50 xmlstr = fread(fid,'*char')'; 51 %xmlstr = fscanf(fid,'%c'); 52 fclose(fid); 53 else 54 xmlstr=webread(varargin{1});%OpenDAP case 48 55 end 49 xmlstr = fread(fid,'*char')';50 %xmlstr = fscanf(fid,'%c');51 fclose(fid);52 56 tree.tree = xml_parser(xmlstr); 53 tree.filename = varargin{1}; 57 tree.filename = varargin{1}; 54 58 end 55 59 tree = class(tree,'xmltree'); 56 else 60 else 57 61 error('[XMLTree] Bad input argument'); 58 62 end -
trunk/src/find_field_bounds.m
r1093 r1095 119 119 FieldOut.ProjModeRequest='interp_tps'; 120 120 end 121 if strcmp(CellInfo{imax(ind)}.ProjModeRequest,'interp_lin')&& ~strcmp(FieldOut.ProjModeRequest,'interp_tps')122 FieldOut.ProjModeRequest='interp_lin';123 end121 % if strcmp(CellInfo{imax(ind)}.ProjModeRequest,'interp_lin')&& ~strcmp(FieldOut.ProjModeRequest,'interp_tps') 122 % FieldOut.ProjModeRequest='interp_lin'; 123 % end 124 124 end 125 125 end -
trunk/src/find_field_cells.m
r1093 r1095 149 149 150 150 %% initate cells around each scalar field with different coordinates 151 % index_remove=[];152 % index_coord_x=zeros(size(ind_coord_x));153 151 cell_counter=0; 154 152 DimCell={}; -
trunk/src/get_field.m
r1093 r1095 79 79 if ischar(filename) % input file name 80 80 set(handles.inputfile,'String',filename)% fill the input file name 81 if ~isempty(regexp(filename,'.mat$'))%case of .mat file 82 Field=mat2struct(filename); 83 errormsg=''; 84 else 81 85 [Field,tild,tild,errormsg]=nc2struct(filename,[]);% reads the field structure, without the variables 86 end 82 87 else 83 88 msgbox_uvmat('ERROR','get_field requires a file name as input')% display error message for input file reading … … 405 410 case '1D plot' 406 411 set(handles.Coordinates,'Visible','on') 407 %set(handles.PanelOrdinate,'Visible','on')408 %pos=get(handles.PanelOrdinate,'Position');409 % pos(1)=2;410 % pos_coord=get(handles.Coordinates,'Position');411 % pos(2)=pos_coord(2)-pos(4)-2;412 %set(handles.PanelOrdinate,'Position',pos)413 412 set(handles.PanelScalar,'Visible','off') 414 413 set(handles.PanelVectors,'Visible','off') … … 419 418 set(handles.Z_title,'Visible','off') 420 419 set(handles.Coord_x,'String',Field.Display.ListVarName') 421 Coord_x_Callback(hObject, VarName, handles) 422 %set(handles.Coord_y,'String',Field.Display.ListVarName') 423 %Coord_x_Callback(hObject, VarName, handles) 420 Coord_x_Callback(hObject, VarName, handles) 424 421 case {'scalar'} 425 422 set(handles.Coordinates,'Visible','on') 426 %set(handles.PanelOrdinate,'Visible','off')427 423 set(handles.PanelScalar,'Visible','on') 428 424 set(handles.PanelVectors,'Visible','off') … … 469 465 set(handles.Coord_y,'Visible','on') 470 466 set(handles.Y_title,'Visible','on') 467 set(handles.Coord_x,'Visible','on') 471 468 %default vector selection 472 469 vector_x_value=get(handles.vector_x,'UserData'); … … 770 767 update_field(handles,VarName) 771 768 end 769 772 770 %------------------------------------------------------------------------ 773 771 % --- Executes on selection change in vector_x or vector_y … … 803 801 var_coord=find(test_coord);% % list of variable indices elligible as structured coordinates 804 802 var_component(var_component==vector_x_index|var_component==vector_y_index)=[]; 805 var_coord(var_coord==vector_x_index|var_coord==vector_y_index)=[];% remove vector components f orm te possible list of coordinates803 var_coord(var_coord==vector_x_index|var_coord==vector_y_index)=[];% remove vector components from the possible list of coordinates 806 804 ListCoord=Field.Display.ListVarName([var_coord var_component]); 807 805 … … 844 842 coord_val=[1 2 3]; 845 843 end 846 set(handles.Coord_x,'Value', coord_val(end))847 set(handles.Coord_y,'Value', coord_val(end-1))844 set(handles.Coord_x,'Value',min(coord_val(end),numel(ListCoord))) 845 set(handles.Coord_y,'Value',min(coord_val(end-1),numel(ListCoord))) 848 846 if numel(coord_val)>=3 849 847 set(handles.Coord_z,'Value',coord_val(end-2)) … … 887 885 %------------------------------------------------------------------------ 888 886 function Coord_x_Callback(hObject, DimCell, handles) 889 DimCell 887 890 888 index=get(handles.Coord_x,'Value'); 891 889 string=get(handles.Coord_x,'String'); -
trunk/src/nc2struct.m
r1093 r1095 1 1 2 2 %'nc2struct': transform a NetCDF file in a corresponding matlab structure 3 % or directly read the a matlab data file .mat (calling the fct mat2struct.m) 3 4 % it reads all the global attributes and all variables, or a selected list. 4 5 % The corresponding dimensions and variable attributes are then extracted … … 60 61 varargin{1}='*'; 61 62 end 62 hhh=which('netcdf.open');% look for built-in matlab NetCDF library 63 64 if ~isempty(hhh) 65 %% default output 66 Data=[];%default 67 var_detect=[];%default 68 ichoice=[];%default 69 70 %% open the NetCDF file for reading 71 if ischar(nc) 72 if exist(nc,'file') 63 64 %% default output 65 Data=[];%default 66 var_detect=[];%default 67 ichoice=[];%default 68 69 %% open the NetCDF (or .mat) file for reading 70 if ischar(nc) 71 testfile=1; 72 if exist(nc,'file') 73 if ~isempty(regexp(nc,'.mat$')) 74 Data=mat2struct(nc,varargin{1}); 75 return 76 else 73 77 try 74 78 nc=netcdf.open(nc,'NC_NOWRITE'); 75 testfile=1;76 79 catch ME 77 80 errormsg=['ERROR opening ' nc ': ' ME.message]; 78 81 return 79 82 end 83 end 84 else %case of OpenDAP files 85 if regexp(nc,'^http://') 86 try 87 nc=netcdf.open(nc,'NC_NOWRITE'); 88 catch ME 89 errormsg=['ERROR opening ' nc ': ' ME.message]; 90 return 91 end 80 92 else 81 if regexp(nc,'^http://')82 nc=netcdf.open(nc,'NC_NOWRITE');83 testfile=1;84 else85 93 errormsg=['ERROR:file ' nc ' does not exist']; 86 94 return 87 end 88 end 95 end 96 end 97 else 98 testfile=0; 99 end 100 101 %% short reading option for global attributes only, if the first argument is 'ListGlobalAttribute' 102 if isequal(varargin{1},'ListGlobalAttribute') 103 for ilist=2:numel(varargin) 104 valuestr=[];%default 105 try 106 valuestr = netcdf.getAtt(nc,netcdf.getConstant('NC_GLOBAL'),varargin{ilist}); 107 catch ME 108 end 109 eval(['Data.' varargin{ilist} '=valuestr;']) 110 end 111 netcdf.close(nc) 112 return 113 end 114 115 %% time variable or dimension 116 input_index=1; 117 CheckTimeVar=0; 118 TimeVarName=''; 119 if isequal(varargin{1},'TimeVarName') 120 TimeVarName=varargin{2}; 121 CheckTimeVar=1; 122 TimeIndex=varargin{3}; 123 input_index=4;% list of variables to read is at fourth argument 124 elseif isequal(varargin{1},'TimeDimName') 125 TimeDimName=varargin{2}; 126 TimeIndex=varargin{3}; 127 input_index=4; 128 end 129 130 %% full reading: get the nbre of dimensions, variables, global attributes 131 ListVarName=varargin{input_index}; 132 [ndims,nvars,ngatts]=netcdf.inq(nc);%nbre of dimensions, variables, global attributes, in the NetCDF file 133 134 %% -------- read all global attributes (constants)----------- 135 Data.ListGlobalAttribute={};%default 136 att_key=cell(1,ngatts);%default 137 for iatt=1:ngatts 138 keystr= netcdf.inqAttName(nc,netcdf.getConstant('NC_GLOBAL'),iatt-1); 139 valuestr = netcdf.getAtt(nc,netcdf.getConstant('NC_GLOBAL'),keystr); 140 keystr=regexprep(keystr,{'\','/','\.','-',' '},{'','','','',''});%remove '\','.' or '-' if exists 141 if strcmp(keystr(1),'_') 142 keystr(1)=[]; 143 end 144 try 145 if ischar(valuestr) %& length(valuestr)<200 & double(valuestr)<=122 & double(valuestr)>=48 %usual characters 146 eval(['Data.' keystr '=''' valuestr ''';']) 147 elseif isnumeric(valuestr) 148 eval(['Data.' keystr '=valuestr;']) 149 else 150 eval(['Data.' keystr '='';']) 151 end 152 att_key{iatt}=keystr; 153 catch ME 154 att_key{iatt}=['attr_' num2str(iatt)]; 155 Data.(att_key{iatt})=[]; 156 end 157 end 158 Data.ListGlobalAttribute=att_key; 159 160 %% -------- read dimension names----------- 161 ListDimNameNetcdf=cell(1,ndims); 162 dim_value=zeros(1,ndims); 163 for idim=1:ndims %loop on the dimensions of the NetCDF file 164 [ListDimNameNetcdf{idim},dim_value(idim)] = netcdf.inqDim(nc,idim-1);%get name and value of each dimension 165 end 166 if ~isempty(ListDimNameNetcdf) 167 flag_used=zeros(1,ndims);%initialize the flag indicating the selected dimensions in the list (0=unused) 168 end 169 if isequal(varargin{1},'TimeDimName')% time dimension introduced 170 TimeDimIndex=find(strcmp(TimeDimName,ListDimNameNetcdf)); 171 if isempty(TimeDimIndex) 172 errormsg=['requested time dimension ' varargin{2} ' not found']; 173 return 174 end 175 if dim_value(TimeDimIndex)<varargin{3} 176 errormsg=['requested time index ' num2str(varargin{3}) ' exceeds matrix dimension']; 177 return 178 end 179 end 180 181 %% -------- read names of variables ----------- 182 ListVarNameNetcdf=cell(1,nvars); %default 183 dimids=cell(1,nvars); 184 nbatt=zeros(1,nvars); 185 for ncvar=1:nvars %loop on the variables of the NetCDF file 186 %get name, type, dimensions and attribute numbers of each variable 187 [ListVarNameNetcdf{ncvar},xtype(ncvar),dimids{ncvar},nbatt(ncvar)] = netcdf.inqVar(nc,ncvar-1); 188 end 189 % testmulti=0; 190 if isequal(ListVarName,'*')||isempty(ListVarName) 191 var_index=1:nvars; %all the variables are selected in the NetCDF file 192 Data.ListVarName=ListVarNameNetcdf; 193 else %select input variables, if requested by the input ListVarName 194 check_keep=ones(1,size(ListVarName,2)); 195 for ivar=1:size(ListVarName,2) % check redondancy of variable names 196 if ~isempty(find(strcmp(ListVarName{1,ivar},ListVarName(1:ivar-1)), 1)) 197 check_keep(ivar)=0;% the variable #ivar is already in the list 198 end 199 end 200 ListVarName=ListVarName(:,logical(check_keep)); 201 if size(ListVarName,1)>1 %multiple choice of variable ranked by order of priority 202 for iline=1:size(ListVarName,1) 203 search_index=find(strcmp(ListVarName{iline,1},ListVarNameNetcdf),1);%look for the first variable name in the list of NetCDF variables 204 if ~isempty(search_index) 205 break % go to the next line 206 end 207 end 208 ichoice=iline-1;%selected line number in the list of input names of variables 89 209 else 90 testfile=0; 91 end 92 93 %% short reading option for global attributes only, if the first argument is 'ListGlobalAttribute' 94 if isequal(varargin{1},'ListGlobalAttribute') 95 for ilist=2:numel(varargin) 96 valuestr=[];%default 97 try 98 valuestr = netcdf.getAtt(nc,netcdf.getConstant('NC_GLOBAL'),varargin{ilist}); 99 catch ME 100 end 101 eval(['Data.' varargin{ilist} '=valuestr;']) 102 end 103 netcdf.close(nc) 104 return 105 end 106 107 %% time variable or dimension 108 input_index=1; 109 CheckTimeVar=0; 110 TimeVarName=''; 111 if isequal(varargin{1},'TimeVarName') 112 TimeVarName=varargin{2}; 113 CheckTimeVar=1; 114 TimeIndex=varargin{3}; 115 input_index=4;% list of variables to read is at fourth argument 116 elseif isequal(varargin{1},'TimeDimName') 117 TimeDimName=varargin{2}; 118 TimeIndex=varargin{3}; 119 input_index=4; 120 end 121 122 %% full reading: get the nbre of dimensions, variables, global attributes 123 ListVarName=varargin{input_index}; 124 [ndims,nvars,ngatts]=netcdf.inq(nc);%nbre of dimensions, variables, global attributes, in the NetCDF file 125 126 %% -------- read all global attributes (constants)----------- 127 Data.ListGlobalAttribute={};%default 128 att_key=cell(1,ngatts);%default 129 for iatt=1:ngatts 130 keystr= netcdf.inqAttName(nc,netcdf.getConstant('NC_GLOBAL'),iatt-1); 131 valuestr = netcdf.getAtt(nc,netcdf.getConstant('NC_GLOBAL'),keystr); 132 keystr=regexprep(keystr,{'\','/','\.','-',' '},{'','','','',''});%remove '\','.' or '-' if exists 133 if strcmp(keystr(1),'_') 134 keystr(1)=[]; 210 iline=1; 211 end 212 %ListVarName=ListVarName(iline,:);% select the appropriate option for input variable (lin ein the input name matrix) 213 if CheckTimeVar 214 TimeVarIndex=find(strcmp(TimeVarName,ListVarNameNetcdf),1); %look for the index of the time variable in the netcdf list 215 if isempty(TimeVarIndex) 216 errormsg='requested variable for time is missing'; 217 return 218 end 219 TimeDimIndex=dimids{TimeVarIndex}(1)+1; 220 ListVarName=[ListVarName {TimeVarName}]; 221 end 222 var_index=zeros(1,size(ListVarName,2));%default list of variable indices 223 for ivar=1:size(ListVarName,2) 224 search_index=find(strcmp(ListVarName{iline,ivar},ListVarNameNetcdf),1);%look for the variable name in the list of NetCDF file 225 if ~isempty(search_index) 226 var_index(ivar)=search_index;%index of the netcdf list corresponding to the input list index ivar 227 end 228 end 229 var_detect=(var_index~=0);%=1 for detected variables 230 list_index=find(var_index);% indices in the input list corresponding to a detected variable 231 var_index=var_index(list_index);% NetCDF variable indices corresponding to the output list of read variable 232 Data.ListVarName=ListVarName(1,list_index);%the first line of ListVarName sets the output names of the variables 233 end 234 235 %% get the dimensions and attributes associated to variables 236 var_dim=cell(size(var_index));% initiate list of dimensions for variables 237 for ivar=1:length(var_index) 238 var_dim{ivar}=dimids{var_index(ivar)}+1; %netcdf dimension indices used by the variable #ivar 239 Data.VarDimName{ivar}=ListDimNameNetcdf(var_dim{ivar}); 240 flag_used(var_dim{ivar})=ones(size(var_dim{ivar}));%flag_used =1 for the indices of used dimensions 241 for iatt=1:nbatt(var_index(ivar)) 242 attname = netcdf.inqAttName(nc,var_index(ivar)-1,iatt-1); 243 valuestr= netcdf.getAtt(nc,var_index(ivar)-1,attname); 244 attname=regexprep(attname,{'\','/','\.','-',' '},{'','','','',''});%remove '\','.' or '-' if exists 245 if strcmp(attname(1),'_') 246 attname(1)=[]; 135 247 end 136 248 try 137 if ischar(valuestr) %& length(valuestr)<200 & double(valuestr)<=122 & double(valuestr)>=48 %usual characters 138 eval(['Data.' keystr '=''' valuestr ''';']) 139 elseif isnumeric(valuestr) 140 eval(['Data.' keystr '=valuestr;']) 141 else 142 eval(['Data.' keystr '='';']) 143 end 144 att_key{iatt}=keystr; 249 if ~isempty(valuestr) 250 Data.VarAttribute{ivar}.(attname)=valuestr; 251 end 145 252 catch ME 146 att_key{iatt}=['attr_' num2str(iatt)]; 147 Data.(att_key{iatt})=[]; 148 end 149 end 150 Data.ListGlobalAttribute=att_key; 151 152 %% -------- read dimension names----------- 153 ListDimNameNetcdf=cell(1,ndims); 154 dim_value=zeros(1,ndims); 155 for idim=1:ndims %loop on the dimensions of the NetCDF file 156 [ListDimNameNetcdf{idim},dim_value(idim)] = netcdf.inqDim(nc,idim-1);%get name and value of each dimension 157 end 158 if ~isempty(ListDimNameNetcdf) 159 flag_used=zeros(1,ndims);%initialize the flag indicating the selected dimensions in the list (0=unused) 160 end 161 if isequal(varargin{1},'TimeDimName')% time dimension introduced 162 TimeDimIndex=find(strcmp(TimeDimName,ListDimNameNetcdf)); 163 if isempty(TimeDimIndex) 164 errormsg=['requested time dimension ' varargin{2} ' not found']; 165 return 166 end 167 if dim_value(TimeDimIndex)<varargin{3} 168 errormsg=['requested time index ' num2str(varargin{3}) ' exceeds matrix dimension']; 169 return 170 end 171 end 172 173 %% -------- read names of variables ----------- 174 ListVarNameNetcdf=cell(1,nvars); %default 175 dimids=cell(1,nvars); 176 nbatt=zeros(1,nvars); 177 for ncvar=1:nvars %loop on the variables of the NetCDF file 178 %get name, type, dimensions and attribute numbers of each variable 179 [ListVarNameNetcdf{ncvar},xtype(ncvar),dimids{ncvar},nbatt(ncvar)] = netcdf.inqVar(nc,ncvar-1); 180 end 181 % testmulti=0; 182 if isequal(ListVarName,'*')||isempty(ListVarName) 183 var_index=1:nvars; %all the variables are selected in the NetCDF file 184 Data.ListVarName=ListVarNameNetcdf; 185 else %select input variables, if requested by the input ListVarName 186 check_keep=ones(1,size(ListVarName,2)); 187 for ivar=1:size(ListVarName,2) % check redondancy of variable names 188 if ~isempty(find(strcmp(ListVarName{1,ivar},ListVarName(1:ivar-1)), 1)) 189 check_keep(ivar)=0;% the variable #ivar is already in the list 190 end 191 end 192 ListVarName=ListVarName(:,logical(check_keep)); 193 if size(ListVarName,1)>1 %multiple choice of variable ranked by order of priority 194 for iline=1:size(ListVarName,1) 195 search_index=find(strcmp(ListVarName{iline,1},ListVarNameNetcdf),1);%look for the first variable name in the list of NetCDF variables 196 if ~isempty(search_index) 197 break % go to the next line 253 display(attname) 254 display(valuestr) 255 display(ME.message) 256 Data.VarAttribute{ivar}.(['atrr_' num2str(iatt)])='not read'; 257 end 258 end 259 end 260 261 %% select the dimensions used for the set of input variables 262 if ~isempty(var_index) 263 dim_index=find(flag_used);%list of netcdf dimensions indices corresponding to used dimensions 264 Data.ListDimName=ListDimNameNetcdf(dim_index); 265 Data.DimValue=dim_value(dim_index); 266 if input_index==4% if a dimension is selected as time 267 Data.DimValue(TimeDimIndex)=numel(TimeIndex); 268 end 269 end 270 271 %% get the values of the input variables 272 if ~isempty(ListVarName) 273 for ivar=1:length(var_index) 274 VarName=Data.ListVarName{ivar}; 275 VarName=regexprep(VarName,'-','_'); %suppress '-' if it exists in the NetCDF variable name (leads to errors in matlab) 276 % CheckSub=0; 277 if input_index==4% if a dimension is selected as time 278 ind_vec=zeros(1,numel(var_dim{ivar}));% vector with zeros corresponding to al the dimensions of the variable VarName 279 ind_size=dim_value(var_dim{ivar});% vector giving the size (for each dimension) of the variable VarName 280 index_time=find(var_dim{ivar}==TimeDimIndex); 281 if ~isempty(index_time) 282 if ind_size(index_time)<max(TimeIndex) 283 errormsg=['requested index ' num2str(TimeIndex) ' exceeds matrix dimension']; 284 return 198 285 end 199 end 200 ichoice=iline-1;%selected line number in the list of input names of variables 286 ind_vec(index_time)=TimeIndex-1;% selected index(or indices) to read 287 ind_size(index_time)=numel(TimeIndex);%length of the selected set of time indices 288 if numel(TimeIndex)==1 && ~strcmp(VarName,TimeVarName) 289 Data.VarDimName{ivar}(index_time)=[];% for a single selected time remove the time in the list of dimensions (except for tTime itself) 290 end 291 end 292 Data.(VarName)=netcdf.getVar(nc,var_index(ivar)-1,ind_vec,ind_size); %read the variable data 293 Data.(VarName)=squeeze(Data.(VarName));%remove singeton dimension 201 294 else 202 iline=1; 203 end 204 %ListVarName=ListVarName(iline,:);% select the appropriate option for input variable (lin ein the input name matrix) 205 if CheckTimeVar 206 TimeVarIndex=find(strcmp(TimeVarName,ListVarNameNetcdf),1); %look for the index of the time variable in the netcdf list 207 if isempty(TimeVarIndex) 208 errormsg='requested variable for time is missing'; 209 return 210 end 211 TimeDimIndex=dimids{TimeVarIndex}(1)+1; 212 ListVarName=[ListVarName {TimeVarName}]; 213 end 214 var_index=zeros(1,size(ListVarName,2));%default list of variable indices 215 for ivar=1:size(ListVarName,2) 216 search_index=find(strcmp(ListVarName{iline,ivar},ListVarNameNetcdf),1);%look for the variable name in the list of NetCDF file 217 if ~isempty(search_index) 218 var_index(ivar)=search_index;%index of the netcdf list corresponding to the input list index ivar 219 end 220 end 221 var_detect=(var_index~=0);%=1 for detected variables 222 list_index=find(var_index);% indices in the input list corresponding to a detected variable 223 var_index=var_index(list_index);% NetCDF variable indices corresponding to the output list of read variable 224 Data.ListVarName=ListVarName(1,list_index);%the first line of ListVarName sets the output names of the variables 225 end 226 227 %% get the dimensions and attributes associated to variables 228 var_dim=cell(size(var_index));% initiate list of dimensions for variables 229 for ivar=1:length(var_index) 230 var_dim{ivar}=dimids{var_index(ivar)}+1; %netcdf dimension indices used by the variable #ivar 231 Data.VarDimName{ivar}=ListDimNameNetcdf(var_dim{ivar}); 232 flag_used(var_dim{ivar})=ones(size(var_dim{ivar}));%flag_used =1 for the indices of used dimensions 233 for iatt=1:nbatt(var_index(ivar)) 234 attname = netcdf.inqAttName(nc,var_index(ivar)-1,iatt-1); 235 valuestr= netcdf.getAtt(nc,var_index(ivar)-1,attname); 236 attname=regexprep(attname,{'\','/','\.','-',' '},{'','','','',''});%remove '\','.' or '-' if exists 237 if strcmp(attname(1),'_') 238 attname(1)=[]; 239 end 240 try 241 if ~isempty(valuestr) 242 Data.VarAttribute{ivar}.(attname)=valuestr; 243 end 244 catch ME 245 display(attname) 246 display(valuestr) 247 display(ME.message) 248 Data.VarAttribute{ivar}.(['atrr_' num2str(iatt)])='not read'; 249 end 250 end 251 end 252 253 %% select the dimensions used for the set of input variables 254 if ~isempty(var_index) 255 dim_index=find(flag_used);%list of netcdf dimensions indices corresponding to used dimensions 256 Data.ListDimName=ListDimNameNetcdf(dim_index); 257 Data.DimValue=dim_value(dim_index); 258 if input_index==4% if a dimension is selected as time 259 Data.DimValue(TimeDimIndex)=numel(TimeIndex); 260 end 261 end 262 263 %% get the values of the input variables 264 if ~isempty(ListVarName) 265 for ivar=1:length(var_index) 266 VarName=Data.ListVarName{ivar}; 267 VarName=regexprep(VarName,'-','_'); %suppress '-' if it exists in the NetCDF variable name (leads to errors in matlab) 268 % CheckSub=0; 269 if input_index==4% if a dimension is selected as time 270 ind_vec=zeros(1,numel(var_dim{ivar}));% vector with zeros corresponding to al the dimensions of the variable VarName 271 ind_size=dim_value(var_dim{ivar});% vector giving the size (for each dimension) of the variable VarName 272 index_time=find(var_dim{ivar}==TimeDimIndex); 273 if ~isempty(index_time) 274 if ind_size(index_time)<max(TimeIndex) 275 errormsg=['requested index ' num2str(TimeIndex) ' exceeds matrix dimension']; 276 return 277 end 278 ind_vec(index_time)=TimeIndex-1;% selected index(or indices) to read 279 ind_size(index_time)=numel(TimeIndex);%length of the selected set of time indices 280 if numel(TimeIndex)==1 && ~strcmp(VarName,TimeVarName) 281 Data.VarDimName{ivar}(index_time)=[];% for a single selected time remove the time in the list of dimensions (except for tTime itself) 282 end 283 end 284 Data.(VarName)=netcdf.getVar(nc,var_index(ivar)-1,ind_vec,ind_size); %read the variable data 285 Data.(VarName)=squeeze(Data.(VarName));%remove singeton dimension 286 else 287 Data.(VarName)=netcdf.getVar(nc,var_index(ivar)-1); %read the whole variable data 288 end 289 if xtype(var_index(ivar))==5 290 Data.(VarName)=double(Data.(VarName)); %transform to double for single pecision 291 end 292 end 293 end 294 Data.VarType=xtype(var_index); 295 296 %% -------- close fle----------- 297 if testfile==1 298 netcdf.close(nc) 299 end 300 301 %% old NetCDF library 302 else 303 [Data,var_detect,ichoice]=nc2struct_toolbox(nc,varargin); 304 end 295 Data.(VarName)=netcdf.getVar(nc,var_index(ivar)-1); %read the whole variable data 296 end 297 if xtype(var_index(ivar))==5 298 Data.(VarName)=double(Data.(VarName)); %transform to double for single pecision 299 end 300 end 301 end 302 Data.VarType=xtype(var_index); 303 304 %% -------- close fle----------- 305 if testfile==1 306 netcdf.close(nc) 307 end 308 -
trunk/src/plot_field.m
r1094 r1095 1426 1426 yi=rangy(1):dxy(1):rangy(2); 1427 1427 A=griddata(vec_X,vec_Y,vec_A,xi,yi'); 1428 A=reshape(A,length(yi),length(xi)); total1428 A=reshape(A,length(yi),length(xi)); 1429 1429 else 1430 1430 x=vec_X(1:index(1));% the set of abscissa (obtained on the first line) -
trunk/src/proj_field.m
r1094 r1095 1126 1126 ProjMode=regexprep(ProjMode,' ',ObjectData.ProjMode); 1127 1127 icell_grid=[];% field cell index which defines the grid 1128 icell_scattered=[];% field cell index which defines fields with scattered coordinates 1128 1129 if strcmp(ObjectData.ProjMode,'projection') 1129 1130 %% case of a grid requested by the input field … … 1131 1132 if isfield(CellInfo{icell},'ProjModeRequest') 1132 1133 switch CellInfo{icell}.ProjModeRequest 1133 case 'interp_lin'1134 ProjMode{icell}='interp_lin';1134 % case 'interp_lin' 1135 % ProjMode{icell}='interp_lin'; 1135 1136 case 'interp_tps' 1136 1137 ProjMode{icell}='interp_tps'; … … 1146 1147 end 1147 1148 check_grid(icell)=1; 1149 elseif strcmp(CellInfo{icell}.CoordType,'scattered') 1150 icell_scattered=icell; 1148 1151 end 1149 1152 end … … 1201 1204 ProjData.VarAttribute{1}.Role='coord_y'; 1202 1205 ProjData.VarAttribute{2}.Role='coord_x'; 1206 if ~isempty(icell_grid) 1203 1207 YAttribute=FieldData.VarAttribute{CellInfo{icell_grid}.CoordIndex(NbDim-1)}; 1204 1208 XAttribute=FieldData.VarAttribute{CellInfo{icell_grid}.CoordIndex(NbDim)}; 1209 elseif ~isempty(icell_scattered) 1210 NbDim=NbDimArray(icell_scattered); 1211 YAttribute=FieldData.VarAttribute{CellInfo{icell_scattered}.CoordIndex(NbDim-1)}; 1212 XAttribute=FieldData.VarAttribute{CellInfo{icell_scattered}.CoordIndex(NbDim)}; 1213 end 1205 1214 if ~testangle 1206 1215 if isfield(YAttribute,'units') -
trunk/src/read_field.m
r1093 r1095 93 93 if ~isempty(errormsg),errormsg=['read_civxdata / ' errormsg];return,end 94 94 ParamOut.CivStage=Field.CivStage; 95 case 'netcdf'% general netcdf file (not recognized as civ)95 case {'netcdf','mat'}% general netcdf file (not recognized as civ) 96 96 ListVarName={}; 97 97 Role={}; 98 98 ProjModeRequest={}; 99 %ListInputField={};100 %checkU=0;101 %checkV=0;102 99 % scan the list InputField 103 100 Operator=cell(1,numel(InputField)); … … 108 105 if isempty(r)% no operator used 109 106 ListVarName=[ListVarName InputField(ilist)];%append the variable name 110 %InputVar{ilist}=InputField(ilist);111 %ListInputField=[ListInputField InputField(ilist)];112 107 if check_colorvar(ilist)% case of field used for vector color 113 108 Role{numel(ListVarName)}='ancillary';% not projected with interpolation … … 129 124 Role=[Role {'vector_x'}]; 130 125 end 131 %ListInputField=[ListInputField InputField(ilist)];132 126 ListVarName=[ListVarName {r.VName}];% append the variable in the list if not previously listed 133 127 Role=[Role {'vector_y'}]; 134 %ListInputField=[ListInputField InputField(ilist)];135 128 Operator{numel(ListVarName)-1}=r.Operator; 136 129 Operator{numel(ListVarName)}=''; … … 238 231 Field.VarDimName=[Field.VarDimName(1:NbCoord) VarDimName]; 239 232 Field.VarAttribute=[Field.VarAttribute(1:NbCoord) VarAttribute]; 240 end 241 case 'mat' 242 Field=load(FileName); 233 end 243 234 case 'video' 244 235 if strcmp(class(ParamIn),'VideoReader') -
trunk/src/read_xls.m
r1093 r1095 13 13 % Copyright 2008-2021, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France 14 14 % http://www.legi.grenoble-inp.fr 15 % Joel.Sommeria - Joel.Sommeria (A) legi.cnrs.fr 15 % Joel.Sommeria - Joel.Sommeria (A) legi.cnrs.frread_xls.m 16 16 % 17 17 % This file is part of the toolbox UVMAT. -
trunk/src/series.m
r1093 r1095 3423 3423 3424 3424 %% fill the GUI series with the content of the xml file 3425 Param=xml2struct(filexml); % read the input xml file as a Matlab structure 3426 3425 [Param,RootTag,errormsg]=xml2struct(filexml); % read the input xml file as a Matlab structure 3426 if ~isempty(errormsg) 3427 msgbox_uvmat('ERROR',errormsg); 3428 return 3429 end 3427 3430 % ask to stop current Action if button RUN is in action (another process is already running) 3428 3431 if isequal(get(handles.RUN,'Value'),1) -
trunk/src/series/civ_series.m
r1093 r1095 366 366 end 367 367 if strcmp(Param.ActionInput.ListCompareMode,'PIV') 368 ncfile_out=fullfile_uvmat(RootPath_A,OutputDir,RootFile_A,'.nc',NomTypeNc,i1_civ2,i2_civ2,j1_civ2,j2_civ2); 368 ncfile_out=fullfile_uvmat(OutputPath,OutputDir,RootFile_A,'.nc',NomTypeNc,i1_civ2,i2_civ2,j1_civ2,j2_civ2); 369 % ncfile_out=fullfile_uvmat(RootPath_A,OutputDir,RootFile_A,'.nc',NomTypeNc,i1_civ2,i2_civ2,j1_civ2,j2_civ2); 369 370 else % displacement 370 ncfile_out=fullfile_uvmat( RootPath_A,OutputDir,RootFile_A,'.nc',NomTypeNc,i2_civ2,[],j2_civ2);371 ncfile_out=fullfile_uvmat(OutputPath,OutputDir,RootFile_A,'.nc',NomTypeNc,i2_civ2,[],j2_civ2); 371 372 end 372 373 end -
trunk/src/series/sliding_average.m
r1094 r1095 121 121 return 122 122 end 123 [FileInfo{iview},MovieObject{iview}]=get_file_info(filecell{iview,1}); 900123 [FileInfo{iview},MovieObject{iview}]=get_file_info(filecell{iview,1}); 124 124 FileType{iview}=FileInfo{iview}.FileType; 125 125 CheckImage{iview}=~isempty(find(strcmp(FileType{iview},ImageTypeOptions)));% =1 for images … … 137 137 if size(time,1)>1 138 138 diff_time=max(max(diff(time))); 139 if diff_time>0 series139 if diff_time>0 140 140 msgbox_uvmat('WARNING',['times of series differ by (max) ' num2str(diff_time)]) 141 141 end … … 185 185 186 186 %% initialisation 187 T=24. 2; %main wave period187 T=24.4; %main wave period 188 188 t0=3; % time for motion start (torus at its maximum x) 189 189 NbPeriod=2; %number of periods for the sliding average … … 195 195 DataOut.ListGlobalAttribute= {'Conventions','Time'}; 196 196 DataOut.Conventions='uvmat'; 197 DataOut.ListVarName={'coord_y','coord_x','Umean','Vmean','Ucos','Vcos',' DUDXsin','DUDXcos','DUDYsin','DVDXsin','DVDXcos'...197 DataOut.ListVarName={'coord_y','coord_x','Umean','Vmean','Ucos','Vcos','Usin','Vsin','DUDXsin','DUDXcos','DUDYsin','DVDXsin','DVDXcos'... 198 198 ,'DVDYsin','Ustokes','Vstokes'}; 199 199 DataOut.VarDimName={'coord_y','coord_x',{'coord_y','coord_x'},{'coord_y','coord_x'},{'coord_y','coord_x'},{'coord_y','coord_x'},... 200 200 {'coord_y','coord_x'},{'coord_y','coord_x'},{'coord_y','coord_x'},{'coord_y','coord_x'},{'coord_y','coord_x'},... 201 {'coord_y','coord_x'},{'coord_y','coord_x'},{'coord_y','coord_x'} };201 {'coord_y','coord_x'},{'coord_y','coord_x'},{'coord_y','coord_x'},{'coord_y','coord_x'},{'coord_y','coord_x'}}; 202 202 203 203 %%%%%%%%%%%%%%%% loop on field indices %%%%%%%%%%%%%%%% … … 237 237 Ucos=zeros(NpTime,npy,npx); 238 238 Vcos=zeros(NpTime,npy,npx); 239 Usin=zeros(NpTime,npy,npx); 240 Vsin=zeros(NpTime,npy,npx); 239 241 DUDXcos=zeros(NpTime,npy,npx); 240 242 DUDXsin=zeros(NpTime,npy,npx); … … 249 251 Ucos=circshift(Ucos,[-1 0 0]); %shift U by ishift along the first index 250 252 Vcos=circshift(Vcos,[-1 0 0]); %shift U by ishift along the first index 253 Usin=circshift(Usin,[-1 0 0]); %shift U by ishift along the first index 254 Vsin=circshift(Vsin,[-1 0 0]); %shift U by ishift along the first index 251 255 DUDXcos=circshift(DUDXcos,[-1 0 0]); 252 256 DUDXsin=circshift(DUDXsin,[-1 0 0]); … … 259 263 Ucos(end,:,:)=Field.U*cos(omega*Time(index)); 260 264 Vcos(end,:,:)=Field.V*cos(omega*Time(index)); 265 Usin(end,:,:)=Field.U*sin(omega*Time(index)); 266 Vsin(end,:,:)=Field.V*sin(omega*Time(index)); 261 267 DUDXcos(end,:,:)=Field.DUDX*cos(omega*Time(index)); 262 268 DUDXsin(end,:,:)=Field.DUDX*sin(omega*Time(index)); … … 269 275 DataOut.Umean=(1/Uscale)*squeeze(nanmean(Umean,1)); 270 276 DataOut.Vmean=(1/Uscale)*squeeze(nanmean(Vmean,1)); 271 DataOut.Ucos=2*squeeze(nanmean(Ucos,1)); 272 DataOut.Vcos=2*squeeze(nanmean(Vcos,1)); 277 DataOut.Ucos=2*(1/Uscale)*squeeze(nanmean(Ucos,1)); 278 DataOut.Vcos=2*(1/Uscale)*squeeze(nanmean(Vcos,1)); 279 DataOut.Usin=2*(1/Uscale)*squeeze(nanmean(Usin,1)); 280 DataOut.Vsin=2*(1/Uscale)*squeeze(nanmean(Vsin,1)); 273 281 DataOut.DUDXcos=2*squeeze(nanmean(DUDXcos,1)); 274 282 DataOut.DUDXsin=2*squeeze(nanmean(DUDXsin,1)); -
trunk/src/series/turb_stat.m
r1093 r1095 303 303 304 304 %% open the result file with uvmat (in RUN mode) 305 if checkrun 305 if checkrun && isequal(Param.IndexRange.NbSlice,1) 306 306 uvmat(OutputFile)% open the last result file with uvmat 307 307 end -
trunk/src/uigetfile_uvmat.m
r1093 r1095 54 54 elseif exist(InputName,'file') 55 55 [InputDir,InputFileName,Ext]=fileparts(InputName); 56 if isempty(InputFileName)% if InputName is alr eady the root56 if isempty(InputFileName)% if InputName is alr2eady the root 57 57 InputFileName=InputDir; 58 58 if ~isempty(strcmp (computer, {'PCWIN','PCWIN64'}))%case of Windows systems … … 308 308 FullSelectName=[DirName '/' SelectName]; 309 309 end 310 end 310 end% end 311 % end 311 312 if CheckSubDir%exist(FullSelectName,'dir')% a directory has been selected 312 313 set(hObject,'BackgroundColor',[1 1 0])% paint list in yellow to indicate action … … 344 345 index_dir=find(strcmp('isdir',fieldnames(ListStruct))); 345 346 check_dir=cell2mat(ListCells(index_dir,:));% =1 for directories, =0 for files 346 % for ilist=1:numel(check_dir)347 % if check_dir(ilist)348 347 ListFiles(check_dir)=regexprep(ListFiles(check_dir),'^.+','+/$0');% put '+/' in front of dir name display 349 % end350 % end351 348 if exist('filter_ext','var') && ~strcmp(filter_ext,'*') &&~strcmp(filter_ext,'uigetdir') 352 349 if strcmp(filter_ext,'image') -
trunk/src/update_imadoc.m
r1093 r1095 90 90 91 91 %% save the output file 92 t=struct2xml(Struct,t,uid_calib); 92 t=struct2xml(Struct,t,uid_calib); 93 93 try 94 save(t,outputfile);94 save(t,outputfile); 95 95 catch ME 96 errormsg=['error in update_imadoc' ME.message];96 errormsg=['error in saving ' outputfile ': ' ME.message]; 97 97 end -
trunk/src/uvmat.m
r1094 r1095 2198 2198 editxml(fileinput); 2199 2199 return 2200 case 'mat'% matlab data file2201 global Data_uvmat2202 Data_uvmat.Field=load(fileinput);2203 evalin('base','global Data_uvmat')%make CurData global in the workspace2204 disp('Data_uvmat.Field=')2205 evalin('base','Data_uvmat.Field') %display CurData in the workspace2206 commandwindow; %brings the Matlab command window to the front2207 return2200 % case 'mat'% matlab data file 2201 % % global Data_uvmat 2202 % Data_uvmat.Field=load(fileinput); 2203 % evalin('base','global Data_uvmat')%make CurData global in the workspace 2204 % disp('Data_uvmat.Field=') 2205 % evalin('base','Data_uvmat.Field') %display CurData in the workspace 2206 % commandwindow; %brings the Matlab command window to the front 2207 % return 2208 2208 otherwise 2209 2209 set(handles_RootPath,'String',RootPath); … … 2278 2278 2279 2279 %enable other menus 2280 % set(handles.MenuOpenCampaign,'Enable','on')2281 2280 set(handles.MenuExport,'Enable','on') 2282 2281 set(handles.MenuExportFigure,'Enable','on') … … 2355 2354 if isfield(FileInfo,'FrameRate')% frame rate given in the file (case of video data) 2356 2355 TimeUnit='s'; 2357 if isempty(j1_series) ;%frame index along i2356 if isempty(j1_series) %frame index along i 2358 2357 XmlData.Time=zeros(FileInfo.NumberOfFrames+1,2); 2359 2358 XmlData.Time(:,2)=(0:1/FileInfo.FrameRate:(FileInfo.NumberOfFrames)/FileInfo.FrameRate)'; … … 2552 2551 set(handles.Coord_x,'String','X'); 2553 2552 set(handles.Coord_y,'String','Y'); 2554 case 'netcdf'2553 case {'netcdf','mat'} 2555 2554 set(handles_Fields,'Value',1) 2556 2555 set(handles_Fields,'String',{'get_field...'}) … … 3019 3018 pause(1.02-get(handles.speed,'Value'))% wait for next image 3020 3019 end 3021 if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj) ,3020 if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj) 3022 3021 UvData.aviobj=close(UvData.aviobj); 3023 3022 set(handles.uvmat,'UserData',UvData); … … 3063 3062 set(handles.MovieBackward,'BusyAction','Cancel') 3064 3063 set(handles.MenuExportMovie,'BusyAction','Cancel') 3065 %set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command buttonback to red3066 3064 set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red 3067 3065 set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red … … 3073 3071 errormsg='';%default 3074 3072 %% check for movie pair status 3075 movie_status=get(handles.movie_pair,'Value');3076 if movie_status3077 STOP_Callback(hObject, eventdata, handles)%interrupt movie pair if active3078 end3073 % movie_status=get(handles.movie_pair,'Value'); 3074 % if movie_status 3075 % STOP_Callback(hObject, eventdata, handles)%interrupt movie pair if active 3076 % end 3079 3077 3080 3078 %% read the current input file name(s) and field indices … … 3090 3088 j1=str2num(get(handles.j1,'String'));%case of indexed movie 3091 3089 end 3092 if movie_status% we read the second index from the edit box3093 i2=str2num(get(handles.i2,'String'));%read the field indices (for movie, it is not given by the file name)3094 if strcmp(get(handles.j2,'Visible'),'on')3095 j2=str2num(get(handles.j2,'String'));%3096 end3097 end3090 % if movie_status% we read the second index from the edit box 3091 % i2=str2num(get(handles.i2,'String'));%read the field indices (for movie, it is not given by the file name) 3092 % if strcmp(get(handles.j2,'Visible'),'on') 3093 % j2=str2num(get(handles.j2,'String'));% 3094 % end 3095 % end 3098 3096 sub_value= get(handles.SubField,'Value'); 3099 3097 if sub_value % a second input file has been entered … … 3113 3111 set(handles.CheckFixPair,'Value',0) 3114 3112 end 3115 CheckFixPair=get(handles.CheckFixPair,'Value')||(isempty(i2)&& isempty(j2));3113 CheckFixPair=get(handles.CheckFixPair,'Value')||(isempty(i2)&& isempty(j2)); 3116 3114 3117 3115 % the pair i1-i2 or j1-j2 is imposed (check box CheckFixPair selected) … … 3132 3130 end 3133 3131 end 3134 3135 % the pair i1-i2 or j1-j2 is free (check box CheckFixPair not selected): the list of existing indices recorded in UvData is used3132 3133 % the pair i1-i2 or j1-j2 is free (check box CheckFixPair not selected): the list of existing indices recorded in UvData is used 3136 3134 else 3137 3135 UvData=get(handles.uvmat,'UserData'); … … 3154 3152 end 3155 3153 else % free increment 3156 % runaction=get(gcbo,'tag');3157 3154 if strcmp(increment,'+')% if runplus or movie is activated 3158 3155 step=1; … … 3203 3200 j2=UvData.j2_series{1}(ref_indices(end)); 3204 3201 end 3205 3202 3206 3203 % case of a second file series 3207 3204 if sub_value … … 3300 3297 end 3301 3298 if strcmp(NomType,'level') 3302 indices=num2str(i1);3299 indices=num2str(i1); 3303 3300 else 3304 indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2);3301 indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2); 3305 3302 end 3306 3303 set(handles.FileIndex,'String',indices); … … 3309 3306 set(handles.FileIndex_1,'String',indices_1); 3310 3307 end 3311 if isequal(movie_status,1) 3312 set(handles.movie_pair,'Value',1) 3313 movie_pair_Callback(hObject, eventdata, handles); %reactivate moviepair if it was activated 3314 else 3315 if isempty(i2), set(handles.i2,'String',''); end % suppress the second index display if not used 3316 if isempty(j2), set(handles.j2,'String',''); end 3317 end 3308 if isempty(i2), set(handles.i2,'String',''); end % suppress the second index display if not used 3309 if isempty(j2), set(handles.j2,'String',''); end 3318 3310 end 3319 3311 … … 3352 3344 msgbox_uvmat('ERROR',errormsg); 3353 3345 end 3354 3355 % set(hima,'CData',Field_b.A); %TODO: generalise to other kinds of fields3356 3346 pause(1.02-get(handles.speed,'Value'));% wait for next image 3357 3347 errormsg=runpm(hObject,eventdata,handles,-increment); 3358 3359 % set(hima,'CData',Field_a.A); 3348 if ~isempty(errormsg) 3349 msgbox_uvmat('ERROR',errormsg); 3350 end 3360 3351 pause(1.02-get(handles.speed,'Value'));% wait for next image 3352 get(handles.speed,'Value')~=0 && isequal(get(handles.movie_pair,'BusyAction'),'queue') 3361 3353 end 3362 3354 set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red … … 3364 3356 set(handles.Dt_txt,'String','') 3365 3357 3366 3367 3368 3369 3358 set(handles.runplus,'BackgroundColor',[1 0 0])%paint the command button back in red 3370 3359 3371 %3372 % set(handles.runmin,'BackgroundColor',[1 1 0])%paint the command button in yellow3373 % drawnow3374 % increment=-str2double(get(handles.num_IndexIncrement,'String')); %get the field increment d3375 % if isnan(increment)% case of free increment: move to previous available field index3376 % increment='-';3377 % end3378 % errormsg=runpm(hObject,eventdata,handles,increment);3379 % if ~isempty(errormsg)3380 % msgbox_uvmat('ERROR',errormsg);3381 % end3382 % set(handles.runmin,'BackgroundColor',[1 0 0])%paint the command button back in red3383 %3384 % %% check the input file indexing:3385 % [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles);3386 % NomType=get(handles.NomType,'String');3387 % if ~isempty(find(regexp(NomType,'-')))3388 % msgbox_uvmat('ERROR','The movie pair requires file series with a single index on the first input line')3389 % return3390 % end3391 % filename=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];% build the input file name (first line)3392 %3393 % set(handles.movie_pair,'BusyAction','queue')%3394 % set(handles.CheckFixPair,'Value',1)% impose fixed pair (needed for function runpm)3395 % set(handles.REFRESH,'BackgroundColor',[1 1 0])%paint the command button in yellow to indicate its activity3396 % set(handles.movie_pair,'BackgroundColor',[1 1 0])%paint the command button in yellow to indicate its activity3397 % drawnow3398 %3399 % num_i1=str2num(get(handles.i1,'String'));3400 % num_j1=stra2num(get(handles.j1,'String'));3401 % num_i2=str2num(get(handles.i2,'String'));3402 % num_j2=stra2num(get(handles.j2,'String'));3403 %3404 % %% determine the name 'imaname_1' of the second file in the pair3405 % imaname_1='';3406 % if isempty(num_j2)% no second j index indicated3407 % if isempty(num_i2)3408 % if strcmp(get(handles.j2,'Visible'),'on') %if the j box is visible3409 % imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,num_i1,[],num_j1+1);3410 % end3411 % if exist(imaname_1,'file')3412 % num_j2=num_j1+1;% look by default for the next j index as the second file3413 % set(handles.j2,'String',num2stra(num_j2,NomType));3414 % else3415 % imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,num_i1+1,[],num_j1);3416 % if exist(imaname_1,'file')3417 % num_i2=num_i1+1;3418 % set(handles.i2,'String',num2str(num_i2));3419 % else3420 % msgbox_uvmat('ERROR', 'a second image index i2 or j2 is needed to show the pair as a movie')3421 % set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red3422 % set(handles.movie_pair,'Value',0)3423 % return3424 % end3425 % end3426 % else3427 % num_j2=num_j1;%repeat the index i1 by default3428 % end3429 % end3430 % if isempty(num_i2)3431 % num_i2=num_i1;%repeat the index i1 by default3432 % end3433 % if isempty(num_j1)3434 % num_j1=1;3435 % end3436 % if isempty(num_j2)3437 % num_j2=num_j1;%repeat the index i1 by default3438 % end3439 % imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,num_i2,[],num_j2);3440 % if strcmp(NomType,'*')3441 % num_frame=num_i2;3442 % else3443 % num_frame=num_j2;3444 % end3445 % if ~exist(imaname_1,'file')3446 % msgbox_uvmat('ERROR',['second input open (-) ' imaname_1 ' not found']);3447 % set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red3448 % set(handles.movie_pair,'Value',0)3449 % return3450 % end3451 %3452 % %% display the first field in the pair (including possibly a background field from second line input filename_1)3453 % filename_1='';%default3454 % FileIndex_1='';3455 % if get(handles.SubField,'Value')3456 % [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles);3457 % filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1];3458 % end3459 % [tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(FileIndex_1);% get the indices of the second series from the string FileIndex_13460 % if isempty(j1_1)% case of movies, the index is not given by file index3461 % j1_1=num_j1;3462 % end3463 %3464 % errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1);3465 %3466 % if isempty(errormsg)3467 % set(handles.REFRESH,'BackgroundColor',[1 0 0])% set button color to red, update successfull3468 % else3469 % msgbox_uvmat('ERROR',errormsg);3470 % set(handles.REFRESH,'BackgroundColor',[1 0 1])% keep button color magenta, input not succesfull3471 % end3472 % UvData=get(handles.uvmat,'UserData');3473 % Field_a=UvData.Field;% movie on the field defined by the second input line3474 %3475 % %% display time interval for the image pair3476 % if isfield(UvData,'XmlData')&&isfield(UvData.XmlData{1},'Time')...3477 % && size(UvData.XmlData{1}.Time,1)>=num_i2+1 && size(UvData.XmlData{1}.Time,2)>=num_j2+13478 % dt=(UvData.XmlData{1}.Time(num_i2+1,num_j2+1)-UvData.XmlData{1}.Time(num_i1+1,num_j1+1));3479 % if isfield(UvData,'TimeUnit')3480 % set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' m' UvData.TimeUnit] )3481 % else3482 % set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' 10^(-3)'] )3483 % end3484 % else3485 % set(handles.Dt_txt,'String','')3486 % end3487 %3488 % %% read the second field3489 % if isempty(UvData.MovieObject)3490 % [Field_b,ParamOut,errormsg] = read_field(imaname_1,UvData.FileInfo{index}.FileType,[],num_frame);3491 % else3492 % [Field_b,ParamOut,errormsg] = read_field(imaname_1,UvData.FileInfo{1}.FileType,UvData.MovieObject{1},num_frame);3493 % end3494 % if ~isempty(errormsg)3495 % msgbox_uvmat('ERROR',['Error in reading second image: ' errormsg])3496 % return3497 % end3498 %3499 % %% apply phys or other transform on the two input fields3500 % transform=get(handles.TransformPath,'UserData');3501 % if ~isempty(transform)3502 % if isfield(UvData,'XmlData') && ~isempty(UvData.XmlData) %use geometry calib recorded from the ImaDoc xml file as first priority3503 % if nargin(transform)>=23504 % Field_b=transform(Field_b,UvData.XmlData{1});3505 % else3506 % Field_b=transform(Field_b);3507 % end3508 % end3509 % end3510 %3511 % %% make movie until movie speed is set to 0 or STOP is activated3512 % hima=findobj(handles.PlotAxes,'Tag','ima');% %handles.PlotAxes =main plotting window (A GENERALISER)3513 % set(handles.STOP,'Visible','on')3514 % set(handles.speed,'Visible','on')3515 % set(handles.speed_txt,'Visible','on')3516 % while get(handles.speed,'Value')~=0 && isequal(get(handles.movie_pair,'BusyAction'),'queue') % enable STOP command3517 % % read and plot the series of images in non erase mode3518 % set(hima,'CData',Field_b.A); %TODO: generalise to other kinds of fields3519 % pause(1.02-get(handles.speed,'Value'));% wait for next image3520 % set(hima,'CData',Field_a.A);3521 % pause(1.02-get(handles.speed,'Value'));% wait for next image3522 % end3523 % set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red3524 % set(handles.movie_pair,'Value',0)3525 % set(handles.Dt_txt,'String','')3526 3360 3527 3361 %------------------------------------------------------------------------ … … 3660 3494 end 3661 3495 switch UvData.FileInfo{1}.FieldType 3662 case {'civdata','netcdf' }3496 case {'civdata','netcdf','mat'} 3663 3497 list_fields=get(handles.FieldName,'String');% list menu fields 3664 3498 FieldName= list_fields{get(handles.FieldName,'Value')}; % selected field 3665 if ~strcmp(FieldName,'get_field...') 3499 if strcmp(FieldName,'get_field...') 3500 FieldName_Callback(hObject, eventdata, handles) 3501 return 3502 else 3666 3503 if get(handles.FixVelType,'Value') 3667 3504 VelTypeList=get(handles.VelType,'String'); … … 3697 3534 end 3698 3535 ParamIn.Coord_z=get(handles.Coord_z,'String'); 3699 %ParamIn.CheckCoordIndex=strcmp(get(handles.SwitchCoordIndex,'String'),'dim');3700 3536 TimeName=get(handles.TimeName,'String'); 3701 3537 r=regexp(TimeName,'^(?<type>(dim:)|(var:))','names');%look for 'var:' or 'dim:' at the beginning of time name … … 3768 3604 end 3769 3605 switch UvData.FileInfo{2}.FileType 3770 case {'civx','civdata','netcdf','pivdata_fluidimage' }3606 case {'civx','civdata','netcdf','pivdata_fluidimage','mat'} 3771 3607 list_fields=get(handles.FieldName_1,'String');% list menu fields 3772 3608 FieldName_1= list_fields{get(handles.FieldName_1,'Value')}; % selected field … … 4170 4006 break 4171 4007 end 4172 if UvData.Field.NbDim==34008 if isfield(UvData.Field,'NbDim') && UvData.Field.NbDim==3 4173 4009 UvData.ProjObject{iobj}.NbDim=3;%test for 3D objects 4174 4010 if ~isfield(UvData.ProjObject{iobj},'RangeZ') … … 5356 5192 prev_path=fullfile(fileparts(which('uvmat')),'transform_field'); 5357 5193 end 5358 if strcmp(transform_name,'more...') ;5194 if strcmp(transform_name,'more...') 5359 5195 transform_fct_chosen=uigetfile_uvmat('Pick the transform function',prev_path,'.m'); 5360 5196 if ~isempty(transform_fct_chosen) … … 5444 5280 %% delete drawn objects if the output CooordUnit is different from the previous one 5445 5281 if ~strcmp(CoordUnit,CoordUnitPrev) 5446 % for iobj=1:numel(UvData.ProjObject)5447 % delete_object(iobj)5448 % end5449 5282 set(handles.CheckFixLimits,'Value',0) 5450 5283 hother=findobj('Tag','proj_object');%find all the proj objects … … 5834 5667 AxeData=[]; 5835 5668 if isfield(UvData,'PlotAxes') 5836 AxeData=UvData.PlotAxes;% retrieve the current plotted data5669 AxeData=UvData.PlotAxes;% retrieve the current plotted data 5837 5670 end 5838 5671 PlotParam=read_GUI(handles.uvmat); -
trunk/src/xml2struct.m
r1093 r1095 29 29 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 30 30 % GNU General Public License (see LICENSE.txt) for more details. 31 %======================================================================= 31 %=======================================================================UVMAT-https 32 32 33 33 function [s,RootTag,errormsg]=xml2struct(filename,varargin)
Note: See TracChangeset
for help on using the changeset viewer.