- Timestamp:
- Mar 17, 2010, 1:30:15 PM (15 years ago)
- Location:
- trunk/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/RUN_FIX.m
r47 r56 153 153 netcdf.close(nc) 154 154 else %old netcdf library 155 nc=netcdf(filename,'write'); %open netcdf file for writing 156 result=redef(nc); 157 if isempty(result), msgbox_uvmat('ERROR','##Bad redef operation.'),end 158 if iter==1 159 nc.fix=1; 160 elseif iter==2 161 nc.fix2=1; 162 end 163 nc{field.fixflag}=ncfloat(field.nb); 164 fixflag_unit=Field.FF-10*floor(Field.FF/10); %unity term of fix_flag 165 nc{field.fixflag}(:)=fixflag_unit+10*flagmagenta; 166 close(nc); 155 netcdf_toolbox(filename,Field,flagmagenta,iter,field) 167 156 end 157 158 function netcdf_toolbox(filename,Field,flagmagenta,iter,field) 159 nc=netcdf(filename,'write'); %open netcdf file for writing 160 result=redef(nc); 161 if isempty(result), msgbox_uvmat('ERROR','##Bad redef operation.'),end 162 if iter==1 163 nc.fix=1; 164 elseif iter==2 165 nc.fix2=1; 166 end 167 nc{field.fixflag}=ncfloat(field.nb); 168 fixflag_unit=Field.FF-10*floor(Field.FF/10); %unity term of fix_flag 169 nc{field.fixflag}(:)=fixflag_unit+10*flagmagenta; 170 close(nc); -
trunk/src/get_field.m
r55 r56 134 134 %------------------------------------------------------------------------ 135 135 inputfile=get(handles.inputfile,'String'); 136 Field=nc2struct(inputfile ,[]);% reads only the lists of fields, dimensions and attributes136 Field=nc2struct(inputfile);% reads the whole field 137 137 hfig=get(handles.inputfile,'parent'); 138 138 set(hfig,'UserData',Field); … … 171 171 set(handles.scalar,'Value',1) 172 172 set(handles.scalar,'String', Txt ) 173 173 'TESTget' 174 Field 174 175 [CellVarIndex,NbDim,VarType,errormsg]=find_field_indices(Field); 175 176 if ~isempty(errormsg) -
trunk/src/nc2struct.m
r55 r56 3 3 % The corresponding dimensions and variable attributes are then extracted 4 4 %---------------------------------------------------------------------- 5 % function [Data,var_detect,ichoice]=nc2struct(nc, ListVarName)5 % function [Data,var_detect,ichoice]=nc2struct(nc,varargin) 6 6 % 7 7 % OUTPUT: … … 19 19 %INPUT: 20 20 % nc: name of a netcdf file (char string) or netcdf object 21 % ListVarName: optional list of variable names to select (cell array of char strings {'VarName1', 'VarName2',...} ) 22 % if ListVarName=[] or {}, no variables is read (only global attributes and lists of dimensions, variables and attriburtes) 21 % additional arguments: 22 % -in the absence of other arguments, all the fields are read 23 % -a cell array, ListVarName, of char strings {'VarName1', 'VarName2',...} ) 24 % if ListVarName=[] or {}, no variables is read (only global attributes) 23 25 % if ListVarName is absent, or = '*', ALL the variables are read. 24 26 % if ListVarName is a cell array with n lines, the set of variables 25 27 % will be sought by order of priority in the list, while output names will be set by the first line 28 % - the string 'ListGlobalAttribute' followed by a list of attribute names: reads only these attributes (fast reading) 26 29 % 27 30 %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA … … 42 45 43 46 function [Data,var_detect,ichoice]=nc2struct(nc,varargin) 44 List=varargin; 47 45 48 if isempty(varargin) 46 List{1}='*';49 varargin{1}='*'; 47 50 end 48 % if ~exist('ListVarName','var')49 % ListVarName='*';50 % end51 51 hhh=which('netcdf.open');% look for built-in matlab netcdf library 52 52 … … 69 69 end 70 70 % short reading of global attributes 71 if isequal( List{1},'ListGlobalAttribute')72 for ilist=2:numel( List)71 if isequal(varargin{1},'ListGlobalAttribute') 72 for ilist=2:numel(varargin) 73 73 try 74 valuestr = netcdf.getAtt(nc,netcdf.getConstant('NC_GLOBAL'), List{ilist});74 valuestr = netcdf.getAtt(nc,netcdf.getConstant('NC_GLOBAL'),varargin{ilist}); 75 75 catch 76 76 valuestr=[]; 77 77 end 78 eval(['Data.' List{ilist} '=valuestr;'])78 eval(['Data.' varargin{ilist} '=valuestr;']) 79 79 end 80 80 netcdf.close(nc) … … 83 83 84 84 % reading of variables, including attributes 85 ListVarName= List{1};85 ListVarName=varargin{1}; 86 86 [ndims,nvars,ngatts]=netcdf.inq(nc);%nbre of dimensions, variables, attributes 87 87 -
trunk/src/nc2struct_toolbox.m
r19 r56 79 79 ListVarName='*'; 80 80 else 81 if isempty(List{1})82 ListVarName='*';83 else84 ListVarName=List{1};85 end81 % if isempty(List{1}) 82 % ListVarName='*'; 83 % else 84 ListVarName=List{1}; 85 % end 86 86 end 87 87 % -------- read global attributes ----------- -
trunk/src/read_get_field.m
r55 r56 532 532 if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=field_var_index 533 533 if isfield(Field.VarAttribute{field_var_index},'Coord_2')&& isfield(Field.VarAttribute{field_var_index},'Coord_1') 534 %Coord_2=Field.VarAttribute{field_var_index}.Coord_2;535 %Coord_1=Field.VarAttribute{field_var_index}.Coord_1;534 Coord_2=Field.VarAttribute{field_var_index}.Coord_2; 535 Coord_1=Field.VarAttribute{field_var_index}.Coord_1; 536 536 testold=1; 537 537 end … … 659 659 if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=field_var_index 660 660 if isfield(Field.VarAttribute{field_var_index},'Coord_2')&& isfield(Field.VarAttribute{field_var_index},'Coord_1') 661 %Coord_2=Field.VarAttribute{field_var_index}.Coord_2;662 %Coord_1=Field.VarAttribute{field_var_index}.Coord_1;661 Coord_2=Field.VarAttribute{field_var_index}.Coord_2; 662 Coord_1=Field.VarAttribute{field_var_index}.Coord_1; 663 663 testold=1; 664 664 end -
trunk/src/uvmat.m
r55 r56 822 822 set(handles.Fields,'String',{'image';'get_field...';'velocity';'vort';'div';'more...'}) 823 823 elseif isequal(FileExt,'.nc')||isequal(FileExt,'.cdf') 824 Data=nc2struct(FileName, []);824 Data=nc2struct(FileName,'ListGlobalAttribute','absolut_time_T0','civ'); 825 825 col_vec=get(handles.col_vec,'String'); 826 if isfield(Data,'absolut_time_T0') %&& (isfield(Data,'civ1')||isfield(Data,'civ'))826 if isfield(Data,'absolut_time_T0')&& ~(isfield(Data,'civ') && isequal(Data.civ,0)) 827 827 set(handles.Fields,'String',{'image';'get_field...';'velocity';'vort';'div';'more...'}) 828 828 set(handles.Fields,'Value',3) % set menu to 'velocity' … … 1986 1986 Field{1}.CoordUnit='pixel'; %used for mouse_motion 1987 1987 end 1988 1989 %read a second image 1988 1990 if ~isfield(UvData,'Txt')&& ~isempty(filename_1) && isequal(FieldName_1,'image') 1989 1991 switch FileType_1 … … 2730 2732 netcdf.close(nc) 2731 2733 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 2747 2734 netcdf_toolbox(filename,AxeData,attrname,nbname,flagname) 2735 end 2736 2737 function netcdf_toolbox(filename,AxeData,attrname,nbname,flagname) 2738 nc=netcdf(filename,'write'); %open netcdf file 2739 result=redef(nc); 2740 eval(['nc.' attrname '=1;']); 2741 theDim=nc(nbname) ;% get the number of velocity vectors 2742 nb_vectors=size(theDim); 2743 var_FixFlag=ncvar(flagname,nc);% var_FixFlag will be written as the netcdf variable vec_FixFlag 2744 var_FixFlag(1:nb_vectors)=AxeData.FF;% 2745 fin=close(nc); 2748 2746 2749 2747
Note: See TracChangeset
for help on using the changeset viewer.