source: trunk/src/series/time_series.m @ 871

Last change on this file since 871 was 871, checked in by sommeria, 10 years ago

histo improved

File size: 24.5 KB
Line 
1%'time_series': extract a time series after projection on an object (points , line..)
2% this function can be used as a template for applying a global operation on a series of input fields
3%------------------------------------------------------------------------
4% function GUI_input=time_series(Param)
5%
6%%%%%%%%%%% GENERAL TO ALL SERIES ACTION FCTS %%%%%%%%%%%%%%%%%%%%%%%%%%%
7%
8%OUTPUT
9% ParamOut: sets options in the GUI series.fig needed for the function
10%
11%INPUT:
12% In run mode, the input parameters are given as a Matlab structure Param copied from the GUI series.
13% In batch mode, Param is the name of the corresponding xml file containing the same information
14% when Param.Action.RUN=0 (as activated when the current Action is selected
15% in series), the function ouput paramOut set the activation of the needed GUI elements
16%
17% Param contains the elements:(use the menu bar command 'export/GUI config' in series to
18% see the current structure Param)
19%    .InputTable: cell of input file names, (several lines for multiple input)
20%                      each line decomposed as {RootPath,SubDir,Rootfile,NomType,Extension}
21%    .OutputSubDir: name of the subdirectory for data outputs
22%    .OutputDirExt: directory extension for data outputs
23%    .Action: .ActionName: name of the current activated function
24%             .ActionPath:   path of the current activated function
25%             .ActionExt: fct extension ('.m', Matlab fct, '.sh', compiled   Matlab fct
26%             .RUN =0 for GUI input, =1 for function activation
27%             .RunMode='local','background', 'cluster': type of function  use
28%             
29%    .IndexRange: set the file or frame indices on which the action must be performed
30%    .FieldTransform: .TransformName: name of the selected transform function
31%                     .TransformPath:   path  of the selected transform function
32%    .InputFields: sub structure describing the input fields withfields
33%              .FieldName: name(s) of the field
34%              .VelType: velocity type
35%              .FieldName_1: name of the second field in case of two input series
36%              .VelType_1: velocity type of the second field in case of two input series
37%              .Coord_y: name of y coordinate variable
38%              .Coord_x: name of x coordinate variable
39%    .ProjObject: %sub structure describing a projection object (read from ancillary GUI set_object)
40%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
41
42%=======================================================================
43% Copyright 2008-2014, LEGI UMR 5519 / CNRS UJF G-INP, Grenoble, France
44%   http://www.legi.grenoble-inp.fr
45%   Joel.Sommeria - Joel.Sommeria (A) legi.cnrs.fr
46%
47%     This file is part of the toolbox UVMAT.
48%
49%     UVMAT is free software; you can redistribute it and/or modify
50%     it under the terms of the GNU General Public License as published
51%     by the Free Software Foundation; either version 2 of the license,
52%     or (at your option) any later version.
53%
54%     UVMAT is distributed in the hope that it will be useful,
55%     but WITHOUT ANY WARRANTY; without even the implied warranty of
56%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
57%     GNU General Public License (see LICENSE.txt) for more details.
58%=======================================================================
59
60function ParamOut=time_series(Param)
61
62%% set the input elements needed on the GUI series when the action is selected in the menu ActionName or InputTable refreshed
63if isstruct(Param) && isequal(Param.Action.RUN,0)% function activated from the GUI series but not RUN
64    ParamOut.AllowInputSort='off';% allow alphabetic sorting of the list of input file SubDir (options 'off'/'on', 'off' by default)
65    ParamOut.WholeIndexRange='off';% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default)
66    ParamOut.NbSlice='on'; %nbre of slices ('off' by default)
67    ParamOut.VelType='two';% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
68    ParamOut.FieldName='two';% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
69    ParamOut.FieldTransform = 'on';%can use a transform function
70    ParamOut.TransformPath=fullfile(fileparts(which('uvmat')),'transform_field');% path to transform functions (needed for compilation only)
71    ParamOut.ProjObject='on';%can use projection object(option 'off'/'on',
72    ParamOut.Mask='off';%can use mask option   (option 'off'/'on', 'off' by default)
73    ParamOut.OutputDirExt='.tseries';%set the output dir extension
74    ParamOut.OutputFileMode='NbSlice';% '=NbInput': 1 output file per input file index, '=NbInput_i': 1 file per input file index i, '=NbSlice': 1 file per slice
75    % check for selection of a projection object
76    hseries=findobj(allchild(0),'Tag','series');% handles of the GUI series
77    if  ~isfield(Param,'ProjObject')
78        answer=msgbox_uvmat('INPUT_Y-N','use a projection object for the time_series?');
79        if strcmp(answer,'Yes')
80            hhseries=guidata(hseries);
81            set(hhseries.CheckObject,'Visible','on')
82            set(hhseries.CheckObject,'Value',1)
83            series('CheckObject_Callback',hseries,[],hhseries); %file input with xml reading  in uvmat, show the image in phys coordinates
84        end
85    end
86    % introduce bin size for histograms
87    if Param.CheckObject
88        SeriesData=get(hseries,'UserData');
89        if checkhisto
90             answer=msgbox_uvmat('INPUT_TXT','set bin size for histograms (or keep ''auto'' by default)?','auto');
91            ParamOut.ActionInput.VarMesh=str2double(answer);
92        end
93    end
94    % check the existence of the first and last file in the series
95     first_j=[];
96    if isfield(Param.IndexRange,'first_j'); first_j=Param.IndexRange.first_j; end
97    last_j=[];
98    if isfield(Param.IndexRange,'last_j'); last_j=Param.IndexRange.last_j; end
99    PairString='';
100    if isfield(Param.IndexRange,'PairString'); PairString=Param.IndexRange.PairString; end
101    [i1,i2,j1,j2] = get_file_index(Param.IndexRange.first_i,first_j,PairString);
102    FirstFileName=fullfile_uvmat(Param.InputTable{1,1},Param.InputTable{1,2},Param.InputTable{1,3},...
103        Param.InputTable{1,5},Param.InputTable{1,4},i1,i2,j1,j2);
104    if ~exist(FirstFileName,'file')
105        msgbox_uvmat('WARNING',['the first input file ' FirstFileName ' does not exist'])
106    else
107        [i1,i2,j1,j2] = get_file_index(Param.IndexRange.last_i,last_j,PairString);
108        LastFileName=fullfile_uvmat(Param.InputTable{1,1},Param.InputTable{1,2},Param.InputTable{1,3},...
109            Param.InputTable{1,5},Param.InputTable{1,4},i1,i2,j1,j2);
110        if ~exist(LastFileName,'file')
111            msgbox_uvmat('WARNING',['the last input file ' LastFileName ' does not exist'])
112        end
113    end
114    return
115end
116
117%%%%%%%%%%%% STANDARD PART  %%%%%%%%%%%%
118ParamOut=[]; %default output
119%% read input parameters from an xml file if input is a file name (batch mode)
120checkrun=1;
121if ischar(Param)
122    Param=xml2struct(Param);% read Param as input file (batch case)
123    checkrun=0;
124end
125hseries=findobj(allchild(0),'Tag','series');
126RUNHandle=findobj(hseries,'Tag','RUN');%handle of RUN button in GUI series
127WaitbarHandle=findobj(hseries,'Tag','Waitbar');%handle of waitbar in GUI series
128
129%% define the directory for result file (with path=RootPath{1})
130OutputDir=[Param.OutputSubDir Param.OutputDirExt];
131
132%% root input file(s) name, type and index series
133RootPath=Param.InputTable(:,1);
134RootFile=Param.InputTable(:,3);
135SubDir=Param.InputTable(:,2);
136NomType=Param.InputTable(:,4);
137FileExt=Param.InputTable(:,5);
138hdisp=disp_uvmat('WAITING...','checking the file series',checkrun);
139[filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param);
140if ~isempty(hdisp),delete(hdisp),end;
141%%%%%%%%%%%%
142% The cell array filecell is the list of input file names, while
143% filecell{iview,fileindex}:
144%        iview: line in the table corresponding to a given file series
145%        fileindex: file index within  the file series,
146% i1_series(iview,ref_j,ref_i)... are the corresponding arrays of indices i1,i2,j1,j2, depending on the input line iview and the two reference indices ref_i,ref_j
147% i1_series(iview,fileindex) expresses the same indices as a 1D array in file indices
148%%%%%%%%%%%%
149nbview=numel(i1_series);%number of input file series (lines in InputTable)
150nbfield_j=size(i1_series{1},1); %nb of fields for the j index (bursts or volume slices)
151nbfield_i=size(i1_series{1},2); %nb of fields for the i index
152nbfield=nbfield_j*nbfield_i; %total number of fields
153
154%% determine the file type on each line from the first input file
155ImageTypeOptions={'image','multimage','mmreader','video'};
156NcTypeOptions={'netcdf','civx','civdata'};
157FileType=cell(1,nbview);
158FileInfo=cell(1,nbview);
159MovieObject=cell(1,nbview);
160CheckImage=cell(1,nbview);
161CheckNc=cell(1,nbview);
162frame_index=cell(1,nbview);
163for iview=1:nbview
164    if ~exist(filecell{iview,1}','file')
165        disp_uvmat('ERROR',['the first input file ' filecell{iview,1} ' does not exist'],checkrun)
166        return
167    end
168    [FileInfo{iview},MovieObject{iview}]=get_file_info(filecell{iview,1});
169    FileType{iview}=FileInfo{iview}.FileType;
170    if strcmp(FileType{iview},'civdata')||strcmp(FileType{iview},'civx')
171        if ~isfield(Param.InputFields,'VelType')
172            FileType{iview}='netcdf';% civ data read as usual netcdf files
173        end
174    end
175    CheckImage{iview}=~isempty(find(strcmp(FileType{iview},ImageTypeOptions)));% =1 for images
176    CheckNc{iview}=~isempty(find(strcmp(FileType{iview},NcTypeOptions)));% =1 for netcdf files
177    if isempty(j1_series{iview})
178        frame_index{iview}=i1_series{iview};
179    else
180        frame_index{iview}=j1_series{iview};
181    end
182end
183
184%% calibration data and timing: read the ImaDoc files
185[XmlData,NbSlice_calib,time,errormsg]=read_multimadoc(RootPath,SubDir,RootFile,FileExt,i1_series,i2_series,j1_series,j2_series);
186if ~isempty(errormsg)
187    disp_uvmat('ERROR',['error in reading xmlfile: ' errormsg],checkrun)
188    return
189end
190if size(time,1)>1
191    diff_time=max(max(diff(time)));
192    if diff_time>0
193        disp_uvmat('WARNING',['times of series differ by (max) ' num2str(diff_time)],checkrun)
194    end
195    time=time(1,:);% choose the time data from the first sequence
196end
197
198%% coordinate transform or other user defined transform
199transform_fct=[];%default
200if isfield(Param,'FieldTransform')&&~isempty(Param.FieldTransform.TransformName)
201    addpath(Param.FieldTransform.TransformPath)
202    transform_fct=str2func(Param.FieldTransform.TransformName);
203    rmpath(Param.FieldTransform.TransformPath)
204end
205
206%%%%%%%%%%%% END STANDARD PART  %%%%%%%%%%%%
207% EDIT FROM HERE
208
209%% check the validity of  the input file types
210if ~CheckImage{1}&&~CheckNc{1}
211    disp_uvmat('ERROR',['invalid file type input ' FileType{1}],checkrun)
212    return
213end
214if nbview==2 && ~isequal(CheckImage{1},CheckImage{2})
215    disp_uvmat('ERROR','input must be two image series or two netcdf file series',checkrun)
216    return
217end
218
219%% settings for the output file
220FileExtOut='.nc';% write result as .nc files for netcdf inputs
221NomTypeOut=nomtype2pair(NomType{1});% determine the index nomenclature type for the output file
222first_i=i1_series{1}(1);
223last_i=i1_series{1}(end);
224if isempty(j1_series{1})% if there is no second index j
225    first_j=1;last_j=1;
226else
227    first_j=j1_series{1}(1);
228    last_j=j1_series{1}(end);
229end
230
231%% Set field names and velocity types
232InputFields{1}=[];%default (case of images)
233if nbview==2
234    InputFields{2}=[];%default (case of images)
235end
236if isfield(Param,'InputFields')
237    InputFields{1}=Param.InputFields;
238    if nbview==2
239        InputFields{2}=Param.InputFields;%default
240        if isfield(Param.InputFields,'FieldName_1')
241            InputFields{2}.FieldName=Param.InputFields.FieldName_1;
242            if isfield(Param.InputFields,'VelType_1')
243                InputFields{2}.VelType=Param.InputFields.VelType_1;
244            end
245        end
246    end
247end
248
249%% Initiate output fields
250%initiate the output structure as a copy of the first input one (reproduce fields)
251[DataOut,tild,errormsg] = read_field(filecell{1,1},FileType{1},InputFields{1},1);
252if ~isempty(errormsg)
253    disp_uvmat('ERROR',['error reading ' filecell{1,1} ': ' errormsg],checkrun)
254    return
255end
256time_1=[];
257if isfield(DataOut,'Time')
258    time_1=DataOut.Time(1);
259end
260if CheckNc{iview}
261    if isempty(strcmp('Conventions',DataOut.ListGlobalAttribute))
262        DataOut.ListGlobalAttribute=['Conventions' DataOut.ListGlobalAttribute];
263    end
264    DataOut.Conventions='uvmat';
265    DataOut.ListGlobalAttribute=[DataOut.ListGlobalAttribute {Param.Action}];
266    ActionKey='Action';
267    while isfield(DataOut,ActionKey)
268        ActionKey=[ActionKey '_1'];
269    end
270    DataOut.(ActionKey)=Param.Action;
271    DataOut.ListGlobalAttribute=[DataOut.ListGlobalAttribute {ActionKey}];
272    if isfield(DataOut,'Time')
273        DataOut.ListGlobalAttribute=[DataOut.ListGlobalAttribute {'Time','Time_end'}];
274    end
275end
276
277nbfile=0;% not used , to check
278nbmissing=0;
279VarMesh=NaN;
280checkhisto=0;
281if isfield(Param,'ProjObject') && ismember(Param.ProjObject.ProjMode,{'inside','outside'})
282    checkhisto=1;
283    if isfield(Param.ActionInput,'VarMesh')%case of histograms
284    VarMesh=Param.ActionInput.VarMesh;
285    end
286end
287%%%%%%%%%%%%%%%% loop on field indices %%%%%%%%%%%%%%%%
288for index=1:nbfield
289    update_waitbar(WaitbarHandle,index/nbfield)
290    if ~isempty(RUNHandle) && ~strcmp(get(RUNHandle,'BusyAction'),'queue')
291        disp('program stopped by user')
292        break % leave the loop if stop is ordered
293    end
294    Data=cell(1,nbview);%initiate the set Data;
295    nbtime=0;
296    dt=[];
297    %%%%%%%%%%%%%%%% loop on views (input lines) %%%%%%%%%%%%%%%%
298    for iview=1:nbview
299        % reading input file(s)
300        [Data{iview},tild,errormsg] = read_field(filecell{iview,index},FileType{iview},InputFields{iview},frame_index{iview}(index));
301        if ~isempty(errormsg)
302            errormsg=['time_series / read_field / ' errormsg];
303            display(errormsg)
304            break
305        end
306        if ~isempty(NbSlice_calib)
307            Data{iview}.ZIndex=mod(i1_series{iview}(index)-1,NbSlice_calib{iview})+1;%Zindex for phys transform
308        end
309    end
310    if isempty(errormsg)
311        Field=Data{1}; % default input field structure
312        % coordinate transform (or other user defined transform)
313        if ~isempty(transform_fct)
314            switch nargin(transform_fct)
315                case 4
316                    if length(Data)==2
317                        Field=transform_fct(Data{1},XmlData{1},Data{2},XmlData{2});
318                    else
319                        Field=transform_fct(Data{1},XmlData{1});
320                    end
321                case 3
322                    if length(Data)==2
323                        Field=transform_fct(Data{1},XmlData{1},Data{2});
324                    else
325                        Field=transform_fct(Data{1},XmlData{1});
326                    end
327                case 2
328                    Field=transform_fct(Data{1},XmlData{1});
329                case 1
330                    Field=transform_fct(Data{1});
331            end
332        end
333       
334        %field projection on an object
335        if Param.CheckObject
336            % calculate tps coefficients if needed
337            if isfield(Param.ProjObject,'ProjMode')&& strcmp(Param.ProjObject.ProjMode,'interp_tps')
338                Field=tps_coeff_field(Field,check_proj_tps);
339            end
340            [Field,errormsg]=proj_field(Field,Param.ProjObject,VarMesh);
341            if ~isempty(errormsg)
342                msgbox_uvmat('ERROR',['time_series / proj_field / ' errormsg])
343                return
344            end
345        end
346%         nbfile=nbfile+1;
347       
348        % initiate the time series at the first iteration
349        if index==1
350            % stop program if the first field reading is in error
351            if ~isempty(errormsg)
352                disp_uvmat('ERROR',['time_series / sub_field / ' errormsg],checkrun)
353                return
354            end
355            DataOut=Field;%default
356            nbvar=length(Field.ListVarName);
357            if nbvar==0
358                disp_uvmat('ERROR','no input variable selected',checkrun)
359                return
360            end
361            if checkhisto%case of histograms
362                testsum=zeros(1,nbvar);%initiate flag for action on each variable
363                for ivar=1:numel(Field.ListVarName)% list of variable names before projection (histogram)
364                    VarName=Field.ListVarName{ivar};
365                    if isfield(Data{1},VarName)
366                        testsum(ivar)=1;
367                        DataOut.(VarName)=Field.(VarName);
368                        DataOut.([VarName 'Histo'])=zeros([nbfield numel(DataOut.(VarName))]);
369                        VarMesh=Field.(VarName)(2)-Field.(VarName)(1);
370                    end
371                end
372                disp(['mesh for histogram = ' num2str(VarMesh)])
373            else
374                testsum=2*ones(1,nbvar);%initiate flag for action on each variable
375                if isfield(Field,'VarAttribute') % look for coordinate and flag variables
376                    for ivar=1:nbvar
377                        if length(Field.VarAttribute)>=ivar && isfield(Field.VarAttribute{ivar},'Role')
378                            var_role=Field.VarAttribute{ivar}.Role;%'role' of the variable
379                            if isequal(var_role,'errorflag')
380                                disp_uvmat('ERROR','do not handle error flags in time series',checkrun)
381                                return
382                            end
383                            if isequal(var_role,'warnflag')
384                                testsum(ivar)=0;  % not recorded variable
385                                eval(['DataOut=rmfield(DataOut,''' Field.ListVarName{ivar} ''');']);%remove variable
386                            end
387                            if strcmp(var_role,'coord_x')||strcmp(var_role,'coord_y')||strcmp(var_role,'coord_z')||strcmp(var_role,'coord')
388                                testsum(ivar)=1; %constant coordinates, record without time evolution
389                            end
390                        end
391                        % check whether the variable ivar is a dimension variable
392                        DimCell=Field.VarDimName{ivar};
393                        if ischar(DimCell)
394                            DimCell={DimCell};
395                        end
396                        if numel(DimCell)==1 && isequal(Field.ListVarName{ivar},DimCell{1})%detect dimension variables
397                            testsum(ivar)=1;
398                        end
399                    end
400                end
401                for ivar=1:nbvar
402                    if testsum(ivar)==2
403                        VarName=Field.ListVarName{ivar};
404                        siz=size(Field.(VarName));
405                        DataOut.(VarName)=zeros([nbfield siz]);
406                    end
407                end
408            end
409            DataOut.ListVarName=[{'Time'} DataOut.ListVarName];
410        end
411       
412        % add data to the current field
413        if checkhisto
414            for ivar=1:length(Field.ListVarName)
415                VarName=Field.ListVarName{ivar};
416                if isfield(Data{1},VarName)
417                    MaxValue=max(DataOut.(VarName));% current max of histogram absissa
418                    MinValue=min(DataOut.(VarName));% current min of histogram absissa
419                    MaxIndex=round(MaxValue/VarMesh);
420                    MinIndex=round(MinValue/VarMesh);
421                    MaxIndex_new=round(max(Field.(VarName)/VarMesh));% max of the current field
422                    MinIndex_new=round(min(Field.(VarName)/VarMesh));
423                    if MaxIndex_new>MaxIndex% the variable max for the current field exceeds the previous one
424                        DataOut.(VarName)=[DataOut.(VarName) VarMesh*(MaxIndex+1:MaxIndex_new)];% append the new variable values
425                        DataOut.([VarName 'Histo'])=[DataOut.([VarName 'Histo']) zeros(nbfield,MaxIndex_new-MaxIndex)]; % append the new histo values
426                    end
427                    if MinIndex_new <= MinIndex-1
428                        DataOut.(VarName)=[VarMesh*(MinIndex_new:MinIndex-1) DataOut.(VarName)];% insert the new variable values
429                        DataOut.([VarName 'Histo'])=[zeros(nbfield,MinIndex-MinIndex_new) DataOut.([VarName 'Histo'])];% insert the new histo values
430                        ind_start=1;
431                    else
432                        ind_start=MinIndex_new-MinIndex+1;
433                    end
434                    DataOut.([VarName 'Histo'])(index,ind_start:ind_start+MaxIndex_new-MinIndex_new)=...
435                        DataOut.([VarName 'Histo'])(index,ind_start:ind_start+MaxIndex_new-MinIndex_new)+Field.([VarName 'Histo']);
436                end
437            end
438        else
439            for ivar=1:length(Field.ListVarName)
440                VarName=Field.ListVarName{ivar};
441                VarVal=Field.(VarName);
442                if testsum(ivar)==2% test for recorded variable
443                    if isempty(errormsg)                     
444                        VarVal=shiftdim(VarVal,-1); %shift dimension
445                        DataOut.(VarName)(index,:,:)=VarVal;%concanete the current field to the time series
446                    end
447                elseif testsum(ivar)==1% variable representing fixed coordinates
448                    VarInit=DataOut.(VarName);
449                    if isempty(errormsg) && ~isequal(VarVal,VarInit)
450                        disp_uvmat('ERROR',['time series requires constant coordinates ' VarName ': use projection mode interp'],checkrun)
451                        return
452                    end
453                end
454            end
455        end
456       
457        % record the time:
458        if isempty(time)% time not set by xml filer(s)
459            if isfield(Data{1},'Time')
460                DataOut.Time(index,1)=Field.Time;
461            else
462                DataOut.Time(index,1)=index;%default
463            end
464        else % time from ImaDoc prevails  TODO: correct
465            DataOut.Time(index,1)=time(index);%
466        end
467       
468        % record the number of missing input fields
469        if ~isempty(errormsg)
470            nbmissing=nbmissing+1;
471            display(['index=' num2str(index) ':' errormsg])
472        end
473    end
474end
475%%%%%%% END OF LOOP WITHIN A SLICE
476
477%remove time for global attributes if exists
478Time_index=find(strcmp('Time',DataOut.ListGlobalAttribute));
479if ~isempty(Time_index)
480    DataOut.ListGlobalAttribute(Time_index)=[];
481end
482DataOut.Conventions='uvmat';
483for ivar=1:numel(DataOut.ListVarName)
484    VarName=DataOut.ListVarName{ivar};
485    eval(['DataOut.' VarName '=squeeze(DataOut.' VarName ');']) %remove singletons
486end
487
488% add time dimension
489for ivar=1:length(Field.ListVarName)
490    DimCell=Field.VarDimName{ivar};
491    if ischar(DimCell),DimCell={DimCell};end
492    if testsum(ivar)==2% variable for which time series is calculated
493        DataOut.VarDimName{ivar}=[{'Time'} DimCell];
494    elseif testsum(ivar)==1 % variable represneting a fixed coordinate
495        DataOut.VarDimName{ivar}=DimCell;
496    end
497end
498indexremove=find(~testsum);
499if ~isempty(indexremove)
500    DataOut.ListVarName(1+indexremove)=[];
501    DataOut.VarDimName(indexremove)=[];
502    if isfield(DataOut,'Role') && ~isempty(DataOut.Role{1})%generaliser aus autres attributs
503        DataOut.Role(1+indexremove)=[];
504    end
505end
506
507%shift variable attributes
508if isfield(DataOut,'VarAttribute')
509    DataOut.VarAttribute=[{[]} DataOut.VarAttribute];
510end
511DataOut.VarDimName=[{'Time'} DataOut.VarDimName];
512DataOut.Action=Param.Action;%name of the processing programme
513test_time=diff(DataOut.Time)>0;% test that the readed time is increasing (not constant)
514if ~test_time
515    DataOut.Time=1:nbfield;
516end
517
518%case of histograms
519if checkhisto
520    for ivar=1:numel(Field.ListVarName)
521        VarName=Field.ListVarName{ivar};
522        if isfield(Data{1},VarName)
523            DataOut.ListVarName=[DataOut.ListVarName {[VarName 'Histo']}];
524            DataOut.VarDimName=[DataOut.VarDimName {{'Time',VarName}}];
525        end
526    end
527end
528% display nbmissing
529if ~isequal(nbmissing,0)
530    disp_uvmat('WARNING',[num2str(nbmissing) ' files skipped: missing files or bad input, see command window display'],checkrun)
531end
532
533%% name of result file
534OutputFile=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},FileExtOut,NomTypeOut,first_i,last_i,first_j,last_j);
535errormsg=struct2nc(OutputFile,DataOut); %save result file
536if isempty(errormsg)
537    display([OutputFile ' written'])
538else
539    disp_uvmat('ERROR',['error in Series/struct2nc: ' errormsg],checkrun)
540end
541
542%% plot the time series (the last one in case of multislices)
543if checkrun
544    figure
545    haxes=axes;
546    plot_field(DataOut,haxes)
547   
548    %% display the result file using the GUI get_field
549    hget_field=findobj(allchild(0),'name','get_field');
550    if ~isempty(hget_field)
551        delete(hget_field)
552    end
553    get_field(OutputFile,DataOut)
554end
555
556
Note: See TracBrowser for help on using the repository browser.