Changeset 675
- Timestamp:
- Aug 27, 2013, 11:25:21 PM (11 years ago)
- Location:
- trunk/src
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/calc_field_interp.m
r667 r675 50 50 switch r.Operator 51 51 case 'curl'% case of CivX data format 52 if ~isfield(Data,'DjUi'), errormsg='field DjUi needed to get curl through linear interp: use ProjMode=interp_tps'; return; end 52 53 UName{ilist}='vort'; 53 54 Data.vort=Data.DjUi(:,1,2)-Data.DjUi(:,2,1); 54 55 case 'div' 56 if ~isfield(Data,'DjUi'), errormsg='field DjUi needed to get div through linear interp: use ProjMode=interp_tps'; return; end 55 57 UName{ilist}='div'; 56 58 Data.div=Data.DjUi(:,1,1)+Data.DjUi(:,2,2); 57 59 case 'strain' 60 if ~isfield(Data,'DjUi'), errormsg='field DjUi needed to get strain through linear interp: use ProjMode=interp_tps'; return; end 58 61 UName{ilist}='strain'; 59 62 Data.strain=Data.DjUi(:,1,2)+Data.DjUi(:,2,1); 60 63 end 61 64 InputVarList=[InputVarList UName{ilist}]; %the variable is added to the list if it is not already in the list 62 else 65 else % case 'norm' for instance 63 66 UName{ilist}=r.UName; 64 67 VName{ilist}=r.VName; -
trunk/src/calc_field_tps.m
r651 r675 6 6 % OUTPUT: 7 7 % DataOut: structure representing the output fields 8 % VarAttribute: cell array of structures coontaining the variable attributes 9 % errormsg: error msg , = '' by default 8 10 % 9 11 % INPUT: … … 14 16 % NbCentre: nbre of tps centres for each subdomain, of dimension nb_subdomain 15 17 % SubRange: coordinate range for each subdomain, of dimensions [nb_coord,2,nb_subdomain] 16 % FieldVar: cell array of list of variables needed to calculate the requested fields 18 % FieldVar: array representing the input fields as tps weights with dimension (nbvec_sub+3,NbSubDomain,nb_dim) 19 % nbvec_sub= max nbre of vectors in a subdomain 20 % NbSubDomain =nbre of subdomains 21 % nb_dim: nbre of dimensions for vector components (x-> 1, y->2) 17 22 % FieldName: cell array representing the list of operations (eg div(U,V), rot(U,V)) 18 23 % Coord_interp: coordinates of sites on which the fields need to be calculated of dimensions … … 49 54 check_grid=0; 50 55 check_der=0; 56 check_vec=0; 57 check_remove=false(size(FieldName)); 58 VarAttribute={}; 51 59 for ilist=1:length(FieldName) 52 FieldNameType=regexprep(FieldName{ilist},'(.+',''); 60 FieldNameType=regexprep(FieldName{ilist},'(.+','');% detect the char string before the parenthesis 61 VarAttributeNew={}; 53 62 switch FieldNameType 54 63 case 'vec' … … 56 65 DataOut.U=zeros(nb_sites,1); 57 66 DataOut.V=zeros(nb_sites,1); 58 VarAttribute{1}.Role='vector_x'; 59 VarAttribute{2}.Role='vector_y'; 60 case {'U','V','norm'} 67 VarAttributeNew{1}.Role='vector_x'; 68 VarAttributeNew{2}.Role='vector_y'; 69 check_vec=1; 70 case {'U','V'} 71 if check_vec% no new data needed 72 check_remove(ilist)=1; 73 else 61 74 check_grid=1; 62 75 DataOut.(FieldNameType)=zeros(nb_sites,1); 63 VarAttribute{1}.Role='scalar'; 76 VarAttributeNew{1}.Role='scalar'; 77 end 78 case 'norm' 79 check_grid=1; 80 DataOut.(FieldNameType)=zeros(nb_sites,1); 81 VarAttributeNew{1}.Role='scalar'; 64 82 case {'curl','div','strain'} 65 83 check_der=1; 66 84 DataOut.(FieldNameType)=zeros(nb_sites,1); 67 VarAttribute {1}.Role='scalar';85 VarAttributeNew{1}.Role='scalar'; 68 86 end 87 VarAttribute=[VarAttribute VarAttributeNew]; 69 88 end 70 89 Attr_FF.Role='errorflag'; 71 90 VarAttribute=[VarAttribute {Attr_FF}]; 91 FieldName(check_remove)=[]; 72 92 73 93 %% loop on subdomains … … 83 103 [EMDX,EMDY] = tps_eval_dxy(Coord_interp(ind_sel,:),Coord_tps(1:nbvec_sub,:,isub));%kernels for calculating the spatial derivatives from tps 'sources' 84 104 end 85 ListVar={};105 % ListVar={}; 86 106 for ilist=1:length(FieldName) 87 var_count=numel(ListVar);107 % var_count=numel(ListVar); 88 108 switch FieldName{ilist} 89 109 case 'vec(U,V)' 90 ListVar=[ListVar {'U', 'V'}];91 VarAttribute{var_count+1}.Role='vector_x';92 VarAttribute{var_count+2}.Role='vector_y';110 % ListVar=[ListVar {'U', 'V'}]; 111 % VarAttribute{var_count+1}.Role='vector_x'; 112 % VarAttribute{var_count+2}.Role='vector_y'; 93 113 DataOut.U(ind_sel)=DataOut.U(ind_sel)+EM *FieldVar(1:nbvec_sub+3,isub,1); 94 114 DataOut.V(ind_sel)=DataOut.V(ind_sel)+EM *FieldVar(1:nbvec_sub+3,isub,2); 95 115 case 'U' 96 ListVar=[ListVar {'U'}];97 VarAttribute{var_count+1}.Role='scalar';116 % ListVar=[ListVar {'U'}]; 117 % VarAttribute{var_count+1}.Role='scalar'; 98 118 DataOut.U(ind_sel)=DataOut.U(ind_sel)+EM *FieldVar(1:nbvec_sub+3,isub,1); 99 119 case 'V' 100 ListVar=[ListVar {'V'}];101 VarAttribute{var_count+1}.Role='scalar';120 % ListVar=[ListVar {'V'}]; 121 % VarAttribute{var_count+1}.Role='scalar'; 102 122 DataOut.V(ind_sel)=DataOut.V(ind_sel)+EM *FieldVar(1:nbvec_sub+3,isub,2); 103 123 case 'norm(U,V)' 104 ListVar=[ListVar {'norm'}];105 VarAttribute{var_count+1}.Role='scalar';124 % ListVar=[ListVar {'norm'}]; 125 % VarAttribute{var_count+1}.Role='scalar'; 106 126 U=DataOut.U(ind_sel)+EM *FieldVar(1:nbvec_sub+3,isub,1); 107 127 V=DataOut.V(ind_sel)+EM *FieldVar(1:nbvec_sub+3,isub,2); 108 128 DataOut.norm(ind_sel)=sqrt(U.*U+V.*V); 109 129 case 'curl(U,V)' 110 ListVar=[ListVar {'curl'}];111 VarAttribute{var_count+1}.Role='scalar';130 % ListVar=[ListVar {'curl'}]; 131 % VarAttribute{var_count+1}.Role='scalar'; 112 132 DataOut.curl(ind_sel)=DataOut.curl(ind_sel)-EMDY *FieldVar(1:nbvec_sub+3,isub,1)+EMDX *FieldVar(1:nbvec_sub+3,isub,2); 113 133 case 'div(U,V)' 114 ListVar=[ListVar {'div'}];115 VarAttribute{var_count+1}.Role='scalar';134 % ListVar=[ListVar {'div'}]; 135 % VarAttribute{var_count+1}.Role='scalar'; 116 136 DataOut.div(ind_sel)=DataOut.div(ind_sel)+EMDX*FieldVar(1:nbvec_sub+3,isub,1)+EMDY *FieldVar(1:nbvec_sub+3,isub,2); 117 137 case 'strain(U,V)' 118 ListVar=[ListVar {'strain'}];119 VarAttribute{var_count+1}.Role='scalar';138 % ListVar=[ListVar {'strain'}]; 139 % VarAttribute{var_count+1}.Role='scalar'; 120 140 DataOut.strain(ind_sel)=DataOut.strain(ind_sel)+EMDY*FieldVar(1:nbvec_sub+3,isub,1)+EMDX *FieldVar(1:nbvec_sub+3,isub,2); 121 141 end -
trunk/src/find_field_cells.m
r674 r675 176 176 CellInfo{icell}.NbCentres_tps= ivar_remain(ivardim);% nbre of sites for each tps subdomain 177 177 check_cell(ivar_remain(ivardim))=1;% mark the variable as selected 178 elseif strcmp(VarDimName{ivardim}{1},DimCell{2}) && strcmp(VarDimName{ivardim}{3},DimCell{3})178 elseif strcmp(VarDimName{ivardim}{1},DimCell{2}) && numel(VarDimName{ivardim})>=3 && strcmp(VarDimName{ivardim}{3},DimCell{3}) 179 179 CellInfo{icell}.SubRange_tps=ivar_remain(ivardim);% subrange definiton for tps 180 180 check_cell(ivar_remain(ivardim))=1;% mark the variable as selected … … 247 247 end 248 248 249 % group the remaining variables in cells sharing the same coordinate variables249 %% group the remaining variables in cells sharing the same coordinate variables 250 250 NewCellInfo={}; 251 251 NewCellDimIndex={}; -
trunk/src/get_field.m
r674 r675 727 727 end 728 728 end 729 var_component=find(test_component);% list of variable indices elligible as unstructured coordi antes729 var_component=find(test_component);% list of variable indices elligible as unstructured coordinates 730 730 var_coord=find(test_coord);% % list of variable indices elligible as structured coordinates 731 731 ListCoord=Field.Display.ListVarName([var_component var_coord]); … … 755 755 end 756 756 end 757 if isempty( coord_val)757 if isempty(find(coord_val)) 758 758 coord_val=var_coord;% case of dimension coordinates 759 759 end 760 760 if numel(find(coord_val))<2 761 coord_val=[numel(var_component)+2 numel(var_component)+1]; 761 %coord_val=[numel(var_component)+2 numel(var_component)+1]; 762 coord_val=[1 2]; 762 763 end 763 764 set(handles.Coord_x,'Value',coord_val(1)) -
trunk/src/get_file_type.m
r664 r675 17 17 % fileinput: name, including path, of the file to analyse 18 18 function [FileType,FileInfo,VideoObject]=get_file_type(fileinput) 19 FileType='txt';%default, text file 19 20 20 FileInfo=[]; 21 21 VideoObject=[]; 22 if exist(fileinput,'file') 23 FileType='txt';%default, text file 24 else 25 FileType=''; 26 return 27 end 22 28 [tild,tild,FileExt]=fileparts(fileinput); 23 29 -
trunk/src/imadoc2struct.m
r611 r675 47 47 %% reading timing 48 48 if isfield(s,'Camera') 49 if isfield(s.Camera,'TimeUnit') 50 s.TimeUnit=s.Camera.TimeUnit; 51 end 49 52 Timing=s.Camera.BurstTiming; 50 53 if ~iscell(Timing) … … 105 108 end 106 109 107 % try108 % t=xmltree(ImaDoc);109 % catch ME110 % errormsg={['error reading ' ImaDoc ': ']; ME.message};111 % display(errormsg);112 % return113 % end114 % uid_root=find(t,'/ImaDoc');115 % if isempty(uid_root), return; end;%not an ImaDoc .xml file116 117 % %% Heading118 % uid_Heading=find(t,'/ImaDoc/Heading');119 % if ~isempty(uid_Heading),120 % uid_Campaign=find(t,'/ImaDoc/Heading/Campaign');121 % uid_Exp=find(t,'/ImaDoc/Heading/Experiment');122 % uid_Device=find(t,'/ImaDoc/Heading/Device');123 % uid_Record=find(t,'/ImaDoc/Heading/Record');124 % uid_FirstImage=find(t,'/ImaDoc/Heading/ImageName');125 % s.Heading.Campaign=get(t,children(t,uid_Campaign),'value');126 % s.Heading.Experiment=get(t,children(t,uid_Exp),'value');127 % s.Heading.Device=get(t,children(t,uid_Device),'value');128 % if ~isempty(uid_Record)129 % s.Heading.Record=get(t,children(t,uid_Record),'value');130 % end131 % s.Heading.ImageName=get(t,children(t,uid_FirstImage),'value');132 % end133 134 %% Camera and timing135 % if strcmp(option,'*') || strcmp(option,'Camera')136 % uid_Camera=find(t,'/ImaDoc/Camera');137 % if ~isempty(uid_Camera)138 % uid_ImageSize=find(t,'/ImaDoc/Camera/ImageSize');139 % if ~isempty(uid_ImageSize);140 % ImageSize=get(t,children(t,uid_ImageSize),'value');141 % xindex=findstr(ImageSize,'x');142 % if length(xindex)>=2143 % s.Npx=str2double(ImageSize(1:xindex(1)-1));144 % s.Npy=str2double(ImageSize(xindex(1)+1:xindex(2)-1));145 % end146 % end147 % uid_TimeUnit=find(t,'/ImaDoc/Camera/TimeUnit');148 % if ~isempty(uid_TimeUnit)149 % s.TimeUnit=get(t,children(t,uid_TimeUnit),'value');150 % end151 % uid_BurstTiming=find(t,'/ImaDoc/Camera/BurstTiming');152 % if ~isempty(uid_BurstTiming)153 % for k=1:length(uid_BurstTiming)154 % subt=branch(t,uid_BurstTiming(k));%subtree under BurstTiming155 % % reading Dtk156 % Frequency=get_value(subt,'/BurstTiming/FrameFrequency',1);157 % Dtj=get_value(subt,'/BurstTiming/Dtj',[]);158 % Dtj=Dtj/Frequency;%Dtj converted from frame unit to TimeUnit (e.g. 's')159 % NbDtj=get_value(subt,'/BurstTiming/NbDtj',1);160 % Dti=get_value(subt,'/BurstTiming/Dti',[]);161 % Dti=Dti/Frequency;%Dtj converted from frame unit to TimeUnit (e.g. 's')162 % NbDti=get_value(subt,'/BurstTiming/NbDti',1);163 % Time_val=get_value(subt,'/BurstTiming/Time',0);%time in TimeUnit164 % if ~isempty(Dti)165 % Dti=reshape(Dti'*ones(1,NbDti),NbDti*numel(Dti),1); %concatene Dti vector NbDti times166 % Time_val=[Time_val;Time_val(end)+cumsum(Dti)];%append the times defined by the intervals Dti167 % end168 % if ~isempty(Dtj)169 % Dtj=reshape(Dtj'*ones(1,NbDtj),1,NbDtj*numel(Dtj)); %concatene Dtj vector NbDtj times170 % Dtj=[0 Dtj];171 % Time_val=Time_val*ones(1,numel(Dtj))+ones(numel(Time_val),1)*cumsum(Dtj);% produce a time matrix with Dtj172 % end173 % % reading Dtk174 % Dtk=get_value(subt,'/BurstTiming/Dtk',[]);175 % NbDtk=get_value(subt,'/BurstTiming/NbDtk',1);176 % if isempty(Dtk)177 % s.Time=[s.Time;Time_val];178 % else179 % for kblock=1:NbDtk+1180 % Time_val_k=Time_val+(kblock-1)*Dtk;181 % s.Time=[s.Time;Time_val_k];182 % end183 % end184 % end185 % end186 % end187 % end188 189 %% motor190 % if strcmp(option,'*') || strcmp(option,'GeometryCalib')191 % uid_subtree=find(t,'/ImaDoc/TranslationMotor');192 % if length(uid_subtree)==1193 % subt=branch(t,uid_subtree);%subtree under GeometryCalib194 % [s.TranslationMotor,errormsg]=read_subtree(subt,{'Nbslice','ZStart','ZEnd'},[1 1 1],[1 1 1]);195 % end196 % end197 %% geometric calibration198 % if strcmp(option,'*') || strcmp(option,'GeometryCalib')199 % uid_GeometryCalib=find(t,'/ImaDoc/GeometryCalib');200 % if ~isempty(uid_GeometryCalib)201 % if length(uid_GeometryCalib)>1202 % errormsg=['More than one GeometryCalib in ' filecivxml];203 % return204 % end205 % subt=branch(t,uid_GeometryCalib);%subtree under GeometryCalib206 % cont=get(subt,1,'contents');207 % if ~isempty(cont)208 % uid_CalibrationType=find(subt,'/GeometryCalib/CalibrationType');209 % if isequal(length(uid_CalibrationType),1)210 % tsai.CalibrationType=get(subt,children(subt,uid_CalibrationType),'value');211 % end212 % uid_CoordUnit=find(subt,'/GeometryCalib/CoordUnit');213 % if isequal(length(uid_CoordUnit),1)214 % tsai.CoordUnit=get(subt,children(subt,uid_CoordUnit),'value');215 % end216 % uid_fx_fy=find(subt,'/GeometryCalib/fx_fy');217 % focal=[];%default fro old convention (Reg Wilson)218 % if isequal(length(uid_fx_fy),1)219 % tsai.fx_fy=str2num(get(subt,children(subt,uid_fx_fy),'value'));220 % else %old convention (Reg Wilson)221 % uid_focal=find(subt,'/GeometryCalib/focal');222 % uid_dpx_dpy=find(subt,'/GeometryCalib/dpx_dpy');223 % uid_sx=find(subt,'/GeometryCalib/sx');224 % if ~isempty(uid_focal) && ~isempty(uid_dpx_dpy) && ~isempty(uid_sx)225 % dpx_dpy=str2num(get(subt,children(subt,uid_dpx_dpy),'value'));226 % sx=str2num(get(subt,children(subt,uid_sx),'value'));227 % focal=str2num(get(subt,children(subt,uid_focal),'value'));228 % tsai.fx_fy(1)=sx*focal/dpx_dpy(1);229 % tsai.fx_fy(2)=focal/dpx_dpy(2);230 % end231 % end232 % uid_Cx_Cy=find(subt,'/GeometryCalib/Cx_Cy');233 % if ~isempty(uid_Cx_Cy)234 % tsai.Cx_Cy=str2num(get(subt,children(subt,uid_Cx_Cy),'value'));235 % end236 % uid_kc=find(subt,'/GeometryCalib/kc');237 % if ~isempty(uid_kc)238 % tsai.kc=str2double(get(subt,children(subt,uid_kc),'value'));239 % else %old convention (Reg Wilson)240 % uid_kappa1=find(subt,'/GeometryCalib/kappa1');241 % if ~isempty(uid_kappa1)&& ~isempty(focal)242 % kappa1=str2double(get(subt,children(subt,uid_kappa1),'value'));243 % tsai.kc=-kappa1*focal*focal;244 % end245 % end246 % uid_Tx_Ty_Tz=find(subt,'/GeometryCalib/Tx_Ty_Tz');247 % if ~isempty(uid_Tx_Ty_Tz)248 % tsai.Tx_Ty_Tz=str2num(get(subt,children(subt,uid_Tx_Ty_Tz),'value'));249 % end250 % uid_R=find(subt,'/GeometryCalib/R');251 % if ~isempty(uid_R)252 % RR=get(subt,children(subt,uid_R),'value');253 % if length(RR)==3254 % tsai.R=[str2num(RR{1});str2num(RR{2});str2num(RR{3})];255 % end256 % end257 %258 % %look for laser plane definitions259 % uid_Angle=find(subt,'/GeometryCalib/PlaneAngle');260 % uid_Pos=find(subt,'/GeometryCalib/SliceCoord');261 % if isempty(uid_Pos)262 % uid_Pos=find(subt,'/GeometryCalib/PlanePos');%old convention263 % end264 % if ~isempty(uid_Angle)265 % tsai.PlaneAngle=str2num(get(subt,children(subt,uid_Angle),'value'));266 % end267 % if ~isempty(uid_Pos)268 % for j=1:length(uid_Pos)269 % tsai.SliceCoord(j,:)=str2num(get(subt,children(subt,uid_Pos(j)),'value'));270 % end271 % uid_DZ=find(subt,'/GeometryCalib/SliceDZ');272 % uid_NbSlice=find(subt,'/GeometryCalib/NbSlice');273 % if ~isempty(uid_DZ) && ~isempty(uid_NbSlice)274 % DZ=str2double(get(subt,children(subt,uid_DZ),'value'));275 % NbSlice=get(subt,children(subt,uid_NbSlice),'value');276 % if isequal(NbSlice,'volume')277 % tsai.NbSlice='volume';278 % NbSlice=NbDtj+1;279 % else280 % tsai.NbSlice=str2double(NbSlice);281 % end282 % tsai.SliceCoord=ones(NbSlice,1)*tsai.SliceCoord+DZ*(0:NbSlice-1)'*[0 0 1];283 % end284 % end285 % tsai.SliceAngle=get_value(subt,'/GeometryCalib/SliceAngle',[0 0 0]);286 % tsai.VolumeScan=get_value(subt,'/GeometryCalib/VolumeScan','n');287 % tsai.InterfaceCoord=get_value(subt,'/GeometryCalib/InterfaceCoord',[0 0 0]);288 % tsai.RefractionIndex=get_value(subt,'/GeometryCalib/RefractionIndex',1);289 %290 % if strcmp(option,'GeometryCalib')291 % tsai.PointCoord=get_value(subt,'/GeometryCalib/SourceCalib/PointCoord',[0 0 0 0 0]);292 % end293 % s.GeometryCalib=tsai;294 % end295 % end296 % end297 298 %--------------------------------------------------299 % read a subtree300 % INPUT:301 % t: xltree302 % head_element: head elelemnt of the subtree303 % Data, structure containing304 % .Key: element name305 % .Type: type of element ('charg', 'float'....)306 % .NbOccur: nbre of occurrence, NaN for un specified number307 110 function [s,errormsg]=read_subtree(subt,Data,NbOccur,NumTest) 308 111 %-------------------------------------------------- -
trunk/src/mask_proj.m
r672 r675 31 31 end 32 32 [Npy,Npx]=size(MaskData.A); 33 DX=(MaskData.AX(2)-MaskData.AX(1))/(Npx-1); 34 DY=(MaskData.AY(2)-MaskData.AY(1))/(Npy-1); 33 35 34 for icell=1:numel(CellInfo) 36 35 if NbDimArray(icell)==2 37 XName=FieldData.ListVarName{CellInfo{icell}.CoordIndex(1)};38 YName=FieldData.ListVarName{CellInfo{icell}.CoordIndex(2)};39 36 if isfield(CellInfo{icell},'VarIndex_errorflag') 40 37 FFName=FieldData.ListVarName{CellInfo{icell}.VarIndex_errorflag}; 38 check_new_error_flag=0; 41 39 else 42 40 FFName='FF';%default error (mask) flag name (if not already used) … … 49 47 end 50 48 ProjData.ListVarName=[FieldData.ListVarName {FFName}]; 51 ProjData.Var DimName=[FieldData.VarDimName FieldData.VarDimName(CellInfo{icell}.CoordIndex(1))];52 ProjData.VarAttribute{numel(FieldData.VarDimName)}.Role='errorflag';49 ProjData.VarAttribute{numel(ProjData.ListVarName)}.Role='errorflag'; 50 check_new_error_flag=1; 53 51 end 54 52 switch CellInfo{icell}.CoordType; 55 case 'scattered' 53 case 'scattered' 54 XName=FieldData.ListVarName{CellInfo{icell}.Coord_x}; 55 YName=FieldData.ListVarName{CellInfo{icell}.Coord_y}; 56 DX=(MaskData.AX(2)-MaskData.AX(1))/(Npx-1); 57 DY=(MaskData.AY(2)-MaskData.AY(1))/(Npy-1); 56 58 mask_ind_i=round(0.5+(FieldData.(XName)-MaskData.AX(1))/DX);%nbpoint terms 57 59 mask_ind_j=round(0.5+(FieldData.(YName)-MaskData.AY(1))/DY);%nbpoint terms … … 65 67 ProjData.(VarName)(checkfalse)=0; 66 68 end 67 if ~isfield(CellInfo{icell},'VarIndex_errorflag')% an error flag already existsin the current cell69 if check_new_error_flag% an error flag needs to be created in the current cell 68 70 ProjData.(FFName)=zeros(size(ProjData.(VarName))); 71 ProjData.VarDimName=[FieldData.VarDimName FieldData.VarDimName(CellInfo{icell}.VarIndex(1))]; 69 72 end 70 ProjData.(FFName)(checkfalse)=1; 73 ProjData.(FFName)(checkfalse)=1;% update the existing error flag 71 74 case 'grid' 75 XName=FieldData.ListVarName{CellInfo{icell}.CoordIndex(2)}; 76 YName=FieldData.ListVarName{CellInfo{icell}.CoordIndex(1)}; 72 77 Var1Name=FieldData.ListVarName{CellInfo{icell}.VarIndex(1)}; 73 78 [Npy_field,Npx_field]=size(FieldData.(Var1Name)); 74 DX_field=(FieldData.(XName)(end)-FieldData.(XName)(1))/(Npx_field-1); 75 DY_field=(FieldData.(YName)(end)-FieldData.(YName)(1))/(Npy_field-1); 76 XArray=FieldData.(XName)(1):DX_field:FieldData.(XName)(end); 77 YArray=FieldData.(YName)(1):DY_field:FieldData.(YName)(end); 78 XMask=MaskData.AX(1):DX:MaskData.AX(end); 79 YMask=MaskData.AY(end):-DY:MaskData.AY(1); 79 XArray=linspace(FieldData.(XName)(1),FieldData.(XName)(end),Npx_field); 80 YArray=linspace(FieldData.(YName)(1),FieldData.(YName)(end),Npy_field); 81 XMask=linspace(MaskData.AX(1),MaskData.AX(end),Npx); 82 YMask=linspace(MaskData.AY(1),MaskData.AY(end),Npy); 80 83 [XMask,YMask]=meshgrid(XMask,YMask); 81 84 Mask = interp2(XMask,YMask,MaskData.A,XArray,YArray','nearest'); … … 87 90 end 88 91 end 89 if isfield(CellInfo{icell},'VarIndex_errorflag')% an error flag already exists in the current cell 92 if check_new_error_flag% an error flag needs to be created in the current cell 93 ProjData.(FFName)= ~Mask; 94 ProjData.VarDimName=[FieldData.VarDimName FieldData.VarDimName(CellInfo{icell}.VarIndex(1))]; 95 else 90 96 ProjData.(FFName)=FieldData.(FFName) | ~Mask; 91 else92 ProjData.(FFName)= ~Mask;93 97 end 94 98 end -
trunk/src/proj_field.m
r672 r675 562 562 NbPoint=ceil(LineLength/DX); 563 563 DX=LineLength/NbPoint;%adjust DX to get an integer nbre of intervals in a closed line 564 DX_e nd=DX/2;564 DX_edge=DX/2; 565 565 else 566 DX_e nd=(LineLength-DX*floor(LineLength/DX))/2;%margin from the first point and first interpolationpoint566 DX_edge=(LineLength-DX*floor(LineLength/DX))/2;%margin from the first point and first interpolation point, the same for the end point 567 567 end 568 568 XI=[]; … … 571 571 dlengthI=[]; 572 572 if strcmp(ObjectData.Type,'ellipse') 573 phi=(DX_e nd:DX:LineLength)*2*pi/LineLength;573 phi=(DX_edge:DX:LineLength)*2*pi/LineLength; 574 574 XI=ObjectData.RangeX*cos(phi); 575 575 YI=ObjectData.RangeY*sin(phi); … … 580 580 costheta=cos(theta(isegment)); 581 581 sintheta=sin(theta(isegment)); 582 XIsegment=(LineCoord(isegment,1)+DX_end*costheta:DX*costheta:LineCoord(isegment+1,1)); 583 YIsegment=(LineCoord(isegment,2)+DX_end*sintheta:DX*sintheta:LineCoord(isegment+1,2)); 582 % XIsegment=LineCoord(isegment,1)+DX_edge*costheta:DX*costheta:LineCoord(isegment+1,1)); 583 % YIsegment=(LineCoord(isegment,2)+DX_edge*sintheta:DX*sintheta:LineCoord(isegment+1,2)); 584 NbInterval=floor((dlength(isegment)-DX_edge)/DX); 585 LastX=DX_edge+DX*NbInterval; 586 NbPoint=NbInterval+1; 587 XIsegment=linspace(LineCoord(isegment,1)+DX_edge*costheta,LineCoord(isegment,1)+LastX*costheta,NbPoint); 588 YIsegment=linspace(LineCoord(isegment,2)+DX_edge*sintheta,LineCoord(isegment,2)+LastX*sintheta,NbPoint); 584 589 XI=[XI XIsegment]; 585 590 YI=[YI YIsegment]; 586 591 ThetaI=[ThetaI theta(isegment)*ones(1,numel(XIsegment))]; 587 592 dlengthI=[dlengthI DX*ones(1,numel(XIsegment))]; 588 DX_e nd=DX_end+DX-(dlength(isegment)-DX*(numel(XIsegment)-1));593 DX_edge=DX-(dlength(isegment)-LastX);%edge for the next segment set to keep DX=DX_end+DX_edge between two segments 589 594 end 590 595 end 591 596 Xproj=cumsum(dlengthI); 592 597 else 593 errormsg=' meshDX needed for interpolation';598 errormsg='abscissa mesh along line DX needed for interpolation'; 594 599 return 595 600 end … … 713 718 [DataOut,VarAttribute,errormsg]=calc_field_tps(Coord,NbCentres,SubRange,FieldVar,CellInfo{icell}.FieldName,cat(3,XI,YI)); 714 719 ProjData.X=Xproj; 715 % ProjData.ListVarName=[ProjData.ListVarName {XName}];716 % ProjData.VarDimName=[ProjData.VarDimName {XName}];717 720 nbvar=numel(ProjData.ListVarName); 718 721 ProjData.VarAttribute{nbvar}.long_name='abscissa along line'; … … 923 926 testXMin=XMax>XMin; 924 927 testXMax=1;% range restriction along X 925 % else926 % XMin=FieldData.XMin;%default927 % XMax=FieldData.XMax;%default928 928 end 929 929 if isfield(ObjectData,'RangeY') … … 932 932 testYMin=YMax>YMin; 933 933 testYMax=1; 934 % else935 % YMin=FieldData.YMin;%default936 % YMax=FieldData.YMax;%default937 934 end 938 935 width=0;%default width of the projection band … … 1036 1033 if ~isfield(FieldData,'XMax') 1037 1034 FieldData=find_field_bounds(FieldData); 1038 % CellIndex=find(check_grid);1039 % for igrid=1:numel(CellIndex)1040 % icell=CellIndex(igrid);% TODO: recalculate coordinates here to get the bounds in the rotated coordinates1041 % NbDim=NbDimArray(icell);1042 % for idim=1:NbDim %loop on space dimensions1043 % ivar=CellInfo{icell}.CoordIndex(idim);% index of the variable corresponding to the current dimension1044 % Coord{idim}=FieldData.(FieldData.ListVarName{ivar});% coord values for the input field1045 % if ~isequal(ivar,0)% a variable corresponds to the dimension #idim1046 %1047 %1048 %1049 % else1050 % Coord_i_str=['Coord_' num2str(idim)];1051 % DCoord_min(idim)=1;%default1052 % Coord{idim}=[0.5 DimValue(idim)-0.5];1053 % test_direct(idim)=1;1054 % end1055 % % default bounds, case of gridded data1056 % if strcmp(CellInfo{icell}.CoordType,'grid')1057 % % find default mesh1058 % for idim=1:NbDim %loop on space dimensions1059 % test_interp(idim)=0;%test for coordiate interpolation (non regular grid), =0 by default1060 % ivar=CellInfo{icell}.CoordIndex(idim);% index of the variable corresponding to the current dimension1061 % DimValue=size(FieldData.(FieldData.ListVarName{ivar}));1062 % if ~isequal(ivar,0)% a variable corresponds to the dimension #idim1063 % Coord{idim}=FieldData.(FieldData.ListVarName{ivar});% coord values for the input field1064 % if numel(Coord{idim})==2 %input array defined on a regular grid1065 % DCoord_min(idim)=(Coord{idim}(2)-Coord{idim}(1))/DimValue(idim);1066 % Coord{idim}=linspace(Coord{idim}(1),Coord{idim}(2),DimValue(idim));1067 % else1068 % DCoord=diff(Coord{idim});%array of coordinate derivatives for the input field1069 % DCoord_min(idim)=min(DCoord);1070 % DCoord_max=max(DCoord);1071 % if abs(DCoord_max-DCoord_min(idim))>abs(DCoord_max/1000)1072 % msgbox_uvmat('ERROR',['non monotonic dimension variable # ' num2str(idim) ' in proj_field.m'])1073 % return1074 % end1075 % test_interp(idim)=(DCoord_max-DCoord_min(idim))> 0.0001*abs(DCoord_max);% test grid regularity1076 % end1077 % test_direct(idim)=(DCoord_min(idim)>0);1078 % else % no variable associated with the dimension #idim, the coordinate value is set equal to the matrix index by default1079 % % Coord_i_str=['Coord_' num2str(idim)];1080 % % DCoord_min(idim)=1;%default1081 % % Coord{idim}=[0.5 DimValue(idim)-0.5];1082 % % test_direct(idim)=1;1083 % end1084 % end1085 % if isempty(DY)1086 % DY=abs(DCoord_min(NbDim-1));1087 % end1088 % npY=1+round(abs(Coord{NbDim-1}(end)-Coord{NbDim-1}(1))/DY);%nbre of points after interpol1089 % if isempty(DX)1090 % DX=abs(DCoord_min(NbDim));1091 % end1092 % npX=1+round(abs(Coord{NbDim}(end)-Coord{NbDim}(1))/DX);%nbre of points after interpol1093 % for idim=1:NbDim1094 % if test_interp(idim)1095 % DimValue(idim)=1+round(abs(Coord{idim}(end)-Coord{idim}(1))/abs(DCoord_min(idim)));%nbre of points after possible interpolation on a regular gri1096 % end1097 % end1098 % Coord_y=linspace(Coord{NbDim-1}(1),Coord{NbDim-1}(end),npY);1099 % test_direct_y=test_direct(NbDim-1);1100 % Coord_x=linspace(Coord{NbDim}(1),Coord{NbDim}(end),npX);1101 % test_direct_x=test_direct(NbDim);1102 % DAX=DCoord_min(NbDim);1103 % DAY=DCoord_min(NbDim-1);1104 % minAX=min(Coord_x);1105 % maxAX=max(Coord_x);1106 % minAY=min(Coord_y);1107 % maxAY=max(Coord_y);1108 % xcorner=[minAX maxAX minAX maxAX]-ObjectData.Coord(1,1);% image corners in the new coordiantes1109 % ycorner=[maxAY maxAY minAY minAY]-ObjectData.Coord(1,2);1110 % xcor_new=xcorner*cos_om+ycorner*sin_om;%coord new frame1111 % ycor_new=-xcorner*sin_om+ycorner*cos_om;1112 % if ~testXMax1113 % XMax(igrid)=max(xcor_new);1114 % end1115 % if ~testXMin1116 % XMin(igrid)=min(xcor_new);1117 % end1118 % if ~testYMax1119 % YMax(igrid)=max(ycor_new);1120 % end1121 % if ~testYMin1122 % YMin(igrid)=min(ycor_new);1123 % end1124 % DX(igrid)=(maxAX-minAX)/(DimValue(NbDim)-1);1125 % DY(igrid)=(maxAY-minAY)/(DimValue(NbDim-1)-1);1126 % if NbDim==31127 % DZ(igrid)=(Coord{1}(end)-Coord{1}(1))/(DimValue(1)-1);1128 % if ~test_direct(1)1129 % DZ=-DZ;1130 % end1131 % Coord_z=linspace(Coord{1}(1),Coord{1}(end),DimValue(1));1132 % test_direct_z=test_direct(1);1133 % end1134 % else1135 %1136 % end1137 % YMax=max(YMax);1138 % YMin=min(YMin);1139 % XMax=max(XMax);1140 % XMin=min(XMin);1141 1035 end 1142 1036 end … … 1188 1082 end 1189 1083 VarIndex=CellInfo{icell}.VarIndex;% indices of the selected variables in the list FieldData.ListVarName 1190 % ivar_U=[];ivar_V=[];ivar_W=[];1191 % if isfield(CellInfo{icell},'VarIndex_vector_x_tps')&&isfield(CellInfo{icell},'VarIndex_vector_y_tps')1192 % ivar_U=CellInfo{icell}.VarIndex_vector_x_tps;1193 % ivar_V=CellInfo{icell}.VarIndex_vector_y_tps;1194 % elseif isfield(CellInfo{icell},'VarIndex_vector_x')&&isfield(CellInfo{icell},'VarIndex_vector_y')1195 % ivar_U=CellInfo{icell}.VarIndex_vector_x;1196 % ivar_V=CellInfo{icell}.VarIndex_vector_y;1197 % end1198 % if isfield(CellInfo{icell},'VarIndex_vector_z')1199 % ivar_W=CellInfo{icell}.VarIndex_vector_z;1200 % end1201 1084 %dimensions 1202 1085 DimCell=FieldData.VarDimName{VarIndex(1)}; … … 1390 1273 Coord_x=[]; 1391 1274 1392 1393 1394 % % default bounds1395 % minAX=min(Coord_x);1396 % maxAX=max(Coord_x);1397 % minAY=min(Coord_y);1398 % maxAY=max(Coord_y);1399 % xcorner=[minAX maxAX minAX maxAX]-ObjectData.Coord(1,1);% image corners in the new coordiantes1400 % ycorner=[maxAY maxAY minAY minAY]-ObjectData.Coord(1,2);1401 % xcor_new=xcorner*cos_om+ycorner*sin_om;%coord new frame1402 % ycor_new=-xcorner*sin_om+ycorner*cos_om;1403 % if ~testXMax1404 % XMax=max(xcor_new);1405 % end1406 % if ~testXMin1407 % XMin=min(xcor_new);1408 % end1409 % if ~testYMax1410 % YMax=max(ycor_new);1411 % end1412 % if ~testYMin1413 % YMin=min(ycor_new);1414 % end1415 % DXinit=(maxAX-minAX)/(DimValue(NbDim)-1);1416 % DYinit=(maxAY-minAY)/(DimValue(NbDim-1)-1);1417 % if DX==01418 % DX=DXinit;1419 % end1420 % if DY==01421 % DY=DYinit;1422 % end1423 % if NbDim==31424 % DZ=(Coord{1}(end)-Coord{1}(1))/(DimValue(1)-1);1425 % if ~test_direct(1)1426 % DZ=-DZ;1427 % end1428 % Coord_z=linspace(Coord{1}(1),Coord{1}(end),DimValue(1));1429 % test_direct_z=test_direct(1);1430 % end1431 %define new coordiantes if not already done by the definition of a projection grid1432 if ~check_grid1433 1434 1435 end1436 1437 1275 if testangle 1438 1276 ProjMode{icell}='interp_lin'; %request linear interpolation for projection on a tilted plane 1439 1277 end 1440 1441 % npX=floor((XMax-XMin)/DX+1); 1442 % npY=floor((YMax-YMin)/DY+1); 1443 % if test_direct_y 1444 % coord_y_proj=linspace(YMin,YMax,npY);%abscissa of the new pixels along the line 1445 % else 1446 % coord_y_proj=linspace(YMax,YMin,npY);%abscissa of the new pixels along the line 1447 % end 1448 % if test_direct_x 1449 % coord_x_proj=linspace(XMin,XMax,npX);%abscissa of the new pixels along the line 1450 % else 1451 % coord_x_proj=linspace(XMax,XMin,npX);%abscissa of the new pixels along the line 1452 % end 1278 1453 1279 if isequal(ProjMode{icell},'projection')% && (~testangle || test90y || test90x) 1454 1280 if NbDim==2 && ~testXMin && ~testXMax && ~testYMin && ~testYMax% no range restriction -
trunk/src/read_field.m
r667 r675 69 69 case 'netcdf' 70 70 ListVar={}; 71 Role={}; 72 ProjModeRequest={}; 71 73 for ilist=1:numel(InputField) 72 74 r=regexp(InputField{ilist},'(?<Operator>(^vec|^norm))\((?<UName>.+),(?<VName>.+)\)$','names'); … … 81 83 end 82 84 else % an operator 'vec' or 'norm' is used 83 ListVar=[ListVar {r.UName,r.VName}];84 Role{numel(ListVar)}='vector_y';85 Role{numel(ListVar)-1}='vector_x';86 85 if ~check_colorvar(ilist) && strcmp(r.Operator,'norm') 87 ProjModeRequest{numel(ListVar)-1}='interp_lin';%scalar field (requires interpolation for plot) 88 ProjModeRequest{numel(ListVar)}='interp_lin'; 86 ProjModeRequestVar='interp_lin';%scalar field (requires interpolation for plot) 89 87 else 90 ProjModeRequest{numel(ListVar)-1}=''; 91 ProjModeRequest{numel(ListVar)}=''; 88 ProjModeRequestVar=''; 89 end 90 ind_var_U=find(strcmp(r.UName,ListVar));%check previous listing of variable r.UName 91 ind_var_V=find(strcmp(r.VName,ListVar));%check previous listing of variable r.VName 92 if isempty(ind_var_U) 93 ListVar=[ListVar r.UName]; % append the variable in the list if not previously listed 94 Role=[Role {'vector_x'}]; 95 ProjModeRequest=[ProjModeRequest {ProjModeRequestVar}]; 96 end 97 if isempty(ind_var_V) 98 ListVar=[ListVar r.VName];% append the variable in the list if not previously listed 99 Role=[Role {'vector_y'}]; 100 ProjModeRequest=[ProjModeRequest {ProjModeRequestVar}]; 92 101 end 93 102 end … … 101 110 errormsg=Field.Txt; 102 111 return 112 end 113 for ilist=3:numel(Field.VarDimName) 114 if isequal(Field.VarDimName{1},Field.VarDimName{ilist}) 115 Field.VarAttribute{1}.Role='coord_x';%unstructured coordinates 116 Field.VarAttribute{2}.Role='coord_y'; 117 break 118 end 103 119 end 104 120 for ivar=1:numel(ListVar) … … 109 125 Field.VarAttribute{ivar+2}.ProjModeRequest=ProjModeRequest{ivar}; 110 126 end 127 111 128 case 'video' 112 129 if strcmp(class(ParamIn),'VideoReader') -
trunk/src/read_multimadoc.m
r620 r675 7 7 % NbSlice_calib: nbre of slices detected in the geometric calibration data 8 8 % Time(iview,i,j): matrix of times, iview =index of the series, i,j=file indices within the series 9 % if the time is not consistent in all series, the time from the first series is chosen 9 10 % warnmsg: warning message, ='' if OK 10 11 % … … 59 60 60 61 function time=get_time(timeimadoc,i1_series,i2_series,j1_series,j2_series) 61 if isempty(i2_series)||size(timeimadoc,1) < i2_series(end) ||( ~isempty(j2_series) && size(timeimadoc,2) < j2_series(end))% time array absent or too short in ImaDoc xml file' 62 time=[]; 63 else 64 timevect=timeimadoc'; 65 if ~isempty(j1_series) 66 vect_index=reshape(j1_series+(i1_series-1)*size(timevect,1),1,[]); 67 time=timevect(vect_index); 68 if ~isempty(j2_series) 69 vect_index=reshape(j2_series+(i1_series-1)*size(timevect,1),1,[]); 70 time=(time+timevect(vect_index))/2; 71 end 72 else 73 time=timevect(i1_series); 74 if ~isempty(i2_series) 75 time=(time+timevect(i2_series))/2; 76 end 77 end 78 end 62 time=[]; 63 if ~ (isempty(i2_series)||size(timeimadoc,1) < i2_series(end) ||( ~isempty(j2_series) && size(timeimadoc,2) < j2_series(end)))% time array absent or too short in ImaDoc xml file' 64 if isempty(j1_series) 65 j1_series=1; 66 end 67 time=timeimadoc(i1_series+1,j1_series+1); 68 if ~isempty(j2_series) 69 time=[time timeimadoc(i1_series+1,j2_series+1)]; 70 end 71 if ~isempty(i2_series) 72 time=[time timeimadoc(i2_series+1,j1_series+1)]; 73 if ~isempty(j2_series) 74 time=[time timeimadoc(i2_series+1,j2_series+1)]; 75 end 76 end 77 time=mean(time); 78 end -
trunk/src/series.m
r672 r675 122 122 series_ResizeFcn(hObject, eventdata, handles)%resize table according to series GUI size 123 123 set(hObject,'WindowButtonDownFcn',{'mouse_down'})%allows mouse action with right button (zoom for uicontrol display) 124 set(handles.InputTable,'KeyPressFcn',{@key_press_fcn,handles})%set keyboard action function (allow action on uvmat when set_object is in front) 124 125 125 126 % check default input data … … 491 492 492 493 %------------------------------------------------------------------------ 494 % --- 'key_press_fcn:' function activated when a key is pressed on the keyboard 495 %------------------------------------------------------------------------ 496 function key_press_fcn(hObject,eventdata,handles) 497 498 xx=double(get(handles.series,'CurrentCharacter')); %get the keyboard character 499 if ismember(xx,[8 127 31])%backspace or delete, or downward 500 InputTable=get(handles.InputTable,'Data'); 501 iline=get(handles.InputTable,'UserData'); 502 if isequal(xx, 31) 503 if isequal(iline,size(InputTable,1))% arrow downward 504 InputTable=[InputTable;cell(1,size(InputTable,2))]; 505 end 506 else 507 InputTable(iline,:)=[];% suppress the current line 508 end 509 set(handles.InputTable,'Data',InputTable); 510 end 511 512 513 %------------------------------------------------------------------------ 493 514 % --- Executes on button press in REFRESH. 494 515 function REFRESH_Callback(hObject, eventdata, handles) … … 508 529 if ~exist(RootPath,'dir') 509 530 i1_series=[]; 510 RootPath=fileparts(RootPath); %will try the upped fo rlder531 RootPath=fileparts(RootPath); %will try the upped folder 511 532 else 512 533 [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileType,FileInfo,MovieObject]=... … … 526 547 end 527 548 set(handles.REFRESH,'Visible','off') 528 set(handles.REFRESH_title,'Visible','off') 529 % set(handles.REFRESH,'UserData',[]) 549 %set(handles.REFRESH_title,'Visible','off') 530 550 531 551 %------------------------------------------------------------------------ … … 1447 1467 [tild,msg1]=mkdir(OutputDir); 1448 1468 if ~strcmp(msg1,'') 1449 errormsg=['cannot create ' OutputDir ': ' msg1];%error message for directory creation1469 msgbox_uvmat('ERROR',['cannot create ' OutputDir ': ' msg1]);%error message for directory creation 1450 1470 return 1451 1471 end … … 1831 1851 set(handles.RUN, 'Value',0) 1832 1852 1833 % %------------------------------------------------------------------------1834 % % --- Executes on button press in BIN.1835 % function BIN_Callback(hObject, eventdata, handles)1836 % %------------------------------------------------------------------------1837 % cmd=['#!/bin/bash \n '...1838 % '#$ -cwd \n '...1839 % 'hostname && date \n '...1840 % 'umask 002 \n'...1841 % Param.xml.CivmBin ' ' Param.xml.RunTime ' ' filename_xml ' ' OutputFile '.nc'];1842 %1843 %------------------------------------------------------------------------1844 % --- Main launch command, called by RUN and BATCH1845 1853 1846 1854 %------------------------------------------------------------------------ … … 2423 2431 function ViewObject_Callback(hObject, eventdata, handles) 2424 2432 2425 % if get(handles.ViewObject,'Value') 2426 % set(handles.EditObject,'Value',0) 2427 UserData=get(handles.series,'UserData'); 2428 hset_object=findobj(allchild(0),'Tag','set_object'); 2429 if ~isempty(hset_object) 2430 delete(hset_object)% refresh set_object if already opened 2431 end 2432 hset_object=set_object(UserData.ProjObject); 2433 set(hset_object,'Name','view_object_series') 2434 % else 2435 % hset_object=findobj(allchild(0),'Tag','set_object'); 2436 % if ~isempty(hset_object) 2437 % delete(hset_object) 2438 % end 2439 % end 2433 UserData=get(handles.series,'UserData'); 2434 hset_object=findobj(allchild(0),'Tag','set_object'); 2435 if ~isempty(hset_object) 2436 delete(hset_object)% refresh set_object if already opened 2437 end 2438 hset_object=set_object(UserData.ProjObject); 2439 set(hset_object,'Name','view_object_series') 2440 2440 2441 2441 2442 %------------------------------------------------------------------------ … … 2484 2485 2485 2486 if get(handles.CheckMask,'Value') 2486 MaskData=get(handles.MaskTable,'Data');2487 2487 InputTable=get(handles.InputTable,'Data'); 2488 2488 nbview=size(InputTable,1); 2489 % MaskTable=cell(nbview,1);2490 2489 MaskTable=cell(nbview,1);%default 2491 2490 ListMask=cell(nbview,1);%default 2491 MaskData=get(handles.MaskTable,'Data'); 2492 MaskData(size(MaskData,1):nbview,1)=cell(size(MaskData,1):nbview,1);%complement if undefined lines 2492 2493 for iview=1:nbview 2493 2494 ListMask{iview,1}=num2str(iview); … … 2496 2497 if isempty(MaskData{iview}) 2497 2498 SubDir=InputTable{iview,2}; 2498 MaskSubDir=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.' 2499 MaskName=fullfile(RootPath,[MaskSubDir '.mask'],'mask_1.png'); 2500 if ~exist(MaskName,'file') 2499 MaskPath=fullfile(RootPath,[regexprep(SubDir,'\..*','') '.mask']);%take the root part of SubDir, before the first dot '.' 2500 if exist(MaskPath,'dir') 2501 ListStruct=dir(MaskPath);%look for a mask file 2502 ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray 2503 check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files 2504 ListFiles=ListCells(1,:);%list of file and dri names 2505 ListFiles=ListFiles(~check_dir);%list of file names (excluding dir) 2506 mdetect=0; 2507 if ~isempty(ListFiles) 2508 for ifile=1:numel(ListFiles) 2509 [tild,tild,MaskFile{ifile},i1_series,i2_series,j1_series,j2_series,MaskNomType,MaskFileType]=find_file_series(MaskPath,ListFiles{ifile},0); 2510 if strcmp(MaskFileType,'image') && isempty(i2_series) && isempty(j2_series) 2511 mdetect=1; 2512 MaskName=ListFiles{ifile}; 2513 end 2514 if ~strcmp(MaskFile{ifile},MaskFile{1}) 2515 mdetect=0;% cancel detection test in case of multiple masks, use the brower for selection 2516 break 2517 end 2518 end 2519 end 2520 if mdetect==1 2521 MaskName=fullfile(MaskPath,'mask_1.png'); 2522 else 2523 MaskName=uigetfile_uvmat('select a mask file:',MaskPath,'image'); 2524 end 2525 else 2501 2526 MaskName=uigetfile_uvmat('select a mask file:',RootPath,'image'); 2502 2527 end … … 2506 2531 end 2507 2532 end 2508 %nbview=size(MaskTable,1);2509 2533 set(handles.MaskTable,'Data',MaskTable) 2510 % set(handles.MaskTable,'ColumnFormat',{MaskTable'})2511 2534 set(handles.MaskTable,'Visible','on') 2512 2535 set(handles.MaskBrowse,'Visible','on') … … 2524 2547 %------------------------------------------------------------------------ 2525 2548 function MaskBrowse_Callback(hObject, eventdata, handles) 2549 2526 2550 InputTable=get(handles.InputTable,'Data'); 2527 2551 iview=get(handles.ListMask,'Value'); 2528 % MaskTable=cell(nbview,1);2529 2530 2552 RootPath=InputTable{iview,1}; 2531 % if ~isempty(RootPath)2532 % SubDir=InputTable{iview,2};2533 % MaskSubDir=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.'2534 % MaskName=fullfile(RootPath,[MaskSubDir '.mask'],'mask_1.png');2535 % if ~exist(MaskName,'file')2536 2553 MaskName=uigetfile_uvmat('select a mask file:',RootPath,'image'); 2537 % end2538 2554 if ~isempty(MaskName) 2539 2555 MaskTable=get(handles.MaskTable,'Data'); 2540 MaskTable{iview,1}=MaskName ; 2541 % end 2542 set(handles.MaskTable,'Data',MaskTable) 2543 end 2544 % set(handles.MaskTable,'ColumnFormat',{MaskTable'}) 2556 MaskTable{iview,1}=MaskName ; 2557 set(handles.MaskTable,'Data',MaskTable) 2558 end 2545 2559 2546 2560 %------------------------------------------------------------------------ … … 2639 2653 InputTable=get(handles.InputTable,'Data'); 2640 2654 filexml=uigetfile_uvmat('pick a xml parameter file',InputTable{1,1},'.xml'); 2641 % [FileName, PathName] = uigetfile( ...2642 % {'*.xml', ' (*.xml)';2643 % '*.xml', '.xml files '; ...2644 % '*.*', 'All Files (*.*)'}, ...2645 % 'Pick a file',InputTable{1,1});2646 % filexml=[PathName FileName];%complete file name2647 2655 if ~isempty(filexml)%abandon if no file is introduced by the browser 2648 2656 Param=xml2struct(filexml); 2649 2657 fill_GUI(Param,handles.series) 2658 REFRESH_Callback([],[],handles)% refresh data relative to the input files 2659 SeriesData=get(handles.series,'UserData'); 2650 2660 if isfield(Param,'ActionInput') 2651 set(handles.ActionInput,'Visible','on') 2652 set(handles.ActionInput_title,'Visible','on') 2653 set(handles.ActionInputView,'Visible','on') 2654 set(handles.ActionInputView,'Value',0) 2655 %set(handles.ActionInput,'String',ActionName) 2656 % ParamOut.ActionInput.Program=ActionName; % record the program in ActionInput 2657 SeriesData=get(handles.series,'UserData'); 2658 SeriesData.ActionInput=Param.ActionInput; 2661 set(handles.ActionInput,'Visible','on') 2662 set(handles.ActionInput_title,'Visible','on') 2663 set(handles.ActionInputView,'Visible','on') 2664 set(handles.ActionInputView,'Value',0) 2665 SeriesData.ActionInput=Param.ActionInput; 2666 end 2667 if isfield(Param,'ProjObject') 2668 SeriesData.ProjObject=Param.ProjObject; 2669 end 2659 2670 set(handles.series,'UserData',SeriesData) 2660 end2661 2671 ActionName_Callback([],[],handles) 2662 2672 end -
trunk/src/set_object.m
r674 r675 270 270 %------------------------------------------------------------------------ 271 271 % --- Executes on selection change in ProjMode. 272 %------------------------------------------------------------------------ 273 272 274 function ProjMode_Callback(hObject, eventdata, handles) 273 275 menu=get(handles.ProjMode,'String'); … … 305 307 switch ObjectStyle 306 308 case 'points' 307 set(handles.num_RangeY_2,'TooltipString','num_ YMax: range of projection around each point')309 set(handles.num_RangeY_2,'TooltipString','num_RangeY_2: range of projection around each point') 308 310 % set(handles.XObject,'TooltipString','XObject: set of x coordinates of the points') 309 311 % set(handles.YObject,'TooltipString','YObject: set of y coordinates of the points') 310 312 % set(handles.ZObject,'TooltipString','ZObject: set of z coordinates of the points') 311 313 case {'line','polyline','polygon'} 312 set(handles.num_RangeY_2,'TooltipString','num_ YMax: range of projection around the line')314 set(handles.num_RangeY_2,'TooltipString','num_RangeY_2: range of projection around the line') 313 315 set(handles.Coord,'TooltipString','Coord: table of x,y, z coordinates defining the line') 314 316 % set(handles.YObject,'TooltipString','YObject: set of y coordinates defining the line') … … 319 321 end 320 322 case {'rectangle','ellipse'} 321 set(handles.num_RangeX_2,'TooltipString',['num_ XMax: half length of the ' ObjectStyle])322 set(handles.num_RangeY_2,'TooltipString',['num_ YMax: half width of the ' ObjectStyle])323 set(handles.num_RangeX_2,'TooltipString',['num_RangeX_2: half length of the ' ObjectStyle]) 324 set(handles.num_RangeY_2,'TooltipString',['num_RangeY_2: half width of the ' ObjectStyle]) 323 325 % set(handles.XObject,'TooltipString',['XObject: x coordinate of the ' Type ' centre']) 324 326 % set(handles.YObject,'TooltipString',['YObject: y coordinate of the ' Type ' centre']) … … 636 638 dir_save=uigetfile_uvmat('select the folder for the new xml object file:',RootPath,'uigetdir'); 637 639 if ~isempty(dir_save) 638 % dir_save=uigetdir(RootPath);639 640 ObjectName=get(handles.Name,'String'); 640 641 if ~isempty(ObjectName)&&~strcmp(ObjectName,'') 641 def= {fullfile(dir_save,[ObjectName '.xml'])};642 def=[ObjectName '.xml']; 642 643 else 643 def= {fullfile(dir_save,[Object.Style '.xml'])};644 end 645 displ_txt= 'save object as an .xml file';%default display644 def=[Object.Style '.xml']; 645 end 646 displ_txt={'save object as an .xml file in';dir_save};%default display 646 647 menu=get(handles.ProjMode,'String'); 647 648 value=get(handles.ProjMode,'Value'); 648 649 ProjMode=menu{value}; 649 650 if strcmp(ProjMode,'mask_inside')||strcmp(ProjMode,'mask_outside') 650 displ_txt='save mask contour as an .xml file: to create a mask image, use save_mask on the GUI uvmat (lower right)'; 651 end 652 answer=msgbox_uvmat('INPUT_TXT','save object as an .xml file',def); 653 if ~isempty(answer) 651 displ_txt={'save mask contour as an .xml file:'; 'to create a mask image, use save_mask on the GUI uvmat (lower right)'}; 652 end 653 answer=msgbox_uvmat('INPUT_TXT',displ_txt,def); 654 if iscell(answer) 655 FullName=fullfile(dir_save,answer{1}); 654 656 t=struct2xml(Object); 655 657 t=set(t,1,'name','ProjObject'); 656 save(t, answer{1})657 end658 msgbox_uvmat('CONFIRMATION',[answer{1} ' saved'])658 save(t,FullName) 659 msgbox_uvmat('CONFIRMATION',[FullName ' saved']) 660 end 659 661 end 660 662 -
trunk/src/uvmat.m
r674 r675 587 587 %------------------------------------------------------------------------ 588 588 %refresh the menu of input fieldname 589 Field s_Callback(hObject, eventdata, handles);589 FieldName_Callback(hObject, eventdata, handles); 590 590 % refresh the current field view 591 591 run0_Callback(hObject, eventdata, handles); … … 874 874 ColorType='falsecolor'; %default 875 875 UvData.MovieObject{index}=VideoObject; 876 if ~isempty(VideoObject) 876 if ~isempty(VideoObject)% case of video data 877 877 imainfo=get(VideoObject); 878 878 TimeUnit='s'; … … 883 883 XmlData.Time=[0;ones(size(i1_series,3)-1,1)]*(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate); 884 884 end 885 set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec885 %set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec 886 886 TimeName='video'; 887 887 ColorType='truecolor'; … … 963 963 (strcmp(FileType,'image')|| strcmp(FileType,'multimage')||strcmp(FileType,'civdata')||strcmp(FileType,'civx')) 964 964 TimeName='xml'; 965 elseif strcmp(FileType,'civdata') 966 TimeName='civdata'; 967 elseif strcmp(FileType,'civx') 968 TimeName='civx'; 965 969 end 966 970 if index==1 … … 1041 1045 1042 1046 %% update the data attached to the uvmat interface 1043 UvData.TimeUnit=TimeUnit; 1047 if ~isempty(TimeUnit) 1048 if index==2 && isfield(UvData,'TimeUnit') && ~strcmp(UvData.TimeUnit,TimeUnit) 1049 msgbox_uvmat('WARNING',['time unit for second file series ' TimeUnit ' inconsistent with first series']) 1050 else 1051 UvData.TimeUnit=TimeUnit; 1052 end 1053 end 1044 1054 UvData.XmlData{index}=XmlData; 1045 1055 UvData.NewSeries=1; … … 1194 1204 %------------------------------------------------------------------------ 1195 1205 %--- update the index display after action on edit boxes i1, i2, j1 or j2 1206 %------------------------------------------------------------------------ 1196 1207 function update_ij(handles,index_rank) 1208 1197 1209 NomType=get(handles.NomType,'String'); 1198 1210 indices=get(handles.FileIndex,'String'); … … 1310 1322 ListFiles=ListFiles(~check_dir);%list of file names (excluding dir) 1311 1323 if ~isempty(ListFiles) 1312 [tild,tild,MaskExt]=fileparts(ListFiles{1}); 1313 [tild,tild,MaskFile,i1_series,i2_series,j1_series,j2_series,MaskNomType,MaskFileType]=find_file_series(MaskPath,ListFiles{1},0); 1314 if strcmp(MaskFileType,'image') && isempty(i2_series) && isempty(j2_series) 1315 mdetect=1; 1316 end 1317 end 1324 for ifile=1:numel(ListFiles) 1325 [tild,tild,MaskExt]=fileparts(ListFiles{1}); 1326 [tild,tild,MaskFile{ifile},i1_series,i2_series,j1_series,j2_series,MaskNomType,MaskFileType]=find_file_series(MaskPath,ListFiles{ifile},0); 1327 if strcmp(MaskFileType,'image') && isempty(i2_series) && isempty(j2_series) 1328 mdetect=1; 1329 end 1330 if ~strcmp(MaskFile{ifile},MaskFile{1}) 1331 mdetect=0;% cancel detection test in case of multiple masks, use the brower for selection 1332 break 1333 end 1334 end 1335 end 1336 RootPath=MaskPath; 1318 1337 end 1319 1338 if mdetect==0 … … 1536 1555 set(handles.MovieBackward,'BusyAction','Cancel') 1537 1556 set(handles.MenuExportMovie,'BusyAction','Cancel') 1538 set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command buttonback to red1557 %set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command buttonback to red 1539 1558 set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red 1540 1559 set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red … … 1556 1575 InputFile.SubDir=regexprep(InputFile.SubDir,'^[\\/]|[\\/]$','');%suppress possible / or \ separator at the beginning or the end of the string 1557 1576 FileExt=InputFile.FileExt; 1558 NomType=get(handles.NomType,'String'); 1559 i1=str2num(get(handles.i1,'String'));%read the field indices (for movie, it is not given by the file name) 1560 i2=[];%default 1561 if strcmp(get(handles.i2,'Visible'),'on') 1562 i2=str2num(get(handles.i2,'String')); 1563 end 1564 j1=[]; 1565 if strcmp(get(handles.j1,'Visible'),'on') 1566 j1=stra2num(get(handles.j1,'String')); 1567 end 1568 j2=j1; 1569 if strcmp(get(handles.j2,'Visible'),'on') 1570 j2=stra2num(get(handles.j2,'String')); 1571 end 1577 NomType=InputFile.NomType; 1578 %NomType=get(handles.NomType,'String'); 1579 % i1=str2num(get(handles.i1,'String'));%read the field indices (for movie, it is not given by the file name) 1580 % i2=[];%default 1581 % if strcmp(get(handles.i2,'Visible'),'on') 1582 % i2=str2num(get(handles.i2,'String')); 1583 % end 1584 % j1=[]; 1585 % if strcmp(get(handles.j1,'Visible'),'on') 1586 % j1=stra2num(get(handles.j1,'String')); 1587 % end 1588 % j2=j1; 1589 % if strcmp(get(handles.j2,'Visible'),'on') 1590 % j2=stra2num(get(handles.j2,'String')); 1591 % end 1592 [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(InputFile.FileIndex);% check back the indices used 1593 1572 1594 sub_value= get(handles.SubField,'Value'); 1573 1595 if sub_value % a second input file has been entered … … 1584 1606 CheckFixPair=get(handles.CheckFixPair,'Value')||(isempty(i2)&&isempty(j2)); 1585 1607 1586 % i1_1=i1;1587 % i2_1=i2;1588 % j1_1=j1;1589 % j2_1=j2;1590 1608 % the pair i1-i2 or j1-j2 is imposed (check box CheckFixPair selected) 1591 1609 if CheckFixPair && isnumeric(increment) … … 1596 1614 i1_1=i1_1+increment; 1597 1615 i2_1=i2_1+increment; 1598 end 1616 end 1599 1617 else % case of scanning along index j (burst numbers) 1600 1618 j1=j1+increment; … … 1606 1624 end 1607 1625 1608 % the pair i1-i2 or j1-j2 is free (check box CheckFixPair not selected): the list of existing indices recorded in UvData is used1626 % the pair i1-i2 or j1-j2 is free (check box CheckFixPair not selected): the list of existing indices recorded in UvData is used 1609 1627 else 1610 1628 UvData=get(handles.uvmat,'UserData'); … … 1677 1695 end 1678 1696 1679 % case of a second file series 1697 % case of a second file series 1680 1698 if sub_value 1681 1699 ref_i_1=i1_1; … … 1698 1716 else % free increment, synchronise the ref indices with the first series 1699 1717 ref_i_1=ref_i; 1700 ref_j_1=ref_j; 1718 ref_j_1=ref_j; 1701 1719 end 1702 1720 if numel(UvData.i1_series)==1 … … 1734 1752 if ~isempty(UvData.j2_series{2}) 1735 1753 j2_1=UvData.j2_series{1}(ref_indices(end)); 1736 end 1754 end 1737 1755 else% the second series (if needed) is the same file as the first 1738 1756 i1_1=i1; … … 1743 1761 end 1744 1762 filename=fullfile_uvmat(InputFile.RootPath,InputFile.SubDir,InputFile.RootFile,FileExt,NomType,i1,i2,j1,j2); 1763 1764 %% refresh plots 1745 1765 if sub_value 1746 1766 filename_1=fullfile_uvmat(InputFile.RootPath_1,InputFile.SubDir_1,InputFile.RootFile_1,InputFile.FileExt_1,InputFile.NomType_1,i1_1,i2_1,j1_1,j2_1); 1767 errormsg=refresh_field(handles,filename,filename_1,i1,i2,j1,j2,i1_1,i2_1,j1_1,j2_1); 1768 else 1769 errormsg=refresh_field(handles,filename,filename_1,i1,i2,j1,j2); 1747 1770 end 1748 1771 1749 1772 %% refresh plots 1750 errormsg=refresh_field(handles,filename,filename_1,i1,i2,j1,j2,i1_1,i2_1,j1_1,j2_1);1773 % errormsg=refresh_field(handles,filename,filename_1,i1,i2,j1,j2,i1_1,i2_1,j1_1,j2_1); 1751 1774 1752 1775 %% update the index counters if the index move is successfull … … 1773 1796 set(handles.movie_pair,'Value',1) 1774 1797 movie_pair_Callback(hObject, eventdata, handles); %reactivate moviepair if it was activated 1775 end 1798 else 1799 if isempty(i2), set(handles.i2,'String',''); end % suppress the second index display if not used 1800 if isempty(j2), set(handles.j2,'String',''); end 1801 end 1802 set(handles.i1,'BackgroundColor',[1 1 1]) 1803 set(handles.i2,'BackgroundColor',[1 1 1]) 1804 set(handles.j1,'BackgroundColor',[1 1 1]) 1805 set(handles.j2,'BackgroundColor',[1 1 1]) 1806 set(handles.FileIndex,'BackgroundColor',[1 1 1]) 1807 set(handles.FileIndex_1,'BackgroundColor',[1 1 1]) 1776 1808 end 1777 1809 … … 1786 1818 set(handles.i2,'String','') 1787 1819 set(handles.j2,'String','') 1820 set(handles.Dt_txt,'String','') 1788 1821 return 1789 1822 else … … 1861 1894 end 1862 1895 1896 %% display time interval for the image pair 1897 if isfield(UvData,'XmlData')&&isfield(UvData.XmlData{1},'Time') 1898 dt=(UvData.XmlData{1}.Time(num_i2+1,num_j2+1)-UvData.XmlData{1}.Time(num_i1+1,num_j1+1)); 1899 if isfield(UvData,'TimeUnit') 1900 set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' m' UvData.TimeUnit] ) 1901 else 1902 set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) ' 10^(-3)'] ) 1903 end 1904 else 1905 set(handles.Dt_txt,'String','') 1906 end 1907 1863 1908 %% get the first image 1864 1909 %Field.AName='image'; … … 1875 1920 end 1876 1921 [Field_b,ParamOut,errormsg] = read_field(imaname_1,UvData.FileType{index},MovieObject,num_frame); 1877 % Field_b.AX=Field_a.AX;1878 % Field_b.AY=Field_a.AY;1879 % % z index1880 % nbslice=str2double(get(handles.num_NbSlice,'String'));1881 % if ~isempty(nbslice)1882 % Field_b.ZIndex=mod(num_i2-1,nbslice)+1;1883 % end1884 % Field_b.CoordUnit='pixel';1885 %1886 % %% determine the input file type1887 % if (test_1 && isfield(UvData,'MovieObject')&& numel(UvData.MovieObject>=2))||(~test_1 && ~isempty(UvData.MovieObject{1}))1888 % FileType='movie';1889 % elseif isequal(lower(Ext),'.avi')1890 % FileType='avi';1891 % elseif isequal(lower(Ext),'.vol')1892 % FileType='vol';1893 % else1894 % form=imformats(Ext(2:end));1895 % if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab1896 % if isequal(NomType,'*');1897 % FileType='multimage';1898 % else1899 % FileType='image';1900 % end1901 % end1902 % end1903 % switch FileType1904 % case 'movie'1905 % if test_11906 % Field_b.A=read(UvData.MovieObject{2},num_i2);1907 % else1908 % Field_b.A=read(UvData.MovieObject{1},num_i2);1909 % end1910 % case 'avi'1911 % mov=aviread(imaname_1,num_i2);1912 % Field_b.A=frame2im(mov(1));1913 % case 'vol'1914 % Field_b.A=imread(imaname_1);1915 % case 'multimage'1916 % Field_b.A=imread(imaname_1,num_i2);1917 % case 'image'1918 % Field_b.A=imread(imaname_1);1919 % end1920 % if get(handles.slices,'Value')1921 % Field.ZIndex=str2double(get(handles.z_index,'String'));1922 % end1923 1922 1924 1923 %px to phys or other transform on field … … 1933 1932 end 1934 1933 1935 1934 % make movie until movie speed is set to 0 or STOP is activated 1936 1935 hima=findobj(handles.PlotAxes,'Tag','ima');% %handles.PlotAxes =main plotting window (A GENERALISER) 1937 1936 set(handles.STOP,'Visible','on') 1938 1937 set(handles.speed,'Visible','on') 1939 1938 set(handles.speed_txt,'Visible','on') 1939 set(handles.i2,'BackgroundColor',[1 1 1])% mark the edit box in white to indicate its use as input 1940 set(handles.j2,'BackgroundColor',[1 1 1])% mark the edit box in white to indicate its use as input 1941 set(handles.FileIndex,'BackgroundColor',[1 1 1])% mark the edit box in white to indicate its use as input 1940 1942 while get(handles.speed,'Value')~=0 && isequal(get(handles.movie_pair,'BusyAction'),'queue')%isequal(get(handles.run0,'BusyAction'),'queue'); % enable STOP command 1941 1943 % read and plot the series of images in non erase mode … … 1946 1948 end 1947 1949 set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red 1948 set(handles.movie_pair,'Value',0) 1950 set(handles.movie_pair,'Value',0) 1951 set(handles.Dt_txt,'String','') 1949 1952 1950 1953 %------------------------------------------------------------------------ … … 1955 1958 drawnow 1956 1959 [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); 1960 [tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(FileIndex);% check back the indices used 1961 if isempty(i2), set(handles.i2,'String',''); end % suppress the second index display if not used 1962 if isempty(j2), set(handles.j2,'String',''); end 1957 1963 filename=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt]; 1958 1964 filename_1='';%default … … 1981 1987 set(handles.j2,'BackgroundColor',[1 1 1]) 1982 1988 set(handles.FileIndex,'BackgroundColor',[1 1 1]) 1983 set(handles.FileIndex_1,'BackgroundColor',[1 1 1]) 1989 set(handles.FileIndex_1,'BackgroundColor',[1 1 1]) 1984 1990 end 1985 1991 set(handles.run0,'BackgroundColor',[1 0 0]) … … 1991 1997 % errormsg: error message char string =[] by default 1992 1998 % INPUT: 1993 % filename: first input file (=[] in the absence of input file)1994 % filename_1: second input file (=[] in the asbsenc of secodninput file)1999 % FileName: first input file (=[] in the absence of input file) 2000 % FileName_1: second input file (=[] in the asbsence of second input file) 1995 2001 % num_i1,num_i2,num_j1,num_j2; frame indices 1996 % Field: structure describing an optional input field (then replace the input file)1997 2002 % i1_1,i2_1,j1_1,j2_1: frame indices for the second input file (needed if FileName_1 is not empty) 2003 %------------------------------------------------------------------------ 1998 2004 function errormsg=refresh_field(handles,FileName,FileName_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1) 1999 2005 %------------------------------------------------------------------------ … … 2320 2326 % get time in the input file, not defined in a xml file or movie 2321 2327 if isempty(abstime) 2322 if ~isempty(regexp(TimeName,'^att:'))||~isempty(regexp(TimeName,'^dim:'))||~isempty(regexp(TimeName,'^var:')) 2328 if strcmp(TimeName,'civdata')||strcmp(TimeName,'civx') 2329 abstime=Field{1}.Time; 2330 elseif ~isempty(regexp(TimeName,'^att:'))||~isempty(regexp(TimeName,'^dim:'))||~isempty(regexp(TimeName,'^var:')) 2323 2331 abstime=Field{1}.(TimeName(5:end));%the time is an attribute or variale selected by get_file 2324 2332 end … … 2362 2370 2363 2371 % get time in the input file of the second series, not defined in a xml file or movie 2364 if isempty(abstime_1) && numel(Field)==2 &&... 2365 ~isempty(regexp(TimeName_1,'^att:')) ||~isempty(regexp(TimeName_1,'^dim:'))||~isempty(regexp(TimeName_1,'^var:')) 2372 if isempty(abstime_1) && numel(Field)==2 2373 if strcmp(TimeName_1,'civdata')||strcmp(TimeName_1,'civx') 2374 abstime_1=Field{2}.Time; 2375 elseif ~isempty(regexp(TimeName_1,'^att:')) ||~isempty(regexp(TimeName_1,'^dim:'))||~isempty(regexp(TimeName_1,'^var:')) 2366 2376 abstime_1=Field{2}.(TimeName_1(5:end));%the time is an attribute or variale selected by get_file 2377 end 2367 2378 end 2368 2379 set(handles.TimeValue_1,'String',num2str(abstime_1,5)) … … 2806 2817 2807 2818 if ~get(handles.CheckFixLimits,'Value') 2808 update_plot(handles); 2819 update_plot(handles) 2820 set(handles.CheckZoom,'Value',0) 2809 2821 end 2810 2822 … … 3069 3081 YName={GetFieldData.Coordinates.Coord_y}; 3070 3082 CName=GetFieldData.PanelVectors.vec_color; 3071 [FieldList,VecColorList]=set_field_list(UName,VName,CName); 3083 FieldList={['vec(' UName ',' VName ')'];... 3084 ['norm(' UName ',' VName ')'];... 3085 UName;VName}; 3086 VecColorList={['norm(' UName ',' VName ')'];... 3087 UName;VName}; 3088 if ~isempty(CName) 3089 VecColorList=[{CName};VecColorList]; 3090 end 3072 3091 case 'scalar' 3073 3092 AName=GetFieldData.PanelScalar.scalar; -
trunk/src/xml2struct.m
r663 r675 48 48 case 'char' 49 49 out=ss; %reproduce the input string 50 if ~strcmp(ss,'image')% bug with Matlab str2num('image')-> child face 50 % try to convert to number if the char does not correspond to a function (otherwise str2num calls this function as it uses 'eval') 51 if ~isempty(regexp(ss,'^(-*\d+\.*\d*\ *)+$')) || ~isempty(regexp(ss,'\d+e(-|+)\d+')) % if the string corresponds to a set of numbers (with possible sign and decimal, or scientific notation) separated by blanks 51 52 out=str2num(ss); 52 %if isempty(regexp(ss,'^(-*\d+\.*\d*\ *)+$'))% if the string does not contain a set of numbers (with possible sign and decimal) separated by blanks 53 if isempty(out) 54 sep_ind=regexp(ss,'\s&\s');% check for separator ' & ' which indicates column separation in tables 55 if ~isempty(sep_ind) 56 sep_ind=[-2 sep_ind length(ss)+1]; 57 for icolumn=1:length(sep_ind)-1 58 out{1,icolumn}=ss(sep_ind(icolumn)+3:sep_ind(icolumn+1)-1); 59 end 60 else 61 out=ss; %reproduce the input string 53 else 54 sep_ind=regexp(ss,'\s&\s');% check for separator ' & ' which indicates column separation in tables 55 if ~isempty(sep_ind) 56 sep_ind=[-2 sep_ind length(ss)+1]; 57 for icolumn=1:length(sep_ind)-1 58 out{1,icolumn}=ss(sep_ind(icolumn)+3:sep_ind(icolumn+1)-1); 62 59 end 60 else 61 out=ss; %reproduce the input string 63 62 end 64 63 end
Note: See TracChangeset
for help on using the changeset viewer.