- Timestamp:
- Apr 30, 2012, 6:46:45 PM (13 years ago)
- Location:
- trunk/src
- Files:
-
- 1 deleted
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/calc_field.m
r399 r404 1 2 1 3 %'calc_field': defines fields (velocity, vort, div...) from civx data and calculate them 2 4 %--------------------------------------------------------------------- … … 35 37 % the scalar is calculated from other fields, as explicited below 36 38 37 list_field={'velocity';...%image correlation corresponding to a vel vector 39 %% list of field options implemented 40 FieldOptions={'velocity';...%image correlation corresponding to a vel vector 38 41 'ima_cor';...%image correlation corresponding to a vel vector 39 42 'norm_vel';...%norm of the velocity … … 48 51 errormsg=[]; %default error message 49 52 if ~exist('FieldList','var') 50 DataOut=list_field;% gives the list of possible fields in the absence of input 53 DataOut=FieldOptions;% gives the list of possible field inputs in the absence of input 54 return 55 end 56 57 %% check input 58 if ~exist('DataIn','var') 59 DataIn=[]; 60 end 61 if ischar(FieldList) 62 FieldList={FieldList};%convert a string input to a cell with one string element 63 end 64 check_grid=0; 65 check_der=0; 66 check_calc=ones(size(FieldList)); 67 for ilist=1:length(FieldList) 68 switch FieldList{ilist} 69 case {'u','v'} 70 check_grid=1;% needs a regular grid 71 case{'vort','div','strain'}% needs spatial derivatives spatial derivatives 72 check_der=1; 73 case {'velocity','norm_vel'}; 74 otherwise 75 check_calc(ilist)=0; 76 end 77 end 78 FieldList=FieldList(check_calc==1); 79 if isempty(FieldList) 80 DataOut=DataIn; 81 return 82 end 83 if isfield(DataIn,'Z')&& isequal(size(DataIn.Z),size(DataIn.X)) 84 nbcoord=3; 51 85 else 52 if ~exist('DataIn','var') 53 DataIn=[]; 54 end 55 if ischar(FieldList) 56 FieldList={FieldList};%convert a string input to a cell with one string element 57 end 58 if isfield(DataIn,'Z')&& isequal(size(DataIn.Z),size(DataIn.X)) 59 nbcoord=3; 60 else 61 nbcoord=2; 62 end 63 ListVarName={}; 64 ValueList={}; 65 RoleList={}; 66 units_cell={}; 67 68 %% interpolation with new civ data 69 if isfield(DataIn,'SubRange') && isfield(DataIn,'Coord_tps')&& exist('Coord_interp','var') 70 DataOut.ListGlobalAttribute=DataIn.ListGlobalAttribute; %reproduce global attribute 71 for ilist=1:numel(DataOut.ListGlobalAttribute) 72 DataOut.(DataOut.ListGlobalAttribute{ilist})=DataIn.(DataIn.ListGlobalAttribute{ilist}); 73 end 74 DataOut.ListVarName={'coord_y','coord_x','FF'}; 75 DataOut.VarDimName{1}='coord_y'; 76 DataOut.VarDimName{2}='coord_x'; 77 XMax=max(max(DataIn.SubRange(1,:,:)));% extrema of the coordinates 78 YMax=max(max(DataIn.SubRange(2,:,:))); 79 XMin=min(min(DataIn.SubRange(1,:,:))); 80 YMin=min(min(DataIn.SubRange(2,:,:))); 81 check_der=0; 82 check_val=0; 83 nb_sites=size(Coord_interp,1); 84 nb_coord=size(Coord_interp,2); 86 nbcoord=2; 87 end 88 ListVarName={}; 89 ValueList={}; 90 RoleList={}; 91 units_cell={}; 92 93 %% interpolation with new civ data 94 if isfield(DataIn,'SubRange') && isfield(DataIn,'Coord_tps') && (exist('Coord_interp','var') || check_grid ||check_der) 95 %create a default grid if needed 96 if ~exist('Coord_interp','var') 97 coord_x=DataIn.XMin:DataIn.Mesh:DataIn.XMax; 98 coord_y=DataIn.XMin:DataIn.Mesh:DataIn.YMax; 99 [XI,YI]=meshgrid(coord_x,coord_y); 100 XI=reshape(XI,[],1); 101 YI=reshape(YI,[],1); 102 Coord_interp=[XI YI]; 103 end 104 DataOut.ListGlobalAttribute=DataIn.ListGlobalAttribute; %reproduce global attribute 105 for ilist=1:numel(DataOut.ListGlobalAttribute) 106 DataOut.(DataOut.ListGlobalAttribute{ilist})=DataIn.(DataIn.ListGlobalAttribute{ilist}); 107 end 108 DataOut.ListVarName={'coord_y','coord_x','FF'}; 109 DataOut.VarDimName{1}='coord_y'; 110 DataOut.VarDimName{2}='coord_x'; 111 XMax=max(max(DataIn.SubRange(1,:,:)));% extrema of the coordinates 112 YMax=max(max(DataIn.SubRange(2,:,:))); 113 XMin=min(min(DataIn.SubRange(1,:,:))); 114 YMin=min(min(DataIn.SubRange(2,:,:))); 115 % check_der=0; 116 % check_val=0; 117 nb_sites=size(Coord_interp,1); 118 nb_coord=size(Coord_interp,2); 119 %initialise output 120 for ilist=1:length(FieldList) 121 switch FieldList{ilist} 122 case 'velocity' 123 DataOut.U=zeros(nb_sites,1); 124 DataOut.V=zeros(nb_sites,1); 125 otherwise 126 % case{'vort','div','strain'}% case of spatial derivatives 127 DataOut.(FieldList{ilist})=zeros(nb_sites,1); 128 % otherwise % case of a scalar 129 % check_val=1; 130 % DataOut.(FieldList{ilist})=zeros(size(Coord_interp,1)); 131 end 132 end 133 nbval=zeros(nb_sites,1); 134 NbSubDomain=size(DataIn.SubRange,3); 135 %DataIn.Coord_tps=DataIn.Coord_tps(1:end-3,:,:);% suppress the 3 zeros used to fit with the dimensions of variables 136 for isub=1:NbSubDomain 137 nbvec_sub=DataIn.NbSites(isub); 138 check_range=(Coord_interp >=ones(nb_sites,1)*DataIn.SubRange(:,1,isub)' & Coord_interp<=ones(nb_sites,1)*DataIn.SubRange(:,2,isub)'); 139 ind_sel=find(sum(check_range,2)==nb_coord); 140 %rho smoothing parameter 141 % epoints = Coord_interp(ind_sel) ;% coordinates of interpolation sites 142 % ctrs=DataIn.Coord_tps(1:nbvec_sub,:,isub);%(=initial points) ctrs 143 nbval(ind_sel)=nbval(ind_sel)+1;% records the number of values for eacn interpolation point (in case of subdomain overlap) 144 if check_val 145 EM = tps_eval(Coord_interp(ind_sel,:),DataIn.Coord_tps(1:nbvec_sub,:,isub));%kernels for calculating the velocity from tps 'sources' 146 end 147 if check_der 148 [EMDX,EMDY] = tps_eval_dxy(Coord_interp(ind_sel,:),DataIn.Coord_tps(1:nbvec_sub,:,isub));%kernels for calculating the spatial derivatives from tps 'sources' 149 end 85 150 for ilist=1:length(FieldList) 86 151 switch FieldList{ilist} 87 152 case 'velocity' 88 check_val=1; 89 DataOut.U=zeros(nb_sites,1); 90 DataOut.V=zeros(nb_sites,1); 91 case{'vort','div','strain'}% case of spatial derivatives 92 check_der=1; 93 DataOut.(FieldList{ilist})=zeros(nb_sites,1); 94 % otherwise % case of a scalar 95 % check_val=1; 96 % DataOut.(FieldList{ilist})=zeros(size(Coord_interp,1)); 153 ListFields={'U', 'V'}; 154 VarAttributes{1}.Role='vector_x'; 155 VarAttributes{2}.Role='vector_y'; 156 DataOut.U(ind_sel)=DataOut.U(ind_sel)+EM *DataIn.U_tps(1:nbvec_sub+3,isub); 157 DataOut.V(ind_sel)=DataOut.V(ind_sel)+EM *DataIn.V_tps(1:nbvec_sub+3,isub); 158 case 'u' 159 ListFields={'U'}; 160 VarAttributes{1}.Role='scalar'; 161 DataOut.U(ind_sel)=DataOut.U(ind_sel)+EM *DataIn.U_tps(1:nbvec_sub+3,isub); 162 case 'v' 163 ListFields={'V'}; 164 VarAttributes{1}.Role='scalar'; 165 DataOut.V(ind_sel)=DataOut.V(ind_sel)+EM *DataIn.V_tps(1:nbvec_sub+3,isub); 166 case 'norm_vel' 167 ListFields={'norm_vel'}; 168 VarAttributes{1}.Role='scalar'; 169 V=DataOut.U(ind_sel)+EM *DataIn.U_tps(1:nbvec_sub+3,isub); 170 V=DataOut.V(ind_sel)+EM *DataIn.V_tps(1:nbvec_sub+3,isub); 171 DataOut.norm_vel(ind_sel)=sqrt(U.*U+V.*V); 172 case 'vort' 173 ListFields={'vort'}; 174 VarAttributes{1}.Role='scalar'; 175 DataOut.vort(ind_sel)=DataOut.vort(ind_sel)+EMDY *DataIn.U_tps(1:nbvec_sub+3,isub)-EMDX *DataIn.V_tps(1:nbvec_sub+3,isub); 176 case 'div' 177 ListFields={'div'}; 178 VarAttributes{1}.Role='scalar'; 179 DataOut.div(ind_sel)=DataOut.div(ind_sel)+EMDX*DataIn.U_tps(1:nbvec_sub+3,isub)+EMDY *DataIn.V_tps(1:nbvec_sub+3,isub); 180 case 'strain' 181 ListFields={'strain'}; 182 VarAttributes{1}.Role='scalar'; 183 DataOut.strain(ind_sel)=DataOut.strain(ind_sel)+EMDY*DataIn.U_tps(1:nbvec_sub+3,isub)+EMDX *DataIn.V_tps(1:nbvec_sub+3,isub); 97 184 end 98 185 end 99 nbval=zeros(nb_sites,1); 100 NbSubDomain=size(DataIn.SubRange,3); 101 %DataIn.Coord_tps=DataIn.Coord_tps(1:end-3,:,:);% suppress the 3 zeros used to fit with the dimensions of variables 102 for isub=1:NbSubDomain 103 nbvec_sub=DataIn.NbSites(isub); 104 check_range=(Coord_interp >=ones(nb_sites,1)*DataIn.SubRange(:,1,isub)' & Coord_interp<=ones(nb_sites,1)*DataIn.SubRange(:,2,isub)'); 105 ind_sel=find(sum(check_range,2)==nb_coord); 106 %rho smoothing parameter 107 % epoints = Coord_interp(ind_sel) ;% coordinates of interpolation sites 108 % ctrs=DataIn.Coord_tps(1:nbvec_sub,:,isub);%(=initial points) ctrs 109 nbval(ind_sel)=nbval(ind_sel)+1;% records the number of values for eacn interpolation point (in case of subdomain overlap) 110 if check_val 111 EM = tps_eval(Coord_interp(ind_sel,:),DataIn.Coord_tps(1:nbvec_sub,:,isub));%kernels for calculating the velocity from tps 'sources' 112 end 113 if check_der 114 [EMDX,EMDY] = tps_eval_dxy(Coord_interp(ind_sel,:),DataIn.Coord_tps(1:nbvec_sub,:,isub));%kernels for calculating the spatial derivatives from tps 'sources' 115 end 116 for ilist=1:length(FieldList) 117 switch FieldList{ilist} 118 case 'velocity' 119 ListFields={'U', 'V'}; 120 VarAttributes{1}.Role='vector_x'; 121 VarAttributes{2}.Role='vector_y'; 122 DataOut.U(ind_sel)=DataOut.U(ind_sel)+EM *DataIn.U_tps(1:nbvec_sub+3,isub); 123 DataOut.V(ind_sel)=DataOut.V(ind_sel)+EM *DataIn.V_tps(1:nbvec_sub+3,isub); 124 case 'u' 125 ListFields={'U'}; 126 VarAttributes{1}.Role='scalar'; 127 DataOut.U(ind_sel)=DataOut.U(ind_sel)+EM *DataIn.U_tps(1:nbvec_sub+3,isub); 128 case 'v' 129 ListFields={'V'}; 130 VarAttributes{1}.Role='scalar'; 131 DataOut.V(ind_sel)=DataOut.V(ind_sel)+EM *DataIn.V_tps(1:nbvec_sub+3,isub); 132 case 'vort' 133 ListFields={'vort'}; 134 VarAttributes{1}.Role='scalar'; 135 DataOut.vort(ind_sel)=DataOut.vort(ind_sel)+EMDY *DataIn.U_tps(1:nbvec_sub+3,isub)-EMDX *DataIn.V_tps(1:nbvec_sub+3,isub); 136 case 'div' 137 ListFields={'div'}; 138 VarAttributes{1}.Role='scalar'; 139 DataOut.div(ind_sel)=DataOut.div(ind_sel)+EMDX*DataIn.U_tps(1:nbvec_sub+3,isub)+EMDY *DataIn.V_tps(1:nbvec_sub+3,isub); 140 case 'strain' 141 ListFields={'strain'}; 142 VarAttributes{1}.Role='scalar'; 143 DataOut.strain(ind_sel)=DataOut.strain(ind_sel)+EMDY*DataIn.U_tps(1:nbvec_sub+3,isub)+EMDX *DataIn.V_tps(1:nbvec_sub+3,isub); 144 end 145 end 146 DataOut.FF=nbval==0; %put errorflag to 1 for points outside the interpolation rang 147 % DataOut.FF=reshape(DataOut.FF,numel(yI),numel(xI)); 148 nbval(nbval==0)=1; 149 % switch FieldList{1} 150 % case {'velocity','u','v'} 151 % DataOut.U=reshape(DataOut.U./nbval,numel(yI),numel(xI)); 152 % DataOut.V=reshape(DataOut.V./nbval,numel(yI),numel(xI)); 153 % case 'vort' 154 % DataOut.vort=reshape(DataOut.vort,numel(yI),numel(xI)); 155 % case 'div' 156 % DataOut.div=reshape(DataOut.div,numel(yI),numel(xI)); 157 % case 'strain' 158 % DataOut.strain=reshape(DataOut.strain,numel(yI),numel(xI)); 159 % end 160 DataOut.ListVarName=[DataOut.ListVarName ListFields]; 161 for ilist=3:numel(DataOut.ListVarName) 162 DataOut.VarDimName{ilist}={'coord_y','coord_x'}; 163 end 164 DataOut.VarAttribute={[],[]}; 165 DataOut.VarAttribute{3}.Role='errorflag'; 166 DataOut.VarAttribute=[DataOut.VarAttribute VarAttributes]; 167 end 168 else 169 170 %% civx data 171 DataOut=DataIn; 172 for ilist=1:length(FieldList) 173 if ~isempty(FieldList{ilist}) 174 [VarName,Value,Role,units]=feval(FieldList{ilist},DataIn);%calculate field with appropriate function named FieldList{ilist} 175 ListVarName=[ListVarName VarName]; 176 ValueList=[ValueList Value]; 177 RoleList=[RoleList Role]; 178 units_cell=[units_cell units]; 179 end 180 end 181 %erase previous data (except coordinates) 182 for ivar=nbcoord+1:length(DataOut.ListVarName) 183 VarName=DataOut.ListVarName{ivar}; 184 DataOut=rmfield(DataOut,VarName); 185 end 186 DataOut.ListVarName=DataOut.ListVarName(1:nbcoord); 187 if isfield(DataOut,'VarDimName') 188 DataOut.VarDimName=DataOut.VarDimName(1:nbcoord); 189 else 190 errormsg='element .VarDimName missing in input data'; 191 return 192 end 193 DataOut.VarAttribute=DataOut.VarAttribute(1:nbcoord); 194 %append new data 195 DataOut.ListVarName=[DataOut.ListVarName ListVarName]; 196 for ivar=1:length(ListVarName) 197 DataOut.VarDimName{nbcoord+ivar}=DataOut.VarDimName{1}; 198 DataOut.VarAttribute{nbcoord+ivar}.Role=RoleList{ivar}; 199 DataOut.VarAttribute{nbcoord+ivar}.units=units_cell{ivar}; 200 DataOut.(ListVarName{ivar})=ValueList{ivar}; 201 end 202 end 203 end 186 DataOut.FF=nbval==0; %put errorflag to 1 for points outside the interpolation rang 187 nbval(nbval==0)=1; 188 DataOut.ListVarName=[DataOut.ListVarName ListFields]; 189 for ilist=3:numel(DataOut.ListVarName) 190 DataOut.VarDimName{ilist}={'coord_y','coord_x'}; 191 end 192 DataOut.VarAttribute={[],[]}; 193 DataOut.VarAttribute{3}.Role='errorflag'; 194 DataOut.VarAttribute=[DataOut.VarAttribute VarAttributes]; 195 end 196 else 197 198 %% civx data 199 DataOut=DataIn; 200 for ilist=1:length(FieldList) 201 if ~isempty(FieldList{ilist}) 202 [VarName,Value,Role,units]=feval(FieldList{ilist},DataIn);%calculate field with appropriate function named FieldList{ilist} 203 ListVarName=[ListVarName VarName]; 204 ValueList=[ValueList Value]; 205 RoleList=[RoleList Role]; 206 units_cell=[units_cell units]; 207 end 208 end 209 %erase previous data (except coordinates) 210 for ivar=nbcoord+1:length(DataOut.ListVarName) 211 VarName=DataOut.ListVarName{ivar}; 212 DataOut=rmfield(DataOut,VarName); 213 end 214 DataOut.ListVarName=DataOut.ListVarName(1:nbcoord); 215 if isfield(DataOut,'VarDimName') 216 DataOut.VarDimName=DataOut.VarDimName(1:nbcoord); 217 else 218 errormsg='element .VarDimName missing in input data'; 219 return 220 end 221 DataOut.VarAttribute=DataOut.VarAttribute(1:nbcoord); 222 %append new data 223 DataOut.ListVarName=[DataOut.ListVarName ListVarName]; 224 for ivar=1:length(ListVarName) 225 DataOut.VarDimName{nbcoord+ivar}=DataOut.VarDimName{1}; 226 DataOut.VarAttribute{nbcoord+ivar}.Role=RoleList{ivar}; 227 DataOut.VarAttribute{nbcoord+ivar}.units=units_cell{ivar}; 228 DataOut.(ListVarName{ivar})=ValueList{ivar}; 229 end 230 end 231 204 232 205 233 -
trunk/src/check_field_structure.m
r385 r404 4 4 % 5 5 % OUTPUT: 6 % DataOut: structure reproducing the input structure Data, with the additional elements: 7 % with fields: 8 % 9 % .ListDimName: cell listing the names of the array dimensions 10 % .DimValue: array dimension values (Matlab vector with the same length as .ListDimName 11 % .VarDimIndex: cell containing the set of dimension indices (in list .ListDimName) for each variable of .ListVarName 12 % .VarDimName: cell containing a cell of dimension names (in list .ListDimName) for each variable of .ListVarName 6 % DataOut: structure reproducing the input structure Data (TODO: suppress this output) 13 7 % errormsg: error message which is not empty when the input structure does not have the right form 14 8 % … … 22 16 23 17 24 function [ DataOut,errormsg]=check_field_structure(Data)18 function [errormsg,ListDimName,DimValue,VarDimIndex]=check_field_structure(Data) 25 19 DataOut=[]; %default 26 20 errormsg=[]; … … 45 39 return 46 40 end 47 if isfield(Data,'DimValue')48 Data=rmfield(Data,'DimValue');49 end41 % if isfield(Data,'DimValue') 42 % Data=rmfield(Data,'DimValue'); 43 % end 50 44 nbdim=0; 51 Data.ListDimName={};45 ListDimName={}; 52 46 53 47 %% main loop on the list of variables … … 103 97 for idim=1:numel(DimCell) %loop on the coordinates of variable #ivar 104 98 DimName=DimCell{idim}; 105 iprev=find(strcmp(DimName, Data.ListDimName),1);%look for dimension name DimName in the current list99 iprev=find(strcmp(DimName,ListDimName),1);%look for dimension name DimName in the current list 106 100 if isempty(iprev)% append the dimension name to the current list 107 101 nbdim=nbdim+1; … … 110 104 RangeTest(nbdim)=1; %to be updated for a later variable 111 105 end 112 D ata.DimValue(nbdim)=sizvar(idim);113 Data.ListDimName{nbdim}=DimName;106 DimValue(nbdim)=sizvar(idim); 107 ListDimName{nbdim}=DimName; 114 108 DimIndex=[DimIndex nbdim]; 115 109 else % DimName is detected in the current list of dimension names 116 if ~isequal(D ata.DimValue(iprev),sizvar(idim))117 if isequal(D ata.DimValue(iprev),2)&& RangeTest(iprev) % the dimension has been already detected as a range [min max]118 D ata.DimValue(iprev)=sizvar(idim); %update with actual value110 if ~isequal(DimValue(iprev),sizvar(idim)) 111 if isequal(DimValue(iprev),2)&& RangeTest(iprev) % the dimension has been already detected as a range [min max] 112 DimValue(iprev)=sizvar(idim); %update with actual value 119 113 elseif ~testrange 120 114 errormsg=['dimension declaration inconsistent with the size =[' num2str(sizvar) '] for ' VarName]; … … 125 119 end 126 120 end 127 Data.VarDimIndex{ivar}=DimIndex;121 VarDimIndex{ivar}=DimIndex; 128 122 end 129 123 DataOut=Data; -
trunk/src/find_field_indices.m
r399 r404 23 23 % INPUT: 24 24 % Data: structure representing fields, output of check_field_structure 25 % .ListDimName: cell listing the names of the array dimensions 26 % .ListVarName: cell listing the names of the variables 27 % .VarDimIndex: cell containing the set of dimension indices (in list .ListDimName) for each variable of .ListVarName 25 % .ListVarName: cell array listing the names (cahr strings) of the variables 26 % .VarDimName: cell array of cells containing the set of dimension names for each variable of .ListVarName 27 % .VarAttribute: cell array of structures containing the variable attributes: 28 % .VarAttribute{ilist}.key=value, where ilist is the variable 29 % index, key is the name of the attribute, value its value (char string or number) 28 30 % 29 31 % HELP: -
trunk/src/nc2struct.m
r236 r404 13 13 % .VarDimName: list of dimension names for each element of .ListVarName (cell array of string cells) 14 14 % .Var1, .Var2....: variables (Matlab arrays) with names listed in .ListVarName 15 % .ListDimName=list of dimension (added information, not requested for field description)16 % .DimValue= vlalues of dimensions (added information, not requested for field description)15 % ListDimName=list of dimension (added information, not requested for field description) 16 % DimValue= vlalues of dimensions (added information, not requested for field description) 17 17 % var_detect: vector with same length as the cell array ListVarName, = 1 for each detected variable and 0 else. 18 18 % var_detect=[] in the absence of input cell array … … 108 108 try 109 109 if ischar(valuestr) %& length(valuestr)<200 & double(valuestr)<=122 & double(valuestr)>=48 %usual characters 110 % valuestr=regexprep(valuestr,{'\\','\/','\.','\-',' '},{'_','_','_','_','_'})%remove '\','.' or '-' if exists111 110 eval(['Data.' keystr '=''' valuestr ''';']) 112 % elseif isempty(valuestr)113 % eval(['Data.' keystr '=[];'])114 111 elseif isnumeric(valuestr) 115 112 eval(['Data.' keystr '=valuestr;']) … … 207 204 if ~isempty(var_index) 208 205 dim_index=find(flag_used);%list of netcdf dimensions indices corresponding to used dimensions 209 Data.ListDimName=ListDimNameNetcdf(dim_index);210 D ata.DimValue=dim_value(dim_index);206 ListDimName=ListDimNameNetcdf(dim_index); 207 DimValue=dim_value(dim_index); 211 208 end 212 209 -
trunk/src/plot_field.m
r402 r404 109 109 index_1D=[]; 110 110 index_0D=[]; 111 [Data,errormsg]=check_field_structure(Data);111 errormsg=check_field_structure(Data); 112 112 if ~isempty(errormsg) 113 113 msgbox_uvmat('ERROR',['input of plot_field/check_field_structure: ' errormsg]) -
trunk/src/read_civdata.m
r397 r404 49 49 function [Field,VelTypeOut,errormsg]=read_civdata(filename,FieldNames,VelType,CivStage) 50 50 errormsg=''; 51 VelTypeOut=VelType;%default52 51 %% default input 53 52 if ~exist('VelType','var') -
trunk/src/read_civxdata.m
r380 r404 96 96 %% adjust for Djui: 97 97 if isfield(Field,'DjUi') 98 Field.ListVarName{end-3}='DjUi'; 99 Field.VarDimName{end-3}=[Field.VarDimName{end-3} {'nb_coord'} {'nb-coord'}]; 98 100 Field.ListVarName(end-2:end)=[]; 99 Field.ListVarName{end}='DjUi';100 101 Field.VarDimName(end-2:end)=[]; 101 102 Field.VarAttribute(end-2:end)=[]; -
trunk/src/read_field.m
r397 r404 50 50 GUIName=ParamIn.GUIName; 51 51 end 52 test_civx=0;52 CivStage=0; 53 53 if ~strcmp(ParamIn.FieldName,'get_field...')% if get_field is not requested, look for Civx data 54 54 FieldList=calc_field;%list of possible fields for Civx data … … 63 63 InputField=[{ParamOut.FieldName} {ParamOut.ColorVar}]; 64 64 [Field,ParamOut.VelType,errormsg]=read_civdata(ObjectName,InputField,ParamIn.VelType,Data.CivStage); 65 test_civx=Field.CivStage;65 CivStage=Field.CivStage; 66 66 %case of old civx conventions 67 67 elseif ~isempty(Data.absolut_time_T0)&& ~isequal(Data.civ,0) … … 70 70 InputField=[{ParamOut.FieldName} {ParamOut.ColorVar}]; 71 71 [Field,ParamOut.VelType]=read_civxdata(ObjectName,InputField,ParamIn.VelType); 72 test_civx=Field.CivStage;72 CivStage=Field.CivStage; 73 73 ParamOut.CivStage=Field.CivStage; 74 74 % not cvix file, fields will be chosen through the GUI get_field … … 90 90 return 91 91 end 92 test_civx=Field.CivStage;92 CivStage=Field.CivStage; 93 93 ParamOut.CivStage=Field.CivStage; 94 94 end 95 95 end 96 if ~test_civx% read the field names on the interface get_field. 96 ParamOut.FieldList=[{'image'};FieldList;{'get_field...'}]; 97 if CivStage==0% read the field names on the interface get_field. 97 98 hget_field=findobj(allchild(0),'Name',GUIName);%find the get_field... GUI 98 99 if isempty(hget_field)% open the GUI get_field if it is not found … … 140 141 ParamOut.TimeValue=Field.TimeValue; 141 142 end 142 end143 if test_civx144 ParamOut.FieldList=[{'image'};FieldList;{'get_field...'}];145 else146 143 ParamOut.FieldList={'get_field...'}; 147 144 end 148 145 % if CivStage~=0 146 % ParamOut.FieldList=[{'image'};FieldList;{'get_field...'}]; 147 % else 148 % % ParamOut.FieldList={'get_field...'}; 149 % end 149 150 case 'video' 150 151 try -
trunk/src/read_get_field.m
r402 r404 31 31 empty_coord_x=0; 32 32 empty_coord_y=0; 33 empty_coord_z=0; 33 34 %dimname_y={}; 34 35 ListVarName={}; -
trunk/src/struct2nc.m
r382 r404 42 42 return 43 43 end 44 hhh=which('netcdf.create');% look for built-in matlab netcdf library 45 46 %USE OF built-in matlab netcdf library 47 if ~isequal(hhh,'') 48 FilePath=fileparts(flname); 49 if ~strcmp(FilePath,'') && ~exist(FilePath,'dir') 50 errormsg=['directory ' FilePath ' needs to be created']; 51 return 52 end 53 [Data,errormsg]=check_field_structure(Data);%check the validity of the input field structure 54 if ~isempty(errormsg) 55 errormsg=['error in struct2nc:invalid input structure_' errormsg]; 56 return 57 end 58 ListVarName=Data.ListVarName; 59 nc=netcdf.create(flname,'NC_CLOBBER');%,'clobber'); %create the netcdf file with name flname 60 %write global constants 61 if isfield(Data,'ListGlobalAttribute') 62 keys=Data.ListGlobalAttribute; 63 for iattr=1:length(keys) 64 if isfield(Data,keys{iattr}) 65 testvar=0; 66 for ivar=1:length(ListVarName)% eliminate possible global attributes with the same name as a variable 67 if isequal(ListVarName{ivar}, keys{iattr}) 68 testvar=1; 69 break 70 end 44 FilePath=fileparts(flname); 45 if ~strcmp(FilePath,'') && ~exist(FilePath,'dir') 46 errormsg=['directory ' FilePath ' needs to be created']; 47 return 48 end 49 % [Data,errormsg]=check_field_structure(Data);%check the validity of the input field structure 50 [errormsg,ListDimName,DimValue,VarDimIndex]=check_field_structure(Data); 51 if ~isempty(errormsg) 52 errormsg=['error in struct2nc:invalid input structure_' errormsg]; 53 return 54 end 55 ListVarName=Data.ListVarName; 56 nc=netcdf.create(flname,'NC_CLOBBER');%,'clobber'); %create the netcdf file with name flname 57 %write global constants 58 if isfield(Data,'ListGlobalAttribute') 59 keys=Data.ListGlobalAttribute; 60 for iattr=1:length(keys) 61 if isfield(Data,keys{iattr}) 62 testvar=0; 63 for ivar=1:length(ListVarName)% eliminate possible global attributes with the same name as a variable 64 if isequal(ListVarName{ivar}, keys{iattr}) 65 testvar=1; 66 break 71 67 end 72 if ~testvar73 eval(['cte=Data.' keys{iattr} ';'])74 if (ischar(cte) ||isnumeric(cte)) && ~isempty(cte)%&& ~isequal(cte,'')75 %write constant only if it is numeric or char string, and not empty76 netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),keys{iattr},cte)77 end68 end 69 if ~testvar 70 eval(['cte=Data.' keys{iattr} ';']) 71 if (ischar(cte) ||isnumeric(cte)) && ~isempty(cte)%&& ~isequal(cte,'') 72 %write constant only if it is numeric or char string, and not empty 73 netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),keys{iattr},cte) 78 74 end 79 75 end 80 76 end 81 77 end 82 %create dimensions 83 dimid=zeros(1,length(Data.ListDimName)); 84 for idim=1:length(Data.ListDimName) 85 dimid(idim) = netcdf.defDim(nc,Data.ListDimName{idim},Data.DimValue(idim)); 86 end87 VarAttribute={}; %default 88 testattr=0; 89 if isfield(Data,'VarAttribute') 90 VarAttribute=Data.VarAttribute; 91 testattr=1;92 end93 varid=zeros(1,length(Data.ListVarName)); 94 for ivar=1:length(ListVarName) 95 varid(ivar)=netcdf.defVar(nc,ListVarName{ivar},'nc_double',dimid(Data.VarDimIndex{ivar}));%define variable 96 end97 %write variable attributes 98 if testattr99 for ivar=1:min(numel(VarAttribute),numel(ListVarName)) 100 if isstruct(VarAttribute{ivar})101 attr_names=fields(VarAttribute{ivar});102 for iattr=1:length(attr_names)103 eval(['attr_val=VarAttribute{ivar}.' attr_names{iattr} ';']);104 if ~isempty(attr_names{iattr})&& ~isempty(attr_val)105 netcdf.putAtt(nc,varid(ivar),attr_names{iattr},attr_val);106 end78 end 79 %create dimensions 80 dimid=zeros(1,length(ListDimName)); 81 for idim=1:length(ListDimName) 82 dimid(idim) = netcdf.defDim(nc,ListDimName{idim},DimValue(idim)); 83 end 84 VarAttribute={}; %default 85 testattr=0; 86 if isfield(Data,'VarAttribute') 87 VarAttribute=Data.VarAttribute; 88 testattr=1; 89 end 90 varid=zeros(1,length(Data.ListVarName)); 91 for ivar=1:length(ListVarName) 92 varid(ivar)=netcdf.defVar(nc,ListVarName{ivar},'nc_double',dimid(VarDimIndex{ivar}));%define variable 93 end 94 %write variable attributes 95 if testattr 96 for ivar=1:min(numel(VarAttribute),numel(ListVarName)) 97 if isstruct(VarAttribute{ivar}) 98 attr_names=fields(VarAttribute{ivar}); 99 for iattr=1:length(attr_names) 100 eval(['attr_val=VarAttribute{ivar}.' attr_names{iattr} ';']); 101 if ~isempty(attr_names{iattr})&& ~isempty(attr_val) 102 netcdf.putAtt(nc,varid(ivar),attr_names{iattr},attr_val); 107 103 end 108 104 end 109 105 end 110 106 end 111 netcdf.endDef(nc); %put in data mode 112 for ivar=1:length(ListVarName) 113 if isfield(Data,ListVarName{ivar}) 114 VarVal=Data.(ListVarName{ivar}); 115 %varval=values of the current variable 116 VarDimIndex=Data.VarDimIndex{ivar}; %indices of the variable dimensions in the list of dimensions 117 VarDimName=Data.VarDimName{ivar}; 118 if ischar(VarDimName) 119 VarDimName={VarDimName}; 120 end 121 siz=size(VarVal); 122 testrange=(numel(VarDimName)==1 && strcmp(VarDimName{1},ListVarName{ivar}) && numel(VarVal)==2);% case of a coordinate defined on a regular mesh by the first and last values. 123 testline=isequal(length(siz),2) && isequal(siz(1),1)&& isequal(siz(2), Data.DimValue(VarDimIndex));%matlab vector 124 testcolumn=isequal(length(siz),2) && isequal(siz(1), Data.DimValue(VarDimIndex))&& isequal(siz(2),1);%matlab column vector 125 % if ~testrange && ~testline && ~testcolumn && ~isequal(siz,Data.DimValue(VarDimIndex)) 107 end 108 netcdf.endDef(nc); %put in data mode 109 for ivar=1:length(ListVarName) 110 if isfield(Data,ListVarName{ivar}) 111 VarVal=Data.(ListVarName{ivar}); 112 %varval=values of the current variable 113 % VarDimIndex=Data.VarDimIndex{ivar}; %indices of the variable dimensions in the list of dimensions 114 VarDimName=Data.VarDimName{ivar}; 115 if ischar(VarDimName) 116 VarDimName={VarDimName}; 117 end 118 siz=size(VarVal); 119 testrange=(numel(VarDimName)==1 && strcmp(VarDimName{1},ListVarName{ivar}) && numel(VarVal)==2);% case of a coordinate defined on a regular mesh by the first and last values. 120 testline=isequal(length(siz),2) && isequal(siz(1),1)&& isequal(siz(2), DimValue(VarDimIndex{ivar}));%matlab vector 121 testcolumn=isequal(length(siz),2) && isequal(siz(1), DimValue(VarDimIndex{ivar}))&& isequal(siz(2),1);%matlab column vector 122 % if ~testrange && ~testline && ~testcolumn && ~isequal(siz,DimValue(VarDimIndex)) 126 123 % errormsg=['wrong dimensions declared for ' ListVarName{ivar} ' in struct2nc.m']; 127 124 % break 128 125 % end 129 if testline || testrange 130 if testrange 131 VarVal=linspace(VarVal(1),VarVal(2),Data.DimValue(VarDimIndex));% restitute the whole array of coordinate values 132 end 133 netcdf.putVar(nc,varid(ivar), double(VarVal')); 134 else 135 netcdf.putVar(nc,varid(ivar), double(VarVal)); 136 end 137 end 126 if testline || testrange 127 if testrange 128 VarVal=linspace(VarVal(1),VarVal(2),DimValue(VarDimIndex{ivar}));% restitute the whole array of coordinate values 129 end 130 netcdf.putVar(nc,varid(ivar), double(VarVal')); 131 else 132 netcdf.putVar(nc,varid(ivar), double(VarVal)); 133 end 138 134 end 139 netcdf.close(nc)140 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%141 %OLD netcdf toolbox142 else143 errormsg=struct2nc_toolbox(flname,Data);144 135 end 136 netcdf.close(nc) 145 137 138 -
trunk/src/uvmat.m
r403 r404 1989 1989 if ~isempty(filename) 1990 1990 ObjectName=filename; 1991 FieldName=[];%default 1992 VelType=[];%default 1993 % FileExt=get(handles.FileExt,'String'); 1994 FileType=UvData.FileType{1}; 1995 switch FileType 1996 % if strcmp(Ext,'.nc')||strcmp(Ext,'.cdf') 1991 FieldName='';%default 1992 VelType='';%default 1993 % FileType=UvData.FileType{1}; 1994 switch UvData.FileType{1} 1997 1995 case {'civx','civdata','netcdf'}; 1998 1996 list_fields=get(handles.Fields,'String');% list menu fields 1999 index_fields=get(handles.Fields,'Value');% selected string index2000 FieldName= list_fields{ index_fields}; % selected field1997 % index_fields=get(handles.Fields,'Value');% selected string index 1998 FieldName= list_fields{get(handles.Fields,'Value')}; % selected field 2001 1999 if ~strcmp(FieldName,'get_field...') 2002 2000 if get(handles.FixVelType,'Value') 2003 2001 VelTypeList=get(handles.VelType,'String'); 2004 2002 VelType=VelTypeList{get(handles.VelType,'Value')}; 2005 % VelType=setfield(handles);% read the velocity type.2006 2003 end 2007 2004 end … … 2029 2026 ParamIn.VelType=VelType; 2030 2027 ParamIn.GUIName='get_field'; 2031 [Field{1},ParamOut,errormsg] = read_field(ObjectName, FileType,ParamIn,num_i1);2028 [Field{1},ParamOut,errormsg] = read_field(ObjectName,UvData.FileType{1},ParamIn,num_i1); 2032 2029 if ~isempty(errormsg) 2033 2030 errormsg=['error in reading ' filename ': ' errormsg]; … … 2056 2053 end 2057 2054 Name=filename_1; 2058 FileType_1=UvData.FileType{2}; 2059 switch FileType_1 2060 % if strcmp(Ext,'.nc')||strcmp(Ext,'.cdf') 2055 % FileType_1=UvData.FileType{2}; 2056 switch UvData.FileType{2} 2061 2057 case {'civx','civdata','netcdf'}; 2062 2058 list_fields=get(handles.Fields_1,'String');% list menu fields … … 2066 2062 VelTypeList=get(handles.VelType_1,'String'); 2067 2063 VelType_1=VelTypeList{get(handles.VelType_1,'Value')};% read the velocity type. 2068 % VelType_1=setfield(handles);% read the velocity type.2069 2064 end 2070 2065 end … … 2102 2097 ParamIn.VelType=VelType_1; 2103 2098 ParamIn.GUIName='get_field_1'; 2104 [Field{2},ParamOut_1,errormsg] = read_field(Name, FileType_1,ParamIn,num_i1);2099 [Field{2},ParamOut_1,errormsg] = read_field(Name,UvData.FileType{2},ParamIn,num_i1); 2105 2100 if ~isempty(errormsg) 2106 2101 errormsg=['error in reading ' FieldName_1 ' in ' filename_1 ': ' errormsg]; … … 2124 2119 test_veltype=0; 2125 2120 % if ~isequal(FileType,'netcdf')|| isequal(FieldName,'get_field...') 2126 if (strcmp( FileType,'civx')||strcmp(FileType,'civdata'))&& ~strcmp(FieldName,'get_field...')2121 if (strcmp(UvData.FileType{1},'civx')||strcmp(UvData.FileType{1},'civdata'))&& ~strcmp(FieldName,'get_field...') 2127 2122 test_veltype=1; 2128 2123 set(handles.VelType,'Visible','on') 2129 2124 set(handles.VelType_1,'Visible','on') 2130 2125 set(handles.FixVelType,'Visible','on') 2131 menu=set_veltype_display(ParamOut.CivStage, FileType);2126 menu=set_veltype_display(ParamOut.CivStage,UvData.FileType{1}); 2132 2127 index_menu=strcmp(ParamOut.VelType,menu);%look for VelType in the menu 2133 2128 index_val=find(index_menu,1); … … 2154 2149 set(handles.Fields_1,'String',[{''};ParamOut.FieldList]); %update the field menu 2155 2150 else 2156 if (~strcmp( FileType_1,'netcdf')&&~strcmp(FileType_1,'civdata')&&~strcmp(FileType_1,'civx'))|| isequal(FieldName_1,'get_field...')2151 if (~strcmp(UvData.FileType{2},'netcdf')&&~strcmp(UvData.FileType{2},'civdata')&&~strcmp(UvData.FileType{2},'civx'))|| isequal(FieldName_1,'get_field...') 2157 2152 set(handles.VelType_1,'Visible','off') 2158 2153 else … … 2228 2223 end 2229 2224 %% update tps in phys coordinates if needed 2230 if (strcmp(VelType,'filter1')||strcmp(VelType,'filter2'))&& strcmp( FileType,'civdata')&&isfield(Field{1},'U')&& isfield(Field{1},'V')2225 if (strcmp(VelType,'filter1')||strcmp(VelType,'filter2'))&& strcmp(UvData.FileType{1},'civdata')&&isfield(Field{1},'U')&& isfield(Field{1},'V') 2231 2226 Field{1}.X=Field{1}.X(Field{1}.FF==0); 2232 2227 Field{1}.Y=Field{1}.Y(Field{1}.FF==0); … … 2235 2230 [Field{1}.SubRange,Field{1}.NbSites,Field{1}.Coord_tps,Field{1}.U_tps,Field{1}.V_tps]=filter_tps([Field{1}.X Field{1}.Y],Field{1}.U,Field{1}.V,[],Field{1}.Patch1_SubDomain,0); 2236 2231 end 2237 if numel(Field)==2 && ~test_keepdata_1 && isequal( FileType_1(1:3),'civ') && ~isequal(ParamOut_1.FieldName,'get_field...')%&&~isempty(FieldName_1)2232 if numel(Field)==2 && ~test_keepdata_1 && isequal(UvData.FileType{2}(1:3),'civ') && ~isequal(ParamOut_1.FieldName,'get_field...')%&&~isempty(FieldName_1) 2238 2233 %update tps in phys coordinates if needed 2239 if (strcmp(VelType_1,'filter1')||strcmp(VelType_1,'filter2'))&& strcmp( FileType_1,'civdata')&&isfield(Field{2},'U')&& isfield(Field{2},'V')2234 if (strcmp(VelType_1,'filter1')||strcmp(VelType_1,'filter2'))&& strcmp(UvData.FileType{2},'civdata')&&isfield(Field{2},'U')&& isfield(Field{2},'V') 2240 2235 Field{2}.X=Field{2}.X(Field{2}.FF==0); 2241 2236 Field{2}.Y=Field{1}.Y(Field{2}.FF==0); … … 2256 2251 2257 2252 %% combine the two input fields (e.g. substract velocity fields) 2253 Field{1}.FieldList=[{ParamOut.FieldName} {ParamOut.ColorVar}]; 2258 2254 if numel(Field)==2 2255 Field{2}.FieldList=[{ParamOut_1.FieldName} {ParamOut_1.ColorVar}]; 2259 2256 [UvData.Field,errormsg]=sub_field(Field{1},Field{2}); 2260 2257 else … … 2265 2262 return 2266 2263 end 2267 UvData.Field.FieldList={FieldName}; % TODO: to generalise, used for proj_field with tps interpolation 2264 %UvData.Field.FieldList={FieldName}; % TODO: to generalise, used for proj_field with tps interpolation 2265 2268 2266 2269 2267 %% get bounds and mesh (needed for mouse action and to open set_object) 2270 2268 test_x=0; 2271 2269 test_z=0;% test for unstructured z coordinate 2272 [ UvData.Field,errormsg]=check_field_structure(UvData.Field);2270 [errormsg,ListDimName,DimValue,VarDimIndex]=check_field_structure(UvData.Field); 2273 2271 if ~isempty(errormsg) 2274 2272 errormsg=['error in uvmat/refresh_field/check_field_structure: ' errormsg]; … … 2336 2334 else 2337 2335 VarIndex=CellVarIndex{imax}; % list of variable indices 2338 DimIndex= UvData.Field.VarDimIndex{VarIndex(1)}; %list of dim indices for the variable2339 nbpoints_x= UvData.Field.DimValue(DimIndex(NbDim));2336 DimIndex=VarDimIndex{VarIndex(1)}; %list of dim indices for the variable 2337 nbpoints_x=DimValue(DimIndex(NbDim)); 2340 2338 DX=(XMax-XMin)/(nbpoints_x-1); 2341 2339 if NbDim >1 2342 nbpoints_y= UvData.Field.DimValue(DimIndex(NbDim-1));2340 nbpoints_y=DimValue(DimIndex(NbDim-1)); 2343 2341 DY=(YMax-YMin)/(nbpoints_y-1); 2344 2342 end 2345 2343 if NbDim==3 2346 nbpoints_z= UvData.Field.DimValue(DimIndex(1));2344 nbpoints_z=DimValue(DimIndex(1)); 2347 2345 DZ=(ZMax-ZMin)/(nbpoints_z-1); 2348 2346 UvData.Field.Mesh=(DX*DY*DZ)^(1/3); … … 2352 2350 UvData.Field.Mesh=DX;%sqrt(DX*DY); 2353 2351 end 2352 end 2353 % adjust the mesh to a value 1, 2 , 5 *10^n 2354 ord=10^(floor(log10(UvData.Field.Mesh)));%order of magnitude 2355 if UvData.Field.Mesh/ord>=5 2356 UvData.Field.Mesh=5*ord; 2357 elseif UvData.Field.Mesh/ord>=2 2358 UvData.Field.Mesh=2*ord; 2359 else 2360 UvData.Field.Mesh=ord; 2354 2361 end 2355 2362 end … … 2362 2369 ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider 2363 2370 if ~isempty(hset_object) %if set_object is detected 2364 % hhset_object=guidata(hset_object); 2365 % % ZBounds_old(1)=get(hhset_object.z_slider,'Min'); 2366 % % ZBounds_old(2)=get(hhset_object.z_slider,'Max'); 2367 % % if isequal(ZBounds_old,ZBounds) 2368 % test_set_object=0;% do not refresh the GUI set_object 2369 % else 2370 delete(hset_object);% delete the GUI set_object if it does not fit 2371 % end 2371 delete(hset_object);% delete the GUI set_object if it does not fit 2372 2372 end 2373 2373 if test_set_object% reinitiate the GUI set_object … … 2380 2380 UvData.Object{1}.Coord(1,3)=(UvData.Field.ZMin+UvData.Field.ZMax)/2;%section at a middle plane chosen 2381 2381 UvData.Object{1}.Angle=[0 0 0]; 2382 % UvData.Object{1}.Theta=0;2383 % UvData.Object{1}.Psi=0;2384 2382 UvData.Object{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR 2385 % PlotHandles=get_plot_handles(handles);2386 2383 UvData.Object{1}.Name='1-PLANE'; 2387 2384 UvData.Object{1}.enable_plot=1; … … 2460 2457 PlotParam{1}.Vectors.ListColorCode= {'rgb'}; 2461 2458 end 2462 keeplim(1)=get(handles.CheckFixLimits,'Value');% test for fixed graph limits2459 %keeplim(1)=get(handles.CheckFixLimits,'Value');% test for fixed graph limits 2463 2460 PosColorbar{1}=UvData.OpenParam.PosColorbar;%prescribe the colorbar position on the uvmat interface 2464 2461 … … 2471 2468 %PlotParam{2}=read_plot_param(plot_handles{2});%read plotting parameters on the viewinterface 2472 2469 PlotParam{2}=read_GUI(handles.uvmat);%read plotting parameters on the uvmat interface 2473 keeplim(2)=get(plot_handles{2}.CheckFixLimits,'Value');2470 % keeplim(2)=get(plot_handles{2}.CheckFixLimits,'Value'); 2474 2471 PosColorbar{2}='*'; %TODO: deal with colorbar position on view_field 2475 2472 end … … 2479 2476 for imap=1:numel(IndexObj) 2480 2477 iobj=IndexObj(imap); 2481 % if iobj==1 && ~isfield(UvData.Object{iobj},'Type')% case with no projection (only for the first empty object) 2482 % ord=10^(floor(log10(UvData.Field.Mesh)));%order of magnitude 2483 % if UvData.Field.Mesh/ord>=5 2484 % mesh=5*ord; 2485 % elseif UvData.Field.Mesh/ord>=2 2486 % mesh=2*ord; 2487 % else 2488 % mesh=ord; 2489 % end 2490 % coord_x=UvData.Field.XMin:mesh:UvData.Field.XMax; 2491 % coord_y=UvData.Field.YMin:mesh:UvData.Field.YMax; 2492 % [XI,YI]=meshgrid(coord_x,coord_y); 2493 % XI=reshape(XI,[],1); 2494 % YI=reshape(YI,[],1); 2495 % [ObjectData,errormsg]=calc_field({FieldName},UvData.Field,[XI YI]); 2496 % else 2478 if iobj==1 && ~isfield(UvData.Object{iobj},'Type')% case with no projection (only for the first empty object) 2479 [ObjectData,errormsg]=calc_field(UvData.Field.FieldList,UvData.Field); 2480 else 2497 2481 [ObjectData,errormsg]=proj_field(UvData.Field,UvData.Object{iobj});% project field on the object 2498 %end2482 end 2499 2483 if ~isempty(errormsg) 2500 2484 return … … 2539 2523 end 2540 2524 ObjectData.ListVarName(ind_off)=[]; 2541 ObjectData.VarDimIndex(ind_off)=[];2525 VarDimIndex(ind_off)=[]; 2542 2526 ind_off=[]; 2543 for ilist=1:length( ObjectData.ListDimName)2544 if isequal( ObjectData.ListDimName{ilist},'MaskX') || isequal(ObjectData.ListDimName{ilist},'MaskY')2527 for ilist=1:length(ListDimName) 2528 if isequal(ListDimName{ilist},'MaskX') || isequal(ListDimName{ilist},'MaskY') 2545 2529 ind_off=[ind_off ilist]; 2546 2530 end 2547 2531 end 2548 ObjectData.ListDimName(ind_off)=[];2549 ObjectData.DimValue(ind_off)=[];2532 ListDimName(ind_off)=[]; 2533 DimValue(ind_off)=[]; 2550 2534 end 2551 2535 end 2552 2536 if ~isempty(ObjectData) 2537 2553 2538 PlotType='none'; %default 2554 2539 if imap==2 && isempty(view_field_handle) … … 3237 3222 data.CoordType=UvData.CoordType; 3238 3223 end 3239 if isfield(UvData ,'Mesh')&~isempty(UvData.Mesh)3240 data.Range Y=UvData.Mesh;3241 data.Range X=UvData.Mesh;3242 data.DX=UvData. Mesh;3243 data.DY=UvData. Mesh;3224 if isfield(UvData.Field,'Mesh')&~isempty(UvData.Field.Mesh) 3225 data.RangeX=[UvData.Field.XMin UvData.Field.XMax]; 3226 data.RangeY=[UvData.Field.YMin UvData.Field.YMax]; 3227 data.DX=UvData.Field.Mesh; 3228 data.DY=UvData.Field.Mesh; 3244 3229 elseif isfield(UvData.Field,'AX')&isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')%only image 3245 3230 np=size(UvData.Field.A); … … 4328 4313 if isfield(UvData,'Field') 4329 4314 Field=UvData.Field; 4330 if isfield(Field,'Mesh')&&~isempty(Field.Mesh) 4331 ord=10^(floor(log10(Field.Mesh)));%order of magnitude 4332 if Field.Mesh/ord>=5 4333 mesh=5*ord; 4334 elseif Field.Mesh/ord>=2 4335 mesh=2*ord; 4336 else 4337 mesh=ord; 4338 end 4339 data.RangeX=mesh; 4340 data.RangeY=mesh; 4341 data.DX=mesh; 4342 data.DY=mesh; 4343 elseif isfield(Field,'AX')&& isfield(Field,'AY')&& isfield(Field,'A')%only image 4344 np=size(Field.A); 4345 meshx=(Field.AX(end)-Field.AX(1))/np(2); 4346 meshy=abs(Field.AY(end)-Field.AY(1))/np(1); 4347 data.RangeY=max(meshx,meshy); 4348 data.RangeX=max(meshx,meshy); 4349 data.DX=max(meshx,meshy); 4315 if isfield(UvData.Field,'Mesh')&&~isempty(UvData.Field.Mesh) 4316 data.RangeX=[UvData.Field.XMin UvData.Field.XMax]; 4317 data.RangeY=[UvData.Field.YMin UvData.Field.YMax]; 4318 data.DX=UvData.Field.Mesh; 4319 data.DY=UvData.Field.Mesh; 4320 % elseif isfield(Field,'AX')&& isfield(Field,'AY')&& isfield(Field,'A')%only image 4321 % np=size(Field.A); 4322 % meshx=(Field.AX(end)-Field.AX(1))/np(2); 4323 % meshy=abs(Field.AY(end)-Field.AY(1))/np(1); 4324 % data.RangeY=max(meshx,meshy); 4325 % data.RangeX=max(meshx,meshy); 4326 % data.DX=max(meshx,meshy); 4350 4327 end 4351 4328 if isfield(Field,'NbDim')&& isequal(Field.NbDim,3) … … 4360 4337 end 4361 4338 hset_object=findobj(allchild(0),'tag','set_object'); 4362 IndexObj=get(handles.ListObject,'Value') 4339 IndexObj=get(handles.ListObject,'Value'); 4363 4340 if ~isempty(hset_object) 4364 4341 delete(hset_object)% delete existing version of set_object
Note: See TracChangeset
for help on using the changeset viewer.