- Timestamp:
- Mar 4, 2015, 12:01:38 AM (10 years ago)
- Location:
- trunk/src
- Files:
-
- 1 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/keyboard_callback.m
r809 r880 65 65 end 66 66 case 112% key 'p' 67 uvmat('runplus_Callback',hObject,eventdata,handleshaxes) 67 huvmat=findobj(allchild(0),'Tag','uvmat'); 68 if ~isempty(huvmat) 69 hhuvmat=guidata(huvmat); 70 uvmat('runplus_Callback',hObject,eventdata,hhuvmat) 71 end 68 72 case 109% key 'm' 73 huvmat=findobj(allchild(0),'Tag','uvmat'); 74 if ~isempty(huvmat) 75 hhuvmat=guidata(huvmat); 69 76 uvmat('runmin_Callback',hObject,eventdata,handleshaxes) 77 end 70 78 otherwise 71 79 if ischar(get(gco,'Tag')) -
trunk/src/plot_field.m
r874 r880 224 224 if ~(isfield(PlotParamOut,'Axes')&&isfield(PlotParamOut.Axes,'TextDisplay')&&(PlotParamOut.Axes.TextDisplay)) % if text is not already given as statistics 225 225 htext=findobj(hfig,'Tag','TableDisplay'); 226 % hchecktable=findobj(hfig,'Tag','CheckTable');227 226 if ~isempty(htext)%&&~isempty(hchecktable) 228 227 if isempty(index_0D) … … 577 576 578 577 %% give statistics for pdf 579 ind_var=find(testplot);578 %ind_var=find(testplot); 580 579 TableData={'Variable';'SampleNbr';'bin size';'Mean';'RMS';'Skewness';'Kurtosis';' centered ';... 581 580 'Min';'FirstCentile';'FirstDecile';'Median';'LastDecile';'LastCentile';'Max'}; 582 %PlotParamOut.TableDisplay={}; 581 583 582 TextDisplay=0; 584 583 for icell=1:numel(CellInfo) 585 584 if isfield(CellInfo{icell},'VarIndex_histo') 586 check_stat=1;587 585 TextDisplay=1; 588 586 VarName=data.ListVarName{CellInfo{icell}.CoordIndex}; 589 587 pdf_val=data.(data.ListVarName{CellInfo{icell}.VarIndex_histo}); 590 588 x=coord_x{icell}; 591 Val=zeros(12,1); 592 Val(1)=sum(pdf_val);% total sample number 593 Val(7)=min(x); 594 Val(13)=max(x); 595 Val(2)=(Val(13)-Val(7))/(numel(x)-1);%bin size 596 pdf_val=pdf_val/Val(1);% normalised pdf 597 Val(3)=sum(x.*pdf_val);%Mean 598 x=x-Val(3); %centered variable 599 Variance=sum(x.*x.*pdf_val); 600 Val(4)=sqrt(Variance); 601 Val(5)=(sum(x.*x.*x.*pdf_val))/(Variance*Val(4));%skewness 602 Val(6)=(sum(x.*x.*x.*x.*pdf_val))/(Variance*Variance);%kurtosis 603 cumpdf=cumsum(pdf_val);% sum of pdf 604 ind_centile=find(cumpdf>=0.01,1);% first index with cumsum >=0.01 605 Val(8)=x(ind_centile)+Val(2)/2;% 606 if ind_centile>1 607 Val(8)=(cumpdf(ind_centile)-0.01)*x(ind_centile-1)+(0.01-cumpdf(ind_centile-1))*x(ind_centile); 608 Val(8)=Val(8)/(cumpdf(ind_centile)-cumpdf(ind_centile-1))+Val(2)/2;%linear interpolation near ind_centile 609 end 610 ind_decile=find(cumpdf>=0.1,1); 611 if ind_decile>1 612 Val(9)=x(ind_decile)+Val(2)/2;% 613 Val(9)=(cumpdf(ind_decile)-0.1)*x(ind_decile-1)+(0.1-cumpdf(ind_decile-1))*x(ind_decile); 614 Val(9)=Val(9)/(cumpdf(ind_decile)-cumpdf(ind_decile-1))+Val(2)/2;%linear interpolation near ind_decile; 615 end 616 ind_median=find(cumpdf>= 0.5,1); 617 Val(10)=(cumpdf(ind_median)-0.5)*x(ind_median-1)+(0.5-cumpdf(ind_median-1))*x(ind_median); 618 Val(10)=Val(10)/(cumpdf(ind_median)-cumpdf(ind_median-1))+Val(2)/2;%linear interpolation near ind_median; 619 % Val(9)=x(ind_median); 620 ind_decile=find(cumpdf>=0.9,1); 621 Val(11)=(cumpdf(ind_decile)-0.9)*x(ind_decile-1)+(0.9-cumpdf(ind_decile-1))*x(ind_decile); 622 Val(11)=Val(11)/(cumpdf(ind_decile)-cumpdf(ind_decile-1))+Val(2)/2;%linear interpolation near ind_median; 623 ind_centile=find(cumpdf>=0.99,1); 624 Val(12)=(cumpdf(ind_centile)-0.99)*x(ind_centile-1)+(0.99-cumpdf(ind_centile-1))*x(ind_centile); 625 Val(12)=Val(12)/(cumpdf(ind_centile)-cumpdf(ind_centile-1))+Val(2)/2;%linear interpolation near ind_centile; 589 590 Val=pdf2stat(x',pdf_val'); 591 626 592 Column=mat2cell(Val,ones(13,1),1); 627 593 Column=[{VarName};Column(1:6);{'stat: --'};Column(7:13)]; … … 632 598 disp(TableData); 633 599 PlotParamOut.TableDisplay=TableData; 634 % PlotParamOut.CheckTable=1;635 % htable=findobj(hfig,'Tag','TableDisplay');636 % set(htable,'Data',TableData)637 % set(htable,'Visible','on')638 % drawnow639 600 else 640 601 if isfield(PlotParamOut,'TableDisplay') -
trunk/src/proj_field.m
r873 r880 509 509 VarSize(nbvar)=mean((ProjData.([VarName 'Max'])-ProjData.([VarName 'Min']))/100); 510 510 end 511 if isempty(VarMesh) || isnan(VarMesh) % mesh not specified as input, estimate from the bounds511 if isempty(VarMesh)% || isnan(VarMesh) % mesh not specified as input, estimate from the bounds 512 512 VarMesh=mean(VarSize); 513 513 ord=10^(floor(log10(VarMesh)));%order of magnitude … … 524 524 LowBound=VarMesh*ceil(ProjData.([VarName 'Min'])/VarMesh); 525 525 UpperBound=VarMesh*floor(ProjData.([VarName 'Max'])/VarMesh); 526 if numel(indsel)<=1 527 errormsg='only one data point or less for histogram'; 528 return 529 elseif isequal(LowBound,UpperBound) 530 errormsg='attempt histogram of uniform field: low bound = high bound'; 531 return 532 end 526 533 ProjData.(VarName)=LowBound:VarMesh:UpperBound; % list of bin values 527 534 ProjData.([VarName 'Histo'])=hist(double(FieldData.(VarName)(indsel,:)),ProjData.(VarName)); % histogram at predefined bin positions -
trunk/src/read_field.m
r871 r880 283 283 Field.Coord_y=[npxy(1)-0.5 0.5]; 284 284 Field.Coord_x=[0.5 npxy(2)-0.5]; % coordinates of the first and last pixel centers 285 ParamOut.Npx=npxy(2);% display image size on the interface286 ParamOut.Npy=npxy(1);285 % ParamOut.Npx=npxy(2);% display image size on the interface 286 % ParamOut.Npy=npxy(1); 287 287 % Field.VarAttribute{3}.Mesh=1; 288 288 end -
trunk/src/series.m
r876 r880 140 140 ActionExtList={'.m';'.sh';'.py (in dev.)'};% default choice of extensions (Matlab fct .m or compiled version .sh 141 141 else 142 ActionExtList={'.m';'.sh'}; 143 disp('python library not installed') 142 ActionExtList={'.m';'.sh'}; % python options not installed 144 143 end 145 144 ActionPathList=cell(NbBuiltinAction,1);%initiate the cell matrix of Action fct paths … … 149 148 if isequal(s,0) 150 149 RunModeList=[RunModeList;{'cluster_oar'}]; 150 set(handles.MonitorCluster,'Visible','on'); % make visible button for access to Monika 151 151 end 152 152 [s,w]=system('qstat');% look for cluster system 'sge' … … 596 596 function InputTable_KeyPressFcn(hObject, eventdata, handles) 597 597 set(handles.REFRESH,'BackgroundColor',[1 0 1])% set REFRESH button to magenta color to indicate that input refresh is needed 598 set(handles.OutputSubDir,'BackgroundColor',[1 0 1])% set edit box OutputSubDir to magenta color to indicate that refresh may be needed 598 599 xx=double(get(handles.series,'CurrentCharacter')); %get the keyboard character 599 600 if ~isempty(xx) … … 1500 1501 compile(ActionName,TransformPath) 1501 1502 cd(currentdir) 1503 else 1504 errormsg='Action launch interrupted'; 1505 return 1502 1506 end 1503 1507 else … … 1530 1534 if strcmp(ActionExt,'.m')% case of Matlab function (uncompiled) 1531 1535 NbCore=1;% one core used only (limitation of Matlab licences) 1532 msgbox_uvmat('WARNING','Number of cores =1: select the compiled version .sh for multi-core processing'); 1536 answer=msgbox_uvmat('INPUT_Y-N','Number of cores =1: select the compiled version .sh for multi-core processing. Proceed with the .m version?'); 1537 if ~strcmp(answer,'Yes') 1538 errormsg='Action launch interrupted'; 1539 return 1540 end 1533 1541 extra_oar=''; 1534 1542 else … … 1558 1566 answer=msgbox_uvmat('INPUT_Y-N-Cancel',['use existing ouput directory: ' fullfile(Param.InputTable{1,1},SubDirOutNew) ', possibly delete previous data']); 1559 1567 if strcmp(answer,'Cancel') 1560 set(handles.RUN,'backgroundcolor',[1 0 0])1561 1568 return 1562 1569 elseif strcmp(answer,'Yes') … … 3298 3305 'Callback',@(hObject,eventdata)num_ref_j_Callback(hObject,eventdata),'String',num2str(ref_j),'FontUnits','points','FontSize',12,'FontWeight','bold',... 3299 3306 'Tag','num_ref_j','TooltipString','''num_ref_j'': reference field index i used to display dt in ''list_pair_civ'''); 3307 uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.01 0.01 0.3 0.12],'BackgroundColor',[0 1 0],... 3308 'Callback',@(hObject,eventdata)OK_Callback(hObject,eventdata),'String','OK','FontUnits','points','FontSize',12,'FontWeight','bold',... 3309 'Tag','OK','TooltipString','''OK'': validate the choice'); 3300 3310 % last raw of the GUI: pushbuttons 3301 3311 % uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.35 0.01 0.3 0.15],'BackgroundColor',[0 1 0],'String','OK','Callback',@(hObject,eventdata)OK_Callback(hObject,eventdata),... … … 3387 3397 3388 3398 %------------------------------------------------------------------------ 3399 function OK_Callback(hObject, eventdata) 3400 %------------------------------------------------------------------------ 3401 delete(get(hObject,'parent')) 3402 3403 3404 %------------------------------------------------------------------------ 3389 3405 % --- Executes on button press in ClearLine. 3390 3406 %------------------------------------------------------------------------ … … 3396 3412 set(handles.InputTable,'Data',InputTable); 3397 3413 end 3414 3415 3416 % --- Executes on button press in MonitorCluster. 3417 function MonitorCluster_Callback(hObject, eventdata, handles) 3418 web('https://www.legi.grenoble-inp.fr/servload/monika') 3419 3420 3421 3422 function OutputSubDir_Callback(hObject, eventdata, handles) 3423 set(handles.OutputSubDir,'BackgroundColor',[1 1 1]) 3424 % hObject handle to OutputSubDir (see GCBO) 3425 % eventdata reserved - to be defined in a future version of MATLAB 3426 % handles structure with handles and user data (see GUIDATA) 3427 3428 % Hints: get(hObject,'String') returns contents of OutputSubDir as text 3429 % str2double(get(hObject,'String')) returns contents of OutputSubDir as a double -
trunk/src/series/civ2vel_3C.m
r878 r880 169 169 %% MAIN LOOP ON FIELDS 170 170 warning off 171 if NbField<2 172 disp_uvmat('ERROR','you need at least 2 images to compute the mean position for the stereo.',checkrun) 173 return 174 end 175 for index=1:NbField-1 171 172 for index=1:NbField 176 173 update_waitbar(WaitbarHandle,index/NbField) 177 174 if ~isempty(RUNHandle) && ~strcmp(get(RUNHandle,'BusyAction'),'queue') … … 191 188 if NbView==3 % if there is only 1 stereo folder, extract directly Xphys,Yphys and Zphys 192 189 193 [Data{3},tild,errormsg] = nc2struct(filecell{3,indextemp}); 190 [Data{3},tild,errormsg] = nc2struct([Param.InputTable{3,1},'/',Param.InputTable{3,2},'/',Param.InputTable{3,3},'_',int2str(indextemp),'.nc']); 191 194 192 195 193 if exist('Data{3}.Civ3_FF','var') % FF is present, remove wrong vector … … 221 219 end 222 220 223 [Data{3},tild,errormsg] = nc2struct( filecell{3,indextemp});221 [Data{3},tild,errormsg] = nc2struct([Param.InputTable{3,1},'/',Param.InputTable{3,2},'/',Param.InputTable{3,3},'_',int2str(indextemp),'.nc']); 224 222 if exist('Data{3}.Civ3_FF','var') % if FF is present, remove wrong vector 225 223 temp=find(Data{3}.Civ3_FF==0); … … 243 241 244 242 245 [Data{4},tild,errormsg] = nc2struct( filecell{4,indextemp});243 [Data{4},tild,errormsg] = nc2struct([Param.InputTable{4,1},'/',Param.InputTable{4,2},'/',Param.InputTable{4,3},'_',int2str(indextemp),'.nc']); 246 244 if exist('Data{4}.Civ3_FF','var') % if FF is present, remove wrong vector 247 245 temp=find(Data{4}.Civ3_FF==0); -
trunk/src/series/civ_input.m
r876 r880 83 83 set(handles.CheckThreshold,'Visible','on') 84 84 set(handles.CheckDeformation,'Value',0)% desactivate (work in progress) 85 %set(handles.CheckDecimal,'Value',0)% desactivate (work in progress)86 85 end 87 86 switch Param.Action.ActionName … … 288 287 if isequal(get(hhseries.REFRESH,'BackgroundColor'),[1 1 0]) &&... 289 288 ~(isfield(Param,'ActionInput') && isfield(Param.ActionInput,'ConfigSource')) 290 % answer=msgbox_uvmat('INPUT_Y-N',['import the civ parameters from the netcdf file']);291 % if strcmp(answer,'Yes')292 289 for index = 1:min(ind_opening,5) 293 290 set(handles.(ListOptions{index}),'value',0) … … 300 297 end 301 298 checkrefresh=1; 302 % end303 299 end 304 300 if ind_opening>=3 … … 696 692 % in mode 'pair j1-j2', j1 and j2 are the file indices, else the indices 697 693 % are relative to the reference indices ref_i and ref_j respectively. 698 if isequal(mode,'pair j1-j2') %| isequal(mode,'st_pair j1-j2')694 if isequal(mode,'pair j1-j2') 699 695 dt=1; 700 696 displ=''; … … 869 865 val=get(handles.ListCompareMode,'Value'); 870 866 compare=compare_list{val}; 871 if strcmp(compare,'displacement')||strcmp(compare,'shift') 872 mode='displacement'; 873 else 867 if ~strcmp(compare,'displacement')%||strcmp(compare,'shift') 868 874 869 mode_list=get(handles.ListPairMode,'String'); 875 870 mode_value=get(handles.ListPairMode,'Value'); … … 880 875 end 881 876 nom_type_ima=CivInputData.NomTypeIma; 877 initial=get(handles.ListPairCiv1,'Value');%previous choice of pair 878 menu_pair=get(handles.ListPairCiv1,'String');%previous choice of pair.ListPairCiv1 879 init_choice=menu_pair{initial}; 882 880 883 881 %% determine nom_type_nc, nomenclature type of the .nc files: … … 977 975 ichoice=find(select,1);% index of first selected pair 978 976 if (isempty(ichoice) || ichoice < 1); ichoice=1; end; 979 i nitial=get(handles.ListPairCiv1,'Value');%initial choice of pair980 if initial>nbpair || (numel(select)>=initial && ~isequal(select(initial),1))977 ichoice=find(strcmp(init_choice,displ_pair'),1); 978 if ~isempty(ichoice) 981 979 set(handles.ListPairCiv1,'Value',ichoice);% first valid pair proposed by default in the menu 982 end 980 else 981 set(handles.ListPairCiv1,'Value',1) 982 end 983 % if initial>nbpair || (numel(select)>=initial && ~isequal(select(initial),1)) 984 % set(handles.ListPairCiv1,'Value',ichoice);% first valid pair proposed by default in the menu 985 % end 983 986 984 987 %% determine the default selection in the pair menu for Civ2 -
trunk/src/series/civ_series.m
r879 r880 1015 1015 end 1016 1016 %threshold on image minimum 1017 if check_MinIma && (image1_mean < par_civ.MinIma || image2_mean < par_civ.MinIma)1018 F(ivec)=3;1019 end1020 %threshold on image maximum1021 if check_MaxIma && (image1_mean > par_civ.MaxIma || image2_mean > par_civ.MaxIma)1022 F(ivec)=3;1023 end1024 1025 1017 if F(ivec)~=3 1026 if checkmask 1027 image1_crop=(image1_crop-image1_mean).*~mask1_crop;%substract the mean, put to zero the masked parts 1028 image2_crop=(image2_crop-image2_mean).*~mask2_crop; 1029 else 1030 image1_crop=(image1_crop-image1_mean); 1031 image2_crop=(image2_crop-image2_mean); 1032 end 1033 if CheckDeformation 1034 xi=(1:mesh:size(image1_crop,2)); 1035 yi=(1:mesh:size(image1_crop,1))'; 1036 [XI,YI]=meshgrid(xi-ceil(size(image1_crop,2)/2),yi-ceil(size(image1_crop,1)/2)); 1037 XIant=XI-par_civ.DUDX(ivec)*XI-par_civ.DUDY(ivec)*YI+ceil(size(image1_crop,2)/2); 1038 YIant=YI-par_civ.DVDX(ivec)*XI-par_civ.DVDY(ivec)*YI+ceil(size(image1_crop,1)/2); 1039 image1_crop=interp2(image1_crop,XIant,YIant); 1040 image1_crop(isnan(image1_crop))=0; 1041 xi=(1:mesh:size(image2_crop,2)); 1042 yi=(1:mesh:size(image2_crop,1))'; 1043 image2_crop=interp2(image2_crop,xi,yi,'*spline'); 1044 image2_crop(isnan(image2_crop))=0; 1045 %par_civ.CorrSmooth=3;%%%%%%%%%%%%%%%%%%% 1046 %% 1047 end 1048 sum_square=sum(sum(image1_crop.*image1_crop)); 1049 %reference: Oliver Pust, PIV: Direct Cross-Correlation 1050 result_conv= conv2(image2_crop,flipdim(flipdim(image1_crop,2),1),'valid'); 1051 corrmax= max(max(result_conv)); 1052 result_conv=(result_conv/corrmax)*255; %normalize, peak=always 255 1053 %Find the correlation max, at 255 1054 [y,x] = find(result_conv==255,1); 1055 subimage2_crop=image2_crop(y:y+2*iby2/mesh,x:x+2*ibx2/mesh);%subimage of image 2 corresponding to the optimum displacement of first image 1056 sum_square=sum_square*sum(sum(subimage2_crop.*subimage2_crop));% product of variances of image 1 and 2 1057 sum_square=sqrt(sum_square);% srt of the variance product to normalise correlation 1058 if ~isempty(y) && ~isempty(x) 1059 try 1060 if par_civ.CorrSmooth==1 1061 [vector,F(ivec)] = SUBPIXGAUSS (result_conv,x,y); 1062 elseif par_civ.CorrSmooth==2 1063 [vector,F(ivec)] = SUBPIX2DGAUSS (result_conv,x,y); 1064 else 1065 [vector,F(ivec)] = quadr_fit(result_conv,x,y); 1066 end 1067 utable(ivec)=vector(1)*mesh+shiftx(ivec); 1068 vtable(ivec)=vector(2)*mesh+shifty(ivec); 1069 xtable(ivec)=iref+utable(ivec)/2-0.5;% convec flow (velocity taken at the point middle from imgae 1 and 2) 1070 ytable(ivec)=jref+vtable(ivec)/2-0.5;% and position of pixel 1=0.5 (convention for image coordinates=0 at the edge) 1071 iref=round(xtable(ivec));% nearest image index for the middle of the vector 1072 jref=round(ytable(ivec)); 1073 % eliminate vectors located in the mask 1074 if checkmask && par_civ.Mask(jref,iref)<200 && par_civ.Mask(jref,iref)>=100 1075 utable(ivec)=0; 1076 vtable(ivec)=0; 1018 if check_MinIma && (image1_mean < par_civ.MinIma || image2_mean < par_civ.MinIma) 1019 F(ivec)=3; 1020 %threshold on image maximum 1021 elseif check_MaxIma && (image1_mean > par_civ.MaxIma || image2_mean > par_civ.MaxIma) 1022 F(ivec)=3; 1023 end 1024 if F(ivec)~=3 1025 %mask 1026 if checkmask 1027 image1_crop=(image1_crop-image1_mean).*~mask1_crop;%substract the mean, put to zero the masked parts 1028 image2_crop=(image2_crop-image2_mean).*~mask2_crop; 1029 else 1030 image1_crop=(image1_crop-image1_mean); 1031 image2_crop=(image2_crop-image2_mean); 1032 end 1033 %deformation 1034 if CheckDeformation 1035 xi=(1:mesh:size(image1_crop,2)); 1036 yi=(1:mesh:size(image1_crop,1))'; 1037 [XI,YI]=meshgrid(xi-ceil(size(image1_crop,2)/2),yi-ceil(size(image1_crop,1)/2)); 1038 XIant=XI-par_civ.DUDX(ivec)*XI-par_civ.DUDY(ivec)*YI+ceil(size(image1_crop,2)/2); 1039 YIant=YI-par_civ.DVDX(ivec)*XI-par_civ.DVDY(ivec)*YI+ceil(size(image1_crop,1)/2); 1040 image1_crop=interp2(image1_crop,XIant,YIant); 1041 image1_crop(isnan(image1_crop))=0; 1042 xi=(1:mesh:size(image2_crop,2)); 1043 yi=(1:mesh:size(image2_crop,1))'; 1044 image2_crop=interp2(image2_crop,xi,yi,'*spline'); 1045 image2_crop(isnan(image2_crop))=0; 1046 %par_civ.CorrSmooth=3;%%%%%%%%%%%%%%%%%%% 1047 %% 1048 end 1049 sum_square=sum(sum(image1_crop.*image1_crop)); 1050 %reference: Oliver Pust, PIV: Direct Cross-Correlation 1051 result_conv= conv2(image2_crop,flipdim(flipdim(image1_crop,2),1),'valid'); 1052 corrmax= max(max(result_conv)); 1053 result_conv=(result_conv/corrmax)*255; %normalize, peak=always 255 1054 %Find the correlation max, at 255 1055 [y,x] = find(result_conv==255,1); 1056 subimage2_crop=image2_crop(y:y+2*iby2/mesh,x:x+2*ibx2/mesh);%subimage of image 2 corresponding to the optimum displacement of first image 1057 sum_square=sum_square*sum(sum(subimage2_crop.*subimage2_crop));% product of variances of image 1 and 2 1058 sum_square=sqrt(sum_square);% srt of the variance product to normalise correlation 1059 if ~isempty(y) && ~isempty(x) 1060 try 1061 if par_civ.CorrSmooth==1 1062 [vector,F(ivec)] = SUBPIXGAUSS (result_conv,x,y); 1063 elseif par_civ.CorrSmooth==2 1064 [vector,F(ivec)] = SUBPIX2DGAUSS (result_conv,x,y); 1065 else 1066 [vector,F(ivec)] = quadr_fit(result_conv,x,y); 1067 end 1068 utable(ivec)=vector(1)*mesh+shiftx(ivec); 1069 vtable(ivec)=vector(2)*mesh+shifty(ivec); 1070 xtable(ivec)=iref+utable(ivec)/2-0.5;% convec flow (velocity taken at the point middle from imgae 1 and 2) 1071 ytable(ivec)=jref+vtable(ivec)/2-0.5;% and position of pixel 1=0.5 (convention for image coordinates=0 at the edge) 1072 iref=round(xtable(ivec));% nearest image index for the middle of the vector 1073 jref=round(ytable(ivec)); 1074 % eliminate vectors located in the mask 1075 if checkmask && par_civ.Mask(jref,iref)<200 && par_civ.Mask(jref,iref)>=100 1076 utable(ivec)=0; 1077 vtable(ivec)=0; 1078 F(ivec)=3; 1079 end 1080 ctable(ivec)=corrmax/sum_square;% correlation value 1081 catch ME 1077 1082 F(ivec)=3; 1078 1083 end 1079 ctable(ivec)=corrmax/sum_square;% correlation value 1080 catch ME 1084 else 1081 1085 F(ivec)=3; 1082 1086 end 1083 else1084 F(ivec)=3;1085 1087 end 1086 1088 end -
trunk/src/series/merge_proj.m
r874 r880 142 142 FileType{iview}=FileInfo{iview}.FileType; 143 143 CheckImage{iview}=~isempty(find(strcmp(FileType{iview},ImageTypeOptions)));% =1 for images 144 if CheckImage{iview} 145 ParamIn{iview}=MovieObject{iview}; 146 else 147 ParamIn{iview}=Param.InputFields; 148 end 144 149 CheckNc{iview}=~isempty(find(strcmp(FileType{iview},NcTypeOptions)));% =1 for netcdf files 145 150 if ~isempty(j1_series{iview}) … … 196 201 FileExtOut='.nc'; %netcdf output 197 202 end 203 if isempty(j1_series{1}) 204 NomTypeOut='_1'; 205 else 206 NomTypeOut='_1_1'; 207 end 198 208 %NomTypeOut=NomType;% output file index will indicate the first and last ref index in the series 199 209 RootFileOut=RootFile{1}; … … 232 242 233 243 %%%%%%%%%%%%%%%% loop on field indices %%%%%%%%%%%%%%%% 244 tstart=tic; %used to record the computing time 234 245 for index=1:NbField 235 246 update_waitbar(WaitbarHandle,index/NbField) … … 238 249 return 239 250 end 240 241 251 %%%%%%%%%%%%%%%% loop on views (input lines) %%%%%%%%%%%%%%%% 242 252 Data=cell(1,NbView);%initiate the set Data 243 253 timeread=zeros(1,NbView); 244 254 for iview=1:NbView 245 %% reading input file(s) 246 [Data{iview},tild,errormsg] = read_field(filecell{iview,index},FileType{iview},Param .InputFields,frame_index{iview}(index));255 %% reading input file(s) 256 [Data{iview},tild,errormsg] = read_field(filecell{iview,index},FileType{iview},ParamIn{iview},frame_index{iview}(index)); 247 257 if ~isempty(errormsg) 248 258 disp_uvmat('ERROR',['ERROR in merge_proj/read_field/' errormsg],checkrun) … … 323 333 end 324 334 end 325 OutputFile=fullfile_uvmat(RootPath{1},OutputDir,RootFileOut,FileExtOut,NomType {1},i1,i2,j1,j2);335 OutputFile=fullfile_uvmat(RootPath{1},OutputDir,RootFileOut,FileExtOut,NomTypeOut,i1,i2,j1,j2); 326 336 327 337 %% recording the merged field … … 337 347 npy=siz(1); 338 348 npx=siz(2); 339 if isfield(MergeData,' coord_x') && isfield(MergeData,'coord_y')340 Rangx=MergeData. coord_x;341 Rangy=MergeData. coord_y;349 if isfield(MergeData,'Coord_x') && isfield(MergeData,'Coord_y') 350 Rangx=MergeData.Coord_x; 351 Rangy=MergeData.Coord_y; 342 352 elseif isfield(MergeData,'AX')&& isfield(MergeData,'AY') 343 353 Rangx=[MergeData.AX(1) MergeData.AX(end)]; … … 392 402 end 393 403 end 394 404 disp(['total ellapsed time ' num2str(toc(tstart))]) 395 405 396 406 %'merge_field': concatene fields -
trunk/src/series/time_series.m
r875 r880 90 90 if ismember(SeriesData.ProjObject.ProjMode,{'inside','outside'}) 91 91 answer=msgbox_uvmat('INPUT_TXT','set bin size for histograms (or keep ''auto'' by default)?','auto'); 92 ParamOut.ActionInput.VarMesh=str2 double(answer);92 ParamOut.ActionInput.VarMesh=str2num(answer); 93 93 end 94 94 end … … 295 295 nbfile=0;% not used , to check 296 296 nbmissing=0; 297 VarMesh= NaN;297 VarMesh=[]; 298 298 checkhisto=0; 299 299 if isfield(Param,'ProjObject') && ismember(Param.ProjObject.ProjMode,{'inside','outside'}) 300 300 checkhisto=1; 301 if isfield(Param .ActionInput,'VarMesh')%case of histograms302 VarMesh=Param.ActionInput.VarMesh;301 if isfield(Param,'ActionInput') && isfield(Param.ActionInput,'VarMesh')%case of histograms 302 VarMesh=Param.ActionInput.VarMesh; 303 303 end 304 304 end … … 320 320 if ~isempty(errormsg) 321 321 errormsg=['time_series / read_field / ' errormsg]; 322 disp lay(errormsg)323 break 322 disp(errormsg) 323 break% exit the loop on iview 324 324 end 325 325 if ~isempty(NbSlice_calib) … … 327 327 end 328 328 end 329 if isempty(errormsg) 330 Field=Data{1}; % default input field structure 331 % coordinate transform (or other user defined transform) 332 if ~isempty(transform_fct) 333 switch nargin(transform_fct) 334 case 4 335 if length(Data)==2 336 Field=transform_fct(Data{1},XmlData{1},Data{2},XmlData{2}); 337 else 338 Field=transform_fct(Data{1},XmlData{1}); 329 if ~isempty(errormsg) 330 continue %in case of input error skip the current input field, go to next index 331 end 332 Field=Data{1}; % default input field structure 333 % coordinate transform (or other user defined transform) 334 if ~isempty(transform_fct) 335 switch nargin(transform_fct) 336 case 4 337 if length(Data)==2 338 Field=transform_fct(Data{1},XmlData{1},Data{2},XmlData{2}); 339 else 340 Field=transform_fct(Data{1},XmlData{1}); 341 end 342 case 3 343 if length(Data)==2 344 Field=transform_fct(Data{1},XmlData{1},Data{2}); 345 else 346 Field=transform_fct(Data{1},XmlData{1}); 347 end 348 case 2 349 Field=transform_fct(Data{1},XmlData{1}); 350 case 1 351 Field=transform_fct(Data{1}); 352 end 353 end 354 355 %field projection on an object 356 if Param.CheckObject 357 % calculate tps coefficients if needed 358 if isfield(Param.ProjObject,'ProjMode')&& strcmp(Param.ProjObject.ProjMode,'interp_tps') 359 Field=tps_coeff_field(Field,check_proj_tps); 360 end 361 [Field,errormsg]=proj_field(Field,Param.ProjObject,VarMesh); 362 if ~isempty(errormsg) 363 disp_uvmat('ERROR',['time_series / proj_field / ' errormsg],checkrun) 364 return 365 end 366 end 367 % nbfile=nbfile+1; 368 369 % initiate the time series at the first iteration 370 if index==1 371 % stop program if the first field reading is in error 372 if ~isempty(errormsg) 373 disp_uvmat('ERROR',['time_series / sub_field / ' errormsg],checkrun) 374 return 375 end 376 if ~isfield(Field,'ListVarName') 377 disp_uvmat('ERROR','no variable in the projected field',checkrun) 378 return 379 end 380 DataOut=Field;%output reproduced the first projected field by default 381 nbvar=length(Field.ListVarName); 382 if nbvar==0 383 disp_uvmat('ERROR','no input variable selected',checkrun) 384 return 385 end 386 if checkhisto%case of histograms 387 testsum=zeros(1,nbvar);%initiate flag for action on each variable 388 for ivar=1:numel(Field.ListVarName)% list of variable names before projection (histogram) 389 VarName=Field.ListVarName{ivar}; 390 if isfield(Data{1},VarName) 391 DataOut.ListVarName=[DataOut.ListVarName {[VarName 'Histo']}]; 392 DataOut.VarDimName=[DataOut.VarDimName {{'Time',VarName}}]; 393 % if isfield(DataOut.VarAttribute{ivar},'Role') 394 % DataOut.VarAttribute{ivar}=rmfield(DataOut.VarAttribute{ivar},'Role'); 395 % end 396 StatName=pdf2stat;% get the names of statistical quantities to calcuilate at each time 397 for istat=1:numel(StatName) 398 DataOut.ListVarName=[DataOut.ListVarName {[VarName StatName{istat}]}]; 399 DataOut.VarDimName=[DataOut.VarDimName {'Time'}]; 339 400 end 340 case 3 341 if length(Data)==2 342 Field=transform_fct(Data{1},XmlData{1},Data{2}); 343 else 344 Field=transform_fct(Data{1},XmlData{1}); 345 end 346 case 2 347 Field=transform_fct(Data{1},XmlData{1}); 348 case 1 349 Field=transform_fct(Data{1}); 401 testsum(ivar)=1; 402 DataOut.(VarName)=Field.(VarName); 403 DataOut.([VarName 'Histo'])=zeros([nbfield numel(DataOut.(VarName))]); 404 VarMesh=Field.(VarName)(2)-Field.(VarName)(1); 405 end 350 406 end 351 end 352 353 %field projection on an object 354 if Param.CheckObject 355 % calculate tps coefficients if needed 356 if isfield(Param.ProjObject,'ProjMode')&& strcmp(Param.ProjObject.ProjMode,'interp_tps') 357 Field=tps_coeff_field(Field,check_proj_tps); 358 end 359 [Field,errormsg]=proj_field(Field,Param.ProjObject,VarMesh); 360 if ~isempty(errormsg) 361 msgbox_uvmat('ERROR',['time_series / proj_field / ' errormsg]) 362 return 363 end 364 end 365 % nbfile=nbfile+1; 366 367 % initiate the time series at the first iteration 368 if index==1 369 % stop program if the first field reading is in error 370 if ~isempty(errormsg) 371 disp_uvmat('ERROR',['time_series / sub_field / ' errormsg],checkrun) 372 return 373 end 374 DataOut=Field;%default 375 nbvar=length(Field.ListVarName); 376 if nbvar==0 377 disp_uvmat('ERROR','no input variable selected',checkrun) 378 return 379 end 380 if checkhisto%case of histograms 381 testsum=zeros(1,nbvar);%initiate flag for action on each variable 382 for ivar=1:numel(Field.ListVarName)% list of variable names before projection (histogram) 383 VarName=Field.ListVarName{ivar}; 384 if isfield(Data{1},VarName) 385 testsum(ivar)=1; 386 DataOut.(VarName)=Field.(VarName); 387 DataOut.([VarName 'Histo'])=zeros([nbfield numel(DataOut.(VarName))]); 388 VarMesh=Field.(VarName)(2)-Field.(VarName)(1); 389 end 390 end 391 disp(['mesh for histogram = ' num2str(VarMesh)]) 392 else 393 testsum=2*ones(1,nbvar);%initiate flag for action on each variable 394 if isfield(Field,'VarAttribute') % look for coordinate and flag variables 395 for ivar=1:nbvar 396 if length(Field.VarAttribute)>=ivar && isfield(Field.VarAttribute{ivar},'Role') 397 var_role=Field.VarAttribute{ivar}.Role;%'role' of the variable 398 if isequal(var_role,'errorflag') 399 disp_uvmat('ERROR','do not handle error flags in time series',checkrun) 400 return 401 end 402 if isequal(var_role,'warnflag') 403 testsum(ivar)=0; % not recorded variable 404 eval(['DataOut=rmfield(DataOut,''' Field.ListVarName{ivar} ''');']);%remove variable 405 end 406 if strcmp(var_role,'coord_x')||strcmp(var_role,'coord_y')||strcmp(var_role,'coord_z')||strcmp(var_role,'coord') 407 testsum(ivar)=1; %constant coordinates, record without time evolution 408 end 407 disp(['mesh for histogram = ' num2str(VarMesh)]) 408 else 409 testsum=2*ones(1,nbvar);%initiate flag for action on each variable 410 if isfield(Field,'VarAttribute') % look for coordinate and flag variables 411 for ivar=1:nbvar 412 if length(Field.VarAttribute)>=ivar && isfield(Field.VarAttribute{ivar},'Role') 413 var_role=Field.VarAttribute{ivar}.Role;%'role' of the variable 414 if isequal(var_role,'errorflag') 415 disp_uvmat('ERROR','do not handle error flags in time series',checkrun) 416 return 409 417 end 410 % check whether the variable ivar is a dimension variable 411 DimCell=Field.VarDimName{ivar}; 412 if ischar(DimCell) 413 DimCell={DimCell}; 418 if isequal(var_role,'warnflag') 419 testsum(ivar)=0; % not recorded variable 420 eval(['DataOut=rmfield(DataOut,''' Field.ListVarName{ivar} ''');']);%remove variable 414 421 end 415 if numel(DimCell)==1 && isequal(Field.ListVarName{ivar},DimCell{1})%detect dimension variables416 testsum(ivar)=1; 422 if strcmp(var_role,'coord_x')||strcmp(var_role,'coord_y')||strcmp(var_role,'coord_z')||strcmp(var_role,'coord') 423 testsum(ivar)=1; %constant coordinates, record without time evolution 417 424 end 418 425 end 419 end 420 for ivar=1:nbvar 421 if testsum(ivar)==2 422 VarName=Field.ListVarName{ivar}; 423 siz=size(Field.(VarName)); 424 DataOut.(VarName)=zeros([nbfield siz]); 426 % check whether the variable ivar is a dimension variable 427 DimCell=Field.VarDimName{ivar}; 428 if ischar(DimCell) 429 DimCell={DimCell}; 425 430 end 431 if numel(DimCell)==1 && isequal(Field.ListVarName{ivar},DimCell{1})%detect dimension variables 432 testsum(ivar)=1; 433 end 426 434 end 427 435 end 428 DataOut.ListVarName=[{'Time'} DataOut.ListVarName]; 429 end 430 431 % add data to the current field 432 if checkhisto 433 for ivar=1:length(Field.ListVarName) 434 VarName=Field.ListVarName{ivar}; 435 if isfield(Data{1},VarName) 436 MaxValue=max(DataOut.(VarName));% current max of histogram absissa 437 MinValue=min(DataOut.(VarName));% current min of histogram absissa 438 MaxIndex=round(MaxValue/VarMesh); 439 MinIndex=round(MinValue/VarMesh); 440 MaxIndex_new=round(max(Field.(VarName)/VarMesh));% max of the current field 441 MinIndex_new=round(min(Field.(VarName)/VarMesh)); 442 if MaxIndex_new>MaxIndex% the variable max for the current field exceeds the previous one 443 DataOut.(VarName)=[DataOut.(VarName) VarMesh*(MaxIndex+1:MaxIndex_new)];% append the new variable values 444 DataOut.([VarName 'Histo'])=[DataOut.([VarName 'Histo']) zeros(nbfield,MaxIndex_new-MaxIndex)]; % append the new histo values 445 end 446 if MinIndex_new <= MinIndex-1 447 DataOut.(VarName)=[VarMesh*(MinIndex_new:MinIndex-1) DataOut.(VarName)];% insert the new variable values 448 DataOut.([VarName 'Histo'])=[zeros(nbfield,MinIndex-MinIndex_new) DataOut.([VarName 'Histo'])];% insert the new histo values 449 ind_start=1; 450 else 451 ind_start=MinIndex_new-MinIndex+1; 452 end 453 DataOut.([VarName 'Histo'])(index,ind_start:ind_start+MaxIndex_new-MinIndex_new)=... 454 DataOut.([VarName 'Histo'])(index,ind_start:ind_start+MaxIndex_new-MinIndex_new)+Field.([VarName 'Histo']); 436 for ivar=1:nbvar 437 if testsum(ivar)==2 438 VarName=Field.ListVarName{ivar}; 439 siz=size(Field.(VarName)); 440 DataOut.(VarName)=zeros([nbfield siz]); 455 441 end 456 442 end 443 end 444 DataOut.ListVarName=[{'Time'} DataOut.ListVarName]; 445 end 446 % end initialisation for index==1 447 448 % append data from the current field 449 450 if checkhisto % case of histogram (projection mode=inside or outside) 451 for ivar=1:length(Field.ListVarName) 452 VarName=Field.ListVarName{ivar}; 453 if isfield(Data{1},VarName) 454 MaxValue=max(DataOut.(VarName));% current max of histogram absissa 455 MinValue=min(DataOut.(VarName));% current min of histogram absissa 456 MaxIndex=round(MaxValue/VarMesh); 457 MinIndex=round(MinValue/VarMesh); 458 MaxIndex_new=round(max(Field.(VarName)/VarMesh));% max of the current field 459 MinIndex_new=round(min(Field.(VarName)/VarMesh)); 460 if MaxIndex_new>MaxIndex% the variable max for the current field exceeds the previous one 461 DataOut.(VarName)=[DataOut.(VarName) VarMesh*(MaxIndex+1:MaxIndex_new)];% append the new variable values 462 DataOut.([VarName 'Histo'])=[DataOut.([VarName 'Histo']) zeros(nbfield,MaxIndex_new-MaxIndex)]; % append the new histo values 463 end 464 if MinIndex_new <= MinIndex-1 465 DataOut.(VarName)=[VarMesh*(MinIndex_new:MinIndex-1) DataOut.(VarName)];% insert the new variable values 466 DataOut.([VarName 'Histo'])=[zeros(nbfield,MinIndex-MinIndex_new) DataOut.([VarName 'Histo'])];% insert the new histo values 467 ind_start=1; 468 else 469 ind_start=MinIndex_new-MinIndex+1; 470 end 471 DataOut.([VarName 'Histo'])(index,ind_start:ind_start+MaxIndex_new-MinIndex_new)=... 472 DataOut.([VarName 'Histo'])(index,ind_start:ind_start+MaxIndex_new-MinIndex_new)+Field.([VarName 'Histo']); 473 VarVal=pdf2stat(Field.(VarName),Field.([VarName 'Histo']));% max of the current field 474 for istat=1:numel(VarVal) 475 DataOut.([VarName StatName{istat}])(index)=VarVal(istat); 476 end 477 end 478 end 479 else % not histogram 480 for ivar=1:length(Field.ListVarName) 481 VarName=Field.ListVarName{ivar}; 482 VarVal=Field.(VarName); 483 if testsum(ivar)==2% test for recorded variable 484 if isempty(errormsg) 485 VarVal=shiftdim(VarVal,-1); %shift dimension 486 DataOut.(VarName)(index,:,:)=VarVal;%concanete the current field to the time series 487 end 488 elseif testsum(ivar)==1% variable representing fixed coordinates 489 VarInit=DataOut.(VarName); 490 if isempty(errormsg) && ~isequal(VarVal,VarInit) 491 disp_uvmat('ERROR',['time series requires constant coordinates ' VarName ': use projection mode interp'],checkrun) 492 return 493 end 494 end 495 end 496 end 497 498 % record the time: 499 if isempty(time)% time not set by xml filer(s) 500 if isfield(Data{1},'Time') 501 DataOut.Time(index,1)=Field.Time; 457 502 else 458 for ivar=1:length(Field.ListVarName) 459 VarName=Field.ListVarName{ivar}; 460 VarVal=Field.(VarName); 461 if testsum(ivar)==2% test for recorded variable 462 if isempty(errormsg) 463 VarVal=shiftdim(VarVal,-1); %shift dimension 464 DataOut.(VarName)(index,:,:)=VarVal;%concanete the current field to the time series 465 end 466 elseif testsum(ivar)==1% variable representing fixed coordinates 467 VarInit=DataOut.(VarName); 468 if isempty(errormsg) && ~isequal(VarVal,VarInit) 469 disp_uvmat('ERROR',['time series requires constant coordinates ' VarName ': use projection mode interp'],checkrun) 470 return 471 end 472 end 473 end 474 end 475 476 % record the time: 477 if isempty(time)% time not set by xml filer(s) 478 if isfield(Data{1},'Time') 479 DataOut.Time(index,1)=Field.Time; 480 else 481 DataOut.Time(index,1)=index;%default 482 end 483 else % time from ImaDoc prevails TODO: correct 484 DataOut.Time(index,1)=time(index);% 485 end 486 487 % record the number of missing input fields 488 if ~isempty(errormsg) 489 nbmissing=nbmissing+1; 490 display(['index=' num2str(index) ':' errormsg]) 491 end 492 end 493 end 503 DataOut.Time(index,1)=index;%default 504 end 505 else % time from ImaDoc prevails TODO: correct 506 DataOut.Time(index,1)=time(index);% 507 end 508 509 % record the number of missing input fields 510 if ~isempty(errormsg) 511 nbmissing=nbmissing+1; 512 display(['index=' num2str(index) ':' errormsg]) 513 end 514 end 515 494 516 %%%%%%% END OF LOOP WITHIN A SLICE 495 517 … … 535 557 end 536 558 537 % case of histograms538 if checkhisto539 for ivar=1:numel(Field.ListVarName)540 VarName=Field.ListVarName{ivar};541 if isfield(Data{1},VarName)542 DataOut.ListVarName=[DataOut.ListVarName {[VarName 'Histo']}];543 DataOut.VarDimName=[DataOut.VarDimName {{'Time',VarName}}];544 end545 end546 end559 % %case of histograms 560 % if checkhisto 561 % for ivar=1:numel(Field.ListVarName) 562 % VarName=Field.ListVarName{ivar}; 563 % if isfield(Data{1},VarName) 564 % DataOut.ListVarName=[DataOut.ListVarName {[VarName 'Histo']}]; 565 % DataOut.VarDimName=[DataOut.VarDimName {{'Time',VarName}}]; 566 % end 567 % end 568 % end 547 569 % display nbmissing 548 570 if ~isequal(nbmissing,0) … … 559 581 end 560 582 561 %% plot the time series (the last one in case of multislices) 562 if checkrun 563 figure 564 haxes=axes; 565 plot_field(DataOut,haxes) 566 567 %% display the result file using the GUI get_field 568 hget_field=findobj(allchild(0),'name','get_field'); 569 if ~isempty(hget_field) 570 delete(hget_field) 571 end 572 get_field(OutputFile,DataOut) 573 end 574 575 583 %% plot the time series for (the last one in case of multislices) 584 if checkrun %&& isfield(Param,'ProjObject') && strcmp(Param.ProjObject.Type,'points') 585 %% open the result file with uvmat (in RUN mode) 586 uvmat(OutputFile)% open the last result file with uvmat 587 end 588 % figure 589 % haxes=axes; 590 % plot_field(DataOut,haxes) 591 % 592 % %% display the result file using the GUI get_field 593 % hget_field=findobj(allchild(0),'name','get_field'); 594 % if ~isempty(hget_field) 595 % delete(hget_field) 596 % end 597 % get_field(OutputFile,DataOut) 598 % end 599 600 -
trunk/src/transform_field/phys_polar.m
r810 r880 95 95 %transform first field to cartesian phys coordiantes 96 96 if ~isempty(Calib{1}) 97 DataOut=phys_1(Data ,Calib{1},origin_xy,radius_offset,angle_offset,angle_scale);97 DataOut=phys_1(DataIn,Calib{1},origin_xy,radius_offset,angle_offset,angle_scale); 98 98 %case of images or scalar 99 if isfield(Data ,'A')&isfield(Data,'Coord_x')&~isempty(Data.Coord_x) & isfield(Data,'Coord_y')&...100 ~isempty(Data .Coord_y)&length(Data.A)>199 if isfield(DataIn,'A')&isfield(DataIn,'Coord_x')&~isempty(DataIn.Coord_x) & isfield(DataIn,'Coord_y')&... 100 ~isempty(DataIn.Coord_y)&length(DataIn.A)>1 101 101 iscalar=1; 102 A{1}=Data .A;102 A{1}=DataIn.A; 103 103 end 104 104 %transform of X,Y coordinates for vector fields 105 if isfield(Data ,'ZIndex')&~isempty(Data.ZIndex)106 ZIndex=Data .ZIndex;105 if isfield(DataIn,'ZIndex')&~isempty(DataIn.ZIndex) 106 ZIndex=DataIn.ZIndex; 107 107 else 108 108 ZIndex=0;
Note: See TracChangeset
for help on using the changeset viewer.