Ignore:
Timestamp:
12/08/20 08:45:53 (4 years ago)
Author:
Mathieu Morlighem
Message:

merged trunk-jpl and trunk for revision 25834

Location:
issm/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk

  • issm/trunk/src

  • issm/trunk/src/m/qmu/dakota_out_parse.m

    r22758 r25836  
    11function [method,dresp,scm,pcm,srcm,prcm]=dakota_out_parse(filei) % {{{
     2%DAKOTA_OUT_PARSE - Read a Dakota .out or .dat output file and parse it.
    23%
    3 %  read a Dakota .out or .dat output file and parse it.
     4%   Usage:
     5%      [method,dresp,scm,pcm,srcm,prcm]=dakota_out_parse(filei)
    46%
    5 %  [method,dresp,scm,pcm,srcm,prcm]=dakota_out_parse(filei)
     7%   where the required input is,
     8%      filei         (character, name of .out file)
    69%
    7 %  where the required input is:
    8 %    filei         (character, name of .out file)
     10%   the required output is,
     11%      method        (character, dakota method name)
     12%      dresp         (structure array, responses)
    913%
    10 %  the required output is:
    11 %    method        (character, dakota method name)
    12 %    dresp         (structure array, responses)
     14%   and the optional output is,
     15%      scm           (double array, simple correlation matrix)
     16%      pcm           (double array, partial correlation matrix)
     17%      srcm          (double array, simple rank correlation matrix)
     18%      prcm          (double array, partial rank correlation matrix)
    1319%
    14 %  and the optional output is:
    15 %    scm           (double array, simple correlation matrix)
    16 %    pcm           (double array, partial correlation matrix)
    17 %    srcm          (double array, simple rank correlation matrix)
    18 %    prcm          (double array, partial rank correlation matrix)
     20%   The filei will be prompted for if empty. The fields of dresp are particular
     21%   to the data contained within the file. The scm, pcm, srcm, and prcm are
     22%   output by dakota only for the sampling methods.
    1923%
    20 %  the filei will be prompted if empty.  the fields of dresp
    21 %  are particular to the data contained within the file.  the
    22 %  scm, pcm, srcm, and prcm are output by dakota only for the
    23 %  sampling methods.
     24%   This function reads a dakota .out output file and parses it into the MATLAB
     25%   workspace. It operates in a content-driven fashion: it skips the
     26%   intermediate data and then parses whatever output data it encounters in the
     27%   order in which it exists in the file, rather than searching for data based
     28%   on the particular method (this makes it independent of method). It also can
     29%   read and parse the .dat tabular_output file.
    2430%
    25 %  this function reads a dakota .out output file and parses it
    26 %  into the matlab workspace.  it operates in a content-driven
    27 %  fashion, where it skips the intermediate data and then parses
    28 %  whatever output data it encounters in the order in which it
    29 %  exists in the file, rather than searching for data based on
    30 %  the particular method.  (this makes it independent of method.)
    31 %  it also can read and parse the .dat tabular_output file.
     31%   This data would typically be used for plotting and other postprocessing
     32%   within MATLAB or Excel.
    3233%
    33 %  this data would typically be used for plotting and other
    34 %  post-processing within matlab or excel.
     34%   "Copyright 2009, by the California Institute of Technology. ALL RIGHTS
     35%   RESERVED. United States Government Sponsorship acknowledged. Any commercial
     36%   use must be negotiated with the Office of Technology Transfer at the
     37%   California Institute of Technology. (NTR 47078)
    3538%
    36 "Copyright 2009, by the California Institute of Technology.
    37 ALL RIGHTS RESERVED. United States Government Sponsorship
    38 acknowledged. Any commercial use must be negotiated with
    39 the Office of Technology Transfer at the California Institute
    40 of Technology.  (NTR 47078)
     39 This software may be subject to U.S. export control laws. By accepting this
     40 software, the user agrees to comply with all applicable U.S. export laws
     41 and regulations. User has the responsibility to obtain export licenses, or
     42 other export authority as may be required before exporting such information
     43 to foreign countries or providing access to foreign persons."
    4144%
    42 %  This software may be subject to U.S. export control laws.
    43 %  By accepting this  software, the user agrees to comply with
    44 %  all applicable U.S. export laws and regulations. User has the
    45 %  responsibility to obtain export licenses, or other export
    46 %  authority as may be required before exporting such information
    47 %  to foreign countries or providing access to foreign persons."
    48 %
    49 
    5045        if ~nargin
    5146                help dakota_out_parse
     
    5853        fidi=fopen(sprintf('%s',filei),'r');
    5954        if (fidi < 0)
    60                 error('''%s'' could not be opened.',filei);
     55                error('''%s'' could not be opened',filei);
    6156        end
    6257
     
    6661        fline=fgetl(fidi);
    6762        if ~ischar(fline)
    68                 error('File ''%s'' is empty.',filei);
     63                error('File ''%s'' is empty',filei);
    6964        end
    7065
     
    9085                        [ntokens,tokens]=fltokens(fline);
    9186                        method=tokens{1}{1};
    92                         display(sprintf('Dakota method =''%s''.',method));
     87                        display(sprintf('Dakota method = ''%s''',method));
    9388                elseif strcmp(tokens{1}{1}(7),'N')
    9489                        [fline]=findline(fidi,'methodName = ');
    9590                        [ntokens,tokens]=fltokens(fline);
    9691                        method=tokens{1}{3};
    97                         display(sprintf('Dakota methodName=''%s''.',method));
     92                        display(sprintf('Dakota methodName = ''%s''',method));
    9893                end
    9994        end
     
    165160        %     return
    166161        % end
    167         display('End of file successfully reached.');
     162        display('End of file successfully reached');
    168163        fclose(fidi);
    169164
     
    172167%%  function to parse the dakota tabular output file
    173168
    174         display('Reading Dakota tabular output file.');
     169        display('Reading Dakota tabular output file');
    175170
    176171        %  process column headings of matrix (skipping eval_id)
     
    178173        [ntokens,tokens]=fltokens(fline);
    179174
    180         % New file DAKOTA versions>6
    181         if strncmpi(fline,'%eval_id interface',18)
     175        if strncmpi(fline,'%eval_id interface',18) % Dakota versions >= 6
    182176                offset=2;
    183         else %DAKOTA versions<6
     177        else % Dakota versions < 6
    184178                offset=1;
    185179        end
    186         desc=cell (1,ntokens-offset);
     180        desc=cell(1,ntokens-offset);
    187181        data=zeros(1,ntokens-offset);
    188182
     
    190184                desc(1,i)=cellstr(tokens{1}{i+offset});
    191185        end
    192         display(sprintf('Number of columns (Dakota V+R)=%d.',ntokens-2));
     186        display(sprintf('Number of columns (Dakota V + R) = %d',ntokens-2));
    193187
    194188        %  process rows of matrix
     
    197191        while 1
    198192                fline=fgetl(fidi);
     193
    199194                if ~ischar(fline) || isempty(fline)
    200195                        break;
     
    209204                end
    210205        end
    211         display(sprintf('Number of rows (Dakota func evals)=%d.',nrow));
     206        display(sprintf('Number of rows (Dakota func evals) = %d',nrow));
    212207
    213208        %  calculate statistics
     
    231226        end
    232227
    233         dmin   =min         (data,[],1);
     228        dmin   =min(data,[],1);
    234229        dquart1=prctile_issm(data,25,1);
    235         dmedian=median      (data,1);
     230        dmedian=median(data,1);
    236231        dquart3=prctile_issm(data,75,1);
    237         dmax   =max         (data,[],1);
    238         dmin95=prctile_issm(data,5,1);
    239         dmax95=prctile_issm(data,95,1);
     232        dmax   =max(data,[],1);
     233        dmin95 =prctile_issm(data,5,1);
     234        dmax95 =prctile_issm(data,95,1);
    240235
    241236        %  same as Dakota scm, Excel correl
     
    285280        [ntokens,tokens]=fltokens(fline);
    286281        nfeval=tokens{1}{5};
    287         display(sprintf('  Dakota function evaluations=%d.',nfeval));
     282        display(sprintf('  Dakota function evaluations = %d',nfeval));
    288283
    289284end % }}}
     
    300295        [ntokens,tokens]=fltokens(fline);
    301296        nsamp=tokens{1}{4};
    302         display(sprintf('  Dakota samples=%d.',nsamp));
     297        display(sprintf('  Dakota samples = %d',nsamp));
    303298
    304299end % }}}
     
    331326        end
    332327
    333         display(sprintf('  Number of Dakota response functions=%d.',...
     328        display(sprintf('  Number of Dakota response functions = %d',...
    334329                length(dresp)));
    335330
     
    368363        end
    369364
    370         display(sprintf('  Number of Dakota response functions=%d.',...
     365        display(sprintf('  Number of Dakota response functions = %d',...
    371366                length(dresp)));
    372367
     
    432427        end
    433428
    434         display(sprintf('  Number of Dakota response functions=%d.',...
     429        display(sprintf('  Number of Dakota response functions = %d',...
    435430                length(dresp)));
    436431
     
    504499        end
    505500
    506         display(sprintf('  Number of Dakota response functions=%d.',...
     501        display(sprintf('  Number of Dakota response functions = %d',...
    507502                length(dresp)));
    508503
     
    568563        end
    569564
    570         display(sprintf('  Number of Dakota response functions=%d.',...
     565        display(sprintf('  Number of Dakota response functions = %d',...
    571566                length(dresp)));
    572567
     
    583578        end
    584579
    585         display(['Reading ''' fline '''.']);
     580        display(['Reading ''' fline '''']);
    586581
    587582        cmat.title=fline;
     
    682677
    683678                if ~idvar
    684                         display('    Importance Factors not available.');
     679                        display('    Importance Factors not available');
    685680                        dresp(end).var   ={};
    686681                        dresp(end).impfac=[];
     
    746741
    747742                if ~icdf
    748                         display('    Cumulative Distribution Function not available.');
     743                        display('    Cumulative Distribution Function not available');
    749744                        dresp(ndresp).cdf=[];
    750745                        while ischar(fline) && ...
     
    757752        end
    758753
    759         display(sprintf('  Number of Dakota response functions=%d.',...
     754        display(sprintf('  Number of Dakota response functions = %d',...
    760755                length(dresp)));
    761756
     
    793788                                [ntokens,tokens]=fltokens(fline);
    794789                                dresp.best.param     (end+1,1)=        tokens{1}{1};
    795                                 dresp.best.descriptor(end+1,1)=cellstr(tokens{1}{2});
     790                                %dresp.best.descriptor(end+1,1)=cellstr(tokens{1}{2}); this line is wrong, there is no descriptor
    796791                                fline=fgetl(fidi);
    797792                        end
     
    902897                dresp(end+1).vum=[];
    903898        end
    904         display('Reading measures for volumetric uniformity.');
     899        display('Reading measures for volumetric uniformity');
    905900
    906901        fline=fgetl(fidi);
     
    941936        [ntokens,tokens]=fltokens(fline);
    942937        method=tokens{1}{3};
    943         display(sprintf('Dakota iterator ''%s'' completed.',method));
     938        display(sprintf('Dakota iterator ''%s'' completed',method));
    944939
    945940end % }}}
     
    963958
    964959        warning('findline:str_not_found',...
    965                 'String ''%s'' not found in file.',string);
     960                'String ''%s'' not found in file',string);
    966961        fseek(fidi,ipos,'bof');
    967962
Note: See TracChangeset for help on using the changeset viewer.