Skip to content

Feature/split out resources#246

Merged
genevievestarke merged 6 commits intoNatLabRockies:developfrom
paulf81:feature/split_out_resources
Apr 9, 2026
Merged

Feature/split out resources#246
genevievestarke merged 6 commits intoNatLabRockies:developfrom
paulf81:feature/split_out_resources

Conversation

@paulf81
Copy link
Copy Markdown
Collaborator

@paulf81 paulf81 commented Apr 1, 2026

PR #221 implemented a refactor of the resources module, but because included both file changes, and movement from a monolith file into seperate files, was hard to review because the specific changes were hard to observe.

This PR starts a more incremental approach by for now only splitting out the contents of hercules/resource/wind_solar_resource_downloader.py into seperate module files, without any additional changes except for correcting the imports. Specifically starting from:

download_nsrdb_data (lines 36-224) -- NSRDB via rex/HSDS
download_wtk_data (lines 227-403) -- WTK via rex/HSDS
download_openmeteo_data (lines 406-670) -- Open-Meteo HTTP API
plot_timeseries (lines 673-706) -- shared by all three
plot_spatial_map (lines 709-820) -- shared by all three
get_variable_label (lines 823-851) -- shared by all three
get_variable_colormap (lines 854-882) -- shared by all three

Move to:

hercules/resource/
  __init__.py                          # NEW - package init, re-exports public API
  resource_utilities.py                # NEW - shared plotting (4 existing funcs, moved as-is)
  nsrdb_downloader.py                  # NEW - download_nsrdb_data (moved as-is)
  wtk_downloader.py                    # NEW - download_wtk_data (moved as-is)
  openmeteo_downloader.py              # NEW - download_openmeteo_data (moved as-is)
  upsample_wind_data.py               # UNCHANGED

And then only make changes where these are imported in examples and discussed in docs. This way future modularization changes, as in #221 can be implemented without also including movement of code between files. (Specifically #221 moves repeated code blocks within the download scripts into new shared functions and that is not done here. The individual functions are moved as is)

@genevievestarke
Copy link
Copy Markdown
Collaborator

Hi @paulf81, this looks great! Would you be able to adjust one of the resource examples to show how the sub package is loaded/works?

Copy link
Copy Markdown
Collaborator

@genevievestarke genevievestarke left a comment

Choose a reason for hiding this comment

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

Looks great!

@genevievestarke genevievestarke merged commit 139e27b into NatLabRockies:develop Apr 9, 2026
3 checks passed
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