source: trunk/src/series/vel2vol.m @ 348

Last change on this file since 348 was 208, checked in by sommeria, 13 years ago

new function vel2vol added: concatene vel fields from slices and interpolate on a gridded volume in phys space

File size: 5.2 KB
RevLine 
[208]1% vel2vol:interpolate 2D velocity fields to volumes with structured coordinates in phys space
2% (specific to RDvision system)
3%----------------------------------------------------------------------
4function GUI_input=vel2vol(num_i1,num_i2,num_j1,num_j2,Series)
5%requests for the visibility of input windows in the GUI series  (activated directly by the selection in the menu ACTION)
6if ~exist('num_i1','var')
7        GUI_input={'RootPath';'one';...%nbre of possible input series (options 'on'/'two'/'many', default:'one')
8        'SubDir';'on';... % subdirectory of derived files (PIV fields), ('on' by default)
9        'RootFile';'on';... %root input file name ('on' by default)
10        'FileExt';'on';... %input file extension ('on' by default)
11        'NomType';'on';...%type of file indexing ('on' by default)
12        'NbSlice';'on'; ...%nbre of slices ('off' by default)
13        'VelTypeMenu';'one';...% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
14        'FieldMenu';'one';...% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
15        'CoordType'; 'on';...%can use a transform function
16        'GetObject';'on';...%can use projection object(option 'off'/'one'/'two',
17               ''}
18    return %exit the function
19end
20
21%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%enable waitbar
22hseries=guidata(Series.hseries);%handles of the GUI series
23WaitbarPos=get(hseries.waitbar_frame,'Position');
24%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
25
26%% PARAMETERS
27listfield=get(hseries.FieldMenu,'String');
28testfield=get(hseries.FieldMenu,'Value');
29FieldName=listfield{testfield}
30listfield=get(hseries.VelTypeMenu,'String');
31testfield=get(hseries.VelTypeMenu,'Value');
32VelType=listfield{testfield}
33transform_fct=Series.transform_fct;%handles of phys transform function
34
35
36%% projection object (volume)
37test_object=get(hseries.GetObject,'Value');
38if test_object%isfield(Series,'sethandles')
39    hset_object=findobj(allchild(0),'tag','set_object');
40    ProjObject=read_set_object(guidata(hset_object));
41    if ~strcmp(ProjObject.Style,'volume')&&~strcmp(ProjObject.ProjMode,'interp')
42        msgbox_uvmat('ERROR',['a volume with projection mode interp must be defined']);
43        return
44    end
45    answer=msgbox_uvmat('CONFIRMATION',['fields will be interpolated at the grid points of the volume']);
46else
47     answer=msgbox_uvmat('CONFIRMATION',['fields will be concatenated without interpolation']);
48end
49
50%% create dir of the volume velocity fields
51basename=fullfile(Series.RootPath,Series.RootFile) ;
52% [dir_ima,namebase]=fileparts(basename);
53% [path,subdir_ima]=fileparts(dir_ima);
54SubDirNew=[Series.SubDir '_vol'];
55newdir=fullfile(Series.RootPath,SubDirNew);
56mkdir(newdir);
57[xx,msg2] = fileattrib(newdir,'+w','g'); %yield writing access (+w) to user group (g)
58if ~strcmp(msg2,'')
59    msgbox_uvmat('ERROR',['pb of permission for ' subdir_vel ': ' msg2])%error message for directory creation
60    return
61end
62display(['volume fields in the directory ' newdir])
63% basename_new=fullfile(newdir,Series.RootFile);
64
65
66%% read imadoc
67[XmlData,warntext]=imadoc2struct([basename '.xml']);
68nbfield1=size(num_i1,1);
69nbfield2=size(XmlData.Time,2);% use the whole set of j indices
70% set(hseries.first_i,'String',num2str(first_label))% display the first image in the process
71set(hseries.last_j,'String',num2str(nbfield2))% display the last image in the process
72
73%% main loop
74for ifile=1:nbfield1
75    update_waitbar(hseries.waitbar,WaitbarPos,ifile/nbfield1)
76    for jfile=1:nbfield2
77        filename=name_generator(basename,num_i1(ifile,jfile),num_j1(ifile,jfile),Series.FileExt,Series.NomType,1,num_i2(ifile,jfile),num_j2(ifile,jfile),Series.SubDir);
78        [Field,VelTypeOut]=read_civxdata(filename,FieldName,VelType);
79        if isfield(Field,'Txt')
80            msgbox_uvmat('ERROR',Field.Txt)
81            return
82        end
83        Field.ZIndex=jfile;
84        % coordinate transform
85        Field=transform_fct(Field,XmlData);
86        % concatene slices
87        if jfile==1
88            %             if isempty(Field.absolut_time_T0) || isequal(Field.civ,0)
89            %                 msgbox_uvmat('ERROR','the input file is not civx data')
90            %                 return
91            %             end
92            FieldVol=Field;
93            FieldVol.NbDim=3;
94        else
95            FieldVol.X=[FieldVol.X; Field.X];
96            FieldVol.Y=[FieldVol.Y; Field.Y];
97            FieldVol.Z=[FieldVol.Z; Field.Z];
98            FieldVol.U=[FieldVol.U; Field.U];
99            FieldVol.V=[FieldVol.V; Field.V];
100            if isfield( Field,'F')
101                FieldVol.F=[FieldVol.F; Field.F];
102            end
103        end
104    end
105    if test_object
106        [FieldVol,errormsg]=proj_field(FieldVol,ProjObject);
107        if ~isempty(errormsg)
108            msgbox_uvmat('ERROR',['error in vel2vol/proj_field:' errormsg])
109            return
110        end
111    end
112    filename_new=name_generator(basename,num_i1(ifile,jfile),[],'.nc','_1',1,num_i2(ifile,jfile),[],SubDirNew);
113    errormsg=struct2nc(filename_new,FieldVol);
114    if isempty(errormsg)
115        display([filename_new ' written'])
116    else
117        msgbox_uvmat('ERROR',['error in vel2vol/struct2nc:' errormsg])
118        return
119    end
120end
121
Note: See TracBrowser for help on using the repository browser.