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

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