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

Last change on this file since 985 was 977, checked in by g7moreau, 7 years ago
  • Update Copyright 2008-2017 notice
File size: 7.1 KB
Line 
1%----------------------------------------------------------------------
2% -process LIF images
3%----------------------------------------------------------------------
4
5%=======================================================================
6% Copyright 2008-2017, 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 GUI_input=LIF_series(num_i1,num_i2,num_j1,num_j2,Series);
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    GUI_input={'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%-------------------------------------------------
44hseries=guidata(Series.hseries);%handles of the GUI series
45WaitbarPos=get(hseries.waitbar_frame,'Position'); %positiopn of waitbar frame
46%-------------------------------------------------
47addpath '/fsnet/project/coriolis/2006/06ICEBOX/0_MATLAB_WORK/LIF'% define path for concentration.m
48% cpath=which('series');
49
50%mode=''; %default
51time=[];
52nbviews=numel(Series.RootPath);
53if nbviews<2
54    msgbox_uvmat('ERROR','enter both LIF and PIV series')% we introduce PIV series to improve the filtering (remove particle image)
55    return
56end
57[PD,LIFdir]=fileparts(Series.RootPath{1});
58
59fulldir=fullfile(PD,'Concentration');
60if ~exist(fulldir,'dir')
61    try
62     mkdir(fulldir)
63     [xx,msg2] = fileattrib(fulldir,'+w','g'); %yield writing access (+w) to user group (g)
64    catch ME
65    msgbox_uvmat('ERROR',ME.message)
66    return
67    end
68end
69
70filebase_LIF=fullfile(fulldir,'LIF');%root name for the merged files
71RootPath=Series.RootPath{1};
72filebase=fullfile(Series.RootPath{1},Series.RootFile{1});%root file name
73filebase_1=fullfile(Series.RootPath{2},Series.RootFile{2});%root file name for PIV (background correction)
74nbfield=numel(num_i1{1});%number of fields in the series
75[XmlData,error]=imadoc2struct([filebase '.xml']);% calibration data for LIF
76%[error,Heading,nom_type_read,ext_ima_read,tt,TimeUnit,mode,NbSlice,npx,npy,Calib{2}]
77[XmlData_1,error]=imadoc2struct([filebase_1 '.xml']);% calibration data for PIV
78if isfield(XmlData,'Time')
79    time=XmlData.Time;
80    if isfield(XmlData_1,'Time')
81        time_1=XmlData_1.Time;
82        if ~isequal(size(time),size(time_1))
83            msgbox_uvmat('WARNING','inconsistent time array lengths in ImaDoc fields')
84        end
85    end
86end
87%check coincidence in time
88if size(time,1)>1
89    diff_time=max(max(abs(time-time_1)))
90    if diff_time>0
91        msgbox_uvmat(['times of series differ by more than ' num2str(diff_time)],'WARNING')
92    end   
93end
94
95
96hRUN=findobj(Series.hseries,'Tag','RUN');%handles the the uicontrol 'RUN'
97itime=0;
98%%%%%%
99%LOOP ON FILES
100        RootPath=fullfile(RootPath,'LIF_REF');
101for ifile=1:nbfield
102    stopstate=get(hRUN,'BusyAction');%enable stop button
103    if isequal(stopstate,'queue')% enable STOP command
104        update_waitbar(hseries.waitbar,WaitbarPos,ifile/nbfield)
105        %name of the current LIF input file
106        [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));
107        if ~idetect
108            msgbox_uvmat('ERROR',[inputfile ' not found'])
109            return
110        end
111        [Data,ParamOut,errormsg] = read_field(inputfile,'image',[]);
112        Data.ZIndex=num_i1{1}(ifile)-Series.NbSlice*(floor((num_i1{1}(ifile)-1)/Series.NbSlice));%second field index
113       
114   
115    file_ref=fullfile(RootPath,['lif_ref_' num2str(Data.ZIndex) '.nc']);
116    Ref=nc2struct(file_ref);%reference file
117        [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));
118        if ~idetect
119            msgbox_uvmat('ERROR',[inputfile_1 ' not found'])
120            return
121        end
122        Data_1=read_field(inputfile_1,'image',{[]});% read the image
123        Data_1.ZIndex=Data.ZIndex;
124        %%% transform image to concentration
125        [DataOut,dd,DataMask]=concentration(Data,XmlData,Data_1,XmlData_1,Ref);
126        % output file name (netcdf)
127        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));
128        % create a structure to prepare the result file
129        Resu.ListGlobalAttribute={'Project','InputFile_1','InputFile_2','Action','Time','ZIndex','z'};
130        [PP,Resu.Project]=fileparts(Series.PathProject);
131        Resu.InputFile_1=inputfile;
132        Resu.InputFile_2=inputfile_1;
133        Resu.Action=Series.Action;
134        if isempty(time)
135            Resu.Time=0;
136        else
137            Resu.Time=time(num_i1{1}(ifile),num_j1{1}(ifile));
138        end
139        Resu.ZIndex=Data.ZIndex;
140        Resu.z=XmlData.GeometryCalib.SliceCoord(Data.ZIndex,3);
141        Resu.ListVarName={'Coord_y' ,'Coord_x' ,'c','mask'};
142        Resu.VarDimName={'Coord_y','Coord_x',{'Coord_y','Coord_x'},{'Coord_y','Coord_x'}};       
143        Resu.Coord_y=[DataOut.Coord_y(1), DataOut.Coord_y(end)];
144        Resu.Coord_x=[DataOut.Coord_x(1), DataOut.Coord_x(end)];
145        Resu.c=DataOut.A;
146        Resu.mask=DataMask.A;%to chnge to  cartesian coordinates (polar2phys)
147        error=struct2nc(outputfile,Resu); %save result file
148        if isempty(error)
149            display(['output file ' outputfile ' written'])
150        else
151           display( error)
152        end
153    end
154end
155     
Note: See TracBrowser for help on using the repository browser.