Changeset 248 for trunk/src


Ignore:
Timestamp:
May 9, 2011, 12:32:20 AM (13 years ago)
Author:
sommeria
Message:

various modifications

Location:
trunk/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r246 r248  
    21522152                Param.Patch1.SubDomain=subdomain_patch1;
    21532153            end
     2154            if box_test(4)==1
     2155                Param.Civ2=par_civ2;
     2156            end
    21542157            [Data,erromsg]=civ_uvmat(Param,filecell.nc.civ1{ifile,j});
    21552158            if isempty(errormsg)
     
    27052708                if ~testdiff % civ2 or patch2 are written in the same file as civ1
    27062709                    if box_test(4)==0 ; %check the existence of civ2 if it is not calculated
    2707                         Data=nc2struct(filename,'ListGlobalAttribute','civ2');
    2708                         if isempty(Data.civ2)||isequal(Data.civ2,0)
     2710                        Data=nc2struct(filename,'ListGlobalAttribute','CivStage','civ2');
     2711                        if ~isempty(Data.CivStage) && Data.CivStage<4 %test for civ files
     2712                            msgbox_uvmat('ERROR',['no civ2 data in ' filename])
     2713                            filecell=[];
     2714                            return
     2715                        elseif isempty(Data.civ2)||isequal(Data.civ2,0)
    27092716                            msgbox_uvmat('ERROR',['no civ2 data in ' filename])
    27102717                            filecell=[];
     
    27122719                        end
    27132720                    elseif box_test(3)==0; %check the existence of patch if it is not calculated
    2714                         Data=nc2struct(filename,'ListGlobalAttribute','patch');
    2715                         if isempty(Data.patch)||isequal(Data.patch,0)
     2721                        Data=nc2struct(filename,'ListGlobalAttribute','CivStage','patch')
     2722                        if ~isempty(Data.CivStage)
     2723                            if Data.CivStage<3 %test for civ files
     2724                                msgbox_uvmat('ERROR',['no patch data in ' filename])
     2725                                filecell=[];
     2726                                return
     2727                            end
     2728                        elseif isempty(Data.patch)||isequal(Data.patch,0)
    27162729                            msgbox_uvmat('ERROR',['no patch data in ' filename])
    27172730                            filecell=[];
     
    28012814                    return
    28022815                else
    2803                     Data=nc2struct(filename,'ListGlobalAttribute','civ2');
    2804                     if isempty(Data.civ2)||isequal(Data.civ2,0)
     2816                    Data=nc2struct(filename,'ListGlobalAttribute','CivStage','civ2');
     2817                    if ~isempty(Data.CivStage) && Data.CivStage<4 %test for civ files
     2818                            msgbox_uvmat('ERROR',['no civ2 data in ' filename])
     2819                            filecell=[];
     2820                            return
     2821                    elseif isempty(Data.civ2)||isequal(Data.civ2,0)
    28052822                        msgbox_uvmat('ERROR',['no civ2 data in ' filename])
    28062823                        filecell=[];
     
    46774694    end
    46784695    [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc,file_ref_fix1,file_ref_fix2]=...
    4679         set_civ_filenames(handles,ref_i,ref_j,[1 0 0 0 0 0]);
     4696        set_civ_filenames(handles,ref_i,ref_j,[1 0 0 0 0 0])
    46804697    Data.ListVarName={'ny','nx','A'};
    46814698    Data.VarDimName={'ny','nx',{'ny','nx'}};
  • trunk/src/civ_uvmat.m

    r246 r248  
    88ListVarCiv1={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_C','Civ1_F'};
    99ListVarFix1={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_C','Civ1_F','Civ1_FF'};
     10mask='';
     11maskname='';%default
    1012
    1113%% Civ1
    1214if isfield (Param,'Civ1')
    1315    par_civ1=Param.Civ1;
    14     str2num(par_civ1.rho)
    1516    image1=imread(par_civ1.filename_ima_a);
    1617    image2=imread(par_civ1.filename_ima_b);
     
    3031    PointCoord(:,1)=reshape(GridX,[],1);
    3132    PointCoord(:,2)=reshape(GridY,[],1);
    32    
     33    if ~isempty(par_civ1.maskname)
     34        maskname=par_civ1.maskname;
     35        mask=imread(maskname);
     36    end
    3337    % caluclate velocity data (y and v in indices, reverse to y component)
    34     [xtable ytable utable vtable ctable F] = pivlab (image1,image2,ibx2,iby2,isx2,isy2,shiftx,-shifty,PointCoord,str2num(par_civ1.rho), []);
     38    [xtable ytable utable vtable ctable F] = pivlab (image1,image2,ibx2,iby2,isx2,isy2,shiftx,-shifty,PointCoord,str2num(par_civ1.rho), mask);
    3539    list_param=(fieldnames(par_civ1))';
    3640    list_remove={'pxcmx','pxcmy','npx','npy','gridflag','maskflag','term_a','term_b','T0'};
     
    148152      Data.CivStage=3;                             
    149153end   
     154
     155%% Civ2
     156if isfield (Param,'Civ2')
     157    par_civ2=Param.Civ2
     158    image1=imread(par_civ2.filename_ima_a);
     159    image2=imread(par_civ2.filename_ima_b);
     160    stepx=str2num(par_civ2.dx);
     161    stepy=str2num(par_civ2.dy);
     162    ibx2=ceil(str2num(par_civ2.ibx)/2);
     163    iby2=ceil(str2num(par_civ2.iby)/2);
     164    isx2=4;
     165    isy2=4;
     166%     shiftx=str2num(par_civ1.shiftx);
     167%     shifty=str2num(par_civ1.shifty);
     168% TO GET shift from par_civ2.filename_nc1
     169    miniy=max(1+isy2+shifty,1+iby2);
     170    minix=max(1+isx2-shiftx,1+ibx2);
     171    maxiy=min(size(image1,1)-isy2+shifty,size(image1,1)-iby2);
     172    maxix=min(size(image1,2)-isx2-shiftx,size(image1,2)-ibx2);
     173    [GridX,GridY]=meshgrid(minix:stepx:maxix,miniy:stepy:maxiy);
     174    PointCoord(:,1)=reshape(GridX,[],1);
     175    PointCoord(:,2)=reshape(GridY,[],1);
     176    if ~isempty(par_civ2.maskname)&& ~strcmp(maskname,par_civ2.maskname)% mask exist, not already read in civ1
     177        mask=imread(par_civ2.maskname);
     178    end
     179    % caluclate velocity data (y and v in indices, reverse to y component)
     180    [xtable ytable utable vtable ctable F] = pivlab (image1,image2,ibx2,iby2,isx2,isy2,shiftx,-shifty,PointCoord,str2num(par_civ1.rho),mask);
     181    list_param=(fieldnames(par_civ1))';
     182    list_remove={'pxcmx','pxcmy','npx','npy','gridflag','maskflag','term_a','term_b','T0'};
     183    index=zeros(size(list_param));
     184    for ilist=1:length(list_remove)
     185        index=strcmp(list_remove{ilist},list_param);
     186        if ~isempty(find(index,1))
     187            list_param(index)=[];
     188        end
     189    end
     190    for ilist=1:length(list_param)
     191        Civ1_param{ilist}=['Civ1_' list_param{ilist}];
     192        eval(['Data.Civ1_' list_param{ilist} '=Param.Civ1.' list_param{ilist} ';'])
     193    end
     194    if isfield(Data,'Civ1_gridname') && strcmp(Data.Civ1_gridname(1:6),'noFile')
     195        Data.Civ1_gridname='';
     196    end
     197    if isfield(Data,'Civ1_maskname') && strcmp(Data.Civ1_maskname(1:6),'noFile')
     198        Data.Civ1_maskname='';
     199    end
     200    Data.ListGlobalAttribute=[Data.ListGlobalAttribute Civ1_param {'Civ1_Time','Civ1_Dt'}];
     201    Data.Civ1_Time=str2double(par_civ1.T0);
     202    Data.Civ1_Dt=str2double(par_civ1.Dt);
     203    Data.ListVarName={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_C','Civ1_F'};%  cell array containing the names of the fields to record
     204    Data.VarDimName={'nbvec1','nbvec1','nbvec1','nbvec1','nbvec1','nbvec1'};
     205    Data.VarAttribute{1}.Role='coord_x';
     206    Data.VarAttribute{2}.Role='coord_y';
     207    Data.VarAttribute{3}.Role='vector_x';
     208    Data.VarAttribute{4}.Role='vector_y';
     209    Data.VarAttribute{5}.Role='warnflag';
     210    Data.Civ1_X=reshape(xtable,[],1);
     211    Data.Civ1_Y=reshape(size(image1,1)-ytable+1,[],1);
     212    Data.Civ1_U=reshape(utable,[],1);
     213    Data.Civ1_V=reshape(-vtable,[],1);
     214    Data.Civ1_C=reshape(ctable,[],1);
     215    Data.Civ1_F=reshape(F,[],1);
     216    Data.CivStage=Data.CivStage+1;
     217end
    150218%% write result
    151219% 'TESTcalc'
  • trunk/src/editxml.m

    r180 r248  
    330330    head_name=get(t,1,'name');
    331331    %Path to shemas:
    332 %     path_uvmat=which('editxml');% check the path detected for source file uvmat
    333 %     path_UVMAT=fileparts(path_uvmat); %path to UVMAT
    334 %     xmlparam=fullfile(path_UVMAT,'PARAM.xml');
     332    path_uvmat=which('editxml');% check the path detected for source file uvmat
     333    path_UVMAT=fileparts(path_uvmat); %path to UVMAT
     334    %     xmlparam=fullfile(path_UVMAT,'PARAM.xml');
    335335    xmlparam='PARAM.xml'; %will find PARAM.xml whose path is set in priority
    336336    if exist(xmlparam,'file')
     
    338338        sparam=convert(tparam);
    339339        if isfield(sparam,'SchemaPath')
    340             schemafile=[fullfile(sparam.SchemaPath,head_name) '.xsd'];
    341         end
    342         if ~exist(schemafile,'file')
    343             schemafile=fullfile(path_UVMAT,schemafile);%look for relative path definition
    344         end
    345         if exist(schemafile,'file')
    346             xs=xmltree(schemafile);
    347         else
    348             msgbox_uvmat('ERROR',['The xml schema for ' CurrentFile ' is unknown, check the schema path set in the file PARAM.xml'])
    349             [FileName, PathName]=uigetfile( ...
    350            {'*.xsd', '(*.xsd)';
    351             '*.xsd',  '.xsd files '; ...
    352             '*.*',  'All Files (*.*)'}, ...
    353             'Pick a .xsd schema' ,schemafile); %file browser
    354             if ischar(PathName) && ischar(FileName) && exist(fullfile(PathName,FileName),'file')
    355                 DataIn.Schema=fullfile(PathName,FileName);
    356                 xs=xmltree(DataIn.Schema);%open the associated schema file
     340            schemafile=[fullfile(sparam.SchemaPath,head_name) '.xsd'];           
     341            if ~exist(schemafile,'file')
     342                schemafile=fullfile(path_UVMAT,schemafile);%look for relative path definition
     343            end
     344            if exist(schemafile,'file')
     345                xs=xmltree(schemafile);
    357346            else
    358                 xs=[];
     347                msgbox_uvmat('ERROR',['The needed xml schema  ' sparam.SchemaPath ' is not found, check the file PARAM.xml'])
     348                [FileName, PathName]=uigetfile( ...
     349                    {'*.xsd', '(*.xsd)';
     350                    '*.xsd',  '.xsd files '; ...
     351                    '*.*',  'All Files (*.*)'}, ...
     352                    'Pick a .xsd schema' ,schemafile); %file browser
     353                if ischar(PathName) && ischar(FileName) && exist(fullfile(PathName,FileName),'file')
     354                    DataIn.Schema=fullfile(PathName,FileName);
     355                    xs=xmltree(DataIn.Schema);%open the associated schema file
     356                else
     357                    xs=[];
     358                end
    359359            end
    360360        end
  • trunk/src/mouse_motion.m

    r231 r248  
    224224                       xround=Field.X(ind_pt);
    225225                       yround=Field.Y(ind_pt);
    226 %                         if isfield(Field,'A')
    227226%                             dx=str2double(par.dx);
    228227%                             dy=str2double(par.dy);
     
    253252                            set(hhhh,'Position',[xround-isx2+shiftx yround-isy2+shifty 2*isx2 2*isy2])
    254253                        end
    255                         [xtable ytable utable vtable ctable typevector result_conv] = pivlab (Field.A,Field.B,ibx2,iby2,isx2,isy2,shiftx,shifty,[xround yround], 1, []);
     254                        [xtable ytable utable vtable ctable typevector result_conv] = pivlab (Field.A,Field.B,ibx2,iby2,isx2,isy2,shiftx,shifty,[xround size(Field.A,1)-yround+1], 1, []);
    256255%                         Asub=Field.A(yround-iby2:yround+iby2,xround-ibx2:xround+ibx2);%first sub-image
    257256%                         Asub=reshape(Asub,[],1);%first sub-image reshaped as matlab vector
  • trunk/src/pivlab.m

    r246 r248  
    4242%% mask
    4343testmask=0;
     44image1=double(image1);
     45image2=double(image2);
    4446if exist('mask','var') && ~isempty(mask)
    4547   testmask=1;
     
    5456    %  100>=mask> 20: velocity not calculated, impermeable (no flux through mask boundaries)
    5557    %  20>=mask: velocity=0
    56     test_noflux=(mask<=100) ;
    57     test_undefined=(mask<=200 & mask>100 );
    58     image1(test_undefined)=min(min(image1))*ones(size(image1));% put image to zero in the undefined  area
    59     image2(test_undefined)=min(min(image1))*ones(size(image1));% put image to zero in the undefined  area
     58    test_noflux=(mask<100) ;
     59    test_undefined=(mask<200 & mask>=100 );
     60    image1(test_undefined)=min(min(image1));% put image to zero in the undefined  area
     61    image2(test_undefined)=min(min(image2));% put image to zero in the undefined  area
    6062end
    61 image1=double(image1);
    62 image2=double(image2);
    6363
    6464%% calculate correlations: MAINLOOP
  • trunk/src/proj_field.m

    r236 r248  
    17721772            testbound=1;
    17731773        end
    1774         if testYMin
     1774        if testYMax
    17751775            testin=testin & (coord_Y <= YMax);
    17761776            testbound=1;
  • trunk/src/series.m

    r246 r248  
    21672167
    21682168%check the current path to the selected function
     2169if ~isempty(list_transform{ind_coord})
    21692170func=functions(list_transform{ind_coord});
    21702171set(handles.path_transform,'String',fileparts(func.file)); %show the path to the senlected function
    2171 
     2172else
     2173   set(handles.path_transform,'String',''); %show the path to the senlected function
     2174end
    21722175%------------------------------------------------------------------------
    21732176% --- generates a series of file names with reference numbers between range1 and
  • trunk/src/uvmat.m

    r247 r248  
    14941494            maskname=maskfiles(ilist).name;% take the first mask file in the list
    14951495            [rr,ff,x1,x2,xa,xb,xext,Mask_NomType{ilist}]=name2display(maskname);
    1496             if ~strcmp(Mask_NomType{ilist},Mask_NomType{1})
    1497                 msgbox_uvmat('ERROR',['inconsistent mask types ' Mask_NomType{1} Mask_NomType{ilist } ' coexist in the current image directory'])
    1498                 return
    1499             end
     1496%
     1497%             if ~strcmp(Mask_NomType{ilist},Mask_NomType{1})
     1498%                 msgbox_uvmat('ERROR',['inconsistent mask types ' Mask_NomType{1} ' and ' Mask_NomType{ilist } ' coexist in the current image directory'])
     1499%                 return
     1500%             end
    15001501            [Path2,Name,ext]=fileparts(maskname);
    15011502            Namedouble=double(Name);
     
    15211522            Mask.NbSlice=nbslice;
    15221523            num_i1=mod(num_i1-1,nbslice)+1;
    1523             Mask.NomType=Mask_NomType{1};
     1524            Mask.NomType=regexprep(Mask_NomType{1},'0','');%remove '0' in nom type for masks
    15241525            [maskname,mdetect]=name_generator(Mask.Base,num_i1,num_j1,'.png',Mask.NomType);%
    15251526            mdetect=exist(maskname,'file');
     
    21472148    ParamIn.GUIName='get_field';
    21482149    [Field{1},ParamOut,errormsg] = read_field(ObjectName,FileType,ParamIn,num_i1);
    2149     Field{1}
    21502150    if ~isempty(errormsg)
    21512151        errormsg=['error in reading ' filename ': ' errormsg];
     
    25942594
    25952595%% Plot the projections on the selected  projection objects
    2596 'PLOT'
     2596
    25972597% main projection object (uvmat display)
    25982598list_object=get(handles.list_object_1,'String');
Note: See TracChangeset for help on using the changeset viewer.