Exporting from a Time History Result Element to a Text File

You can export outputs that are specified within a Time History Result to a tab-delimited text file.  This export can be set to occur automatically at the end of a simulation, or can be triggered manually while in Result Mode. Unlike spreadsheet exports, when running multiple realizations, instead of outputting only a single statistic for each result, in addition, all realizations can be exported to the text file.

   Note: You cannot export scenario results to a text file. If you need to export scenario results, you can do so by choosing to export to a spreadsheet rather than a text file.

To enable this capability for a Time History Result element, select “Text File” from the Export Results To drop-list at the bottom of the Time History Result element dialog:

By default, this is set to “None”.  When you select “Text File”, an Export tab is added to the dialog:

You must first specify the text filename to which you wish to export. You can enter the name of an existing file to which you wish to link by pressing the Options >> button.  This will provide options for either selecting an existing text file (with the extension .txt), or creating (and then selecting) a new file.  You can also type in the name of a file directly.  In this case, you must provide a full or relative path (relative to the model file).

   Note: The output file must have the extension “.txt”.

The file does not need to exist prior to the export.  If you type in a file that does not exist, GoldSim will create it at the time of export.  The filename that you enter can contain one or more of the following keywords which will be replaced with the appropriate text at the time of export:

 

Keyword

Description

%en%

The name of the Result element

%filename%

The name of the GoldSim file (without the extension)

%rundate%

Date simulation was started (displayed using Regional time format settings)

%runtime%

Time simulation was started (displayed using Regional time format settings).

If the file exists at the time of export, it will be overwritten by the new data.  If Confirm before overwriting contents of an existing file is checked, GoldSim will confirm before doing so.

You then must specify what you would like to export.  If running a single realization, the options are not relevant.  However, when running multiple realizations, you can export two kinds of information:

You can export the individual histories for each result and/or you can export the Custom Statistic for each result.

   Note: If you wish to export multiple statistics, you can do so by simply adding multiple result items to the Result element that reference the same output but have different Custom Statistics. Alternatively, you could choose to export to a spreadsheet, which provides an option for export multiple statistics (i.e., those used for Probability Histories)

Data is always exported in a tab-delimited format, with header information written at the top of the file. If multiple realizations are run, all (unscreened) realizations are written to the file.  Multiple results are exported in separate blocks (unless the results reference the same output, have the same label and the same axis mapping, in which case they are exported in the same block so as to list all results referencing the same output together).

An example of what the exported data in a text file looks like is provided below:

In this particular example, the Result element contained two results (Flow and Cost).  The model was run for 5 realizations, and contains 5 timesteps. If you export both realizations and one or more statistics, for each result, the realizations are listed first, followed by columns for the statistics.

Note that the first 10 lines contain header information (each preceded by a “!”):

   Version number

   Filename

   Time simulation was run

   Time export took place

   Name of Result element

   Full path to Result element

   Description for Result element

   The number of time points

   The number of realizations

   The relative realization weights (only included if realization are exported)

The time points that are exported to the text file are the same as those displayed in result charts and tables for the result element.

The relative realization weights are normally all 1.  However, if you use importance sampling (e.g., for Stochastics or Timed Events) or directly specify weights in the Simulation Settings dialog, they will be different and it is critical to take this into account for any post-processing that you carry out on results.

After the header information, the result data is written.  For each result, there are two header rows (preceded by a “!”) indentifying the result name and the units. The realization numbers are then shown, followed by a row for each timepoint.  Each row contains all the (unscreened) realizations.

   Note: GoldSim exports the results as single-precision values.

If your Result element is configured to display Reporting Periods, and you have more than one Reporting Period defined, you must specify which period you wish to export in the When using Reporting Periods drop-list. The type of Reporting Period results that are exported (e.g., Average, Cumulative, etc.) are as specified in the Properties dialog for the Result element.

If a result is an array, it is simply treated in the text file as separate items (i.e., an array of 10 items would produce 10 result groupings).

Several other points regarding result export to text files should be noted:

   Conditions are exported as 0 (False) or 1 (True).

   All dates are exported wrapped in quotes.

   If an output is an array, only those items of the array which have been selected to be viewed (via the Array Label Set dialog) are exported.

   For simulations involving multiple realizations, only those realizations which have been specifically selected to be included (via the Monte Carlo Result Options dialog) are exported.

   High resolution results are not exported.  That is, if your Time History Result is configured to include unscheduled updates, these are not exported.  Only scheduled updates are exported.

   You cannot export time history results from a SubModel (i.e., if the Time Display Setting in the Result element is “SubModel Time”).

The actual export of the results can be triggered in two ways: manually and automatically.  This is determined by the Export automatically when simulation completes checkbox.  If this box is cleared, GoldSim only exports the data if and when you press the Export Now button in the Export tab of the Result element dialog. If this box is checked, however, GoldSim automatically exports the results at the end of the simulation. 

For elements which are set to export automatically, you can globally control their behavior from the Results tab of the Options dialog (accessed from the main menu via Model|Options…, and then selecting the Results tab):

The options in the drop-list affect all Time History Result elements which are set to export automatically when the simulation completes.  If “Export results after simulation” is selected, any Result elements which are set to export results will export (silently) at the end of the simulation. If “Prompt before exporting results” is selected, at the end of the simulation, you will be prompted to determine whether or not to carry out an automatic export.  If “Do not export results” is selected, no automatic export is carried out (i.e., this overrides the selection for each individual Result element).

Pressing the Export Now button manually exports results from all Time History Result elements.

   Note: Within Dashboards, the Button control provides a command option that is equivalent to pressing the Export Now button from the Result tab of the Options dialog.

Several points should be noted regarding automatic export of text file results:

   Automatic export is ignored when carrying out a Sensitivity Analysis or an Optimization run.

   Automatic export is ignored if the Result element is inside a SubModel.

   Automatic export is ignored when running and comparing scenarios.

Related Topics…

Learn more about: