-
Notifications
You must be signed in to change notification settings - Fork 34
Recreate iron mapping functionality #413
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
Changes from all commits
Commits
Show all changes
71 commits
Select commit
Hold shift + click to select a range
53942e8
Merge pull request #3 from dakotaramos/develop
dakotaramos d57423a
Merge pull request #4 from dakotaramos/develop
dakotaramos d147e1d
Merge pull request #5 from dakotaramos/develop
dakotaramos d2920ed
refactor of iron mapping functionality, need to update docs
dakotaramos 3a02013
correcting references to local file paths, updated save file logic an…
dakotaramos 354d063
Correcting default argument behavior and adding utilities.find_file()…
dakotaramos 049e33a
refactored code with GeospatialMapConfig class, added doc strings, fu…
dakotaramos 48fd67d
running pre-commit hooks
dakotaramos ea26194
updating bool values for default behavior
dakotaramos 0ab7c32
Adding examples/26_iron_map
dakotaramos f82ccc4
correcting doc strings for GeospatialMapConfig
dakotaramos 39ab33d
updating README.md and environment.yml with necessary conda install c…
dakotaramos 7abddc5
Updating ore and shipping prices to $/kg
dakotaramos 7408098
update examples/26_iron_map/run_iron.py with correct units and explic…
dakotaramos 0c6846e
add colorbar_limits attribute to GeospatialMapConfig, added helper fu…
dakotaramos 1878c64
correcting example_ore_prices.csv
dakotaramos 6182724
Updating doc strings, refactored some logic to make it more readable …
dakotaramos 9a3a4cb
added test_26_iron_map_example() in test_all_examples.py
dakotaramos c4a2bc5
updated pyproject.toml with geopandas and contextily in [.examples], …
dakotaramos b5d621e
Adding docs/user_guide docs page for iron mapping functionality
dakotaramos 832c64e
updating docs/_toc.yml to include new docs page
dakotaramos ef6b4cd
resolving conflicts for merge
dakotaramos 30ae640
Merge branch 'develop' into iron_mapping
dakotaramos f5868bc
updated CHANGELOG.md
dakotaramos 8b00ada
Merge branch 'develop' into iron_mapping
kbrunik 8b23bcd
Update docs/_toc.yml
dakotaramos 08a6acd
resolving merge on CHANGELOG.md
dakotaramos 28db00f
Merge branch 'develop' into iron_mapping
dakotaramos ca04dc4
Updating files paths to use ROOT_DIR and EXAMPLE_DIR, removed extra s…
dakotaramos 392e9b5
correcting type in filepaths
dakotaramos fc86c76
updating pyproject.toml and ci.yml for failing test
dakotaramos dfb421e
force git tracking of cases.csv for use in pytest to avoid having to …
dakotaramos 2a0278b
removing commented code from test_27_iron_map_example()
dakotaramos 388c57c
updating map_preferences default value = None, removing excess inline…
dakotaramos 935c92c
simplifying extra step to convert results geodataframes to web marcat…
dakotaramos d6cafc7
simplified setting of vmin and vmax
dakotaramos 71d3417
removed unnecessary check for save_plot_fpath as Path object
dakotaramos d5a92fc
removing uncessary tuple brackets around string checks
dakotaramos 052a44b
updating multiline string comments for traceback legibility
dakotaramos 5315815
simplifying fig,ax,base_layer_gdf object check
dakotaramos 1a9dd67
simplifying validate_gdfs_are_same_crs()
dakotaramos a278ead
simplifying auto_detect_lat_long_columns() logic
dakotaramos 0ee576a
updating colorbar_limits definition and attrs validation
dakotaramos f8aa978
attempt to resolve failed CI test
dakotaramos ae1c044
Merge branch 'develop' into iron_mapping
johnjasa ed99152
updating example driver_config.yaml run_parallel = False
dakotaramos ddc495c
pulling in merge
dakotaramos 7f54255
Merge branch 'develop' into iron_mapping
dakotaramos 6d5e02e
Update examples/27_iron_map/run_iron.py
dakotaramos 46b209c
Update examples/27_iron_map/run_iron.py
dakotaramos c380776
Update examples/27_iron_map/run_iron.py
dakotaramos 1610e6a
Update examples/27_iron_map/run_iron.py
dakotaramos 6788464
correcting pre-commit errors
dakotaramos 084074e
updating colorbar_limits typing and validators to accept integers
dakotaramos 25078ac
correcting GeospatialMapconfig instantiation
dakotaramos 9395e3d
updating docs md
dakotaramos 2de3f47
adding install guidance to docs md
dakotaramos 1d9b85b
adding install guidance to docs md
dakotaramos 51f5bc0
adding try except block for geopandas and contextily imports
dakotaramos b01112e
updating run_iron.py comments and adding dpi argument for saving plots
dakotaramos c2c46cf
correcting failed test
dakotaramos 3faed45
adding save_plot_dpi argument to run_iron.py
dakotaramos 98ac906
minor updates to mapping.py, added unit tests for mapping helper func…
dakotaramos 68d217a
minor updates to mapping.py, added unit tests for mapping helper func…
dakotaramos e619879
Merge branch 'develop' into iron_mapping
dakotaramos c4a1c8d
Merge branch 'develop' into iron_mapping
johnjasa 806bc7b
updating to examples 28
dakotaramos 228887d
adding example 28 output cases.csv for tests
dakotaramos dddeee0
Merge branch 'develop' into iron_mapping
johnjasa e6047f0
Minor linting updates
johnjasa 87ec7cd
Minor doc update
johnjasa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
155 changes: 155 additions & 0 deletions
155
docs/user_guide/plotting_geospatial_data_with_geopandas.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,155 @@ | ||
| # Plotting geospatial data with GeoPandas and Contextily | ||
|
|
||
| When running H2Integrate simulations across a range of site locations, GeoPandas can be leveraged to plot results and create maps with multiple layers. Contextily is leveraged to add visually pleasing open source basemaps. | ||
|
|
||
| Currently all GIS and GeoPandas mapping functionality lives in `/H2Integrate/h2integrate/postprocess/mapping.py` | ||
|
|
||
| Note: to leverage this functionality users must install H2Integrate with the `gis` or `examples` modifier. ie: `pip install ".[examples]"` or `pip install ".[develop,gis]"`. | ||
|
|
||
| ## Create a multi-layer geospatial point heat map with simple straight line transport routes | ||
|
|
||
| An example use case, mirroring the simulation and workflow in /examples/28_iron_map/run_iron.py, we can use GeoPandas and Contextily to create a multi-layer point heat map which displays the level costs of iron ore pellets from select mines, simplified waterway shipping routes and associated costs to transport the iron ore pellets, and the final levelized cost of iron production via Hydrogen DRI across a range of site locations. | ||
|
|
||
| In this example the configuration .yaml files are set such that a design of experiments is run across multiple site locations (latitude,longitude) read in from the "ned_reduced_sitelist.csv" which contains precomputed levelized cost of electricity (LCOE) and levelized cost of hydrogen (LCOH) at each location. This information is then used to calculate the levelized cost of iron production via hydrogen DRI at these locations. Upon running the model, results are saved to a "cases.sql" file. | ||
|
|
||
| ```python | ||
| from h2integrate.postprocess.mapping import ( | ||
| plot_geospatial_point_heat_map, | ||
| plot_straight_line_shipping_routes, | ||
| ) | ||
| from h2integrate.core.h2integrate_model import H2IntegrateModel | ||
|
|
||
| model = H2IntegrateModel("iron_map.yaml") | ||
| model.run() | ||
| ``` | ||
|
|
||
| Here is an example of how we can then uses the results in cases.sql to plot a multi-layer point heat map and straight line shipping routes in one figure. | ||
|
|
||
| ```python | ||
| # Plot the LCOI results with geopandas and contextily | ||
| # NOTE: you can swap './ex_28_out/cases.sql' with './ex_28_out/cases.csv' to read results from csv | ||
| fig, ax, lcoi_layer_gdf = plot_geospatial_point_heat_map( | ||
| case_results_fpath="./ex_28_out/cases.sql", | ||
| metric_to_plot="iron.LCOI (USD/kg)", | ||
| map_preferences={ | ||
| "figsize": (10, 8), | ||
| "colorbar_label": "Levelized Cost of\nIron [$/kg]", | ||
| "colorbar_limits": (0.6, 1.0), | ||
| }, | ||
| save_sql_file_to_csv=True, | ||
| ) | ||
|
|
||
| # Add a layer for example ore cost prices from select mines | ||
| fig, ax, ore_cost_layer_gdf = plot_geospatial_point_heat_map( | ||
| case_results_fpath="./example_ore_prices.csv", | ||
| metric_to_plot="ore_cost_per_kg", | ||
| map_preferences={ | ||
| "colormap": "Greens", | ||
| "marker": "o", | ||
| "colorbar_bbox_to_anchor": (0.025, 0.97, 1, 1), | ||
| "colorbar_label": "Levelized Cost of\nIron Ore Pellets\n[$/kg ore]", | ||
| "colorbar_limits": (0.11, 0.14), | ||
| }, | ||
| fig=fig, | ||
| ax=ax, | ||
| base_layer_gdf=lcoi_layer_gdf, | ||
| ) | ||
|
|
||
| # Add a layer for example waterway shipping cost from select mines to select ports | ||
| fig, ax, shipping_cost_layer_gdf = plot_geospatial_point_heat_map( | ||
| case_results_fpath="./example_shipping_prices.csv", | ||
| metric_to_plot="shipping_cost_per_kg", | ||
| map_preferences={ | ||
| "colormap": "Greys", | ||
| "marker": "d", | ||
| "markersize": 80, | ||
| "colorbar_bbox_to_anchor": (0.4, 0.97, 1, 1), | ||
| "colorbar_label": "Waterway Shipping Cost\n[$/kg ore]", | ||
| "colorbar_limits": (0.11, 0.14), | ||
| }, | ||
| fig=fig, | ||
| ax=ax, | ||
| base_layer_gdf=[lcoi_layer_gdf, ore_cost_layer_gdf], | ||
| ) | ||
|
|
||
| # Define example water way shipping routes for plotting straight line transport | ||
| cleveland_route = [ | ||
| "Duluth", | ||
| "Keweenaw", | ||
| "Sault St Marie", | ||
| "De Tour", | ||
| "Lake Huron", | ||
| "Port Huron", | ||
| "Erie", | ||
| "Cleveland", | ||
| ] | ||
|
|
||
| buffalo_route = [ | ||
| "Duluth", | ||
| "Keweenaw", | ||
| "Sault St Marie", | ||
| "De Tour", | ||
| "Lake Huron", | ||
| "Port Huron", | ||
| "Erie", | ||
| "Cleveland", | ||
| "Buffalo", | ||
| ] | ||
|
|
||
| chicago_route = [ | ||
| "Duluth", | ||
| "Keweenaw", | ||
| "Sault St Marie", | ||
| "De Tour", | ||
| "Mackinaw", | ||
| "Manistique", | ||
| "Chicago", | ||
| ] | ||
|
|
||
| # Add cleveland route as layer | ||
| fig, ax, transport_layer1_gdf = plot_straight_line_shipping_routes( | ||
| shipping_coords_fpath="./example_shipping_coords.csv", | ||
| shipping_route=cleveland_route, | ||
| map_preferences={}, | ||
| fig=fig, | ||
| ax=ax, | ||
| base_layer_gdf=[lcoi_layer_gdf, ore_cost_layer_gdf, shipping_cost_layer_gdf], | ||
| ) | ||
|
|
||
| # Add buffalo route as layer | ||
| fig, ax, transport_layer2_gdf = plot_straight_line_shipping_routes( | ||
| shipping_coords_fpath="./example_shipping_coords.csv", | ||
| shipping_route=buffalo_route, | ||
| map_preferences={}, | ||
| fig=fig, | ||
| ax=ax, | ||
| base_layer_gdf=[ | ||
| lcoi_layer_gdf, | ||
| ore_cost_layer_gdf, | ||
| shipping_cost_layer_gdf, | ||
| transport_layer1_gdf, | ||
| ], | ||
| ) | ||
|
|
||
| # Add chicago route as layer | ||
| fig, ax, transport_layer3_gdf = plot_straight_line_shipping_routes( | ||
| shipping_coords_fpath="./example_shipping_coords.csv", | ||
| shipping_route=chicago_route, | ||
| map_preferences={"figure_title": "Example H2 DRI Iron Costs"}, | ||
| fig=fig, | ||
| ax=ax, | ||
| base_layer_gdf=[ | ||
| lcoi_layer_gdf, | ||
| ore_cost_layer_gdf, | ||
| shipping_cost_layer_gdf, | ||
| transport_layer1_gdf, | ||
| transport_layer2_gdf, | ||
| ], | ||
| show_plot=True, | ||
| save_plot_fpath="./ex_28_out/example_28_iron_map.png", | ||
| ) | ||
| ``` | ||
|
|
||
| After running the above code, a display window will show the image and the image will be saved to the specified `save_plot_fpath`. | ||
|
|
||
|  | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| name: "driver_config" | ||
| description: "This analysis runs a hybrid plant to match the first example in H2Integrate" | ||
|
|
||
| general: | ||
| folder_output: outputs | ||
|
|
||
| general: | ||
| folder_output: ex_28_out | ||
| create_om_reports: false | ||
| driver: | ||
| design_of_experiments: | ||
| flag: true | ||
| debug_print: true | ||
| generator: "csvgen" | ||
| filename: "ned_reduced_sitelist.csv" | ||
| run_parallel: False | ||
| design_variables: | ||
| site: | ||
| latitude: | ||
| flag: True | ||
| units: "deg" | ||
| lower: -90.0 | ||
| upper: 90.0 | ||
| longitude: | ||
| flag: True | ||
| units: "deg" | ||
| lower: -180.0 | ||
| upper: 180.0 | ||
| iron: | ||
| LCOE: | ||
| flag: True | ||
| units: "USD/MW/h" | ||
| lower: 0 | ||
| upper: 100 | ||
| LCOH: | ||
| flag: True | ||
| units: "USD/kg" | ||
| lower: 0 | ||
| upper: 10 | ||
| objective: | ||
| name: iron.LCOI | ||
| recorder: | ||
| file: cases.sql | ||
| overwrite_recorder: true | ||
| flag: true | ||
| includes: ['site.latitude','site.longitude','iron.LCOI'] | ||
| excludes: ['*'] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.