Skip to content

Feature add: Download wind resource for Alaska #461

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

Merged
merged 21 commits into from
Apr 15, 2025

Conversation

elenya-grant
Copy link
Collaborator

@elenya-grant elenya-grant commented Mar 26, 2025

API Calls to WIND Toolkit Alaska

Added ability to make API calls to WIND Toolkit Alaska and download resource data for Alaska sites. This also required added tools to convert csv files to the proper wind resource data format that is expected by WindPlant.

PR Checklist

  • RELEASE.md has been updated to describe the changes made in this PR
  • Documentation
    • Docstrings are up-to-date
    • Related docs/ files are up-to-date, or added when necessary
    • Documentation has been rebuilt successfully
    • [-] Examples have been updated
  • Tests pass (If not, and this is expected, please elaborate in the tests section)
  • PR description thoroughly describes the new feature, bug fix, etc.

Related issues

Impacted areas of the software

  • modified files:

    • hopp/simulation/technologies/resource/wind_resource.py
      • updated combine_files() function to call combine_and_write_srw_files() function from pysam_wind_tools.py
    • hopp/tools/resource/wind_tools.py
      • modified parsing method if using pressure at different hub-height
    • hopp/simulation/technologies/sites/site_info.py
      • wind_resource_region is new attribute that can be used to specify the wind resource region as Alaska ("conus" is default for existing wind resource downloads, "ak" is used for Alaska)
    • hopp/simulation/technologies/resource/resource.py
      • call_api() updated to replace possible weird characters in download data (mostly relevant for BC-HRRR dataset which is not yet included)
  • tests added:

    • tests/hopp/test_site_info.py
      • test_alaska_wind_resource() new integration test of Alaska wind resource data with SiteInfo
    • tests/hopp/test_wind_resource_tools.py: test the new function combine_wind_files() in hopp/tools/resource/pysam_wind_tools.py for combining wind resource data
      • test_pysam_combine_wind_files_csv
      • test_pysam_combine_wind_files_srw
    • tests/hopp/test_wind.py
      • test_alaska_wind_floris: tests that floris simulation is compatible with resource data format from Alaska wind data
      • test_alaska_wind_pysam: tests that pysam simulation is compatible with resource data format from Alaska wind data
  • new files:

    • hopp/tools/resource/pysam_wind_tools.py: functions to convert csv files into wind data format and combine wind resource files (either csv or srw)
    • hopp/simulation/technologies/resource/alaska_wind.py: script similar to wind_resource.py that downloads wind resource data for Alaska.
    • hopp/simulation/resource_files/wind/66.68_-162.5_WTK_Alaksa_2019_60min_80m_100m.csv: resource file for Alaska site that is used in new tests
  • changes to docs/ files:

    • docs/_toc.yaml: updated to include Alaska wind
    • docs/api/resource/index.md: updated to include Alaska wind
    • docs/api/resource/wind_api.md: updated to specify that this is for continental U.S. sites and include the constraints for wind resource year.
    • docs/api/resource/alaska_wind.md: new file with documentation for Alaska wind API calls

Additional supporting information

Test results, if applicable

@elenya-grant elenya-grant self-assigned this Mar 26, 2025
@elenya-grant elenya-grant added documentation Improvements or additions to documentation enhancement New feature or request labels Mar 26, 2025
Copy link
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 good to me!

Copy link
Collaborator

@johnjasa johnjasa left a comment

Choose a reason for hiding this comment

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

Looks slick and useful for future resource integration! Some small notes and questions, otherwise good to go imo.

Comment on lines 157 to 177
def combine_and_write_srw_files(file_resource_heights, output_filepath):

data = [None] * 2
for height, f in file_resource_heights.items():
if os.path.isfile(f):
with open(f) as file_in:
csv_reader = csv.reader(file_in, delimiter=',')
line = 0
for row in csv_reader:
if line < 2:
data[line] = row
else:
if line >= len(data):
data.append(row)
else:
data[line] += row
line += 1

with open(output_filepath, 'w', newline='') as fo:
writer = csv.writer(fo)
writer.writerows(data)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you add a docstring please?

}
return combined_resource_data

def combine_CSV_to_wind_data(file_resource_heights, fake_resource_year = '1900'):
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is this fake_resource_year used for? If it's just to pass in a year to other functions and has no real meaning, could we change it to None and then modify the functions that use it elsewhere? Or maybe even have None be the default for those functions and then only use the year if it's not None. Feel free to call me if this isn't making sense, I just want to avoid confusion about why there's a fake_resource_year

if isinstance(wind_resource_filepath,list):
if len(wind_resource_filepath) != len(resource_heights):
raise ValueError("wind resource filepath must be a list of filenames that same length as")
file_resource_heights = dict(zip(resource_heights,filepaths))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should the filepaths variable be defined here?

@elenya-grant elenya-grant requested a review from johnjasa April 14, 2025 17:05
Copy link
Collaborator

@johnjasa johnjasa 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, thanks for improving the usability of the wind resource setup!

@johnjasa johnjasa merged commit 219437b into NREL:develop Apr 15, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants