Changeset 319 for trunk/src/civ_matlab.m


Ignore:
Timestamp:
Dec 6, 2011, 8:14:57 PM (12 years ago)
Author:
sommeria
Message:

civ: bugs for displacement mode repaired
civ and civ_matlab prepared for batch in Matlab (file .civ.xml created)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ_matlab.m

    r317 r319  
    4646check_patch1=0;%default
    4747
     48if ischar(Param)
     49    t=xmltree(Param);
     50    Param=convert(t);
     51end
     52
    4853%% Civ1
    4954if isfield (Param,'Civ1')
     
    6267    end
    6368    Data.ListGlobalAttribute=[Data.ListGlobalAttribute Civ1_param];% {'Civ1_Time','Civ1_Dt'}];
    64 %     if exist('ncfile','var')% TEST for use interactively with mouse_motion (no file created)
    65         Data.ListVarName={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_C','Civ1_F'};%  cell array containing the names of the fields to record
    66         Data.VarDimName={'nbvec1','nbvec1','nbvec1','nbvec1','nbvec1','nbvec1'};
    67         Data.VarAttribute{1}.Role='coord_x';
    68         Data.VarAttribute{2}.Role='coord_y';
    69         Data.VarAttribute{3}.Role='vector_x';
    70         Data.VarAttribute{4}.Role='vector_y';
    71         Data.VarAttribute{5}.Role='warnflag';
     69    %     if exist('ncfile','var')% TEST for use interactively with mouse_motion (no file created)
     70    Data.ListVarName={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_C','Civ1_F'};%  cell array containing the names of the fields to record
     71    Data.VarDimName={'nbvec1','nbvec1','nbvec1','nbvec1','nbvec1','nbvec1'};
     72    Data.VarAttribute{1}.Role='coord_x';
     73    Data.VarAttribute{2}.Role='coord_y';
     74    Data.VarAttribute{3}.Role='vector_x';
     75    Data.VarAttribute{4}.Role='vector_y';
     76    Data.VarAttribute{5}.Role='warnflag';
    7277    Data.Civ1_X=reshape(xtable,[],1);
    7378    Data.Civ1_Y=reshape(Param.Civ1.ImageHeight-ytable+1,[],1);
     
    7782    Data.Civ1_F=reshape(F,[],1);
    7883    Data.CivStage=1;
    79 
     84   
    8085else
    81     Data=nc2struct(ncfile,'ListGlobalAttribute','absolut_time_T0') %look for the constant 'absolut_time_T0' to detect old civx data format
     86    if exist('ncfile','var')
     87        CivFile=ncfile;
     88    elseif isfield(Param.Patch1,'CivFile')
     89        CivFile=Param.Patch1.CivFile;
     90    end
     91    Data=nc2struct(CivFile,'ListGlobalAttribute','absolut_time_T0') %look for the constant 'absolut_time_T0' to detect old civx data format
    8292    if isfield(Data,'Txt')
    83             errormsg=Data.Txt;
     93        errormsg=Data.Txt;
    8494        return
    8595    end
    8696    if ~isempty(Data.absolut_time_T0')%read civx file
    8797        check_civx=1;% test for old civx data format
    88         [Data,vardetect,ichoice]=nc2struct(ncfile);%read the variables in the netcdf file
     98        [Data,vardetect,ichoice]=nc2struct(CivFile);%read the variables in the netcdf file
    8999    else
    90100        if isfield(Param,'Fix1')
    91             Data=nc2struct(ncfile,ListVarCiv1);%read civ1 data in the existing netcdf file
     101            Data=nc2struct(CivFile,ListVarCiv1);%read civ1 data in the existing netcdf file
    92102        else
    93             Data=nc2struct(ncfile,ListVarFix1);%read civ1 and fix1 data in the existing netcdf file
     103            Data=nc2struct(CivFile,ListVarFix1);%read civ1 and fix1 data in the existing netcdf file
    94104        end
    95105    end
    96 
    97106end
    98107
     
    296305
    297306%% write result in a netcdf file if requested
    298 if exist('ncfile','var') && ~(isfield(Param,'CheckOuputFile')&&Param.CheckOuputFile)
     307if exist('ncfile','var')
    299308    errormsg=struct2nc(ncfile,Data);
    300309end
     
    420429    iref=par_civ.Grid(ivec,1);% xindex on the image A for the middle of the correlation box
    421430    jref=par_civ.Grid(ivec,2);% yindex on the image B for the middle of the correlation box
    422 %     xtable(ivec)=iref;
    423 %     ytable(ivec)=jref;%default
     431    %     xtable(ivec)=iref;
     432    %     ytable(ivec)=jref;%default
    424433    if ~(checkmask && par_civ.Mask(jref,iref)<=20) %velocity not set to zero by the black mask
    425         if jref-iby2<1 || jref+iby2>par_civ.ImageHeight|| iref-ibx2<1 || iref+ibx2>par_civ.ImageWidth
     434        if jref-iby2<1 || jref+iby2>par_civ.ImageHeight|| iref-ibx2<1 || iref+ibx2>par_civ.ImageWidth% we are outside the image
    426435            F(ivec)=3;
    427436        else
     
    434443                F(ivec)=3;
    435444            end
     445            %threshold on image maximum
     446            if check_MaxIma && (image1_mean > par_civ.MaxIma || image2_mean > par_civ.MaxIma)
     447                F(ivec)=3;
     448            end
    436449        end
    437         %threshold on image maximum
    438         if check_MaxIma && (image1_mean > par_civ.MaxIma || image2_mean > par_civ.MaxIma)
    439             F(ivec)=3;
    440         end
     450       
    441451        if F(ivec)~=3
    442452            image1_crop=image1_crop-image1_mean;%substract the mean
Note: See TracChangeset for help on using the changeset viewer.