Updated write_tmy_file()#763
Conversation
vicford
left a comment
There was a problem hiding this comment.
Okay, I believe the problem arises with what we want the column headers to be vs. what the data columns themselves are. The reason csv breaks is that the columns list is being used for both the headers and to subset the underlying dataframe by column name.
This is seen more so in the .tmy data format -- the data columns are what the WRF variables actually are, but the header function resets what the header labels are.
If we want the csv to have cleaner looking header labels, create a separate csv_header function to handle. Alternatively and likely easier: the .tmy format is actually a .csv file with a fancy header, and most importantly the filename extension is specifically .tmy not .csv. We can feed two birds with one scone by reusing the .tmy code with the only difference being what the filename extension is. In other words, I'm suggesting that if a user requests a .csv format, they actually get back a .tmy file with the filename extension of .csv
| "Wind direction at 10m (degrees)", | ||
| "Surface pressure (Pa)", | ||
| ] | ||
| print(df.columns) |
| "Air temperature at 2m (degC)", | ||
| "Dew point temperature at 2m (degC)", | ||
| "Relative humidity (0-100)", | ||
| "Instantaneous downwelling shortwave flux at bottom (W/m2)", | ||
| "Shortwave surface downward direct normal irradiance (W/m2)", | ||
| "Shortwave surface downward diffuse irradiance (W/m2)", | ||
| "Instantaneous downwelling longwave flux at bottom (W/m2)", | ||
| "Wind speed at 10m (m/s)", | ||
| "Wind direction at 10m (degrees)", | ||
| "Surface pressure (Pa)", |
There was a problem hiding this comment.
Revert this change. These are the data columns. The dataframe headers labels are reset in the _tmy_header() function.
| "Air temperature at 2m (degC)", | ||
| "Dew point temperature at 2m (degC)", | ||
| "Relative humidity (0-100)", | ||
| "Instantaneous downwelling shortwave flux at bottom (W/m2)", | ||
| "Shortwave surface downward direct normal irradiance (W/m2)", | ||
| "Shortwave surface downward diffuse irradiance (W/m2)", | ||
| "Instantaneous downwelling longwave flux at bottom (W/m2)", | ||
| "Wind speed at 10m (m/s)", | ||
| "Wind direction at 10m (degrees)", | ||
| "Surface pressure (Pa)", |
There was a problem hiding this comment.
Revert this change. This is attempting to rename the data columns to the desired header labels.
Updated variable list and removed setting the order of "scenario" column.
Summary of changes and related issue
Updated write_tmy_file() to be compatible to recent changes to TMY scripts/notebooks, which affected the variable names and column structure.
Link to corresponding Jira ticket(s)
Testing
How to Test
Run the shock XMY methodology notebook and use write_tmy_file() to export results.
Documentation
Code Quality
_Review Process
Administrative Reminders