Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typo in Electricity:HVAC [J](Hourly) meter output variable in meter.csv #10488

Closed
Sashadf1 opened this issue May 1, 2024 · 3 comments
Closed

Comments

@Sashadf1
Copy link

Sashadf1 commented May 1, 2024

Issue overview

When loading AnnualRunMeter.csv into a pandas dataframe for post-processing energy modeling results, I tried to index a column titled Electricity:HVAC J

meter_df["Electricity:Facility [kWh](Hourly)"] = meter_df["Electricity:Facility [J](Hourly)"]*2.77778e-7
meter_df["Electricity:Building [kWh](Hourly)"] = meter_df["Electricity:Building [J](Hourly)"]*2.77778e-7
meter_df["Electricity:Plant [kWh](Hourly)"] = meter_df["Electricity:Plant [J](Hourly)"]*2.77778e-7
meter_df["Electricity:HVAC [kWh](Hourly)"] = meter_df["Electricity:HVAC [J](Hourly)"]*2.77778e-7

The following KeyError was thrown.

KeyError: 'Electricity:HVAC [J](Hourly)'

Printing out column titles by executing meter_df.columns revealed that the issue is caused by a typo in the dataframe column header specifically for Electricity:HVAC [J] (Hourly). There is an erroneous extra space after the parentheses closing "Hourly" and the end of the string. This seems to be a problem with E+ output reporting code because I did not modify the meter.csv at all before loading it into the pandas dataframe, and the error occurs for multiple separate E+ runs. I don't know if this error is occurring for the last meter variable in the meter.csv file, or specifically for the Electricity:HVAC variable.

Workarounds for users are manually changing the title of the meter column in the csv or other post-processing tool.

Validate that a fix is complete by opening meter.csv and confirming the typo no longer appears.

image

Details

Operating System: 64-bit operating system, x64-based processor
EnergyPlus v23.2.0

@jmarrec
Copy link
Contributor

jmarrec commented May 27, 2024

When opening issues, it's always much appreciated if you can provide an IDF to reproduce (ideally a minimum complete verifiable example (MCVE)). That avoids us having to guess how we can trigger the same conditions.

Anyways, I tested with 5ZoneAirCooled.idf. The issue is just that ReadVarsEso is adding an extra space at the end of each line in the eplusout.csv.

You do not get that problem if instead of relying on ReadVarsEso you use the newer OutputControl:Files

  OutputControl:Files,
    Yes;                     !- Output CSV

@jmarrec
Copy link
Contributor

jmarrec commented May 27, 2024

I'm tempted to say just "Won't fix". ReadVarsEso is a historical fortran utility, replaced with a native C++ capability (OutputControl:Files), and you can easily work around it if you need to anyways.

df = pd.read_csv('eplusout.csv')
df.columns = df.columns.str.strip() # ReadVarsEso straps an extra space at the end of the line

Or even just do it once and for all in text mode before reading it

from pathlib import Path
out_file = Path('eplusout.csv')
out_file.write_text("\n".join([x.strip() for x in out_file.read_text().splitlines()])
df = pd.read_csv(out_file)

@Myoldmopar Is it worth tweaking ReadVarsEso?

@Sashadf1
Copy link
Author

Ok thanks for specifying the workarounds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants