- Timestamp:
- Mar 17, 2010, 10:26:41 AM (15 years ago)
- Location:
- trunk/src
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/civ.m
r54 r55 139 139 patch_new_exe=sparam.PatchNew_exe; 140 140 end 141 142 if isfield(sparam,'SGE') 143 sge=str2double(sparam.SGE); 144 end 145 146 test_batch=sge;%default 141 147 if isfield(sparam,'Todo_path') 142 148 todo_path=sparam.Todo_path; 143 end 144 if isfield(sparam,'SGE') 145 sge=str2num(sparam.SGE); 146 end 147 name_todo=fullfile(todo_path,'TODO.txt'); 148 test_batch=1; 149 if ~sge 150 if isequal(todo_path,'') || isequal(todo_path,[]) 151 display(['no batch distributed processing available:file path TODO.txt not defined in UVMAT/PARAM.xml']) 152 test_batch=0; 153 end 154 if exist(name_todo,'file')~=2 155 msgbox_uvmat('WARNING',['no batch distributed processing available, queue file ' name_todo ' absent']); 156 % test_batch=0; % Problems to detect file on linux/nfs filesystems 149 name_todo=fullfile(todo_path,'TODO.txt'); 150 if exist(name_todo,'file') 151 test_batch=1; 157 152 end 158 153 end -
trunk/src/editxml.m
r54 r55 185 185 testupfile=0; 186 186 DataIn=get(get(hObject,'parent'),'UserData'); 187 if isfield(DataIn,'UpFile')& ~isempty(DataIn.UpFile)187 if isfield(DataIn,'UpFile')&&~isempty(DataIn.UpFile) 188 188 [UpPath,UpName,UpExt]=fileparts(DataIn.UpFile{1}); 189 189 if isequal(UpExt,'.xml') … … 283 283 CurrentFile=fullfile(PathName,FileName); 284 284 sizf=size(CurrentFile); 285 if (~ischar(CurrentFile)| ~isequal(sizf(1),1)),return;end% keep only character strings as input file name285 if (~ischar(CurrentFile)||~isequal(sizf(1),1)),return;end% keep only character strings as input file name 286 286 if exist(CurrentFile,'file') 287 287 % set(handles.CurrentAttributes,'UserDataIn',PathName); %store the path to the xml file 288 288 [CurPath,CurName,CurExt]=fileparts(CurrentFile); 289 289 if isequal(CurExt,'.xls') 290 if isfield(DataIn,'hfig_xls') &ishandle(DataIn.hfig_xls)290 if isfield(DataIn,'hfig_xls') && ishandle(DataIn.hfig_xls) 291 291 [hfig_xls]=read_xls(CurrentFile,DataIn.hfig_xls); 292 292 else … … 310 310 t=xmltree(CurrentFile);%open the xml file 311 311 head_element=get(t,1); 312 if ~isfield(head_element,'name') | ~isfield(head_element,'attributes')312 if ~isfield(head_element,'name') || ~isfield(head_element,'attributes') 313 313 msgbox_uvmat('ERROR','root element of the .xml file not in correct format') 314 314 end … … 317 317 xstest=0; 318 318 for iattr=1:length(head_attr) 319 if isequal(head_attr{iattr}.key,'xmlns:xsi')& isequal(head_attr{iattr}.val,'none')%no schema to read319 if isequal(head_attr{iattr}.key,'xmlns:xsi')&& isequal(head_attr{iattr}.val,'none')%no schema to read 320 320 xs=[]; 321 321 % xstest=1; 322 322 end 323 if isequal(head_attr{iattr}.key,'xsi:noNamespaceSchemaLocation') & exist(head_attr{iattr}.val,'file')323 if isequal(head_attr{iattr}.key,'xsi:noNamespaceSchemaLocation') && exist(head_attr{iattr}.val,'file') 324 324 DataIn.Schema=head_attr{iattr}.val; 325 325 xs=xmltree(DataIn.Schema);%open the associated schema file … … 332 332 path_uvmat=which('editxml');% check the path detected for source file uvmat 333 333 path_UVMAT=fileparts(path_uvmat); %path to UVMAT 334 % if isunix 335 xmlparam=fullfile(path_UVMAT,'PARAM.xml'); 336 if exist(xmlparam,'file') 337 tparam=xmltree(xmlparam); 338 sparam=convert(tparam); 339 if isfield(sparam,'SchemaPath') 340 schemapath=[fullfile(sparam.SchemaPath,head_name) '.xsd'] 341 end 342 if exist(fullfile(path_UVMAT,schemapath) 343 schemapath=fullfile(path_UVMAT,schemapath);%look for relative path definition 344 end 345 schemapath=fullfile(path_UVMAT,schemapath); 346 % schemapath=['/coriolis/papillon/data/civbin/XML_SCHEMAS/' head_name '.xsd']%current dir for schema 347 % else 348 % xmlparam=fullfile(path_UVMAT,'PARAM_WIN.xml') 349 % if exist(xmlparam,'file') 350 % tparam=xmltree(xmlparam); 351 % sparam=convert(tparam) 352 % if isfield(sparam,'SchemaPath') 353 % schemapath=[fullfile(sparam.SchemaPath,head_name) '.xsd'] 354 % end 355 % end 356 % schemapath=['\\Papillon\data\civbin\XML_SCHEMAS\' head_name '.xsd']%current dir for schemas 357 % end 358 if exist(schemapath,'file') 359 xs=xmltree(schemapath); 360 else 361 msgbox_uvmat('ERROR',['The xml schema for ' CurrentFile ' is unknown, check the schema path set in the file PARAM.xml']) 362 [FileName, PathName]=uigetfile( ... 363 {'*.xsd', '(*.xsd)'; 364 '*.xsd', '.xsd files '; ... 365 '*.*', 'All Files (*.*)'}, ... 366 ['Pick a .xsd schema'] ,schemapath); %file browser 367 if ischar(PathName)&ischar(FileName)& exist(fullfile(PathName,FileName),'file') 368 DataIn.Schema=fullfile(PathName,FileName); 369 xs=xmltree(DataIn.Schema);%open the associated schema file 334 xmlparam=fullfile(path_UVMAT,'PARAM.xml'); 335 if exist(xmlparam,'file') 336 tparam=xmltree(xmlparam); 337 sparam=convert(tparam); 338 if isfield(sparam,'SchemaPath') 339 schemafile=[fullfile(sparam.SchemaPath,head_name) '.xsd']; 340 end 341 if ~exist(schemafile,'file') 342 schemafile=fullfile(path_UVMAT,schemafile);%look for relative path definition 343 end 344 if exist(schemafile,'file') 345 xs=xmltree(schemafile); 370 346 else 371 xs=[]; 347 msgbox_uvmat('ERROR',['The xml schema for ' CurrentFile ' is unknown, check the schema path set in the file PARAM.xml']) 348 [FileName, PathName]=uigetfile( ... 349 {'*.xsd', '(*.xsd)'; 350 '*.xsd', '.xsd files '; ... 351 '*.*', 'All Files (*.*)'}, ... 352 'Pick a .xsd schema' ,schemapath); %file browser 353 if ischar(PathName) && ischar(FileName) && exist(fullfile(PathName,FileName),'file') 354 DataIn.Schema=fullfile(PathName,FileName); 355 xs=xmltree(DataIn.Schema);%open the associated schema file 356 else 357 xs=[]; 358 end 372 359 end 373 360 end … … 376 363 if isempty(xs) 377 364 displ_xml(handles,t,1,DataIn,get(hObject,'parent'));%no associated schema, default display of the xml file 378 % set(handles.inport_file,'Visible','off')379 % set(handles.RefFile,'Visible','off')380 365 else 381 366 DataIn.xs_CurrentUid=find(xs,'/xs:schema/xs:element');%uid of the root element in the schema … … 383 368 [element,subelem]=get_xml(t,path,xs_element,1,xs_subelem);% read the corresponding xml data 384 369 update_list(handles,path,xs_element,element,1,xs_subelem,subelem);%update the display of information on the interface 385 % set(handles.inport_file,'Visible','on')386 % set(handles.RefFile,'Visible','on')387 370 end 388 371 set(heditxml,'UserData',DataIn);%store the new input xml file name … … 890 873 end 891 874 set(handles.element_value,'UserData',node) 892 if ~testedit && isfield(element,'attrup') & isfield(element.attrup,'source')&& ~isequal(element.attrup.source,'manual')875 if ~testedit && isfield(element,'attrup') && isfield(element.attrup,'source')&& ~isequal(element.attrup.source,'manual') 893 876 set(handles.element_value,'Enable','inactive') 894 877 else -
trunk/src/get_field.m
r38 r55 228 228 for icell=1:numel(CellVarIndex) 229 229 VarIndex=CellVarIndex{icell}; 230 if ~isempty(find(VarIndex==yindex )) && (isempty(VarType{icell}.coord_x)||~isequal(VarType{icell}.coord_x,VarIndex))230 if ~isempty(find(VarIndex==yindex,1)) && (isempty(VarType{icell}.coord_x)||~isequal(VarType{icell}.coord_x,VarIndex)) 231 231 cell_select=icell; 232 232 break … … 237 237 set(handles.abscissa,'Value',min(val,2)); 238 238 coord_x_index=VarType{cell_select}.coord; 239 coord_x_index=coord_x_index( find(coord_x_index));239 coord_x_index=coord_x_index(coord_x_index~=0); 240 240 set(handles.abscissa,'String',[{''}; (Field.ListVarName(coord_x_index))'; (Field.ListVarName(VarIndex))']) 241 241 % Field.VarIndex.y=yindex; … … 1245 1245 %default setting for the visibility of the GUI elements* 1246 1246 if ~isequal(ACTION,'PLOT') 1247 varargout=feval(ACTION) % input list asked by the selected function1247 varargout=feval(ACTION);% input list asked by the selected function 1248 1248 test_1Dplot=[]; 1249 1249 test_scalar=[]; … … 1253 1253 %RootFile always visible 1254 1254 case 'check_1Dplot' 1255 test_1Dplot=isequal(lower(varargout{ilist,2}),'y') 1255 test_1Dplot=isequal(lower(varargout{ilist,2}),'y'); 1256 1256 case 'check_scalar' 1257 test_scalar=isequal(lower(varargout{ilist,2}),'y') 1257 test_scalar=isequal(lower(varargout{ilist,2}),'y'); 1258 1258 case 'check_vector' 1259 test_vector=isequal(lower(varargout{ilist,2}),'y') 1259 test_vector=isequal(lower(varargout{ilist,2}),'y'); 1260 1260 end 1261 1261 end … … 1449 1449 set(handles.MenuFile_5,'Label',MenuFile_5) 1450 1450 dir_perso=prefdir; 1451 profil_perso=fullfile(dir_perso,'uvmat_perso.mat') 1451 profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); 1452 display(profil_perso) 1452 1453 if exist(profil_perso,'file') 1453 1454 save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat -
trunk/src/nc2struct.m
r45 r55 2 2 % it reads all the global attributes and all variables, or a selected list. 3 3 % The corresponding dimensions and variable attributes are then extracted 4 %%%%%% TODO: add the possibility to read only attributes, see nc2struct_toolbox %%%5 4 %---------------------------------------------------------------------- 6 5 % function [Data,var_detect,ichoice]=nc2struct(nc,ListVarName) … … 9 8 % Data: structure containing all the information of the netcdf file (or netcdf object) 10 9 % with fields: 11 % .ListGlobalAttribute: cell listing the names of the global attributes 12 % .Att_1,Att_2... : values of the global attributes 13 % .ListDimName: cell listing the names of the array dimensions 14 % .DimValue: array dimension values (Matlab vector with the same length as .ListDimName 15 % .ListVarName: cell listing the names of the variables 16 % .VarDimIndex: cell containing the set of dimension indices (in list .ListDimName) for each variable of .ListVarName 17 % .VarDimName: cell containing a cell of dimension names (in list .ListDimName) for each variable of .ListVarName 18 % .VarAttribute: cell of structures s containing names and values of variable attributes (s.name=value) for each variable of .ListVarName 19 % .Var1, .Var2....: variables (Matlab arrays) with names listed in .ListVarName 20 % var_detect: vector with same length as ListVarName, with 1 for each detected variable and 0 else. 21 % ichoice: = line 22 % 10 % (optional) .ListGlobalAttribute: cell listing the names of the global attributes 11 % .Att_1,Att_2... : values of the global attributes 12 % .ListVarName: list of variable names to select (cell array of char strings {'VarName1', 'VarName2',...} ) 13 % .VarDimName: list of dimension names for each element of .ListVarName (cell array of string cells) 14 % .Var1, .Var2....: variables (Matlab arrays) with names listed in .ListVarName 15 % .ListDimName=list of dimension (added information, not requested for field description) 16 % .DimValue= vlalues of dimensions (added information, not requested for field description) 17 % .VarDimIndex= list of dimension indices (added information, 18 23 19 %INPUT: 24 20 % nc: name of a netcdf file (char string) or netcdf object … … 47 43 function [Data,var_detect,ichoice]=nc2struct(nc,varargin) 48 44 List=varargin; 49 if nargin==045 if isempty(varargin) 50 46 List{1}='*'; 51 47 end … … 122 118 123 119 % -------- read dimensions ----------- 124 dim_name={};120 ListDimName={}; 125 121 dim_value=[]; 126 122 for idim=1:ndims%length(dim_read); 127 [dim_name{idim},dim_value(idim)] = netcdf.inqDim(nc,idim-1); 128 end 129 if ~isempty(dim_name) && ~isempty(dim_value) 130 Data.ListDimName=dim_name; 131 Data.DimValue=dim_value; 123 [ListDimName{idim},dim_value(idim)] = netcdf.inqDim(nc,idim-1); 124 end 125 if ~isempty(ListDimName) %&& ~isempty(dim_value) 126 % Data.DimValue=dim_value; 132 127 % DimIndices=[1:ndims]; %index of the dimension in the netcdf file 133 dim_used=zeros(1,ndims);%initialize test of used dimensions128 flag_used=zeros(1,ndims);%initialize test of used dimensions 134 129 end 135 130 … … 198 193 end 199 194 end 200 201 195 202 196 %select variable attributes and associate dimensions 203 197 % var_dim_index=[]; %default … … 211 205 end 212 206 var_dim=dimids{var_index(ivar)}+1; %dimension indices used by the variable 213 dim_used(var_dim)=ones(size(var_dim));207 flag_used(var_dim)=ones(size(var_dim));%flag_used =1 for the indices of used dimensions 214 208 VarDimIndex{ivar}=var_dim; 215 209 … … 233 227 234 228 %select the used dimensions 235 if isempty(var_read)236 if isfield(Data,'ListDimName')&& isfield(Data,'DimValue')237 Data=rmfield(Data,'ListDimName');238 239 end240 else229 if ~isempty(var_read) 230 % if isfield(Data,'ListDimName') %&& isfield(Data,'DimValue') 231 % Data=rmfield(Data,'ListDimName'); 232 % %Data=rmfield(Data,'DimValue'); 233 % end 234 % else 241 235 % list_dim=1:ndims; 242 dim_index=find( dim_used);236 dim_index=find(flag_used); 243 237 % list_dim=list_dim(dim_index); 244 old2new=cumsum( dim_used);245 Data.ListDimName=Data.ListDimName(dim_index);246 Data.DimValue=Data.DimValue(dim_index);238 old2new=cumsum(flag_used); 239 ListDimName=ListDimName(dim_index); 240 dim_value=dim_value(dim_index); 247 241 end 248 242 for ivar=1:length(var_read) 249 Data.VarDimIndex{ivar}=old2new(VarDimIndex{ivar});% ENLEVER Data.VarDimIndex ulterieurement 250 Data.VarDimName{ivar}=Data.ListDimName(Data.VarDimIndex{ivar}); 251 end 243 %Data.VarDimIndex{ivar}=old2new(VarDimIndex{ivar});% ENLEVER Data.VarDimIndex ulterieurement 244 %Data.VarDimName{ivar}=Data.ListDimName(Data.VarDimIndex{ivar}); 245 Data.VarDimName{ivar}=ListDimName(old2new(VarDimIndex{ivar})); 246 end 247 Data.ListDimName=ListDimName; 248 Data.DimValue=dim_value; 249 Data.VarDimIndex= VarDimIndex; 252 250 %variable values 253 251 if ~isempty(ListVarName) … … 259 257 end 260 258 eval(['Data.' VarName '=netcdf.getVar(nc,var_index(ivar)-1);'])%read the variable data 261 eval(['siz=size(Data.' VarName ');'])262 if numel(siz)<=2263 eval(['Data.' VarName '=Data.' VarName ''';'])%read the variable data264 end259 %eval(['siz=size(Data.' VarName ');']) 260 % if numel(siz)<=2 261 %eval(['Data.' VarName '=Data.' VarName ''';'])%read the variable data 262 %end 265 263 end 266 264 end -
trunk/src/plot_field.m
r46 r55 777 777 test_interp=0; % no interpolation done 778 778 end 779 if test_interp==1%if we interpolate 779 if test_interp==1%if we interpolate 780 780 x=linspace(AX(1),AX(2),np(2)); 781 781 y=linspace(AY(1),AY(2),np(1)); -
trunk/src/proj_field.m
r46 r55 90 90 return 91 91 end 92 FieldData93 92 %introduce default field properties (reading old standards) 94 93 if ~isfield(ObjectData,'Style')||~isfield(ObjectData,'Coord')||~isfield(ObjectData,'ProjMode') -
trunk/src/read_get_field.m
r47 r55 708 708 if testpermute(ilist) 709 709 eval(['SubField.' VarName '=permute(SubField.' VarName ',[2 1]);']) 710 subvarindex(ilist)711 SubField.VarDimName{subvarindex(ilist)}712 710 SubField.VarDimName{subvarindex(ilist)}=SubField.VarDimName{subvarindex(ilist)}([2 1]); 713 711 end -
trunk/src/series.m
r46 r55 1537 1537 %------------------------------------------------------------------------ 1538 1538 % hseries=get(handles.last_i,'parent'); 1539 first_i=str2num(get(handles.first_i,'String'));1540 last_i=str2num(get(handles.last_i,'String'));1541 ref_i=ceil((first_i+last_i)/2);1542 set(handles.ref_i,'String', num2str(ref_i))1543 ref_i_Callback(hObject, eventdata, handles)1539 % first_i=str2num(get(handles.first_i,'String')); 1540 % last_i=str2num(get(handles.last_i,'String')); 1541 % ref_i=ceil((first_i+last_i)/2); 1542 % set(handles.ref_i,'String', num2str(ref_i)) 1543 % ref_i_Callback(hObject, eventdata, handles) 1544 1544 SeriesData=get(handles.figure1,'UserData'); 1545 1545 if ~isfield(SeriesData,'Time') … … 2165 2165 ind_coord=get(handles.transform_fct,'Value'); 2166 2166 coord_option=menu{ind_coord}; 2167 list_transform=get(handles.transform_fct,'UserData') 2167 list_transform=get(handles.transform_fct,'UserData'); 2168 2168 ff=functions(list_transform{end}); 2169 2169 if isequal(coord_option,'more...'); … … 2200 2200 if exist(profil_perso,'file') 2201 2201 for ilist=nb_transform+1:numel(list_transform) 2202 ff=functions(list_transform{ilist}) 2202 ff=functions(list_transform{ilist}); 2203 2203 transform_fct{ilist-nb_transform}=ff.file; 2204 2204 end -
trunk/src/series/aver_stat.m
r43 r55 241 241 %check coincidence in time 242 242 multitime=0; 243 if length(timecell)==0243 if isempty(timecell) 244 244 time=[]; 245 245 elseif length(timecell)==1 … … 454 454 end 455 455 display([filemean ' written']); 456 else % determine global attributes456 else %case of netcdf input file , determine global attributes 457 457 DataMean.ListGlobalAttribute=[DataMean.ListGlobalAttribute {Series.Action}]; 458 458 ActionKey='Action'; … … 493 493 end 494 494 end 495 495 496 hget_field=findobj(allchild(0),'name','get_field');%find the get_field... GUI 496 497 delete(hget_field) -
trunk/src/set_object.m
r41 r55 7 7 % hset_object: handle of the GUI figure 8 8 % 9 % IN TPUT:9 % INPUT: 10 10 % data: structure describing the object properties 11 % PlotHandles: handles for projection plots 11 % .Style=... 12 % .ProjMode 13 % .CoordType: 'phys' or 'px' 14 % .DX,.DY,.DZ : mesh along each dirction 15 % .RangeX, RangeY 16 % .Coord(j,i), i=1, 2, 3, components x, y, z of j=1...n position(s) characterizing the object components 17 % PlotHandles: handles for projection plots 12 18 % Zbounds: bounds on Z ( 3D case) 13 19 % … … 86 92 desable_plot=0;%default 87 93 SetData.PlotHandles=PlotHandles; 88 if exist('data','var') & isfield(data,'ParentButton')94 if exist('data','var') && isfield(data,'ParentButton') 89 95 SetData.ParentButton=data.ParentButton; 90 96 set(hObject,'DeleteFcn',{@closefcn,SetData.ParentButton})% … … 94 100 % fill the interface as set in the input data: 95 101 if exist('data','var') 96 % if isfield(data,'desable_open')97 % desable_open=data.desable_open;%test to desable button OPEN (edit or display mode)98 % end99 102 if isfield(data,'desable_plot') 100 103 desable_plot=data.desable_plot;%test to desable button PLOT (display mode) 101 104 end 102 if ~isfield(data,'NbDim')| ~isequal(data.NbDim,3)%2D case105 if ~isfield(data,'NbDim')||~isequal(data.NbDim,3)%2D case 103 106 set(handles.ZObject,'Visible','off') 104 107 set(handles.z_slider,'Visible','off') … … 110 113 end 111 114 end 112 % if isfield(data,'ProjMode') && isfield(data,'Style')113 % data.TITLE=set_title(data.Style,data.ProjMode);% define TITLE in set_object (POINTS, LINE, PATCH,...)114 % end115 % if isfield(data,'TITLE')116 % menutitle=get(handles.TITLE,'String');117 % for iline=1:length(menutitle)118 % strmenu=menutitle{iline};119 % if isequal(data.TITLE,strmenu)120 % set(handles.TITLE,'Value',iline)121 % break122 % end123 % end124 % TITLE_Callback(hObject, eventdata, handles)% enable edit boxes depending on TITLE125 % end126 % if isfield(data,'fixedtitle')&isequal(data.fixedtitle,1)127 % set(handles.TITLE,'enable','off')128 % end129 115 if isfield(data,'Style') 130 116 menu=get(handles.ObjectStyle,'String'); … … 147 133 end 148 134 ProjMode_Callback(hObject, eventdata, handles) 149 if isfield(data,'Coord') & size(data.Coord,2)>=2 150 sizcoord=size(data.Coord); 151 for i=1:sizcoord(1) 152 XObject{i}=num2str(data.Coord(i,1),4); 153 YObject{i}=num2str(data.Coord(i,2),4); 154 end 155 set(handles.XObject,'String',XObject) 156 set(handles.YObject,'String',YObject) 157 %set(handles.XObject,'String',mat2cell(data.Coord(:,1),sizcoord(1))) 158 %set(handles.YObject,'String',mat2cell(data.Coord(:,2),sizcoord(1))) 159 if sizcoord(2)>3 135 if isfield(data,'Coord') 136 if ischar(data.Coord) 137 data.Coord=str2num(data.Coord); 138 elseif iscell(data.Coord) 139 CoordCell=data.Coord; 140 data.Coord=zeros(numel(CoordCell),3); 141 for iline=1:numel(CoordCell) 142 data.Coord(iline,:)=str2num(CoordCell{iline}); 143 end 144 end 145 if size(data.Coord,2)>=2 146 sizcoord=size(data.Coord); 160 147 for i=1:sizcoord(1) 161 ZObject{i}=num2str(data.Coord(i,3),4); 148 XObject{i}=num2str(data.Coord(i,1),4); 149 YObject{i}=num2str(data.Coord(i,2),4); 162 150 end 163 set(handles.ZObject,'String',ZObject) 151 set(handles.XObject,'String',XObject) 152 set(handles.YObject,'String',YObject) 153 if sizcoord(2)>3 154 for i=1:sizcoord(1) 155 ZObject{i}=num2str(data.Coord(i,3),4); 156 end 157 set(handles.ZObject,'String',ZObject) 158 end 164 159 end 165 160 end 166 161 if isfield(data,'DX') 167 set(handles.DX,'String',num2str(data.DX,3)) 162 if ~ischar(handles.DX) 163 data.DX=num2str(data.DX,3); 164 end 165 set(handles.DX,'String',data.DX) 168 166 end 169 167 if isfield(data,'DY') 170 set(handles.DY,'String',num2str(data.DY,3)) 171 end 172 %OBSOLETE (replaced by Range) 173 % if isfield(data,'XMin') 174 % set(handles.XMin,'String',num2str(data.XMin,3)) 175 % end 176 % if isfield(data,'XMax') 177 % set(handles.XMax,'String',num2str(data.XMax,3)) 178 % end 179 % if isfield(data,'YMin') 180 % set(handles.YMin,'String',num2str(data.YMin,3)) 181 % end 182 % if isfield(data,'YMax') 183 % set(handles.YMax,'String',num2str(data.YMax,3)) 184 % end 168 if ~ischar(handles.DY) 169 data.DY=num2str(data.DY,3); 170 end 171 set(handles.DY,'String',data.DX) 172 end 185 173 if isfield(data,'RangeZ') && length(ZBounds) >= 2 186 174 set(handles.ZMax,'String',num2str(max(data.RangeZ),3)) … … 197 185 end 198 186 if isfield(data,'RangeX') 199 set(handles.XMax,'String',num2str(max(data.RangeX),3)) 200 set(handles.XMin,'String',num2str(min(data.RangeX),3)) 187 if ischar(data.RangeX) 188 data.RangeX=str2num(data.RangeX); 189 end 190 set(handles.XMax,'String',num2str(max(data.RangeX),3)) 191 set(handles.XMin,'String',num2str(min(data.RangeX),3)) 201 192 end 202 193 if isfield(data,'RangeY') 203 set(handles.YMax,'String',num2str(max(data.RangeY),3)) 204 set(handles.YMin,'String',num2str(min(data.RangeY),3)) 194 if ischar(data.RangeY) 195 data.RangeY=str2num(data.RangeY); 196 end 197 set(handles.YMax,'String',num2str(max(data.RangeY),3)) 198 set(handles.YMin,'String',num2str(min(data.RangeY),3)) 205 199 end 206 200 if isfield(data,'RangeZ') 207 set(handles.ZMax,'String',num2str(max(data.RangeZ),3)) 208 set(handles.ZMin,'String',num2str(min(data.RangeZ),3)) 201 if ischar(data.RangeZ) 202 data.RangeZ=str2num(data.RangeZ); 203 end 204 set(handles.ZMax,'String',num2str(max(data.RangeZ),3)) 205 set(handles.ZMin,'String',num2str(min(data.RangeZ),3)) 209 206 end 210 207 if isfield(data,'Phi') 211 set(handles.Phi,'String',num2str(data.Phi,3)) 208 if ~ischar(handles.Phi) 209 data.DY=num2str(data.Phi,3); 210 end 211 set(handles.Phi,'String',data.Phi) 212 212 end 213 213 if isfield(data,'Theta') 214 set(handles.Theta,'String',num2str(data.Theta,3)) 214 if ~ischar(handles.Theta) 215 data.DY=num2str(data.Theta,3); 216 end 217 set(handles.Theta,'String',data.Theta) 215 218 end 216 219 if isfield(data,'Psi') 217 set(handles.Psi,'String',num2str(data.Psi,3)) 220 if ~ischar(handles.Psi) 221 data.DY=num2str(data.Psi,3); 222 end 223 set(handles.Psi,'String',data.Psi) 218 224 end 219 225 if isfield(data,'DZ') 220 set(handles.DZ,'String',num2str(data.DZ,3)) 226 if ~ischar(handles.DZ) 227 data.DY=num2str(data.DZ,3); 228 end 229 set(handles.DZ,'String',data.DZ) 221 230 end 222 231 if isfield(data,'CoordType') … … 506 515 507 516 %----------------------------------------------------- 508 % --- Executes on button press in OPEN .517 % --- Executes on button press in OPEN: DESACTIVATED use uvmat browser 509 518 function OPEN_Callback(hObject, eventdata, handles) 510 519 %get the object file -
trunk/src/struct2nc.m
r45 r55 10 10 % Data: structure containing all the information of the netcdf file (or netcdf object) 11 11 % with fields: 12 % .ListGlobalAttribute: cell listing the names of the global attributes (note that a global atribute with the same name as a variable is excluded) 13 % .Att_1,Att_2... : values of the global attributes 14 % .ListDimName: cell listing the names of the array dimensions 15 % .DimValue: array dimension values (Matlab vector with the same length as .ListDimName 16 % .ListVarName: cell listing the names of the variables 17 % .VarDimIndex: cell containing the set of dimension indices (in list .ListDimName) for each variable of .ListVarName 18 % .VarAttribute: cell of structures s containing names and values of variable attributes (s.name=value) for each variable of .ListVarName 19 % .Var1, .Var2....: variables (Matlab arrays) with names listed in .ListVarName 12 % (optional) .ListGlobalAttribute: cell listing the names of the global attributes 13 % .Att_1,Att_2... : values of the global attributes 14 % (requested) .ListVarName: list of variable names to select (cell array of char strings {'VarName1', 'VarName2',...} ) 15 % (requested) .VarDimName: list of dimension names for each element of .ListVarName (cell array of string cells) 16 % (requested) .Var1, .Var2....: variables (Matlab arrays) with names listed in .ListVarName 20 17 % 21 18 %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA … … 126 123 break 127 124 end 128 if testline || testrange %NEW125 if testline || testrange 129 126 if testrange 130 VarVal=linspace(VarVal(1),VarVal(2),Data.DimValue(VarDimIndex)); %NEW127 VarVal=linspace(VarVal(1),VarVal(2),Data.DimValue(VarDimIndex)); 131 128 end 132 129 %nc{ListVarName{ivar}}=ncfloat(Data.ListDimName(VarDimIndex));%vector of x coordinates 133 netcdf.putVar(nc,varid(ivar), VarVal');130 netcdf.putVar(nc,varid(ivar), double(VarVal')); 134 131 else 135 netcdf.putVar(nc,varid(ivar), VarVal);132 netcdf.putVar(nc,varid(ivar), double(VarVal)); 136 133 %nc{ListVarName{ivar}}(:) = VarVal; 137 134 end -
trunk/src/uvmat.m
r45 r55 1426 1426 Mask.Base=[FileBase Name(i:ind_mask+3)]; 1427 1427 Mask.NbSlice=nbslice; 1428 num_i1=mod(num_i1-1,nbslice)+1 1428 num_i1=mod(num_i1-1,nbslice)+1; 1429 1429 Mask.NomType=Mask_NomType{1}; 1430 [maskname,mdetect]=name_generator(Mask.Base,num_i1,num_j1,'.png',Mask.NomType) %1431 mdetect=exist(maskname,'file') 1430 [maskname,mdetect]=name_generator(Mask.Base,num_i1,num_j1,'.png',Mask.NomType);% 1431 mdetect=exist(maskname,'file'); 1432 1432 if mdetect 1433 1433 set(handles.nb_slice,'String',Name(i+1:ind_mask-1)); … … 2695 2695 AxeData=get(gca,'UserData'); 2696 2696 [erread,message]=fileattrib(filename); 2697 if ~isempty(message) & ~isequal(message.UserWrite,1)2697 if ~isempty(message) && ~isequal(message.UserWrite,1) 2698 2698 msgbox_uvmat('ERROR',['no writting access to ' filename]) 2699 2699 return 2700 2700 end 2701 nc=netcdf(filename,'write'); %open netcdf file2702 result=redef(nc);2703 if isempty(result), msgbox_uvmat('ERROR','##Bad redef operation.'),end2704 2701 test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]); 2705 if ~test_civ2 2706 test_civ1=isequal(get(handles.civ1,'BackgroundColor'),[1 1 0]); 2707 end 2708 if test_civ2 % for civ2 2709 2710 theDim=nc('nb_vectors2') ;% get the number of velocity vectors 2711 nb_vectors2=size(theDim); 2712 var_FixFlag=ncvar('vec2_FixFlag',nc);% var_FixFlag will be written as the netcdf variable vec_FixFlag 2713 var_FixFlag(1:nb_vectors2)=AxeData.FF;% 2714 elseif test_civ1 % for civ1 2715 2716 theDim=nc('nb_vectors') ;% get the number of velocity vectors 2717 nb_vectors=size(theDim); 2718 var_FixFlag=ncvar('vec_FixFlag',nc);% var_FixFlag will be written as the netcdf variable vec_FixFlag 2719 var_FixFlag(1:nb_vectors)=AxeData.FF;% 2720 else 2702 test_civ1=isequal(get(handles.civ1,'BackgroundColor'),[1 1 0]); 2703 if ~test_civ2 && ~test_civ1 2721 2704 msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields') 2722 2705 end 2723 fin=close(nc); 2706 if test_civ2 2707 nbname='nb_vectors2'; 2708 flagname='vec2_FixFlag'; 2709 attrname='fix2'; 2710 end 2711 if test_civ1 2712 nbname='nb_vectors'; 2713 flagname='vec_FixFlag'; 2714 attrname='fix'; 2715 end 2716 %write fix flags in the netcdf file 2717 hhh=which('netcdf.open');% look for built-in matlab netcdf library 2718 if ~isequal(hhh,'')% case of new builtin Matlab netcdf library 2719 nc=netcdf.open(filename,'NC_WRITE'); 2720 netcdf.reDef(nc) 2721 netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),attrname,1) 2722 dimid = netcdf.inqDimID(nc,nbname); 2723 try 2724 varid = netcdf.inqVarID(nc,flagname);% look for already existing fixflag variable 2725 catch 2726 varid=netcdf.defVar(nc,flagname,'double',dimid);%create fixflag variable if it does not exist 2727 end 2728 netcdf.endDef(nc) 2729 netcdf.putVar(nc,varid,AxeData.FF); 2730 netcdf.close(nc) 2731 else %old netcdf library 2732 nc=netcdf(filename,'write'); %open netcdf file 2733 result=redef(nc); 2734 eval(['nc.' attrname '=1;']); 2735 theDim=nc(nbname) ;% get the number of velocity vectors 2736 nb_vectors=size(theDim); 2737 var_FixFlag=ncvar(flagname,nc);% var_FixFlag will be written as the netcdf variable vec_FixFlag 2738 var_FixFlag(1:nb_vectors)=AxeData.FF;% 2739 fin=close(nc); 2740 end 2741 2742 2743 2744 2745 2746 2724 2747 2725 2748 … … 3680 3703 function edit_vect_Callback(hObject, eventdata, handles) 3681 3704 %------------------------------------------------------- 3682 huvmat=get(handles.edit_vect,'parent'); 3683 UvData=get(h uvmat,'UserData');%read UvData properties stored on the uvmat interface3705 3706 UvData=get(handles.uvmat,'UserData');%read UvData properties stored on the uvmat interface 3684 3707 if isequal(get(handles.edit_vect,'Value'),1) 3708 test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]); 3709 test_civ1=isequal(get(handles.civ1,'BackgroundColor'),[1 1 0]); 3710 if ~test_civ2 && ~test_civ1 3711 msgbox_uvmat('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields') 3712 end 3685 3713 set(handles.record,'Visible','on') 3686 3714 set(handles.edit_vect,'BackgroundColor',[1 1 0]) … … 3696 3724 UvData.MouseAction='none'; 3697 3725 end 3698 set(h uvmat,'UserData',UvData)3726 set(handles.uvmat,'UserData',UvData) 3699 3727 3700 3728 %---------------------------------------------- … … 4879 4907 % -------------------------------------------------------------------- 4880 4908 function Menupoints_Callback(hObject, eventdata, handles) 4881 % set(handles.create,'Visible','on')4882 % set(handles.create,'Value',1)4883 % POINTS_Callback(hObject,eventdata,handles)4884 4909 data.Style='points'; 4885 4910 data.ProjMode='projection';%default 4886 PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters 4887 create_object(data,handles.uvmat,PlotHandles) 4911 create_object(data,handles) 4888 4912 4889 4913 % -------------------------------------------------------------------- … … 4894 4918 data.Style='line'; 4895 4919 data.ProjMode='projection';%default 4896 PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters 4897 create_object(data,handles.uvmat,PlotHandles) 4920 create_object(data,handles) 4898 4921 4899 4922 %------------------------------------------------------------------------ … … 4902 4925 data.Style='polyline'; 4903 4926 data.ProjMode='projection';%default 4904 PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters 4905 create_object(data,handles.uvmat,PlotHandles) 4906 4907 % ------------------------------------------------------------------ 4927 create_object(data,handles) 4928 4929 %------------------------------------------------------------------------ 4908 4930 function Menupolygon_Callback(hObject, eventdata, handles) 4909 % set(handles.create,'Visible','on') 4910 % set(handles.create,'Value',1) 4911 % PATCH_Callback(hObject,eventdata,handles) 4931 %------------------------------------------------------------------------ 4912 4932 data.Style='polygon'; 4913 4933 data.ProjMode='inside';%default 4914 PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters 4915 create_object(data,handles.uvmat,PlotHandles) 4934 create_object(data,handles) 4916 4935 4917 4936 %------------------------------------------------------------------------ … … 4920 4939 data.Style='rectangle'; 4921 4940 data.ProjMode='inside';%default 4922 PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters 4923 create_object(data,handles.uvmat,PlotHandles) 4941 create_object(data,handles) 4924 4942 4925 4943 %------------------------------------------------------------------------ … … 4928 4946 data.Style='ellipse'; 4929 4947 data.ProjMode='inside';%default 4930 PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters 4931 create_object(data,handles.uvmat,PlotHandles) 4948 create_object(data,handles) 4932 4949 4933 4950 % ------------------------------------------------------------------ … … 4938 4955 data.Style='plane'; 4939 4956 data.ProjMode='projection';%default 4940 PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters 4941 create_object(data,handles .uvmat,PlotHandles)4957 4958 create_object(data,handles) 4942 4959 4943 4960 % ------------------------------------------------------------------ … … 4966 4983 4967 4984 %read the file 4968 t=xmltree(fileinput); 4969 data=convert(t); 4970 if ~isfield(data,'Style') 4971 data.Style='points'; 4972 end 4973 if ~isfield(data,'ProjMode') 4974 data.ProjMode='none'; 4975 end 4985 t=xmltree(fileinput); 4986 data=convert(t); 4976 4987 PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters 4977 create_object(data,handles.uvmat,PlotHandles) 4978 4979 %------------------------------------------------------------------------ 4980 function create_object(data,huvmat,PlotHandles) 4981 %------------------------------------------------------------------------ 4982 hset_object=findobj(allchild(0),'Name','set_object') 4988 hset_object=findobj(allchild(0),'Name','set_object'); 4983 4989 if ~isempty(hset_object) 4984 4990 delete(hset_object)% delete existing version of set_object 4985 4991 end 4986 UvData=get(huvmat,'UserData'); 4992 [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface 4993 UvData.MouseAction='create_object'; 4994 set(handles.uvmat,'UserData',UvData) 4995 4996 %------------------------------------------------------------------------ 4997 function create_object(data,handles) 4998 %------------------------------------------------------------------------ 4999 hset_object=findobj(allchild(0),'Name','set_object'); 5000 if ~isempty(hset_object) 5001 delete(hset_object)% delete existing version of set_object 5002 end 5003 UvData=get(handles.uvmat,'UserData'); 4987 5004 if isfield(UvData,'CoordType') 4988 5005 data.CoordType=UvData.CoordType; 4989 5006 end 4990 if isfield(UvData,'Mesh')& ~isempty(UvData.Mesh)5007 if isfield(UvData,'Mesh')&&~isempty(UvData.Mesh) 4991 5008 data.RangeX=UvData.Mesh; 4992 5009 data.RangeY=UvData.Mesh; 4993 5010 data.DX=UvData.Mesh; 4994 5011 data.DY=UvData.Mesh; 4995 elseif isfield(UvData.Field,'AX')& isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')%only image5012 elseif isfield(UvData.Field,'AX')&& isfield(UvData.Field,'AY')&& isfield(UvData.Field,'A')%only image 4996 5013 np=size(UvData.Field.A); 4997 5014 meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/np(2); … … 5001 5018 data.DX=max(meshx,meshy); 5002 5019 end 5003 if isfield(data,'DX') 5004 data.Coord=[[0 0 0];[data.DX 0 0]]; %default 5005 else 5006 data.Coord=[[0 0 0];[1 0 0]]; %default 5020 data.Coord=[0 0 0]; %default 5021 if isfield(data,'Style') && isequal(data.Style,'line') 5022 if isfield(data,'DX') 5023 data.Coord=[[0 0 0];[data.DX 0 0]]; %default 5024 else 5025 data.Coord=[[0 0 0];[1 0 0]]; %default 5026 end 5007 5027 end 5008 5028 %data.ParentButton=handles.create; 5009 5029 if ishandle(handles.UVMAT_title) 5030 delete(handles.UVMAT_title)%delete the initial display of uvmat if no field has been entered 5031 end 5032 PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters 5010 5033 [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface 5011 5034 UvData.MouseAction='create_object'; 5012 set(huvmat,'UserData',UvData) 5013 5014 5035 set(handles.uvmat,'UserData',UvData) 5036 set(handles.zoom,'Value',0) 5037 zoom_Callback(handles.uvmat, [], handles) 5038
Note: See TracChangeset
for help on using the changeset viewer.