Skip to content

Fix: Minor update to EIA NG pricing#777

Open
RHammond2 wants to merge 16 commits into
NatLabRockies:developfrom
RHammond2:fix/ng-price-file
Open

Fix: Minor update to EIA NG pricing#777
RHammond2 wants to merge 16 commits into
NatLabRockies:developfrom
RHammond2:fix/ng-price-file

Conversation

@RHammond2

@RHammond2 RHammond2 commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

Fix: Minor update to EIA NG pricing

This fix provides a series of minor patches to the EIA natural gas feedstock cost model and preprocessing functionality.

  • Updated control flow for reading from an already downloaded file, and not requiring the API
  • Add a missing conditional in the dataframe filtering
  • Adds the missing discrete_inputs and discrete_outputs
  • Ensures a truth array is not passed directly to an if

Section 1: Type of Contribution

  • Feature Enhancement
    • Framework
    • New Model
    • Updated Model
    • Tools/Utilities
    • Other (please describe):
  • Bug Fix
  • Documentation Update
  • CI Changes
  • Other (please describe):

Section 3: General PR Checklist

  • PR description thoroughly describes the new feature, bug fix, etc.
  • Added tests for new functionality or bug fixes
  • Tests pass (If not, and this is expected, please elaborate in the Section 6: Test Results)
  • 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 (if applicable)
  • CHANGELOG.md
    • At least one complete sentence has been provided to describe the changes made in this PR
    • After the above, a hyperlink has been provided to the PR using the following format:
      "A complete thought. [PR XYZ]((https://github.com/NatLabRockies/H2Integrate/pull/XYZ)", where
      XYZ should be replaced with the actual number.

Section 4: Related Issues

Section 5: Impacted Areas of the Software

Section 5.1: New Files

N/A

Section 5.2: Modified Files

  • h2integrate/feedstocks/eia_ng_price.py
    • EIANaturalGasFeedstockConfig.price: Converted to the expected NumPy array type.
    • EIANaturalGasFeedstockCostModel.setup: Passes the price array to the configuration instead of a dataframe.
    • EIANaturalGasFeedstockCostModel.compute: Includes previously unnecessary discrete_inputs and discrete_outputs, and fixes the if condition to an array.all() in place of a truth array.
  • h2integrate/preprocess/eia.py
    • get_eia_ng_data: URL creation is moved to after checking and using an existing file, a missing conditional is added, and missing function arguments are added.
  • h2integrate/feedstocks/test/test_feedstocks.py: Adds a test to run the EIA NG feedstock model from a downloaded file, and updates for duplicated plant_config usage.

Section 6: Additional Supporting Information

Section 7: Test Results, if applicable

Tests pass.

@RHammond2 RHammond2 marked this pull request as ready for review June 9, 2026 17:20
@RHammond2 RHammond2 requested review from elenya-grant and johnjasa and removed request for johnjasa June 9, 2026 17:20
Comment thread h2integrate/feedstocks/eia_ng_price.py

@elenya-grant elenya-grant left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hi Rob! I think this looks great! Had a few minor suggestions but nothing blocking.

One consideration/thought I want to run by ya! In the resource models, it downloads data from the API and each resource model has a specified file-naming convention. So, even if a user does not provide a filename, it will look to see if that filename already exists in the RESOURCE_DIR. If that filename does not exist, the resource data will be downloaded to the RESOURCE_DIR using the user-supplied filename instead of the default. This ends up having a bit of complicated logic but my main thought is would a built-in file naming convention be useful here so that duplicate files aren't downloaded? I also think that the EIA grid data you've uploaded for testing here could be saved in the resource_files folder in a subfolder named natural_gas_prices or similar (but maybe with a filename like EIA_ng_prices_MN_2001.csv). (I'll admit that I haven't run this myself so I'm not sure if there is already a file naming convention that I'm missing)

Again - nothing blocking from me at the moment! Thanks!

Comment thread h2integrate/feedstocks/test/test_feedstocks.py Outdated
Comment thread h2integrate/feedstocks/test/test_feedstocks.py Outdated
RHammond2 and others added 2 commits June 9, 2026 14:13
Co-authored-by: elenya-grant <116225007+elenya-grant@users.noreply.github.com>
Co-authored-by: elenya-grant <116225007+elenya-grant@users.noreply.github.com>
@RHammond2

Copy link
Copy Markdown
Collaborator Author

One consideration/thought I want to run by ya! In the resource models, it downloads data from the API and each resource model has a specified file-naming convention. So, even if a user does not provide a filename, it will look to see if that filename already exists in the RESOURCE_DIR. If that filename does not exist, the resource data will be downloaded to the RESOURCE_DIR using the user-supplied filename instead of the default. This ends up having a bit of complicated logic but my main thought is would a built-in file naming convention be useful here so that duplicate files aren't downloaded? I also think that the EIA grid data you've uploaded for testing here could be saved in the resource_files folder in a subfolder named natural_gas_prices or similar (but maybe with a filename like EIA_ng_prices_MN_2001.csv). (I'll admit that I haven't run this myself so I'm not sure if there is already a file naming convention that I'm missing)

I think this is a good idea in general. Is there a model example to base this off of? Based on perusing the current usage, I think the biggest lift will be adding the resource_dir into the existing eia.py workflows, but I think we could just pawn that off to the cost configuration class to create the expected filename. If we're mostly using this to set the default resource_dir to DEFAULT_RESOURCE_DIR, then I think this update would especially make sense.

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.

3 participants