Changeset 1165


Ignore:
Timestamp:
Jul 30, 2024, 6:44:35 PM (2 months ago)
Author:
sommeria
Message:

various bugs repaired

Location:
trunk/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/filter_tps_3D.m

    r1164 r1165  
    3838%=======================================================================
    3939
    40 function [SubRange,NbCentre,Coord_tps,U_tps,V_tps,W_tps,U_smooth,V_smooth,W_smooth,FF] =filter_tps_3D(Coord_x,Coord_y,Coord_z,U,V,W,SubDomainSize,FieldSmooth,Threshold)
     40function [SubRange,NbCentre,Coord_tps,U_tps,V_tps,W_tps,U_smooth,V_smooth,W_smooth,FF] =filter_tps_3D(Coord,U,V,W,SubDomainSize,FieldSmooth,Threshold)
    4141
    4242%% adjust subdomain decomposition
    4343warning off
    4444% [npz,npy,npx]=size(Coord_x);
    45 Coord=[Coord_x Coord_y Coord_z];
    46 NbVec=numel(Coord_x);% nbre of vectors in the field to interpolate
     45% Coord=[Coord_x Coord_y Coord_z];
     46NbVec=size(Coord,1);% nbre of vectors in the field to interpolate
    4747NbCoord=3;% space dimension,Coord(:,1)= x,Coord(:,2)=  y , Coord(:,3)=  z
    4848MinCoord=min(Coord,[],1);%lower coordinate bounds
    4949MaxCoord=max(Coord,[],1);%upper coordinate bounds
    5050Range=MaxCoord-MinCoord;%along eacch coordiante x,y,z
    51 Cellmesh=(10*prod(Range)/NbVec)^(1/3);
     51Cellmesh=(10*prod(Range)*SubDomainSize/NbVec)^(1/3);
    5252NbSubDomainX=ceil(Range(1)/Cellmesh);
    5353NbSubDomainY=ceil(Range(2)/Cellmesh);
  • trunk/src/geometry_calib.m

    r1159 r1165  
    850850    end
    851851    outputfile=[filebase '.xml'];
    852     [~,RootFile]=fileparts(filebase);
    853     [~,~,errormsg]=update_imadoc(RootPath,SubDir,'GeometryCalib',GeometryCalib,0);
    854     if ~strcmp(errormsg,'')
    855         msgbox_uvmat('ERROR',errormsg);
     852 %   [~,RootFile]=fileparts(filebase);
     853
     854    t=xmltree;
     855    t=set(t,1,'name','ImaDoc');
     856    [t,uid_calib]=add(t,1,'element','GeometryCalib');
     857   % xmlfile=[filebase '.xml'];
     858    t=struct2xml(GeometryCalib,t,uid_calib);
     859    save(t)
     860    try
     861        save(t,outputfile);
     862    catch ME
     863        errormsg=['error in saving ' outputfile ': ' ME.message];
     864         msgbox_uvmat('ERROR',errormsg);
    856865    end
    857866    listfile=get(handles.ListCoordFiles,'string');
  • trunk/src/get_file_info.m

    r1164 r1165  
    147147                        nbfield=numel(fieldnames(FileInfo));
    148148                        FileInfo=orderfields(FileInfo,[nbfield nbfield-1 nbfield-2 (1:nbfield-3)]); %reorder the fields of fileInfo for clarity
     149                    catch ME
     150                        FileInfo.error=ME.message
    149151                    end
    150152                else
     
    209211                                end
    210212                                FileInfo.ListDimName=Data.ListDimName;
    211                                 FileInfo.NumberOfFrames=Data.DimValue;
     213%                                 FileInfo.NumberOfFrames=Data.DimValue;
    212214                            end
    213215                        else
  • trunk/src/series/civ_3D.m

    r1164 r1165  
    299299        par_civ1.ImageA=zeros(2*SearchRange_z+1,npy,npx);%image block initiation
    300300        par_civ1.ImageB=zeros(2*SearchRange_z+1,npy,npx);
    301         Data.Coord_z=SearchRange_z+1:par_civ1.Dz:NbSlice-1;
    302         z_index=1;%first vertical block centered at image index z_index=SearchRange_z+1
    303         for iz=1:2*SearchRange_z+1
     301        Data.Coord_z=(1:floor((NbSlice-SearchRange_z)/par_civ1.Dz))+SearchRange_z;%SearchRange_z+1:par_civ1.Dz:NbSlice-1;
     302        z_index=1;%first vertical block centered at image index par_civ1.Dz (not SearchRange_z+1
     303        for iz=1:par_civ1.Dz+SearchRange_z%2*SearchRange_z+1
    304304            j_image_index=j1_series_Civ1(iz,1)% j index of the current image
    305305            ImageName_A=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_series_Civ1(1,ifield),[],j_image_index);%
     
    307307            ImageName_B=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_series_Civ1(1,ifield),[],j_image_index);
    308308            B= read_image(ImageName_B,FileType_B);
    309             par_civ1.ImageA(iz,:,:) = A;
    310             par_civ1.ImageB(iz,:,:) = B;
     309            par_civ1.ImageA(iz+SearchRange_z-par_civ1.Dz+1,:,:) = A;
     310            par_civ1.ImageB(iz+SearchRange_z-par_civ1.Dz+1,:,:) = B;
    311311        end
    312312       
     
    354354            par_civ1.ImageB=circshift(par_civ1.ImageB,-par_civ1.Dz,1);
    355355            for iz=1:par_civ1.Dz %read the new images at the end of the image block
    356                 image_index=z_index*par_civ1.Dz+SearchRange_z-par_civ1.Dz+iz+1;
    357                 if image_index<=size(j1_series_Civ1,1)
    358                     j_image_index=j1_series_Civ1(z_index*par_civ1.Dz+SearchRange_z-par_civ1.Dz+iz+1,1)
     356                j_image_index=z_index*par_civ1.Dz+SearchRange_z-par_civ1.Dz+iz
     357                if j_image_index<=size(j1_series_Civ1,1)
     358%                     j_image_index=j1_series_Civ1(image_index,1)
    359359                    ImageName_A=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_series_Civ1(1,ifield),[],j_image_index);%
    360360                    A= read_image(ImageName_A,FileType_A);
     
    444444        Data.VarAttribute{nbvar+2}.Role='vector_y';
    445445        Data.VarAttribute{nbvar+5}.Role='vector_z';
     446       
     447        [Data.ListVarName,IA]=unique(Data.ListVarName);%suppress duplicate definition of variables (in cas of patch redone from previous file)
     448        Data.VarDimName=Data.VarDimName(IA);
     449        Data.VarAttribute=Data.VarAttribute(IA);
    446450        Data.Civ1_U_smooth=Data.Civ1_U;
    447451        Data.Civ1_V_smooth=Data.Civ1_V;
     
    466470        [Data.Civ1_SubRange,Data.Civ1_NbCentres,Data.Civ1_Coord_tps,Data.Civ1_U_tps,Data.Civ1_V_tps,Data.Civ1_W_tps,...
    467471            Data.Civ1_U_smooth(ind_good),Data.Civ1_V_smooth(ind_good),Data.Civ1_W_smooth(ind_good),FFres]=...
    468             filter_tps_3D(Data.Civ1_X(ind_good),Data.Civ1_Y(ind_good),Civ1_Z(ind_good),Data.Civ1_U(ind_good),Data.Civ1_V(ind_good),Data.Civ1_W(ind_good),...
     472            filter_tps_3D([Data.Civ1_X(ind_good) Data.Civ1_Y(ind_good) Civ1_Z(ind_good)],Data.Civ1_U(ind_good),Data.Civ1_V(ind_good),Data.Civ1_W(ind_good),...
    469473            Data.Patch1_SubDomainSize,Data.Patch1_FieldSmooth,Data.Patch1_MaxDiff);
    470474        Data.Civ1_FF(ind_good)=uint8(4*FFres);
     
    699703        Data.VarDimName=[Data.VarDimName {'nb_vec_2','nb_vec_2',{'nb_coord','nb_bounds','nb_subdomain_2'},{'nb_subdomain_2'},...
    700704            {'nb_tps_2','nb_coord','nb_subdomain_2'},{'nb_tps_2','nb_subdomain_2'},{'nb_tps_2','nb_subdomain_2'}}];
     705     
     706       
    701707       
    702708        Data.VarAttribute{nbvar+1}.Role='vector_x';
  • trunk/src/series/civ_series.m

    r1164 r1165  
    456456                    par_civ1.NbSlice_j=par_civ1.NbSlice;
    457457                end
    458             end
    459         else
    460             maskname=Param.ActionInput.Civ1.Mask;
    461         end
    462         if strcmp(maskoldname,maskname)% mask exist, not already read in civ1
    463             par_civ1.Mask=mask; %use mask already opened
    464         else
    465             if ~isempty(regexp(maskname,'(^http://)|(^https://)', 'once'))|| exist(maskname,'file')
    466                 try
    467                     par_civ1.Mask=imread(maskname);%update the mask, an store it for future use
    468                 catch ME
    469                     if ~isempty(ME.message)
    470                         errormsg=['error reading input image: ' ME.message];
    471                         disp_uvmat('ERROR',errormsg,checkrun)
    472                         return
     458            else
     459                maskname=Param.ActionInput.Civ1.Mask;
     460            end
     461            if strcmp(maskoldname,maskname)% mask exist, not already read in civ1
     462                par_civ1.Mask=mask; %use mask already opened
     463            else
     464                if ~isempty(regexp(maskname,'(^http://)|(^https://)', 'once'))|| exist(maskname,'file')
     465                    try
     466                        par_civ1.Mask=imread(maskname);%update the mask, an store it for future use
     467                    catch ME
     468                        if ~isempty(ME.message)
     469                            errormsg=['error reading input image: ' ME.message];
     470                            disp_uvmat('ERROR',errormsg,checkrun)
     471                            return
     472                        end
    473473                    end
    474                 end
    475             else
    476                 par_civ1.Mask=[];
    477             end
    478             mask=par_civ1.Mask;
    479             maskoldname=maskname;
    480         end
    481        
     474                else
     475                    par_civ1.Mask=[];
     476                end
     477                mask=par_civ1.Mask;
     478                maskoldname=maskname;
     479            end
     480        end
    482481       
    483482        % case of input grid
     
    495494            return
    496495        end
    497        
    498         if exist('ncfile','var')
    499             CivFile=ncfile;
    500             % [Data,tild,tild,errormsg]=nc2struct(CivFile,'ListGlobalAttribute','absolut_time_T0'); %look for the constant 'absolut_time_T0' to detect old civx data format
    501             % if ~isempty(errormsg)
    502             %     disp_uvmat('ERROR',errormsg,checkrun)
    503             %     return
    504             % end
    505             [Data,tild,tild,errormsg]=nc2struct(CivFile);%read civ1 and fix1 data in the existing netcdf file
    506         elseif isfield(Param,'Civ1_X')
    507             Data.ListGlobalAttribute={};
    508             Data.ListVarName={};
    509             Data.VarDimName={};
    510             Data.Civ1_X=Param.Civ1_X;
    511             Data.Civ1_Y=Param.Civ1_Y;
    512             Data.Civ1_U=Param.Civ1_U;
    513             Data.Civ1_V=Param.Civ1_V;
    514             Data.Civ1_FF=Param.Civ1_FF;
    515         end
     496%         
     497%         if exist('ncfile','var')
     498%             CivFile=ncfile;
     499%             % [Data,tild,tild,errormsg]=nc2struct(CivFile,'ListGlobalAttribute','absolut_time_T0'); %look for the constant 'absolut_time_T0' to detect old civx data format
     500%             % if ~isempty(errormsg)
     501%             %     disp_uvmat('ERROR',errormsg,checkrun)
     502%             %     return
     503%             % end
     504%             [Data,tild,tild,errormsg]=nc2struct(CivFile);%read civ1 and fix1 data in the existing netcdf file
     505%             if ~isempty(errormsg)
     506%                 disp(errormsg)
     507%                 return
     508%             end
     509%         elseif isfield(Param,'Civ1_X')
     510%             Data.ListGlobalAttribute={};
     511%             Data.ListVarName={};
     512%             Data.VarDimName={};
     513%             Data.Civ1_X=Param.Civ1_X;
     514%             Data.Civ1_Y=Param.Civ1_Y;
     515%             Data.Civ1_U=Param.Civ1_U;
     516%             Data.Civ1_V=Param.Civ1_V;
     517%             Data.Civ1_FF=Param.Civ1_FF;
     518%         end
    516519    end
    517520
  • trunk/src/series/filter_time.m

    r1158 r1165  
    128128NbField_j=size(i1_series{1},1); %nb of fields for the j index (bursts or volume slices)
    129129NbField_i=size(i1_series{1},2); %nb of fields for the i index
    130 NbField=NbField_j*NbField_i; %total number of fields
     130NbSeries=NbField_j*NbField_i; %total number of fields
    131131
    132132%% define the output file (unique for the whole series)
     
    146146disp('loop for filtering started')
    147147     
    148 for index=1:NbField
     148for index=1:NbSeries
    149149    index
    150150   
    151     Field= read_field(filecell{1,index},'netcdf',Param.InputFields);
     151    [Field,~,errormsg]= read_field(filecell{1,index},'netcdf',Param.InputFields);
     152
     153
    152154   
    153155    %%%%%%%%%%% MAIN RUNNING OPERATIONS  %%%%%%%%%%%%
     
    181183    % Vblock=circshift(Vblock,[-1 0 0 0]); %shift U by ishift along the first index
    182184    % Wblock=circshift(Wblock,[-1 0 0]); %shift U by ishift along the first index
    183     TimeBlock(end)=Field.Time;
    184     for ilist=1:NbField
    185     UVblock(end,ilist,:,:)=Field.(ListFields{ilist});
     185   
     186    if isempty(errormsg)
     187        TimeBlock(end)=Field.Time;
     188        for ilist=1:NbField
     189            UVblock(end,ilist,:,:)=Field.(ListFields{ilist});
     190        end
     191    else
     192        TimeBlock(end)=NaN;
     193        for ilist=1:NbField
     194            UVblock(end,ilist,:,:)=NaN;
     195        end
    186196    end
    187197    % Vblock(end,:,:)=Field.V;
    188198    % Vblock(end,:,:)=Field.W;
    189199    sumindex=min(index,Param.ActionInput.WindowLength)-1;
    190     DataOut.Timefilter=mean(TimeBlock(end-sumindex:end,:));%mid time
     200    DataOut.Timefilter=mean(TimeBlock(end-sumindex:end,:),'omitnan');%mid time
    191201    for ilist=1:NbField
    192     DataOut.(ListFilter{ilist})=squeeze(mean(UVblock(end-sumindex:end,ilist,:,:),1,'omitnan'));
     202    DataOut.(ListFilter{ilist})=squeeze(mean(UVblock(end-sumindex:end,ilist,:,:),1,'omitnan'));% take average in the block, omitting NaN
    193203    end
    194204    % DataOut.Vfilter=squeeze(mean(Vblock(end-sumindex:end,:,:),1,'omitnan'));
  • trunk/src/update_imadoc.m

    r1152 r1165  
    8282    t=set(t,1,'name','ImaDoc');
    8383    [t,uid_calib]=add(t,1,'element',StructName);
     84    xmlfile=fullfile(RootPath,[SubDir '.xml']);
    8485end
    8586
Note: See TracChangeset for help on using the changeset viewer.