|
1 | | -Replace Fortran ReadVars with Python ReadVarsESO |
| 1 | +Replace Fortran ReadVarsESO with a Python Equivalent |
2 | 2 | ================ |
3 | 3 |
|
4 | | -**EnergyPlus Development Team** |
| 4 | +Jason W. DeGraw, ORNL |
5 | 5 |
|
6 | 6 | - Original Date: 06/18/2026 |
7 | | - - Revision Date: 06/18/2026 |
8 | | - |
| 7 | + - Revision Date: N/A |
9 | 8 |
|
10 | 9 | ## Justification for New Feature ## |
11 | 10 |
|
12 | | -ReadVarsESO is a post-processing utility used to convert EnergyPlus ESO and MTR output files into delimited tabular output. The current implementation is written in modern Fortran, which keeps a Fortran build dependency alive for a small utility that is otherwise independent of the simulation engine. |
| 11 | +ReadVarsESO is a post-processing utility used to convert EnergyPlus ESO and MTR output files into delimited tabular output (primarily into comma-separated value or CSV form). The current implementation is written in modern Fortran, requiring a Fortran build dependency for a utility that is somewhat independent of the simulation engine. The utility is invoked by the engine if the `-r` flag is passed on the command line, so there is a limited relationship between the engine and the utility. Python has been a requirement for EnergyPlus development for some time now and is a somewhat easier dependency to manage. |
13 | 12 |
|
14 | | -This proposal replaces the Fortran ReadVarsESO program with a vanilla Python implementation. The goal is to preserve the existing command-line behavior for current workflows while making the tool easier to maintain, test, package, and extend. |
| 13 | +This proposal replaces the Fortran ReadVarsESO program with a vanilla Python implementation, where "vanilla" means that there are no dependencies outside of what comes with standard Python. The goal is to preserve the existing command-line behavior for current workflows while making the tool easier to maintain, test, package, and extend. The script has outperformed the Fortran executable in all testing thus far. |
15 | 14 |
|
16 | 15 | ## E-mail and Conference Call Conclusions ## |
17 | 16 |
|
18 | 17 | N/A |
19 | 18 |
|
20 | 19 | ## Overview ## |
21 | 20 |
|
22 | | -The new ReadVarsESO implementation will be a Python script distributed with EnergyPlus and wrapped by platform-appropriate launcher scripts. Existing RVI/MVI based conversion workflows should continue to work, including frequency filters, unlimited column handling, and fixed header behavior. |
| 21 | +The new ReadVarsESO implementation is a Python script distributed with EnergyPlus and wrapped by platform-appropriate launcher scripts. Existing RVI/MVI based conversion workflows should continue to work, including frequency filters, unlimited column handling, and fixed header behavior. |
23 | 22 |
|
24 | | -The Python version will also provide a modern subcommand-based interface for direct inspection and conversion of ESO/MTR files. Initial modern commands include listing available output variables and reading data directly to CSV without requiring a separate RVI/MVI file. |
| 23 | +The Python version provides a modern subcommand-based interface for direct inspection and conversion of ESO/MTR files. Initial modern commands include listing available output variables and reading data directly to CSV without requiring a separate RVI/MVI file. |
25 | 24 |
|
26 | | -### Legacy behavior to preserve ### |
| 25 | +### Legacy Behavior ### |
27 | 26 |
|
28 | | -The historical ReadVarsESO interface is positional and file-oriented. When called with no arguments, it reads `eplusout.eso`, selects all available variables from the ESO data dictionary, and writes `eplusout.csv`. When called with an RVI/MVI file, the control file identifies the input ESO/MTR file, the output file, and the requested variables. |
| 27 | +The historical ReadVarsESO interface is primarily file-oriented. When called with no arguments, it reads `eplusout.eso`, selects all available variables from the ESO data dictionary, and writes `eplusout.csv`. When called with an RVI/MVI file, the control file identifies the input ESO/MTR file, the output file, and the requested variables. |
29 | 28 |
|
30 | 29 | Legacy variable requests may be made by report number or by matching variable names from the data dictionary. The RVI/MVI file can also exclude variables by prefixing report numbers or variable requests with `~`. Command-line options select broad output frequencies such as detailed/timestep, hourly, daily, monthly, and annual/run-period output. Existing options also include limited versus unlimited column handling and `fixheader` behavior. |
31 | 30 |
|
32 | 31 | The legacy converter writes delimited output using the output file extension to determine the delimiter: comma-separated output for CSV, tab-separated output for TAB files, and space-separated output for TXT files. It also writes a `readvars.audit` file and preserves the long-standing header, timestamp, and row formatting used by existing workflows. |
33 | 32 |
|
34 | 33 | ### Enhancements in the Python version ### |
35 | 34 |
|
36 | | -The Python replacement adds a modern subcommand interface while retaining the legacy interface. The `list` command, also available as `variables`, inspects an ESO/MTR data dictionary and reports the available report number, frequency, key, variable name, units, and legacy label. It supports table, CSV, and JSON output, plus filtering by reporting frequency and search text. Internal timestamp dictionary records, such as annual calendar-year records used only to label report periods, are omitted from the modern list output. |
| 35 | +The Python replacement adds a modern subcommand interface while retaining the legacy interface. The new `list` command inspects an ESO/MTR data dictionary and reports the available report number, frequency, key, variable name, units, and legacy label. It supports table, CSV, and JSON output, plus filtering by reporting frequency and search text. Internal timestamp dictionary records, such as annual calendar-year records used only to label report periods, are omitted from the modern list output. |
37 | 36 |
|
38 | 37 | The new `read` command converts an ESO/MTR file directly to CSV without requiring an RVI/MVI file. Calling `ReadVarsESO read <input-file>` selects all user-reportable variables and writes a CSV file next to the input using the same base file name. The output file can be configured with `--output`, and conversion can be narrowed with the same frequency and search filters used by `list`. |
39 | 38 |
|
40 | 39 | The modern commands are intended to be easier to script and discover. They avoid legacy audit-file side effects where practical, provide structured output for tooling, and make it possible for users to inspect available variables before selecting data to convert. |
41 | 40 |
|
| 41 | +### Performance of the Python version ### |
| 42 | + |
| 43 | +To investigate the performance of the Python version, a test file with an existing RVI file was selected: 5ZoneDetailedIceStorage.idf. This model includes 35 output variables and the RVI has 34 entries, and an annual simulation of the model results in an ESO file that is approximately 7.3 MB in size. The Python and Fortran versions were each run ten times on an small Windows desktop system running on a Intel Core i7-8700 @ 3.20GHz processor, resulting in the following timings: |
| 44 | + |
| 45 | +| | Fortran (ms) | Python (ms) | |
| 46 | +|:-------:|:------------:|:-----------:| |
| 47 | +| 1 | 4720.9429 | 924.1084 | |
| 48 | +| 2 | 4649.1618 | 832.2611 | |
| 49 | +| 3 | 4635.4731 | 831.3671 | |
| 50 | +| 4 | 4647.0617 | 885.8676 | |
| 51 | +| 5 | 5082.1201 | 840.9368 | |
| 52 | +| 6 | 4631.1113 | 843.4879 | |
| 53 | +| 7 | 4633.1652 | 835.8188 | |
| 54 | +| 8 | 4719.2226 | 844.0984 | |
| 55 | +| 9 | 4794.5117 | 843.9699 | |
| 56 | +| 10 | 4707.4851 | 839.8434 | |
| 57 | +| Average | 4722.02555 | 852.1759 | |
| 58 | +| Std Dev | 137.3253939 | 29.61428 | |
| 59 | + |
| 60 | +The Python script is roughly five times faster than the Fortran executable for this test case. |
| 61 | + |
42 | 62 | ## Approach ## |
43 | 63 |
|
44 | | -The implementation will port the existing ReadVarsESO behavior to a Python script with no third-party package dependencies. CMake will copy the Python script and wrapper into the EnergyPlus runtime and install locations in place of building a Fortran executable. |
| 64 | +The implementation ports the existing ReadVarsESO behavior to a Python script with no third-party package dependencies. CMake copies the Python script and wrapper into the EnergyPlus runtime and install locations in place of building a Fortran executable. |
45 | 65 |
|
46 | 66 | The legacy interface will remain available for compatibility. A modern interface will be added alongside it, including: |
47 | 67 |
|
48 | | -- `list` or `variables` to inspect available report variables, keys, units, and reporting frequencies. |
| 68 | +- `list` to inspect available report variables, keys, units, and reporting frequencies. |
49 | 69 | - `read` to convert an ESO/MTR file directly to CSV. |
50 | 70 | - Command options for output file selection and basic filtering by frequency or search text. |
51 | 71 |
|
52 | | -The modern commands will avoid legacy audit-file side effects where practical and will omit internal timestamp dictionary records that are not user-reportable output variables. Shared parsing and conversion routines will be used where possible so that legacy and modern behavior stay aligned. |
| 72 | +The modern commands avoid legacy audit-file side effects where practical and omits internal timestamp dictionary records that are not user-reportable output variables. Shared parsing and conversion routines will be used where possible so that legacy and modern behavior stay aligned. |
53 | 73 |
|
54 | 74 | ## Testing/Validation/Data Sources ## |
55 | 75 |
|
|
0 commit comments