Changeset 1122


Ignore:
Timestamp:
Apr 21, 2023, 11:01:06 AM (18 months ago)
Author:
sommeria
Message:

various updates

Location:
trunk/src
Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/fill_GUI.m

    r1107 r1122  
    103103                                    input_string=num2str(input_data(ibox),4);
    104104                                end
    105                             else
     105                            elseif ischar(input_data)
    106106                                input_string=input_data;
    107107                            end
  • trunk/src/get_file_info.m

    r1120 r1122  
    5858FileInfo.FileType='';% input file does not exist
    5959FileInfo.FieldType=''; %default output
     60if ~ischar(fileinput)
     61    return
     62end
    6063% check the existence (not possible for OpenDAP data)
    6164if ~isempty(regexp(fileinput,'^http://'))|| exist(fileinput,'file')
  • trunk/src/read_image.m

    r1107 r1122  
    3535%-----------------------------------------------------------------------
    3636if ~exist('FileType','var')
     37    FileType='image';
     38end
     39if isempty(FileType)
    3740    FileType='image';
    3841end
  • trunk/src/series/civ_input.m

    r1107 r1122  
    114114        end
    115115        NomTypeNc=NomTypeInput;
    116         ind_opening=FileInfo.CivStage;
     116        ind_opening=SeriesData.FileInfo{1}.CivStage;
    117117        if isempty(regexp(NomTypeInput,'[ab|AB|-]', 'once'))
    118118            set(handles.ListCompareMode,'Value',2) %mode displacement advised if the nomencalture does not involve index pairs
     
    120120            set(handles.ListCompareMode,'Value',1)
    121121        end
    122         [Data,tild,tild,errormsg]=nc2struct(FileInfo.FileName,[]);
     122        [Data,tild,tild,errormsg]=nc2struct(SeriesData.FileInfo{1}.FileName,[]);
    123123        if ~isempty(errormsg)
    124124            msgbox_uvmat('ERROR',['error in netcdf input file: ' errormsg])
  • trunk/src/series/civ_series.m

    r1115 r1122  
    377377        end
    378378    end
     379    ImageName_A='';ImageName_B='';%default
     380    VideoObject_A=[];VideoObject_B=[];
    379381    %% Civ1
    380382    % if Civ1 computation is requested
     
    650652            par_civ2.ImageB=[];
    651653            if strcmp(Param.ActionInput.ListCompareMode,'displacement')
    652                     ImageName_A_Civ2=Param.ActionInput.RefFile;
    653                 else
    654             ImageName_A_Civ2=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_civ2,[],j1_civ2);
     654                ImageName_A_Civ2=Param.ActionInput.RefFile;
     655            else
     656                ImageName_A_Civ2=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_civ2,[],j1_civ2);
    655657            end
    656658            if strcmp(ImageName_A_Civ2,ImageName_A) && isequal(FrameIndex_A_Civ1(ifield),FrameIndex_A_Civ2(ifield))
     
    665667                [par_civ2.ImageB,VideoObject_B] = read_image(ImageName_B_Civ2,FileType_B,VideoObject_B,FrameIndex_B_Civ2(ifield));
    666668            end
     669            [FileInfo_A,VideoObject_A]=get_file_info(ImageName_A_Civ2);
    667670            par_civ2.ImageWidth=FileInfo_A.Width;
    668671            par_civ2.ImageHeight=FileInfo_A.Height;
  • trunk/src/series/merge_proj_volume.m

    r1121 r1122  
    200200DataVol.Time=0; %TO UPDATE
    201201DataVol.ListVarName={'coord_x','coord_y','coord_z','A'};
    202 DataVol.VarDimName={'coord_x','coord_y','coord_z',{'coord_z','coord_y','coord_x'}};
     202DataVol.VarDimName={'coord_x','coord_y','coord_z',{'coord_y','coord_x','coord_z'}};
    203203DataVol.VarAttribute{1}.Role='coord_x';
    204204DataVol.VarAttribute{2}.Role='coord_y';
     
    257257
    258258for index_i=1:NbField_i
    259     AMerge=zeros(NbField_j,numel(DataVol.coord_y),numel(DataVol.coord_x));
     259   
    260260    for index_j=1:NbField_j
    261261        index_j
     
    268268
    269269        %%%%%%%%%%%%%%%% loop on views (input lines) %%%%%%%%%%%%%%%%
    270         Data=cell(1,NbView);%initiate the set Data
     270       
    271271        timeread=zeros(1,NbView);
    272         for iview=1:NbView
     272%         for iview=1:NbView
    273273            %% reading input file(s)
    274             [Data{iview},tild,errormsg] = read_field(filecell{iview,index_j},FileType{iview},ParamIn{iview},frame_index{iview}(index_j));
     274            [Data,tild,errormsg] = read_field(filecell{1,index_j},FileType{1},ParamIn{1},frame_index{1}(index_j));
    275275            if ~isempty(errormsg)
    276276                disp_uvmat('ERROR',['ERROR in merge_proj/read_field/' errormsg],checkrun)
    277277                return
    278278            end
    279             ListVar=Data{iview}.ListVarName;
     279            Data.A=Data.A(1:4:end,1:4:end);% reduce the mage size
     280            ListVar=Data.ListVarName;
     281            %reduce the image size
    280282            for ilist=1:numel(ListVar)
    281                 Data{iview}.(ListVar{ilist})=double(Data{iview}.(ListVar{ilist}));% transform all fields in double before all operations
     283                Data.(ListVar{ilist})=double(Data.(ListVar{ilist}));% transform all fields in double before all operations
    282284            end
    283285            % get the time defined in the current file if not already defined from the xml file
    284             if ~isempty(time) && isfield(Data{iview},'Time')
    285                 timeread(iview)=Data{iview}.Time;
     286            if ~isempty(time) && isfield(Data,'Time')
     287                timeread(iview)=Data.Time;
    286288            end
    287             Data{iview}.ZIndex=index_j;
    288             [X,Y]=meshgrid(DataVol.coord_x,DataVol.coord_y);%grid in physical coordinates
    289             Data{iview}=proj_plane(Data{iview},XmlData{iview},X,Y); %project on the common x,y plane
     289            Data.ZIndex=index_j;
     290            [X,Y,Z]=meshgrid(DataVol.coord_x,DataVol.coord_y,DataVol.coord_z);%grid in physical coordinates
     291            %Data{iview}=proj_plane(Data{iview},XmlData{iview},X,Y); %project on the common x,y plane
     292
     293        if index_j==1
     294            AMerge=zeros(size(Data.A,1),size(Data.A,2),NbField_j);
    290295        end
    291         % merge the NbView fields only to merge views from several cameras)
    292 
    293         %     [MergeData,errormsg]=merge_field(ProjData);
    294         %     if ~isempty(errormsg)
    295         %         disp_uvmat('ERROR',errormsg,checkrun);
    296         %         return
    297         %     end
    298         AMerge(index_j,:,:)=Data{iview}.A;
     296        AMerge(:,:,index_j)=Data.A;
    299297
    300298        %%%%%%%%%%%%%%%% END LOOP FOR VOLUME SCAN %%%%%%%%%%%%%%%%
    301299    end
    302300    %interpolate on the vertical grid
    303     Z=zeros(1,NbField_j);
    304     for j_index=1:numel(DataVol.coord_y)
    305         for i_index=1:numel(DataVol.coord_x)
    306             for ZIndex=1:NbField_j
    307             Z(ZIndex)=Zpos(XmlData{iview},ZIndex,X(j_index,i_index),Y(j_index,i_index));
    308             end
    309             DataVol.A(:,j_index,i_index) = interp1(Z,AMerge(:,j_index,i_index),DataVol.coord_z);
    310         end
    311     end
     301    DataVol.A=proj_volume(AMerge,XmlData{1},X,Y,Z);
     302%     Z=zeros(1,NbField_j);
     303%     for j_index=1:numel(DataVol.coord_y)
     304%         for i_index=1:numel(DataVol.coord_x)
     305%             for ZIndex=1:NbField_j
     306%             Z(ZIndex)=Zpos(XmlData{iview},ZIndex,X(j_index,i_index),Y(j_index,i_index));
     307%             end
     308%             DataVol.A(:,j_index,i_index) = interp1(Z,AMerge(:,j_index,i_index),DataVol.coord_z);
     309%         end
     310%     end
    312311    error=struct2nc(OutputFile,DataVol)%save result file
    313312
    314 
    315     %     if index==1
    316     %         TimeData.ListGlobalAttribute={'Conventions','Project','CoordUnit','TimeUnit','ZPos','Time'};
    317     %         TimeData.Conventions='uvmat';
    318     %         TimeData.Project='2016_Circumpolar';
    319     %         TimeData.CoordUnit='cm';
    320     %         TimeData.TimeUnit='s';
    321     % %         TimeData.ZPos=ZPos;
    322     %         TimeData.ListVarName={'radius','azimuth','U','V','curl','div'};
    323     %         TimeData.VarDimName={'radius','azimuth',{'radius','azimuth'},{'radius','azimuth'}...
    324     %             {'radius','azimuth'},{'radius','azimuth'}};
    325     %         TimeData.VarAttribute{1}.Role='';
    326     %         TimeData.VarAttribute{2}.Role='';
    327     %         TimeData.VarAttribute{3}.Role='vector_x';
    328     %         TimeData.VarAttribute{4}.Role='vector_y';
    329     %         TimeData.VarAttribute{5}.Role='scalar';
    330     %         TimeData.VarAttribute{6}.Role='scalar';
    331     %
    332     %     end
    333     %
    334     %         %% append data to the netcdf file for next iterations
    335     %
    336     %
    337     %             error=struct2nc(OutputFile,TimeData);%save result file
    338     %         if isempty(error)
    339     %             disp(['output file ' OutputFile ' written'])
    340     %         else
    341     %             disp(error)
    342     %         end
    343     %             ellapsed_time=toc(tstart);
    344     %     disp(['ellapsed time since start ' num2str(ellapsed_time/60,2) ' minutes'])
    345313end
    346314
     
    426394end
    427395
     396
     397function ZIndex=XYZtoIndex(XmlData,X,Y,Z)% Z positions corresponding to X,Y positions
     398Zp=Z-XmlData.Slice.SliceCoord(1,3);
     399DZ=XmlData.Slice.SliceCoord(end,3)-XmlData.Slice.SliceCoord(1,3)/(size(XmlData.Slice.SliceCoord,1)-1);
     400if DZ~=0
     401ZIndex=(Z-XmlData.Slice.SliceCoord(1,3))/DZ+1;% Z=XmlData.SliceCoord(1,3)+(ZIndex-1)*DZ
     402end
     403% effect of angular deviation
     404SliceAngleMax=XmlData.Slice.SliceAngle(end,:)-XmlData.Slice.SliceAngle(1,:);
     405normAxe=norm(SliceAngleMax);
     406if normAxe>0 % case of angle scan
     407a=-SliceAngleMax(2)/normAxe;
     408b=-SliceAngleMax(1)/normAxe;
     409c=-a*XmlData.Slice.SliceCoord(1,1)+b*XmlData.Slice.SliceCoord(1,2);%equation of the axis ax+by+c=0
     410DNormal=norm(a*X+b*Y+c);
     411Ang=atand(Zp./DNormal);
     412ZIndex=ZIndex+Ang-norm(XmlData.Slice.SliceAngle(1,:))+1;
     413end
     414
     415%------------------------------------------------------------
     416% proj_volume: poject each image on a common grid given by coord_x and coord_y
     417function A=proj_volume(AMerge,XmlData,X,Y,Z)
     418
     419A=[]; %default output
     420
     421%% initial image coordinates
     422[npy,npx,npz]=size(AMerge);
     423xima=0.5:npx-0.5;%image coordinates of corners
     424%yima=npy-0.5:-1:0.5;
     425yima=0.5:npy-0.5;
     426zima=0.5:npz-0.5;
     427[XIMA_init,YIMA_init,ZIMA_init]=meshgrid(xima,yima,zima);%grid of initial image in px coordinates
     428
     429%% projected coordinates
     430ZIndex=XYZtoIndex(XmlData,X,Y,Z);% Z positions correspoonding to X,Y positions
     431
     432%% interpolation on the new grid
     433[XIMA,YIMA]=px_XYZ(XmlData.GeometryCalib,XmlData.Slice,X,Y,Z);% image coordinates for each point in the real
     434A=interp3(XIMA_init,YIMA_init,ZIMA_init,AMerge,XIMA,YIMA,ZIndex);
     435
     436
     437
    428438% proj_plane: poject each image on a common grid given by coord_x and coord_y
    429439function DataOut=proj_plane(DataIn,XmlData,X,Y)
  • trunk/src/series/sliding_average.m

    r1119 r1122  
    1 %'turb_correlation_time': calculate the time correlation function at each point
     1%'sliding_average_natalya'
    22%------------------------------------------------------------------------
    3 % function ParamOut=turb_correlation_time(Param)
     3% function ParamOut=sliding_average(Param)
    44%
    55%%%%%%%%%%% GENERAL TO ALL SERIES ACTION FCTS %%%%%%%%%%%%%%%%%%%%%%%%%%%
  • trunk/src/tps_coeff_field.m

    r1107 r1122  
    11%'tps_coeff_field': calculate the thin plate spline (tps) coefficients within subdomains for a field structure
    22%---------------------------------------------------------------------
    3 % DataOut=tps_coeff_field(DataIn,checkall)
     3% DataOut=tps_coeff_field(DataIn,checkall,Smoothing)
    44%
    55% OUTPUT:
     
    1313% checkall:=1 if tps is needed for all fields (a projection mode interp_tps has been chosen),
    1414%          =0 otherwise (tps only needed to get spatial derivatives of scattered data)
    15 %
     15% Smoothing parameter: =0 (no smoothing) by default
     16
    1617% called functions:
    1718% 'find_field_cells': analyse the input field structure, grouping the variables  into 'fields' with common coordinates
     
    3738%=======================================================================
    3839
    39 function [DataOut,errormsg]=tps_coeff_field(DataIn,checkall)     
     40function [DataOut,errormsg]=tps_coeff_field(DataIn,checkall,Smoothing)     
    4041DataOut=DataIn;%default
     42if ~exist('Smoothing','var')
     43Smoothing=0;
     44end
    4145SubDomainNbPoint=1000; %default, estimated nbre of data source points in a subdomain used for tps
    4246if isfield(DataIn,'SubDomain')
     
    5357nbtps=0;% indicate the number of tps coordinate sets in the field structure (in general =1)
    5458
    55 for icell=1:numel(CellInfo);
     59for icell=1:numel(CellInfo)
    5660    if NbDimArray(icell)>=2 && strcmp(CellInfo{icell}.CoordType,'scattered') %if the coordinates are scattered
    5761        NbCoord=NbDimArray(icell);% dimension of space
     
    129133                for isub=1:size(SubRange,3)
    130134                    ind_sel=IndSelSubDomain(1:NbCentre(isub),isub);% array indices selected for the subdomain
    131                     [tild,Var_tps(1:NbCentre(isub)+NbCoord+1,isub)]=tps_coeff([X(ind_sel) Y(ind_sel)],DataIn.(ListVarInterp{ilist})(ind_sel),0);%calculate the tps coeff in the subdomain
     135                    [tild,Var_tps(1:NbCentre(isub)+NbCoord+1,isub)]=tps_coeff([X(ind_sel) Y(ind_sel)],DataIn.(ListVarInterp{ilist})(ind_sel),Smoothing);%calculate the tps coeff in the subdomain
    132136                end
    133137                DataOut.(ListNewVar{ilist+3})=Var_tps;
  • trunk/src/transform_field/ima_filter.m

    r1119 r1122  
    1 % 'ima_filter': example of image transform with input parameters: low-pass filter of an image
     1% 'ima_filter': low-pass filter of an image or other 2D fields defined on a regular grid
     2% the size of the filtering window in x and y is interactivement defined
    23
    34%------------------------------------------------------------------------
    45%%%%  Use the general syntax for transform fields with a single input and parameters %%%%
    5 % OUTPUT: 
    6 % DataOut:   output field structure 
     6% OUTPUT:
     7% DataOut:   output field structure
    78%
    89%INPUT:
    910% DataIn:  input field structure
     11%
    1012% Param: matlab structure whose field Param.TransformInput contains the filter parameters
     13% DataIn_1: variables possibly introduced as a second input field
    1114%-----------------------------------
    1215
     
    7881if exist('DataIn_1','var')
    7982    [CellInfo,NbDim,errormsg]=find_field_cells(DataIn_1);
    80 for icell=1:numel(CellInfo)
    81     if isfield(CellInfo{icell},'CoordType')&& strcmp(CellInfo{icell}.CoordType,'grid')
    82         for ivar=1:numel(CellInfo{icell}.VarIndex)
    83             VarName=DataIn_1.ListVarName{CellInfo{icell}.VarIndex(ivar)};
    84             Atype=class(DataIn_1.(VarName));% detect integer 8 or 16 bits
    85             if numel(size(DataIn_1.(VarName)))==3
    86                 DataOut.(VarName)=filter2(Mfiltre,sum(DataIn_1.(VarName),3));%filter the input image, after summation on the color component (for color images)
    87                 DataOut.(VarName)=uint16(DataOut.(VarName)); %transform to 16 bit images
    88             else
    89                 DataOut.(VarName)=filter2(Mfiltre,DataIn_1.(VarName));
    90                 DataOut.(VarName)=feval(Atype,DataOut.(VarName));%transform to the initial image format
     83    for icell=1:numel(CellInfo)
     84        if isfield(CellInfo{icell},'CoordType')&& strcmp(CellInfo{icell}.CoordType,'grid')
     85            for ivar=1:numel(CellInfo{icell}.VarIndex)
     86                VarName=DataIn_1.ListVarName{CellInfo{icell}.VarIndex(ivar)};
     87                Atype=class(DataIn_1.(VarName));% detect integer 8 or 16 bits
     88                if numel(size(DataIn_1.(VarName)))==3
     89                    DataOut.(VarName)=filter2(Mfiltre,sum(DataIn_1.(VarName),3));%filter the input image, after summation on the color component (for color images)
     90                    DataOut.(VarName)=uint16(DataOut.(VarName)); %transform to 16 bit images
     91                else
     92                    DataOut.(VarName)=filter2(Mfiltre,DataIn_1.(VarName));
     93                    DataOut.(VarName)=feval(Atype,DataOut.(VarName));%transform to the initial image format
     94                end
    9195            end
    9296        end
    9397    end
    9498end
    95 end
    9699
    97100 
Note: See TracChangeset for help on using the changeset viewer.