- Timestamp:
- Aug 31, 2012, 11:44:55 AM (12 years ago)
- Location:
- trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/calc_field_interp.m
r521 r533 60 60 for ilist=1:numel(Operation) 61 61 if ~check_skipped(ilist) 62 nbvar=numel(ListVarName); 63 switch Operator{ilist} 64 case 'vec' 65 if exist('XI','var') 66 VarVal{nbvar+1}=F.(UName{ilist})(XI,YI); 67 VarVal{nbvar+2}=F.(VName{ilist})(XI,YI); 68 else 69 VarVal{nbvar+1}=Data.(UName{ilist}); 70 VarVal{nbvar+2}=Data.(VName{ilist}); 71 end 72 ListVarName{nbvar+1}=UName{ilist}; 73 ListVarName{nbvar+2}=VName{ilist}; 74 VarAttribute{nbvar+1}.Role='vector_x'; 75 VarAttribute{nbvar+2}.Role='vector_y'; 76 case 'norm' 77 if exist('XI','var') 78 U2=F.(UName{ilist})(XI,YI).*F.(UName{ilist})(XI,YI); 79 V2=F.(VName{ilist})(XI,YI).*F.(VName{ilist})(XI,YI); 80 else 81 U2=Data.(UName{ilist}).*Data.(UName{ilist}); 82 V2=Data.(VName{ilist}).*Data.(VName{ilist}); 83 end 84 VarVal{nbvar+1}=sqrt(U2+V2); 85 ListVarName{nbvar+1}='norm'; 86 VarAttribute{nbvar+1}.Role='scalar'; 87 otherwise 88 if ~isempty(Operation{ilist}) 62 nbvar=numel(ListVarName); 63 switch Operator{ilist} 64 case 'vec' 89 65 if exist('XI','var') 90 VarVal{nbvar+1}=F.(Operation{ilist})(XI,YI); 66 VarVal{nbvar+1}=F.(UName{ilist})(XI,YI); 67 VarVal{nbvar+2}=F.(VName{ilist})(XI,YI); 91 68 else 92 VarVal{nbvar+1}= Data.(Operation{ilist}); 69 VarVal{nbvar+1}=Data.(UName{ilist}); 70 VarVal{nbvar+2}=Data.(VName{ilist}); 93 71 end 94 ListVarName{nbvar+1}=Operation{ilist}; 72 ListVarName{nbvar+1}=UName{ilist}; 73 ListVarName{nbvar+2}=VName{ilist}; 74 VarAttribute{nbvar+1}.Role='vector_x'; 75 VarAttribute{nbvar+2}.Role='vector_y'; 76 case 'norm' 77 if exist('XI','var') 78 U2=F.(UName{ilist})(XI,YI).*F.(UName{ilist})(XI,YI); 79 V2=F.(VName{ilist})(XI,YI).*F.(VName{ilist})(XI,YI); 80 else 81 U2=Data.(UName{ilist}).*Data.(UName{ilist}); 82 V2=Data.(VName{ilist}).*Data.(VName{ilist}); 83 end 84 VarVal{nbvar+1}=sqrt(U2+V2); 85 ListVarName{nbvar+1}='norm'; 95 86 VarAttribute{nbvar+1}.Role='scalar'; 96 end 97 end 87 otherwise 88 if ~isempty(Operation{ilist}) 89 if exist('XI','var') 90 VarVal{nbvar+1}=F.(Operation{ilist})(XI,YI); 91 else 92 VarVal{nbvar+1}= Data.(Operation{ilist}); 93 end 94 ListVarName{nbvar+1}=Operation{ilist}; 95 VarAttribute{nbvar+1}.Role='scalar'; 96 end 97 end 98 98 end 99 99 end 100 100 % put an error flag to indicate NaN data 101 101 if exist('XI','var') 102 nbvar=numel(ListVarName);103 ListVarName{nbvar+1}='FF';104 VarVal{nbvar+1}=isnan(VarVal{nbvar});105 VarAttribute{nbvar+1}.Role='errorflag';102 nbvar=numel(ListVarName); 103 ListVarName{nbvar+1}='FF'; 104 VarVal{nbvar+1}=isnan(VarVal{nbvar}); 105 VarAttribute{nbvar+1}.Role='errorflag'; 106 106 end 107 107 -
trunk/src/proj_field.m
r530 r533 184 184 % 185 185 % select types of variables to be projected 186 ListProj ect={'VarIndex_scalar','VarIndex_image','VarIndex_color','VarIndex_vector_x','VarIndex_vector_y'};187 check_project=false(size(VarIndex));188 for ilist=1:numel(ListProj ect)189 if isfield(CellInfo{icell},ListProj ect{ilist})190 check_proj ect(CellInfo{icell}.(ListProject{ilist}))=1;186 ListProj={'VarIndex_scalar','VarIndex_image','VarIndex_color','VarIndex_vector_x','VarIndex_vector_y'}; 187 check_proj=false(size(FieldData.ListVarName)); 188 for ilist=1:numel(ListProj) 189 if isfield(CellInfo{icell},ListProj{ilist}) 190 check_proj(CellInfo{icell}.(ListProj{ilist}))=1; 191 191 end 192 192 end 193 VarIndex=VarIndex(check_project); 194 195 % if isempty(ivar_X) 196 % test_grid=1;%test for input data on regular grid (e.g. image)coordinates 197 % else 198 % if length(ivar_X)>1 || length(ivar_Y)>1 || length(ivar_Z)>1 199 % errormsg='multiple coordinate input in proj_field.m'; 200 % return 201 % end 202 % if length(ivar_Y)~=1 203 % errormsg='y coordinate not defined in proj_field.m'; 204 % return 205 % end 206 % test_grid=0; 207 % end 193 VarIndex=find(check_proj); 208 194 ProjData.ListVarName={'Y','X','NbVal'}; 209 195 ProjData.VarDimName={'nb_points','nb_points','nb_points'}; … … 360 346 361 347 %group the variables (fields of 'FieldData') in cells of variables with the same dimensions 362 testfalse=0;363 ListIndex={};364 % DimVarIndex=0;%initilise list of indices for dimension variables365 idimvar=0;366 348 [CellInfo,NbDim,errormsg]=find_field_cells(FieldData); 367 %[CellVarIndex,NbDim,VarTypeCell,errormsg]=find_field_cells(FieldData);368 349 if ~isempty(errormsg) 369 350 errormsg=['error in proj_field/proj_patch:' errormsg]; … … 372 353 373 354 %LOOP ON GROUPS OF VARIABLES SHARING THE SAME DIMENSIONS 374 dimcounter=0;375 355 for icell=1:length(CellInfo) 376 356 testX=0; 377 357 testY=0; 378 358 test_Amat=0; 379 testfalse=0;380 VarIndex=CellInfo{icell}.VarIndex;% indices of the selected variables in the list FieldData.ListVarName381 % VarType=VarTypeCell{icell};382 % DimIndices=FieldData.VarDimIndex{VarIndex(1)};%indices of the dimensions of the first variable (common to all variables in the cell)383 359 if NbDim(icell)~=2% proj_patch acts only on fields of space dimension 2 384 360 continue 385 361 end 386 %testX=~isempty(VarType.coord_x) && ~isempty(VarType.coord_y);362 ivar_FF=[]; 387 363 testfalse=isfield(CellInfo{icell},'VarIndex_errorflag'); 388 testproj(VarIndex)=zeros(size(VarIndex));%default 364 if testfalse 365 ivar_FF=CellInfo{icell}.VarIndex_errorflag; 366 FFName=FieldData.ListVarName{ivar_FF}; 367 errorflag=FieldData.(FFName); 368 end 369 % select types of variables to be projected 370 ListProj={'VarIndex_scalar','VarIndex_image','VarIndex_color','VarIndex_vector_x','VarIndex_vector_y'}; 371 check_proj=false(size(FieldData.ListVarName)); 372 for ilist=1:numel(ListProj) 373 if isfield(CellInfo{icell},ListProj{ilist}) 374 check_proj(CellInfo{icell}.(ListProj{ilist}))=1; 375 end 376 end 377 VarIndex=find(check_proj); 378 389 379 ivar_X=CellInfo{icell}.CoordIndex(end); 390 380 ivar_Y=CellInfo{icell}.CoordIndex(end-1); 391 381 ivar_Z=[]; 392 if NbDim Array(icell)==3382 if NbDim(icell)==3 393 383 ivar_Z=CellInfo{icell}.CoordIndex(1); 394 384 end 395 ivar_rem=[];396 if isfield(CellInfo{icell},'VarIndex_ancillary')397 ivar_rem=CellInfo{icell}.VarIndex_ancillary;398 end399 if isfield(CellInfo{icell},'VarIndex_warnflag')400 ivar_rem=[ivar_rem CellInfo{icell}.VarIndex_warnflag];401 end402 if isfield(CellInfo{icell},'VarIndex_errorflag')403 ivar_rem=[ivar_rem CellInfo{icell}.VarIndex_errorflag];404 ivar_FF=CellInfo{icell}.VarIndex_errorflag;405 end406 VarIndex([ivar_X ivar_Y ivar_Z ivar_rem])=[];% not projected variables removed frlom list407 408 385 if strcmp(CellInfo{icell}.CoordType,'scattered')%case of unstructured coordinates 409 eval(['nbpoint=numel(FieldData.' FieldData.ListVarName{VarIndex(1)} ');']) 410 for ivar=[VarIndex VarType.coord_x VarType.coord_y VarType.errorflag] 411 VarName=FieldData.ListVarName{ivar}; 412 eval(['FieldData.' VarName '=reshape(FieldData.' VarName ',nbpoint,1);']) 413 end 414 XName=FieldData.ListVarName{CellInfo{icell}.CoordIndex(end)}; 415 YName=FieldData.ListVarName{CellInfo{icell}.CoordIndex(end-1)}; 416 eval(['coord_x=FieldData.' XName ';']) 417 eval(['coord_y=FieldData.' YName ';']) 418 end 419 if testfalse 420 FFName=FieldData.ListVarName{VarType.errorflag}; 421 eval(['errorflag=FieldData.' FFName ';']) 386 %nbpoint=numel(FieldData.(FieldData.ListVarName{VarIndex(1)})); 387 for ivar=[VarIndex ivar_X ivar_Y ivar_FF] 388 VarName=FieldData.ListVarName{ivar}; 389 FieldData.(VarName)=reshape(FieldData.(VarName),[],1); 390 end 391 XName=FieldData.ListVarName{ivar_X}; 392 YName=FieldData.ListVarName{ivar_Y}; 393 coord_x=FieldData.(XName); 394 coord_y=FieldData.(YName); 422 395 end 423 396 % image or 2D matrix … … 430 403 VarName=FieldData.ListVarName{VarIndex(1)}; 431 404 DimValue=size(FieldData.(VarName)); 432 if length(AX)==2 433 AX=linspace(AX(1),AX(end),DimValue(2)); 434 end 435 if length(AY)==2 436 AY=linspace(AY(1),AY(end),DimValue(1)); 437 end 438 % for idim=1:length(DimValue) 439 % Coord_i_str=['Coord_' num2str(idim)]; 440 % DCoord_min(idim)=1;%default 441 % Coord{idim}=[0.5 DimValue(idim)]; 442 % test_direct(idim)=1; 443 % end 444 % AX=linspace(Coord{2}(1),Coord{2}(2),DimValue(2)); 445 % AY=linspace(Coord{1}(1),Coord{1}(2),DimValue(1)); %TODO : 3D case 446 % testcolor=find(numel(DimValue)==3); 405 if length(AX)==2 406 AX=linspace(AX(1),AX(end),DimValue(2)); 407 end 408 if length(AY)==2 409 AY=linspace(AY(1),AY(end),DimValue(1)); 410 end 447 411 if length(DimValue)==3 448 412 testcolor=1; … … 459 423 for ivar=1:length(VarIndex) 460 424 VarName=FieldData.ListVarName{VarIndex(ivar)}; 461 FieldData.(VarName)=reshape(FieldData.(VarName),npxy(1)*npxy(2),npxy(3)); % keep only non false vectors 462 end 463 end 464 %select the indices in the range of action425 FieldData.(VarName)=reshape(FieldData.(VarName),npxy(1)*npxy(2),npxy(3)); % keep only non false vectors 426 end 427 end 428 %select the indices in the range of action 465 429 testin=[];%default 466 430 if isequal(ObjectData.Type,'rectangle') 467 % if ~isfield(ObjectData,'RangeX')|~isfield(ObjectData,'RangeY') 468 % errormsg='rectangle half sides RangeX and RangeY needed' 469 % return 470 % end 471 if testX 431 if strcmp(CellInfo{icell}.CoordType,'scattered') 472 432 distX=abs(coord_x-ObjectData.Coord(1,1)); 473 433 distY=abs(coord_y-ObjectData.Coord(1,2)); 474 434 testin=distX<widthx & distY<widthy; 475 elseif test_Amat476 distX=abs(Xi-ObjectData.Coord(1,1));477 distY=abs(Yi-ObjectData.Coord(1,2));478 testin=distX<widthx & distY<widthy;479 end435 elseif test_Amat 436 distX=abs(Xi-ObjectData.Coord(1,1)); 437 distY=abs(Yi-ObjectData.Coord(1,2)); 438 testin=distX<widthx & distY<widthy; 439 end 480 440 elseif isequal(ObjectData.Type,'polygon') 481 441 if testX 482 442 testin=inpolygon(coord_x,coord_y,ObjectData.Coord(:,1),ObjectData.Coord(:,2)); 483 443 elseif test_Amat 484 testin=inpolygon(Xi,Yi,ObjectData.Coord(:,1),ObjectData.Coord(:,2));485 else%calculate the scalar486 testin=[]; %A REVOIR487 end444 testin=inpolygon(Xi,Yi,ObjectData.Coord(:,1),ObjectData.Coord(:,2)); 445 else%calculate the scalar 446 testin=[]; %A REVOIR 447 end 488 448 elseif isequal(ObjectData.Type,'ellipse') 489 X2Max=widthx*widthx;490 Y2Max=(widthy)*(widthy);491 if testX449 X2Max=widthx*widthx; 450 Y2Max=(widthy)*(widthy); 451 if testX 492 452 distX=(coord_x-ObjectData.Coord(1,1)); 493 453 distY=(coord_y-ObjectData.Coord(1,2)); 494 454 testin=(distX.*distX/X2Max+distY.*distY/Y2Max)<1; 495 elseif test_Amat %case of usual 2x2 matrix496 distX=(Xi-ObjectData.Coord(1,1));497 distY=(Yi-ObjectData.Coord(1,2));498 testin=(distX.*distX/X2Max+distY.*distY/Y2Max)<1;499 end455 elseif test_Amat %case of usual 2x2 matrix 456 distX=(Xi-ObjectData.Coord(1,1)); 457 distY=(Yi-ObjectData.Coord(1,2)); 458 testin=(distX.*distX/X2Max+distY.*distY/Y2Max)<1; 459 end 500 460 end 501 461 %selected indices 502 462 if isequal(ObjectData.ProjMode,'outside') 503 463 testin=~testin; 504 464 end 505 465 if testfalse 506 testin=testin & (errorflag==0); % keep only non false vectors 466 testin=testin & (errorflag==0); % keep only non false vectors 507 467 end 508 468 indsel=find(testin); 509 469 for ivar=VarIndex 510 if testproj(ivar) 511 VarName=FieldData.ListVarName{ivar}; 512 ProjData.([VarName 'Mean'])=mean(double(FieldData.(VarName)(indsel,:))); % take the mean in the selected region, for each color component 513 ProjData.([VarName 'Min'])=min(double(FieldData.(VarName)(indsel,:))); % take the min in the selected region , for each color component 514 ProjData.([VarName 'Max'])=max(double(FieldData.(VarName)(indsel,:))); % take the max in the selected region , for each color component 515 if isequal(Mesh(ivar),0) 516 eval(['[ProjData.' VarName 'Histo,ProjData.' VarName ']=hist(double(FieldData.' VarName '(indsel,:,:)),100);']); % default histogram with 100 bins 517 else 518 eval(['ProjData.' VarName '=(ProjData.' VarName 'Min+Mesh(ivar)/2:Mesh(ivar):ProjData.' VarName 'Max);']); % list of bin values 519 eval(['ProjData.' VarName 'Histo=hist(double(FieldData.' VarName '(indsel,:)),ProjData.' VarName ');']); % histogram at predefined bin positions 520 end 521 ProjData.ListVarName=[ProjData.ListVarName {VarName} {[VarName 'Histo']} {[VarName 'Mean']} {[VarName 'Min']} {[VarName 'Max']}]; 522 if test_Amat && testcolor 523 ProjData.VarDimName=[ProjData.VarDimName {VarName} {{VarName,'rgb'}} {'rgb'} {'rgb'} {'rgb'}];%{{'nb_point','rgb'}}; 524 else 525 ProjData.VarDimName=[ProjData.VarDimName {VarName} {VarName} {'one'} {'one'} {'one'}]; 526 end 527 ProjData.VarAttribute=[ProjData.VarAttribute FieldData.VarAttribute{ivar} {[]} {[]} {[]} {[]}]; 528 end 529 end 530 % if test_Amat & testcolor 531 % %ProjData.ListDimName=[ProjData.ListDimName {'rgb'}]; 532 % % ProjData.DimValue=[ProjData.DimValue 3]; 533 % % ProjData.VarDimIndex={[1 2]}; 534 % ProjData.VarDimName=[ProjData.VarDimName {VarName} {VarName,'rgb'}];%{{'nb_point','rgb'}}; 535 % ProjData.VarDimName 536 % end 470 VarName=FieldData.ListVarName{ivar}; 471 ProjData.([VarName 'Mean'])=mean(double(FieldData.(VarName)(indsel,:))); % take the mean in the selected region, for each color component 472 ProjData.([VarName 'Min'])=min(double(FieldData.(VarName)(indsel,:))); % take the min in the selected region , for each color component 473 ProjData.([VarName 'Max'])=max(double(FieldData.(VarName)(indsel,:))); % take the max in the selected region , for each color component 474 if isequal(Mesh(ivar),0) 475 eval(['[ProjData.' VarName 'Histo,ProjData.' VarName ']=hist(double(FieldData.' VarName '(indsel,:,:)),100);']); % default histogram with 100 bins 476 else 477 eval(['ProjData.' VarName '=(ProjData.' VarName 'Min+Mesh(ivar)/2:Mesh(ivar):ProjData.' VarName 'Max);']); % list of bin values 478 eval(['ProjData.' VarName 'Histo=hist(double(FieldData.' VarName '(indsel,:)),ProjData.' VarName ');']); % histogram at predefined bin positions 479 end 480 ProjData.ListVarName=[ProjData.ListVarName {VarName} {[VarName 'Histo']} {[VarName 'Mean']} {[VarName 'Min']} {[VarName 'Max']}]; 481 if test_Amat && testcolor 482 ProjData.VarDimName=[ProjData.VarDimName {VarName} {{VarName,'rgb'}} {'rgb'} {'rgb'} {'rgb'}];%{{'nb_point','rgb'}}; 483 else 484 ProjData.VarDimName=[ProjData.VarDimName {VarName} {VarName} {'one'} {'one'} {'one'}]; 485 end 486 ProjData.VarAttribute=[ProjData.VarAttribute FieldData.VarAttribute{ivar} {[]} {[]} {[]} {[]}]; 487 end 537 488 end 538 489 … … 615 566 616 567 % select types of variables to be projected 617 ListProj ect={'VarIndex_scalar','VarIndex_image','VarIndex_color','VarIndex_vector_x','VarIndex_vector_y'};618 check_proj ect=false(size(FieldData.ListVarName));619 for ilist=1:numel(ListProj ect)620 if isfield(CellInfo{icell},ListProj ect{ilist})621 check_proj ect(CellInfo{icell}.(ListProject{ilist}))=1;568 ListProj={'VarIndex_scalar','VarIndex_image','VarIndex_color','VarIndex_vector_x','VarIndex_vector_y'}; 569 check_proj=false(size(FieldData.ListVarName)); 570 for ilist=1:numel(ListProj) 571 if isfield(CellInfo{icell},ListProj{ilist}) 572 check_proj(CellInfo{icell}.(ListProj{ilist}))=1; 622 573 end 623 574 end 624 VarIndex=find(check_proj ect);575 VarIndex=find(check_proj); 625 576 626 577 %identify vector components -
trunk/src/read_civxdata.m
r530 r533 85 85 end 86 86 var_ind=find(vardetect); 87 %for ilist=1:length(FieldNames)88 % testinterp=~isempty(regexp(FieldNames{ilist},'(^curl|^div|strain|norm)', 'once'));%test need for gridded data89 %if testinterp, break;end90 %end87 for ilist=1:length(FieldNames) 88 testinterp=isempty(regexp(FieldNames{ilist},'(^vec|^C)', 'once'));%test need for gridded data 89 if testinterp, break;end 90 end 91 91 for ivar=1:length(var_ind) 92 92 Field.VarAttribute{ivar}.Role=role{var_ind(ivar)}; … … 94 94 if strcmp(role{var_ind(ivar)},'vector_x') 95 95 Field.VarAttribute{ivar}.Operation=FieldNames; 96 if testinterp 97 Field.VarAttribute{ivar}.FieldRequest='interp_lin'; 98 end 96 99 end 97 100 end … … 151 154 Field.Dt=0; 152 155 end 153 154 155 156 156 157 %% rescale fields to pixel coordinates -
trunk/src/series.m
r526 r533 978 978 979 979 %% set the waitbar position with respect to the min and max in the series 980 % for iview=1:numel(SeriesData.i1_series)981 % [tild,index_min(iview)]=min(SeriesData.i1_series{iview}(SeriesData.i1_series{iview}>0));982 % [tild,index_max(iview)]=max(SeriesData.i1_series{iview}(SeriesData.i1_series{iview}>0));983 % end984 980 for iview=1:numel(SeriesData.i1_series) 985 981 pair_max{iview}=squeeze(max(SeriesData.i1_series{iview},[],1)); %max on pair index … … 994 990 [index_max,iview_max]=min(index_max); 995 991 if size(SeriesData.i1_series{iview_min},2)==1% movie 996 index_first=ref_i(1); 997 index_last=ref_i(2); 998 else 999 %index_first=(ref_i(1)-1)*(size(SeriesData.i1_series{iview_min},2)-1)+ref_j(1); 1000 %index_last=(ref_i(2)-1)*(size(SeriesData.i1_series{iview_max},2)-1)+ref_j(2); 1001 index_first=(ref_i(1))*(size(SeriesData.i1_series{iview_min},2))+ref_j(1)+1; 1002 index_last=(ref_i(2))*(size(SeriesData.i1_series{iview_max},2))+ref_j(2)+1; 992 index_first=ref_i(1); 993 index_last=ref_i(2); 994 else 995 index_first=(ref_i(1)-1)*(size(SeriesData.i1_series{iview_min},1))+ref_j(1)+1; 996 index_last=(ref_i(2)-1)*(size(SeriesData.i1_series{iview_max},1))+ref_j(2)+1; 1003 997 end 1004 998 range=index_max-index_min+1; 1005 999 coeff_min=(index_first-index_min)/range; 1006 1000 coeff_max=(index_last-index_min+1)/range; 1007 Position=get(handles.Waitbar,'Position'); 1001 Position=get(handles.Waitbar,'Position');% position of the waitbar:= [ x,y, width, height] 1008 1002 Position_status=get(handles.FileStatus,'Position'); 1009 1003 Position(1)=coeff_min*Position_status(3)+Position_status(1); -
trunk/src/set_object.m
r511 r533 213 213 if ~isempty(hseries) 214 214 hhseries=guidata(hseries); 215 set(hhseries. GetObject,'Value',0)216 set(hhseries. GetObject,'BackgroundColor',[0 1 0])%put unactivated buttons to green215 set(hhseries.CheckObject,'Value',0) 216 set(hhseries.CheckObject,'BackgroundColor',[0 1 0])%put unactivated buttons to green 217 217 end 218 218
Note: See TracChangeset
for help on using the changeset viewer.