Skip to content

Updated write_tmy_file()#763

Open
vdmachuca wants to merge 2 commits into
mainfrom
updated-tmy-export
Open

Updated write_tmy_file()#763
vdmachuca wants to merge 2 commits into
mainfrom
updated-tmy-export

Conversation

@vdmachuca
Copy link
Copy Markdown
Contributor

@vdmachuca vdmachuca commented May 11, 2026

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

  • Unit tests written for new/modified code (goal: 80% coverage)
    • All public functions have unit tests
    • Functions that must produce specific values have unit tests
  • Verified that notebooks utilizing affected functions still work
  • Appropriate manual testing completed
  • Advanced Testing label added to PR if this PR makes major changes to the codebase

How to Test

Run the shock XMY methodology notebook and use write_tmy_file() to export results.

Documentation

  • Complex code includes comments explaining logic
  • Function documentation created (docstrings)

Code Quality

  • Follows PEP8 naming and style conventions
  • Helper functions prefixed with underscore _
  • Linting completed and all issues resolved
  • Does not replicate existing functionality
  • Aligns with general coding standards of existing codebase
  • Code generalized for multiple uses (unless too complex/time-intensive)

Review Process

  • PR review instructions provided:
    • Type of review requested (scientific/technical/debugging)
    • Level of review detail needed

Administrative Reminders

  • Jira ticket moved to "Review" when PR created
  • Jira ticket will be moved to "Done" when complete
  • PR branch will be deleted after merge

@vdmachuca vdmachuca marked this pull request as ready for review May 11, 2026 18:29
@vdmachuca vdmachuca requested a review from vicford May 11, 2026 18:39
@acordonez acordonez self-requested a review May 12, 2026 18:50
Copy link
Copy Markdown
Contributor

@vicford vicford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread climakitae/core/data_export.py Outdated
"Wind direction at 10m (degrees)",
"Surface pressure (Pa)",
]
print(df.columns)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please drop if not needed

Comment on lines +1615 to +1624
"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)",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert this change. These are the data columns. The dataframe headers labels are reset in the _tmy_header() function.

Comment on lines +1663 to +1672
"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)",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert this change. This is attempting to rename the data columns to the desired header labels.

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

Successfully merging this pull request may close these issues.

2 participants