Changeset 32 for trunk/src


Ignore:
Timestamp:
Mar 3, 2010, 1:47:56 PM (15 years ago)
Author:
sommeria
Message:

-subfunction find_file_indices put back in series (it had been extracted by mistake to check_files
-aver_stat: name of output file rationalized
-read_get_field : pb with vector fields, yet to solve

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/read_get_field.m

    r19 r32  
    1 %'read_get_field': read the list of selected variables from the GUI get_field (SAME AS THE FIRST
     1%'read_get_field': read the list of selected variables from the GUI get_field
     2
     3% OUTPUT:
     4% SubField: structure with fields
     5   %  .ListVarName: list of selected variables
     6   %  .VarDimName: cells with the  corresponding dimension names
     7   %  .Field1, 2...: if an input file has been opened by get_field
     8% errormsg: error message (=[] when no error)
     9
    210% INPUT:
    311% hget_field: handles of the GUI get_field
     
    3442dim_vec_z=0;
    3543c_index=[];
     44
     45%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     46%  ordinary (1D) plot
    3647if test_1Dplot
    37      % select ordinate variable(s)
     48    % select ordinate variable(s)
    3849    inputlist=get(handles.ordinate,'String');
    3950    val=get(handles.ordinate,'Value');% selection(s) for ordinate
     
    4253        VarIndex_y(ilist)=name2index(VarNameCell{ilist},Field.ListVarName);%index of the variable in ListVarName
    4354        dim_ordinate{ilist}=Field.VarDimName{VarIndex_y(ilist)};% name of the corresponding dimension
    44 %         if iscell(dim_ordinate{ilist})
    45 %             dim_ordinate{ilist}=dim_ordinate{ilist}{1};%take the first dimension name (char chain) in case of a matrix
    46 %         end
    4755        testpermute(ilist)=0;%default
    4856        nbvar=nbvar+1;
     
    5664    end
    5765   
    58         % select abscissa variable
     66    % select abscissa variable
    5967    inputlist=get(handles.abscissa,'String');
    6068    val=get(handles.abscissa,'Value');% a single selection is expected for abscissa
     
    95103    end
    96104end
    97 
    98105test3D=strcmp(get(handles.coord_z_scalar,'Visible'),'on')||strcmp(get(handles.coord_z_vectors,'Visible'),'on');
    99106VarSubIndexA=[];
    100107
    101 %scalar variable
     108%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     109%scalar field
    102110test_xdimvar=0;%default
    103111test_ydimvar=0;%default
     
    233241   end
    234242end
     243
     244%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     245% vectors
    235246test_vec_x_dimvar=0;%default
    236247test_vec_y_dimvar=0;%default
     
    278289        SubVarAttribute{nbvar}=VarAttribute{VarIndexV};
    279290    end
    280     SubVarAttribute{nbvar}.Role='vector_y';
    281    
     291    SubVarAttribute{nbvar}.Role='vector_y';   
    282292 
    283      % select x variable for vector
     293    % select x variable for vector
    284294    inputlist=get(handles.coord_x_vectors,'String');
    285295    val=get(handles.coord_x_vectors,'Value');% a single selection is expected for abscissa
     
    287297    VarIndex=name2index(VarName,Field.ListVarName);%index of the variable in ListVarName
    288298    if isempty(VarIndex)% default abscissa = matrix indexTODO like scalar
    289 %         coord_x_name=dimname_u{2};% name of the x coordinate = dimension of the plotted quantity
    290299        empty_coord_vec_x=1;
    291300    else
     
    315324    end
    316325       
    317          % select y variable for vector
     326     % select y variable for vector
    318327    inputlist=get(handles.coord_y_vectors,'String');
    319328    val=get(handles.coord_y_vectors,'Value');% a single selection is expected for abscissa
     
    321330    VarIndex=name2index(VarName,Field.ListVarName);%index of the variable in ListVarName
    322331    if isempty(VarIndex)% default abscissa = matrix indexTODO like scalar
    323 %         coord_x_name=dimname_u{2};% name of the x coordinate = dimension of the plotted quantity
    324332        empty_coord_vec_y=1;
    325333    else
     
    383391        end       
    384392    end   
    385        
    386      
    387      if test3D %  (a revoir) 
     393           
     394    if test3D %  (a revoir) 
    388395         %scalar w variable
    389396        inputlist=get(handles.vector_z,'String');
     
    428435    end
    429436end
     437%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    430438
    431439% get the input field
     
    434442    SubField=nc2struct(inputfield,ListVarName);
    435443else  % subfield stored in memory
     444    SubField.ListGlobalAttribute={};
    436445    SubField.ListVarName=ListVarName;
    437446    SubField.VarDimName=VarDimName;
     
    441450SubField.VarAttribute=SubVarAttribute;
    442451
    443 %permute indices if coord_y is not the first matrix index
     452%permute indices if coord_y is not the first matrix index: scalar case
    444453if test_scalar
    445454    VarNameA=Field.ListVarName{VarIndexA};
     
    560569end
    561570
    562 %permute indices if coord_y is not the first matrix index
     571%permute indices if coord_y is not the first matrix index: vector case
    563572if test_vector
    564573    VarNameU=Field.ListVarName{VarIndexU};
    565     DimCellU=Field.VarDimName{VarIndexU};  
    566     eval(['npxy=size(SubField.' VarNameU ')'])
     574    DimCellU=Field.VarDimName{VarIndexU} % list of dimensions for u component 
     575    eval(['npxy=size(SubField.' VarNameU ')']) % npxy= dimension values for the u component
    567576    SingleCellU={};
    568577    if numel(npxy) < numel(DimCellU)
  • trunk/src/series.m

    r29 r32  
    614614end
    615615      %read the ImaDoc file
    616 % mode=''; %default
    617 % testheading=0; 
    618616XmlData=[];
    619617NbSlice_calib={};
     
    660658    elseif error==1, warntext='inconsistent number of fields in the .civ file';
    661659    end 
    662 %     set(handles.npx,'String',num2str(npx));%fills nbre of pixels x box
    663 %     set(handles.npy,'String',num2str(npy));%fills nbre of pixels y box
    664 %     set(handles.pxcm,'String',num2str(pxcmx));%fills scale x (pixel/cm) box
    665 %     set(handles.pycm,'String',num2str(pxcmy));%fills scale y (pixel/cm) box
    666 %     set(handles.pxcm,'Visible','on');%fills scale x (pixel/cm) box
    667 %     set(handles.pycm,'Visible','on');%fills scale y (pixel/cm) box
    668 %     set(handles.view_xml,'Visible','on')
    669 %     set(handles.view_xml,'String','view .civ')
    670660end 
    671661if addtest
     
    917907    enable_j(handles,'Off')
    918908end   
    919    
    920    
    921 % elseif isequal(mode,'series(Dj)')       
    922 %     enable_j(handles,'On')     
    923 %     if nbfield==1
    924 %         enable_i(handles,'Off')
    925 %     else
    926 %         enable_i(handles,'On')
    927 %     end
    928 % elseif isequal(mode,'series(Di)')
    929 %     if nbfield2 > 1
    930 %          enable_j(handles,'On')
    931 %     else
    932 %          enable_j(handles,'Off')
    933 %     end
    934 % end 
    935909set(handles.list_pair_civ,'Value',indchosen);%set the default choice of image pairs for civ1
    936 % SetSeries.displ_num=displ_num;
    937910set(hseries,'UserData',SeriesData)
    938911
     
    16671640%check the current path to the selected function
    16681641PathName=list_path{index_ACTION};%current recorded path
    1669 % if ~isequal(path_series,PathName)
    1670 %     CurrentPath=fileparts(which(ACTION));
    1671 %     if ~isequal(CurrentPath,PathName)
    1672 %         addpath(PathName)
    1673 %         errormsg=check_functions;
    1674 %         msgbox_uvmat('CONFIRMATION',[['path ' PathName ' added to the current Matlab pathes'];errormsg])
    1675 %     end
    1676 % end
    16771642set(handles.path,'String',PathName); %show the path to the senlected function
    16781643
    16791644%default setting for the visibility of the GUI elements
    1680 %set( handles.Field,'Visible','off')%default
    16811645set(handles.RootPath,'UserData','many')
    16821646set(handles.SubDir,'Visible','on')
     
    19811945end
    19821946
    1983 
    1984 
    1985 % %----------------------------------------------------------------------
    1986 % % --- display image movie and display time average
    1987 % %OBSOLETE: A SUPPRIMER
    1988 % %----------------------------------------------------------------------
    1989 % function movie_ima(handles,filecell,filecell_1,num1,num_a,field)
    1990 %
    1991 % global hfig1 hfig2 hfig3 poscolbar
    1992 % global A val HIST
    1993 %
    1994 % A=[];aviobj=[];
    1995 % % set(hfig1,'UserData','ima')% set the current field state to 'image'
    1996 % set(handles.zoom,'Value',1); %put zoom on
    1997 % nom_type=get(handles.file_input,'UserData');
    1998 % % field=get(handles.civ1,'UserData');
    1999 % % fields=field(1).fields;
    2000 % set(handles.speed,'Visible','On')%show slider to set movie speed
    2001 % set(handles.mo_speed_txt,'Visible','On')
    2002 %
    2003 % if ~isempty(filecell_1)
    2004 %    file1=get(handles.file1_input,'UserData');
    2005 %    field1=file1.field;
    2006 %    scal_type1=field1.fields;
    2007 %    vel_type1=field1.vel_type;
    2008 %    filename_1=filecell_1(1);% first file name in the series
    2009 % else
    2010 %    filename_1=[];
    2011 % end
    2012 % scal_type{1}=field(1).fields;
    2013 % vel_type{1}=field(1).vel_type;
    2014 % % display the first field
    2015 % [A,time,dt,rangx0,rangy0]=view_ima(handles,cell2mat(filecell(1)),filename_1,num1(1),num_a(1));
    2016 %
    2017 % % calculate the histogram of the first image
    2018 % nxy=size(A);
    2019 % ndim=length(nxy);
    2020 % if ndim==2 % case of B/W images
    2021 %     nxy(3)=1;
    2022 % end
    2023 % C=reshape(A,nxy(1)*nxy(2),nxy(3));
    2024 % Amaxmax=double(max(max(max(A))));
    2025 % Aminmin=double(min(min(min(A))));
    2026 % if isa(C,'uint8')|isa(C,'uint16')
    2027 %     C=double(C);
    2028 %     dC=1;
    2029 % else
    2030 %     dC=(Amaxmax-Aminmin)/100;
    2031 % end
    2032 % val=[Aminmin:dC:Amaxmax];% define bins for histogram
    2033 % HIST=hist(C,val);% initiate the global histogram
    2034 % if ndim==2, HIST=HIST'; end;
    2035 %
    2036 % auto_scale=get(handles.auto_scale,'Value');
    2037 % min_input=str2num(get(handles.min_input,'String'));% select the minimum
    2038 % max_input=str2num(get(handles.scale_input,'String'));% select the max
    2039 % zoomstate=get(handles.zoom,'Value');
    2040 %
    2041 % if isequal(get(handles.window_input,'String'),'avi'),
    2042 %     basename=get(handles.file_input,'String');
    2043 %     prompt = {'file name';'frames per second';'frame resolution ([nbpixels x y])';'axis position relative to the frame'};
    2044 %     dlg_title = 'select properties of the output avi movie';
    2045 %     num_lines= 1;
    2046 %     def     = {[basename '_out.avi'];'5';'[1024 768]';'[0.05 0.07 0.87 0.88]'};
    2047 %     answer = inputdlg(prompt,dlg_title,num_lines,def);
    2048 %     aviname=answer{1};
    2049 %     fps=str2num(answer{2});
    2050 %     if exist(aviname,'file')==2
    2051 %         delete(aviname);
    2052 %     end;
    2053 %     aviobj=avifile(aviname,'Compression','None','fps',fps);
    2054 %     
    2055 %     %display first view for tests
    2056 %     figure(2);
    2057 %     hh=get(gcf,'CurrentAxes');
    2058 %     if isempty(hh),
    2059 %         hfig1=axes;
    2060 %     else
    2061 %         hfig1=hh;
    2062 %     end;
    2063 %     if isequal(filecell_1,{})
    2064 %         filename_1=[];
    2065 %     else
    2066 %         filename_1=cell2mat(filecell_1(1));
    2067 %     end
    2068 %     poscolbar=[0.93 0.15 0.02 0.7];
    2069 %     view_ima(handles,cell2mat(filecell(1)),filename_1,num1(1),num_a(1));% show the first field
    2070 %     nbpix=eval(answer{3});
    2071 %     set(gcf,'Position',[1 1 nbpix])% resolution XVGA
    2072 %     set(hfig1,'Position',eval(answer{4}));
    2073 %     
    2074 %     msgbox({'adjust figure 2 with its matlab edit menu ' ;...
    2075 %             'then type any keyboard key to get the avi movie as a copy of figure 2 display'})
    2076 %     pause;
    2077 %     hh=colorbar;
    2078 %     poscolbar=get(hh,'Position');
    2079 % end
    2080 %
    2081 % %%%%%%%%%%%%%%%%
    2082 % %mask and usrdfct
    2083 % maskname=[]; %default
    2084 % if isequal(get(handles.mask_test,'Value'),1)
    2085 %     maskbase=get(handles.mask_test,'UserData');
    2086 % end
    2087 % % image or scalar processing programme set by user
    2088 % % if (get(handles.usr_fct,'Value')==1)
    2089 % %      usrfct=get(handles.usr_fct,'UserData');
    2090 % % else
    2091 % %      usrfct='';
    2092 % % end
    2093 % nburst=1; % nburst(1) =nbre of names in filename= nbre of bursts
    2094 % set(handles.text_display_1,'String',['image movie'])
    2095 % nbfield=length(filecell);
    2096 % if nbfield >1
    2097 % for ifile=2:nbfield
    2098 %     stopstate=get(handles.run0,'BusyAction');
    2099 %     if isequal(stopstate,'queue')% enable STOP command
    2100 %        pausetime=1.02-get(handles.speed,'Value');
    2101 %          pause(pausetime)
    2102 %          if isequal(get(handles.mask_test,'Value'),1)
    2103 %                 maskname=name_generator(maskbase,num1(ifile),1,'.png','png_series');
    2104 %             end
    2105 %             if isequal(AName{1},'image')
    2106 %                 A=read_image(cell2mat(filecell(ifile)),num1(ifile),maskname);% read the first image, num2 is the counter for avi files
    2107 %             else % read the first field from the netcdf file, imposing the pixel positions in the selected domain
    2108 %                  [A,time(ifile),dtr,rgx,rgy,vt_out,erread]=read_scalar(filecell{ifile},vel_type,scal_type,rangx0,rangy0,nxy,maskname);
    2109 %                 if erread==1;
    2110 %                     errordlg({['no spatial derivative in ' filecell{ifile}]; 'run patch first'}); return
    2111 %                 elseif erread==2;
    2112 %                     errordlg(['no field ' vel_type{1} ' in ' filecell{ifile}]); return
    2113 %                 elseif erread==3;
    2114 %                     errordlg(['scalar ' scal_type{1} ' not found in' filecell{ifile}]); return
    2115 %                 elseif erread==4;
    2116 %                     errordlg(['all points aligned in' filecell{ifile}]); return
    2117 %                 end
    2118 %             end
    2119 %           
    2120 %             % read the second image
    2121 %             if ~isempty(filecell_1)
    2122 %                 if isequal(scal_type{1},'image')
    2123 %                     A1=read_image(cell2mat(filecell_1(ifile)),num1(ifile),maskname);% read the second image, num2 is the counter for avi files
    2124 %                     Avalue_1=double(A1(indy,indx,:));
    2125 %                 else % read the second field from the netcdf file, imposing the pixel positions in the selected domain
    2126 %                     [Avalue_1,time1(ifile),dtr,rgx,rgy,vt_out,erread]=read_scalar(filecell_1{ifile},{vel_type1},{scal_type1},rangx0,rangy0,npxy,maskname,usrfct);
    2127 %                     if erread==1;
    2128 %                         errordlg({['no spatial derivative in ' filecell_1{ifile}]; 'run patch first'}); return
    2129 %                     elseif erread==2;
    2130 %                         errordlg(['no field ' vel_type1 ' in ' filecell_1{ifile}]); return
    2131 %                     elseif erread==3;
    2132 %                         errordlg(['scalar ' scal_type1 ' not found in' filecell_1{ifile}]); return
    2133 %                     elseif erread==4;
    2134 %                         errordlg(['all points aligned in' filecell_1{ifile}]); return
    2135 %                     end
    2136 %                 end
    2137 %                 time(ifile)=(time(ifile)+time1(ifile))/2;
    2138 %                 Avalue=Avalue-Avalue_1;
    2139 %             end
    2140 %         set(handles.abs_time,'String',time);
    2141 %         set(handles.field_counter,'String',num2str(num1(ifile)));
    2142 %         set(handles.a_input,'String',num2stra(num_a(ifile),nom_type));
    2143 %         C=reshape(A,nxy(1)*nxy(2),nxy(3));% reshape in a vector
    2144 %         [val,HIST]=hist_update(val,HIST,C,dC);
    2145 %         [h,Amin,Amax]=plot_image(hfig1,rangx0,rangy0,1,scal_type{1},auto_scale,min_input,max_input,poscolbar,A);
    2146 %         set(handles.min_input,'String',num2str(Amin));% select the minimum
    2147 %         set(handles.scale_input,'String',num2str(Amax));% select the minimum
    2148 %          if ~isequal(aviobj,[]),
    2149 % %              mov=getframe(hfig1);
    2150 %               mov=getframe(gcf);
    2151 %              aviobj=addframe(aviobj,mov);end
    2152 %          if (get(handles.zoom,'Value') == get(handles.zoom,'Max')),zoom on,end
    2153 %          set(handles.field_counter,'String',num2str(num1(ifile)))
    2154 % %     end
    2155 % end
    2156 % end
    2157 % end
    2158 % aviobj=close(aviobj);
    2159 %
    2160 % %plot global image histogram
    2161 %         HIST=HIST/(nbfield*nxy(1)*nxy(2));% normalized by the number of points
    2162 %         axes(hfig2) %in main window
    2163 %         if ndim==2
    2164 %             plot(val,HIST)
    2165 %         else
    2166 %             plot(val,HIST(:,1),'r',val,HIST(:,2),'g',val,HIST(:,3),'b')
    2167 %         end
    2168 %         residu=1-sum(HIST,1);
    2169 %         title(['histo, residu ' num2str(residu)])
    2170 %         grid on
    2171 %         axes(hfig3)
    2172 %         cla %clear the second histogram window
    2173 %         
    2174 
    2175 
    2176 
    2177 
    21781947%%%%%%%%%%%%%
    21791948function [ind_remove]=find_pairs(dirpair,ind_i,last_i)
     
    22011970        end
    22021971
    2203 %--------------------------------------------------------
     1972%----------------------------------------------------
     1973%  determine the list of index pairs of processing file
     1974%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     1975function [num_i1,num_i2,num_j1,num_j2,num_i_out,num_j_out]=find_file_indices(num_i,num_j,ind_shift,NomType,mode)
     1976num_i1=num_i;% set of first image numbers by default
     1977num_i2=num_i;
     1978num_j1=num_j;
     1979num_j2=num_j;
     1980num_i_out=num_i;
     1981num_j_out=num_j;
     1982if isequal (NomType,'_i1-i2_j') |isequal (NomType,'_i1-i2')
     1983    num_i1_line=num_i+ind_shift(3);% set of first image numbers
     1984    num_i2_line=num_i+ind_shift(4);
     1985    % adjust the first and last field number
     1986        indsel=find(num_i1_line >= 1);
     1987    num_i_out=num_i(indsel);
     1988    num_i1_line=num_i1_line(indsel);
     1989    num_i2_line=num_i2_line(indsel);
     1990    num_j1=meshgrid(num_j,ones(size(num_i1_line)));
     1991    num_j2=meshgrid(num_j,ones(size(num_i1_line)));
     1992    [xx,num_i1]=meshgrid(num_j,num_i1_line);
     1993    [xx,num_i2]=meshgrid(num_j,num_i2_line);
     1994elseif isequal (NomType,'_i_j1-j2') || isequal (NomType,'#_ab')
     1995    if isequal(mode,'bursts') %case of bursts (png_old or png_2D)
     1996        num_j1=ind_shift(1)*ones(size(num_i));
     1997        num_j2=ind_shift(2)*ones(size(num_i));
     1998    else
     1999        num_j1_col=num_j+ind_shift(1);% set of first image numbers
     2000        num_j2_col=num_j+ind_shift(2);
     2001        % adjust the first field number
     2002        indsel=find((num_j1_col >= 1));   
     2003        num_j_out=num_j(indsel);
     2004        num_j1_col=num_j1_col(indsel);
     2005        num_j2_col=num_j2_col(indsel);
     2006        [num_i1,num_j1]=meshgrid(num_i,num_j1_col);
     2007        [num_i2,num_j2]=meshgrid(num_i,num_j2_col);
     2008    end   
     2009end
    22042010
    22052011 
  • trunk/src/series/check_files.m

    r27 r32  
    150150    hh=uicontrol('Style','listbox', 'Position', [20 340 500 40], 'String', message);
    151151end
    152 %----------------------------------------------------
    153 %  determine the list of index pairs of processing file
    154 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    155 function [num_i1,num_i2,num_j1,num_j2,num_i_out,num_j_out]=find_file_indices(num_i,num_j,ind_shift,NomType,mode)
    156 num_i1=num_i;% set of first image numbers by default
    157 num_i2=num_i;
    158 num_j1=num_j;
    159 num_j2=num_j;
    160 num_i_out=num_i;
    161 num_j_out=num_j;
    162 if isequal (NomType,'_i1-i2_j') |isequal (NomType,'_i1-i2')
    163     num_i1_line=num_i+ind_shift(3);% set of first image numbers
    164     num_i2_line=num_i+ind_shift(4);
    165     % adjust the first and last field number
    166         indsel=find(num_i1_line >= 1);
    167     num_i_out=num_i(indsel);
    168     num_i1_line=num_i1_line(indsel);
    169     num_i2_line=num_i2_line(indsel);
    170     num_j1=meshgrid(num_j,ones(size(num_i1_line)));
    171     num_j2=meshgrid(num_j,ones(size(num_i1_line)));
    172     [xx,num_i1]=meshgrid(num_j,num_i1_line);
    173     [xx,num_i2]=meshgrid(num_j,num_i2_line);
    174 elseif isequal (NomType,'_i_j1-j2') || isequal (NomType,'#_ab')
    175     if isequal(mode,'bursts') %case of bursts (png_old or png_2D)
    176         num_j1=ind_shift(1)*ones(size(num_i));
    177         num_j2=ind_shift(2)*ones(size(num_i));
    178     else
    179         num_j1_col=num_j+ind_shift(1);% set of first image numbers
    180         num_j2_col=num_j+ind_shift(2);
    181         % adjust the first field number
    182         indsel=find((num_j1_col >= 1));   
    183         num_j_out=num_j(indsel);
    184         num_j1_col=num_j1_col(indsel);
    185         num_j2_col=num_j2_col(indsel);
    186         [num_i1,num_j1]=meshgrid(num_i,num_j1_col);
    187         [num_i2,num_j2]=meshgrid(num_i,num_j2_col);
    188     end   
    189 end
Note: See TracChangeset for help on using the changeset viewer.