Changeset 248 for trunk/src/civ_uvmat.m


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

various modifications

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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'
Note: See TracChangeset for help on using the changeset viewer.