source: trunk/src/series/LIF_series.m @ 1093

Last change on this file since 1093 was 1093, checked in by g7moreau, 3 years ago
  • Update Copyright to 2021
File size: 6.8 KB
Line 
1%----------------------------------------------------------------------
2% -process LIF images:old function to update
3%----------------------------------------------------------------------
4
5%=======================================================================
6% Copyright 2008-2021, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France
7%   http://www.legi.grenoble-inp.fr
8%   Joel.Sommeria - Joel.Sommeria (A) legi.cnrs.fr
9%
10%     This file is part of the toolbox UVMAT.
11%
12%     UVMAT is free software; you can redistribute it and/or modify
13%     it under the terms of the GNU General Public License as published
14%     by the Free Software Foundation; either version 2 of the license,
15%     or (at your option) any later version.
16%
17%     UVMAT is distributed in the hope that it will be useful,
18%     but WITHOUT ANY WARRANTY; without even the implied warranty of
19%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20%     GNU General Public License (see LICENSE.txt) for more details.
21%=======================================================================
22
23function ParamOut=LIF_series(Param)
24
25%requests for the visibility of input windows in the GUI series  (activated directly by the selection in the menu ACTION)
26if ~exist('num_i1','var')
27    ParamOut={'RootPath';'two';...%nbre of possible input series (options 'on'/'two'/'many', default:'one')
28        'SubDir';'on';... % subdirectory of derived files (PIV fields), ('on' by default)
29        'RootFile';'on';... %root input file name ('on' by default)
30        'FileExt';'on';... %input file extension ('on' by default)
31        'NomType';'on';...%type of file indexing ('on' by default)
32        'NbSlice';'on'; ...%nbre of slices ('off' by default)
33        'VelTypeMenu';'one';...% menu for selecting the velocity type (civ1,..) options 'off'/'one'/'two', 'off' by default)
34        'FieldMenu';'one';...% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
35        'CoordType';'on';...%can use a transform function 'off' by default
36        'GetObject';'on';...%can use projection object ,'off' by default
37        %'GetMask';'on'...%can use mask option   ,'off' by default
38        %'PARAMETER'; options: name of the user defined parameter',repeat a line for each parameter
39               ''};
40    return %exit the function
41end
42
43%mode=''; %default
44time=[];
45nbviews=numel(Series.RootPath);
46if nbviews<2
47    msgbox_uvmat('ERROR','enter both LIF and PIV series')% we introduce PIV series to improve the filtering (remove particle image)
48    return
49end
50[PD,LIFdir]=fileparts(Series.RootPath{1});
51
52fulldir=fullfile(PD,'Concentration');
53if ~exist(fulldir,'dir')
54    try
55     mkdir(fulldir)
56     [xx,msg2] = fileattrib(fulldir,'+w','g'); %yield writing access (+w) to user group (g)
57    catch ME
58    msgbox_uvmat('ERROR',ME.message)
59    return
60    end
61end
62
63filebase_LIF=fullfile(fulldir,'LIF');%root name for the merged files
64RootPath=Series.RootPath{1};
65filebase=fullfile(Series.RootPath{1},Series.RootFile{1});%root file name
66filebase_1=fullfile(Series.RootPath{2},Series.RootFile{2});%root file name for PIV (background correction)
67nbfield=numel(num_i1{1});%number of fields in the series
68[XmlData,error]=imadoc2struct([filebase '.xml']);% calibration data for LIF
69%[error,Heading,nom_type_read,ext_ima_read,tt,TimeUnit,mode,NbSlice,npx,npy,Calib{2}]
70[XmlData_1,error]=imadoc2struct([filebase_1 '.xml']);% calibration data for PIV
71if isfield(XmlData,'Time')
72    time=XmlData.Time;
73    if isfield(XmlData_1,'Time')
74        time_1=XmlData_1.Time;
75        if ~isequal(size(time),size(time_1))
76            msgbox_uvmat('WARNING','inconsistent time array lengths in ImaDoc fields')
77        end
78    end
79end
80%check coincidence in time
81if size(time,1)>1
82    diff_time=max(max(abs(time-time_1)))
83    if diff_time>0
84        msgbox_uvmat(['times of series differ by more than ' num2str(diff_time)],'WARNING')
85    end   
86end
87
88
89hRUN=findobj(Series.hseries,'Tag','RUN');%handles the the uicontrol 'RUN'
90itime=0;
91%%%%%%
92%LOOP ON FILES
93        RootPath=fullfile(RootPath,'LIF_REF');
94for ifile=1:nbfield
95    stopstate=get(hRUN,'BusyAction');%enable stop button
96    if isequal(stopstate,'queue')% enable STOP command
97        update_waitbar(hseries.waitbar,WaitbarPos,ifile/nbfield)
98        %name of the current LIF input file
99        [inputfile,idetect]=name_generator(filebase,num_i1{1}(ifile),num_j1{1}(ifile),Series.FileExt{1},Series.NomType{1},1,num_i1{1}(ifile),num_j2{1}(ifile));
100        if ~idetect
101            msgbox_uvmat('ERROR',[inputfile ' not found'])
102            return
103        end
104        [Data,ParamOut,errormsg] = read_field(inputfile,'image',[]);
105        Data.ZIndex=num_i1{1}(ifile)-Series.NbSlice*(floor((num_i1{1}(ifile)-1)/Series.NbSlice));%second field index
106       
107   
108    file_ref=fullfile(RootPath,['lif_ref_' num2str(Data.ZIndex) '.nc']);
109    Ref=nc2struct(file_ref);%reference file
110        [inputfile_1,idetect]=name_generator(filebase_1,num_i1{2}(ifile),num_j1{2}(ifile),Series.FileExt{2},Series.NomType{2},1,num_i2{2}(ifile),num_j2{2}(ifile));
111        if ~idetect
112            msgbox_uvmat('ERROR',[inputfile_1 ' not found'])
113            return
114        end
115        Data_1=read_field(inputfile_1,'image',{[]});% read the image
116        Data_1.ZIndex=Data.ZIndex;
117        %%% transform image to concentration
118        [DataOut,dd,DataMask]=concentration(Data,XmlData,Data_1,XmlData_1,Ref);
119        % output file name (netcdf)
120        outputfile=name_generator(filebase_LIF,num_i1{1}(ifile),num_j1{1}(ifile),'.nc',Series.NomType{2},1,num_i2{1}(ifile),num_j2{1}(ifile));
121        % create a structure to prepare the result file
122        Resu.ListGlobalAttribute={'Project','InputFile_1','InputFile_2','Action','Time','ZIndex','z'};
123        [PP,Resu.Project]=fileparts(Series.PathProject);
124        Resu.InputFile_1=inputfile;
125        Resu.InputFile_2=inputfile_1;
126        Resu.Action=Series.Action;
127        if isempty(time)
128            Resu.Time=0;
129        else
130            Resu.Time=time(num_i1{1}(ifile),num_j1{1}(ifile));
131        end
132        Resu.ZIndex=Data.ZIndex;
133        Resu.z=XmlData.GeometryCalib.SliceCoord(Data.ZIndex,3);
134        Resu.ListVarName={'Coord_y' ,'Coord_x' ,'c','mask'};
135        Resu.VarDimName={'Coord_y','Coord_x',{'Coord_y','Coord_x'},{'Coord_y','Coord_x'}};       
136        Resu.Coord_y=[DataOut.Coord_y(1), DataOut.Coord_y(end)];
137        Resu.Coord_x=[DataOut.Coord_x(1), DataOut.Coord_x(end)];
138        Resu.c=DataOut.A;
139        Resu.mask=DataMask.A;%to chnge to  cartesian coordinates (polar2phys)
140        error=struct2nc(outputfile,Resu); %save result file
141        if isempty(error)
142            display(['output file ' outputfile ' written'])
143        else
144           display( error)
145        end
146    end
147end
148     
Note: See TracBrowser for help on using the repository browser.