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