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

Last change on this file since 776 was 647, checked in by sommeria, 11 years ago

bug corrected in time_series, LIF functions introduced (but not in operation)

File size: 6.2 KB
Line 
1%----------------------------------------------------------------------
2% -process LIF images
3%----------------------------------------------------------------------
4function GUI_input=LIF_series(num_i1,num_i2,num_j1,num_j2,Series);
5
6%requests for the visibility of input windows in the GUI series  (activated directly by the selection in the menu ACTION)
7if ~exist('num_i1','var')
8    GUI_input={'RootPath';'two';...%nbre of possible input series (options 'on'/'two'/'many', default:'one')
9        'SubDir';'on';... % subdirectory of derived files (PIV fields), ('on' by default)
10        'RootFile';'on';... %root input file name ('on' by default)
11        'FileExt';'on';... %input file extension ('on' by default)
12        'NomType';'on';...%type of file indexing ('on' by default)
13        'NbSlice';'on'; ...%nbre of slices ('off' by default)
14        'VelTypeMenu';'one';...% menu for selecting the velocity type (civ1,..) options 'off'/'one'/'two', 'off' by default)
15        'FieldMenu';'one';...% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
16        'CoordType';'on';...%can use a transform function 'off' by default
17        'GetObject';'on';...%can use projection object ,'off' by default
18        %'GetMask';'on'...%can use mask option   ,'off' by default
19        %'PARAMETER'; options: name of the user defined parameter',repeat a line for each parameter
20               ''};
21    return %exit the function
22end
23
24%-------------------------------------------------
25hseries=guidata(Series.hseries);%handles of the GUI series
26WaitbarPos=get(hseries.waitbar_frame,'Position'); %positiopn of waitbar frame
27%-------------------------------------------------
28addpath '/fsnet/project/coriolis/2006/06ICEBOX/0_MATLAB_WORK/LIF'% define path for concentration.m
29% cpath=which('series');
30
31%mode=''; %default
32time=[];
33nbviews=numel(Series.RootPath);
34if nbviews<2
35    msgbox_uvmat('ERROR','enter both LIF and PIV series')% we introduce PIV series to improve the filtering (remove particle image)
36    return
37end
38[PD,LIFdir]=fileparts(Series.RootPath{1});
39
40fulldir=fullfile(PD,'Concentration');
41if ~exist(fulldir,'dir')
42    try
43     mkdir(fulldir)
44     [xx,msg2] = fileattrib(fulldir,'+w','g'); %yield writing access (+w) to user group (g)
45    catch ME
46    msgbox_uvmat('ERROR',ME.message)
47    return
48    end
49end
50
51filebase_LIF=fullfile(fulldir,'LIF');%root name for the merged files
52RootPath=Series.RootPath{1};
53filebase=fullfile(Series.RootPath{1},Series.RootFile{1});%root file name
54filebase_1=fullfile(Series.RootPath{2},Series.RootFile{2});%root file name for PIV (background correction)
55nbfield=numel(num_i1{1});%number of fields in the series
56[XmlData,error]=imadoc2struct([filebase '.xml']);% calibration data for LIF
57%[error,Heading,nom_type_read,ext_ima_read,tt,TimeUnit,mode,NbSlice,npx,npy,Calib{2}]
58[XmlData_1,error]=imadoc2struct([filebase_1 '.xml']);% calibration data for PIV
59if isfield(XmlData,'Time')
60    time=XmlData.Time;
61    if isfield(XmlData_1,'Time')
62        time_1=XmlData_1.Time;
63        if ~isequal(size(time),size(time_1))
64            msgbox_uvmat('WARNING','inconsistent time array lengths in ImaDoc fields')
65        end
66    end
67end
68%check coincidence in time
69if size(time,1)>1
70    diff_time=max(max(abs(time-time_1)))
71    if diff_time>0
72        msgbox_uvmat(['times of series differ by more than ' num2str(diff_time)],'WARNING')
73    end   
74end
75
76
77hRUN=findobj(Series.hseries,'Tag','RUN');%handles the the uicontrol 'RUN'
78itime=0;
79%%%%%%
80%LOOP ON FILES
81        RootPath=fullfile(RootPath,'LIF_REF');
82for ifile=1:nbfield
83    stopstate=get(hRUN,'BusyAction');%enable stop button
84    if isequal(stopstate,'queue')% enable STOP command
85        update_waitbar(hseries.waitbar,WaitbarPos,ifile/nbfield)
86        %name of the current LIF input file
87        [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));
88        if ~idetect
89            msgbox_uvmat('ERROR',[inputfile ' not found'])
90            return
91        end
92        [Data,ParamOut,errormsg] = read_field(inputfile,'image',[]);
93        Data.ZIndex=num_i1{1}(ifile)-Series.NbSlice*(floor((num_i1{1}(ifile)-1)/Series.NbSlice));%second field index
94       
95   
96    file_ref=fullfile(RootPath,['lif_ref_' num2str(Data.ZIndex) '.nc']);
97    Ref=nc2struct(file_ref);%reference file
98        [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));
99        if ~idetect
100            msgbox_uvmat('ERROR',[inputfile_1 ' not found'])
101            return
102        end
103        Data_1=read_field(inputfile_1,'image',{[]});% read the image
104        Data_1.ZIndex=Data.ZIndex;
105        %%% transform image to concentration
106        [DataOut,dd,DataMask]=concentration(Data,XmlData,Data_1,XmlData_1,Ref);
107        % output file name (netcdf)
108        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));
109        % create a structure to prepare the result file
110        Resu.ListGlobalAttribute={'Project','InputFile_1','InputFile_2','Action','Time','ZIndex','z'};
111        [PP,Resu.Project]=fileparts(Series.PathProject);
112        Resu.InputFile_1=inputfile;
113        Resu.InputFile_2=inputfile_1;
114        Resu.Action=Series.Action;
115        if isempty(time)
116            Resu.Time=0;
117        else
118            Resu.Time=time(num_i1{1}(ifile),num_j1{1}(ifile));
119        end
120        Resu.ZIndex=Data.ZIndex;
121        Resu.z=XmlData.GeometryCalib.SliceCoord(Data.ZIndex,3);
122        Resu.ListVarName={'AY' ,'AX' ,'c','mask'};
123        Resu.VarDimName={'AY','AX',{'AY','AX'},{'AY','AX'}};       
124        Resu.AY=[DataOut.AY(1), DataOut.AY(end)];
125        Resu.AX=[DataOut.AX(1), DataOut.AX(end)];
126        Resu.c=DataOut.A;
127        Resu.mask=DataMask.A;%to chnge to  cartesian coordinates (polar2phys)
128        error=struct2nc(outputfile,Resu); %save result file
129        if isempty(error)
130            display(['output file ' outputfile ' written'])
131        else
132           display( error)
133        end
134    end
135end
136     
Note: See TracBrowser for help on using the repository browser.