Changeset 25836 for issm/trunk/src/m/qmu/dakota_out_parse.m
- Timestamp:
- 12/08/20 08:45:53 (4 years ago)
- Location:
- issm/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk
- Property svn:mergeinfo changed
-
issm/trunk/src
- Property svn:mergeinfo changed
-
issm/trunk/src/m/qmu/dakota_out_parse.m
r22758 r25836 1 1 function [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. 2 3 % 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) 4 6 % 5 % [method,dresp,scm,pcm,srcm,prcm]=dakota_out_parse(filei) 7 % where the required input is, 8 % filei (character, name of .out file) 6 9 % 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) 9 13 % 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) 13 19 % 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. 19 23 % 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. 24 30 % 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. 32 33 % 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) 35 38 % 36 % "Copyright 2009, by the California Institute of Technology.37 % ALL RIGHTS RESERVED. United States Government Sponsorship38 % acknowledged. Any commercial use must be negotiated with39 % the Office of Technology Transfer at the California Institute40 % 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." 41 44 % 42 % This software may be subject to U.S. export control laws.43 % By accepting this software, the user agrees to comply with44 % all applicable U.S. export laws and regulations. User has the45 % responsibility to obtain export licenses, or other export46 % authority as may be required before exporting such information47 % to foreign countries or providing access to foreign persons."48 %49 50 45 if ~nargin 51 46 help dakota_out_parse … … 58 53 fidi=fopen(sprintf('%s',filei),'r'); 59 54 if (fidi < 0) 60 error('''%s'' could not be opened .',filei);55 error('''%s'' could not be opened',filei); 61 56 end 62 57 … … 66 61 fline=fgetl(fidi); 67 62 if ~ischar(fline) 68 error('File ''%s'' is empty .',filei);63 error('File ''%s'' is empty',filei); 69 64 end 70 65 … … 90 85 [ntokens,tokens]=fltokens(fline); 91 86 method=tokens{1}{1}; 92 display(sprintf('Dakota method = ''%s''.',method));87 display(sprintf('Dakota method = ''%s''',method)); 93 88 elseif strcmp(tokens{1}{1}(7),'N') 94 89 [fline]=findline(fidi,'methodName = '); 95 90 [ntokens,tokens]=fltokens(fline); 96 91 method=tokens{1}{3}; 97 display(sprintf('Dakota methodName =''%s''.',method));92 display(sprintf('Dakota methodName = ''%s''',method)); 98 93 end 99 94 end … … 165 160 % return 166 161 % end 167 display('End of file successfully reached .');162 display('End of file successfully reached'); 168 163 fclose(fidi); 169 164 … … 172 167 %% function to parse the dakota tabular output file 173 168 174 display('Reading Dakota tabular output file .');169 display('Reading Dakota tabular output file'); 175 170 176 171 % process column headings of matrix (skipping eval_id) … … 178 173 [ntokens,tokens]=fltokens(fline); 179 174 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 182 176 offset=2; 183 else % DAKOTA versions<6177 else % Dakota versions < 6 184 178 offset=1; 185 179 end 186 desc=cell 180 desc=cell(1,ntokens-offset); 187 181 data=zeros(1,ntokens-offset); 188 182 … … 190 184 desc(1,i)=cellstr(tokens{1}{i+offset}); 191 185 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)); 193 187 194 188 % process rows of matrix … … 197 191 while 1 198 192 fline=fgetl(fidi); 193 199 194 if ~ischar(fline) || isempty(fline) 200 195 break; … … 209 204 end 210 205 end 211 display(sprintf('Number of rows (Dakota func evals) =%d.',nrow));206 display(sprintf('Number of rows (Dakota func evals) = %d',nrow)); 212 207 213 208 % calculate statistics … … 231 226 end 232 227 233 dmin =min 228 dmin =min(data,[],1); 234 229 dquart1=prctile_issm(data,25,1); 235 dmedian=median 230 dmedian=median(data,1); 236 231 dquart3=prctile_issm(data,75,1); 237 dmax =max 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); 240 235 241 236 % same as Dakota scm, Excel correl … … 285 280 [ntokens,tokens]=fltokens(fline); 286 281 nfeval=tokens{1}{5}; 287 display(sprintf(' Dakota function evaluations =%d.',nfeval));282 display(sprintf(' Dakota function evaluations = %d',nfeval)); 288 283 289 284 end % }}} … … 300 295 [ntokens,tokens]=fltokens(fline); 301 296 nsamp=tokens{1}{4}; 302 display(sprintf(' Dakota samples =%d.',nsamp));297 display(sprintf(' Dakota samples = %d',nsamp)); 303 298 304 299 end % }}} … … 331 326 end 332 327 333 display(sprintf(' Number of Dakota response functions =%d.',...328 display(sprintf(' Number of Dakota response functions = %d',... 334 329 length(dresp))); 335 330 … … 368 363 end 369 364 370 display(sprintf(' Number of Dakota response functions =%d.',...365 display(sprintf(' Number of Dakota response functions = %d',... 371 366 length(dresp))); 372 367 … … 432 427 end 433 428 434 display(sprintf(' Number of Dakota response functions =%d.',...429 display(sprintf(' Number of Dakota response functions = %d',... 435 430 length(dresp))); 436 431 … … 504 499 end 505 500 506 display(sprintf(' Number of Dakota response functions =%d.',...501 display(sprintf(' Number of Dakota response functions = %d',... 507 502 length(dresp))); 508 503 … … 568 563 end 569 564 570 display(sprintf(' Number of Dakota response functions =%d.',...565 display(sprintf(' Number of Dakota response functions = %d',... 571 566 length(dresp))); 572 567 … … 583 578 end 584 579 585 display(['Reading ''' fline ''' .']);580 display(['Reading ''' fline '''']); 586 581 587 582 cmat.title=fline; … … 682 677 683 678 if ~idvar 684 display(' Importance Factors not available .');679 display(' Importance Factors not available'); 685 680 dresp(end).var ={}; 686 681 dresp(end).impfac=[]; … … 746 741 747 742 if ~icdf 748 display(' Cumulative Distribution Function not available .');743 display(' Cumulative Distribution Function not available'); 749 744 dresp(ndresp).cdf=[]; 750 745 while ischar(fline) && ... … … 757 752 end 758 753 759 display(sprintf(' Number of Dakota response functions =%d.',...754 display(sprintf(' Number of Dakota response functions = %d',... 760 755 length(dresp))); 761 756 … … 793 788 [ntokens,tokens]=fltokens(fline); 794 789 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 796 791 fline=fgetl(fidi); 797 792 end … … 902 897 dresp(end+1).vum=[]; 903 898 end 904 display('Reading measures for volumetric uniformity .');899 display('Reading measures for volumetric uniformity'); 905 900 906 901 fline=fgetl(fidi); … … 941 936 [ntokens,tokens]=fltokens(fline); 942 937 method=tokens{1}{3}; 943 display(sprintf('Dakota iterator ''%s'' completed .',method));938 display(sprintf('Dakota iterator ''%s'' completed',method)); 944 939 945 940 end % }}} … … 963 958 964 959 warning('findline:str_not_found',... 965 'String ''%s'' not found in file .',string);960 'String ''%s'' not found in file',string); 966 961 fseek(fidi,ipos,'bof'); 967 962
Note:
See TracChangeset
for help on using the changeset viewer.