Skip to content
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

Feat/offshore lcp #150

Merged
merged 41 commits into from
Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
ec4db3e
start README for least_cost_xmission
mikebannis May 16, 2022
05dc719
Add example config
mikebannis May 18, 2022
1d0651d
progress
mikebannis May 23, 2022
01094a6
Add save_paths and radius options to path calcs
mikebannis May 25, 2022
81fbf4b
Add poi to lines utility function and example notebook
mikebannis May 25, 2022
1851259
Add barrier and friction processing to utils
mikebannis May 26, 2022
0a0cb61
Include slope in barriers
mikebannis May 31, 2022
4f9fda0
Fix h5 attrs bug
mikebannis Jun 2, 2022
5e2d8e7
Delay startup of workers to prevent memory spike
mikebannis Jun 2, 2022
abe4a2b
Allow eagle runs to split across multiple nodes
mikebannis Jun 3, 2022
6b24337
Updated README and example configs
mikebannis Jun 5, 2022
fcf7e2e
Merge branch 'feat/offshore_lcp' of github.com:NREL/reVX into feat/of…
mikebannis Jun 5, 2022
17bbff8
Add merge output option to CLI
mikebannis Jun 5, 2022
9acc628
Merge branch 'feat/offshore_lcp' of github.com:NREL/reVX into feat/of…
mikebannis Jun 5, 2022
852a465
Update LCP README
mikebannis Jun 7, 2022
8ee60b7
Merge branch 'main' into feat/offshore_lcp
mikebannis Jun 7, 2022
c74beac
Make simplify_geo a config file option
mikebannis Jun 8, 2022
845aa98
progress fixing tests
mikebannis Jun 8, 2022
ffd5ba2
Merge branch 'feat/offshore_lcp' of github.com:NREL/reVX into feat/of…
mikebannis Jun 8, 2022
c239740
Fix test broken by aoswt code
mikebannis Jun 8, 2022
0915fb9
Optionally drop trans features when merging output
mikebannis Jun 9, 2022
9daf315
Clean up README and example config files
mikebannis Jun 10, 2022
d7688dd
Use execution_control.nodes instead of split_gids
mikebannis Jun 10, 2022
d0d4b38
Merge branch 'feat/offshore_lcp' of github.com:NREL/reVX into feat/of…
mikebannis Jun 10, 2022
9f8dabf
Update README
mikebannis Jun 10, 2022
8946db8
Merge branch 'feat/offshore_lcp' of github.com:NREL/reVX into feat/of…
mikebannis Jun 10, 2022
bdb3459
Fix various linter issues
mikebannis Jun 10, 2022
3126d17
fix multi-process max_worker bug
mikebannis Jun 13, 2022
c795d22
Merge branch 'main' into feat/offshore_lcp
mikebannis Jun 13, 2022
216cfac
Disable unnecessary linter checks
mikebannis Jun 13, 2022
0a8cbac
Allow simplify-geo during output merging
mikebannis Jul 1, 2022
3fd5ac3
document simplify-geo
mikebannis Jul 1, 2022
dc071dc
include example layers notebook
mikebannis Jul 7, 2022
b3f75b5
update README
mikebannis Jul 7, 2022
de5e86a
Merge branch 'feat/offshore_lcp' of github.com:NREL/reVX into feat/of…
mikebannis Jul 7, 2022
4335805
Update POI processing in README and example notebook
mikebannis Aug 15, 2022
148844c
Updates based on PR review
ppinchuk Dec 6, 2022
bf948a0
Merge remote-tracking branch 'origin/main' into feat/offshore_lcp
ppinchuk Dec 6, 2022
d26a201
Linter updates
ppinchuk Dec 6, 2022
b64707e
Add flake8 ignore back
ppinchuk Dec 6, 2022
2d2e27c
Pin shapely version
ppinchuk Dec 12, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/linters/.python-lint
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ confidence=
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"
disable=
arguments-renamed,
unspecified-encoding,
use-maxsplit-arg,
arguments-renamed,
unspecified-encoding,
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pull_request_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
run: |
conda install rtree pip pytest
pip install geopandas
pip install --upgrade --force-reinstall shapely
pip install --upgrade --force-reinstall shapely~=1.8
pip install pytest-cov
pip install -e .
pip install HOPP
Expand Down
320 changes: 320 additions & 0 deletions examples/least_cost_paths/combine_layers_and_add_to_h5.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,320 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Combine all on- and off-shore land and barrier layers"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"from reVX.least_cost_xmission.aoswt_utilities import CombineRasters"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"# Default layer location so we don't have to write the full path\n",
"layer_dir = '/shared-projects/rev/projects/aoswt/data/exclusions'\n",
"\n",
"# Template raster to pull transform, etc. from\n",
"template_f ='/shared-projects/rev/projects/aoswt/data/exclusions/adjusted_shipping_lanes.tif'"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"# The barriers have one or more values to \"bar\" in the first position of\n",
"# the tuple. Single values should be an int, multiple values should use a list. \n",
"# Any other values in the raster are considered open and not to be a barrier.\n",
"barrier_files = [\n",
" (1, 'military_ship_shock_boxes.tif'),\n",
" (1, 'artificial_reefs.tif'),\n",
" (1, 'danger_zones_and_restricted_areas.tif'),\n",
" (1, 'usace_placement_areas.tif'),\n",
" (1, 'usace_sand_borrow_areas.tif'),\n",
" (1, 'usace_sad_sand_borrow_areas.tif'),\n",
" (1, 'boem_sand_borrow_areas.tif'),\n",
" (1, 'boem_marine_mineral_areas.tif'),\n",
" (1, 'unexploded_ordnance_locations_100m_buffer.tif'),\n",
" (1, 'dpp_option_areas.tif'),\n",
" (3, 'dod_designations.tif'),\n",
" ([1,2,3,4], 'ocean_disposal_sites.tif'),\n",
" ([1,2,3,4,6], 'conservation_areas.tif'),\n",
" (1, '/shared-projects/rev/projects/aoswt/data/rasters/conmap_sediment_low_medium_high.tif'),\n",
"]\n",
"\n",
"# Force include layers. These layers will override the barrier layers. Cells with values in \n",
"# the first position of the tuple (int or list) will be forced \"open\" if barricaded \n",
"# by the barrier_files. Cells with any other values will not be affected.\n",
"fi_files = [\n",
" (1, 'boem_wind_planning_areas_03292021.tif'),\n",
" (1, 'boem_wind_leases_06082021.tif'),\n",
" (1, 'aoswt_ad_hoc_forced_inclusions.tif'),\n",
"]\n",
"\n",
"friction_files = [\n",
" # ({'cell value in tiff': 'corresponding friction', ...}, 'filename.tif')\n",
" ({1: 1, 2: 10, 3:5}, 'adjusted_shipping_lanes.tif'),\n",
" ({1: 5}, 'abb_gas_pipelines_61m_buffer.tif'),\n",
" ({1: 10}, 'federal_channels.tif'),\n",
" ({1: 10, 2: 5, 3: 0},'/shared-projects/rev/projects/aoswt/data/rasters/conmap_sediment_low_medium_high.tif'),\n",
"]\n",
"\n",
"slope_file = 'atlantic_coast_slope.tif'"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"cr = CombineRasters(template_f, layer_dir=layer_dir)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Loading barrier layers\n",
"--- military_ship_shock_boxes.tif\n",
"--- artificial_reefs.tif\n",
"--- danger_zones_and_restricted_areas.tif\n",
"--- usace_placement_areas.tif\n",
"--- usace_sand_borrow_areas.tif\n",
"--- usace_sad_sand_borrow_areas.tif\n",
"--- boem_sand_borrow_areas.tif\n",
"--- boem_marine_mineral_areas.tif\n",
"--- unexploded_ordnance_locations_100m_buffer.tif\n",
"--- dpp_option_areas.tif\n",
"--- dod_designations.tif\n",
"--- ocean_disposal_sites.tif\n",
"--- conservation_areas.tif\n",
"--- /shared-projects/rev/projects/aoswt/data/rasters/conmap_sediment_low_medium_high.tif\n",
"--- calculating slope barrier\n",
"Building composite off-shore barrier layers\n",
"Loading forced inclusion layers\n",
"--- boem_wind_planning_areas_03292021.tif\n",
"--- boem_wind_leases_06082021.tif\n",
"--- aoswt_ad_hoc_forced_inclusions.tif\n",
"Building composite forced inclusion layers\n",
"Saving barriers to os_barriers.tif\n",
"Done building barrier layers\n"
]
}
],
"source": [
"# Build composite barrier layer\n",
"cr.build_off_shore_barriers(barrier_files, fi_files, slope_file=slope_file, save_tiff=True)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Loading friction layers\n",
"--- setting raster value 1 to fricton 1 for adjusted_shipping_lanes.tif\n",
"--- setting raster value 2 to fricton 10 for adjusted_shipping_lanes.tif\n",
"--- setting raster value 3 to fricton 5 for adjusted_shipping_lanes.tif\n",
"--- setting raster value 1 to fricton 5 for abb_gas_pipelines_61m_buffer.tif\n",
"--- setting raster value 1 to fricton 10 for federal_channels.tif\n",
"--- setting raster value 1 to fricton 10 for /shared-projects/rev/projects/aoswt/data/rasters/conmap_sediment_low_medium_high.tif\n",
"--- setting raster value 2 to fricton 5 for /shared-projects/rev/projects/aoswt/data/rasters/conmap_sediment_low_medium_high.tif\n",
"--- setting raster value 3 to fricton 0 for /shared-projects/rev/projects/aoswt/data/rasters/conmap_sediment_low_medium_high.tif\n",
"--- calculating slope friction\n",
"Combining off-shore friction layers\n",
"Saving combined friction to tiff\n",
"Done processing friction layers\n"
]
}
],
"source": [
"# Build composite friction layer\n",
"cr.build_off_shore_friction(friction_files, slope_file=slope_file, save_tiff=True)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"# Existing AOSWT h5 file to pull lat/lng, profile from\n",
"ex_aoswt_h5 = '/shared-projects/rev/projects/aoswt/data/exclusions/AOSWT_Exclusions.h5'\n",
"\n",
"# New AOSWT h5 file to write costs and barriers to\n",
"aoswt_h5 = '/shared-projects/rev/projects/aoswt/data/processing/aoswt_costs.h5'\n",
"\n",
"# Existing land costs and barrier\n",
"land_h5 = '/shared-projects/rev/exclusions/xmission_costs.h5'\n",
"land_barrier_layer = 'transmission_barrier'\n",
"land_costs_layer = 'tie_line_costs_102MW'"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"# Create new AOSWT h5 file if needed\n",
"if False:\n",
" cr.create_aoswt_h5(ex_aoswt_h5, aoswt_h5, overwrite=True)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Rasterizing /shared-projects/rev/projects/aoswt/data/shapefiles/coast/gshhs_f_l1_rev.shp\n",
"Saving land mask to land_mask.tif\n",
"Rasterizing complete\n"
]
}
],
"source": [
"# Convert coastal boundary shp file to mask if not already done\n",
"if False:\n",
" land_shp = '/shared-projects/rev/projects/aoswt/data/shapefiles/coast/gshhs_f_l1_rev.shp'\n",
" cr.create_land_mask(land_shp, save_tiff=True)\n",
"else:\n",
" cr.load_land_mask()"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Loading land barriers \"transmission_barrier\" from /shared-projects/rev/exclusions/xmission_costs.h5\n",
"Reprojecting land barriers\n",
"Combining land and off-shore barriers\n",
"Saving combined barriers to combo_barriers.tif\n",
"Writing combined data to \"transmission_barrier\" in /shared-projects/rev/projects/aoswt/data/processing/aoswt_costs.h5\n"
]
}
],
"source": [
"# Merge barriers and write to h5\n",
"cr.merge_os_and_land_barriers(land_h5, land_barrier_layer, aoswt_h5, save_tiff=True)"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Loading land friction \"tie_line_costs_102MW\" from /shared-projects/rev/exclusions/xmission_costs.h5\n",
"Reprojecting land friction\n",
"Combining land and off-shore friction\n",
"Saving combined friction to combo_friction.tif\n",
"Writing combined data to \"tie_line_costs_102MW\" in /shared-projects/rev/projects/aoswt/data/processing/aoswt_costs.h5\n"
]
}
],
"source": [
"# Merge frictions and write to h5\n",
"cr.merge_os_and_land_friction(land_h5, land_costs_layer, aoswt_h5, \n",
" land_cost_mult=1/15000, save_tiff=True) # just right?\n",
" # land_cost_mult=1/10000, save_tiff=True) # too expensive (from first run)\n",
" # land_cost_mult=1/25000, save_tiff=False) #better, still too cheap\n",
" # land_cost_mult=1/50000, save_tiff=True) # to cheap\n",
" # land_cost_mult=1/75000, save_tiff=True) #to cheap, full paths around cape cod\n",
" # land_cost_mult=1/100000, save_tiff=True) # to cheap"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
" "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.5"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Loading