PyPSA / pypsa-usa

PyPSA-USA: An Open-Source Energy System Optimization Model for the United States
https://pypsa-usa.readthedocs.io
MIT License
55 stars 23 forks source link

Can not dissolve `CA OSW` offshore wind shape #140

Closed trevorb1 closed 11 months ago

trevorb1 commented 11 months ago

Checklist

The Issue

If I use the the ca osw offshore wind shape, a geopandas error is raised in the build_shapes rule

Steps To Reproduce

  1. Set the following config option
offshore_shape:
  use: ca_osw #options are ca_osw, eez
  1. Run the workflow with snakemake -j6

Expected Behavior

The workflow runs using the ca osw shapes

Error Message

INFO:__main__:Building Offshore GIS shapes with CA OSW shapes
Traceback (most recent call last):
  File "/home/trevor/repos/pypsa-usa/workflow/.snakemake/scripts/tmp7szx3m8n.build_shapes.py", line 295, in <module>
    main(snakemake)
  File "/home/trevor/repos/pypsa-usa/workflow/.snakemake/scripts/tmp7szx3m8n.build_shapes.py", line 279, in main
    offshore = combine_offshore_shapes(
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/trevor/repos/pypsa-usa/workflow/.snakemake/scripts/tmp7szx3m8n.build_shapes.py", line 122, in combine_offshore_shapes
    offshore = _dissolve_boem(shape)
               ^^^^^^^^^^^^^^^^^^^^^
  File "/home/trevor/repos/pypsa-usa/workflow/.snakemake/scripts/tmp7szx3m8n.build_shapes.py", line 132, in _dissolve_boem
    shape_split = shape.dissolve().explode(index_parts=False) 
                  ^^^^^^^^^^^^^^
  File "/home/trevor/miniconda3/envs/pypsa-usa/lib/python3.11/site-packages/pandas/core/generic.py", line 5989, in __getattr__
    return object.__getattribute__(self, name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'GeoSeries' object has no attribute 'dissolve'
[Tue Dec  5 21:47:11 2023]
Error in rule build_shapes:
    jobid: 9
    input: data/breakthrough_network/base_grid/zone.csv, repo_data/NERC_Regions/NERC_Regions_Subregions.shp, repo_data/BA_shapes_new/Modified_BE_BA_Shapes.shp, repo_data/BOEM_CA_OSW_GIS/CA_OSW_BOEM_CallAreas.shp
    output: resources/texas/country_shapes.geojson, resources/texas/onshore_shapes.geojson, resources/texas/offshore_shapes.geojson, resources/texas/state_boundaries.geojson
    log: logs/build_shapes_texas.log (check log file(s) for error details)

RuleException:
CalledProcessError in file /home/trevor/repos/pypsa-usa/workflow/Snakefile, line 264:
Command 'set -euo pipefail;  /home/trevor/miniconda3/envs/pypsa-usa/bin/python3.11 /home/trevor/repos/pypsa-usa/workflow/.snakemake/scripts/tmp7szx3m8n.build_shapes.py' returned non-zero exit status 1.
  File "/home/trevor/repos/pypsa-usa/workflow/Snakefile", line 264, in __rule_build_shapes
  File "/home/trevor/miniconda3/envs/pypsa-usa/lib/python3.11/concurrent/futures/thread.py", line 58, in run
Removing output files of failed job build_shapes since they might be corrupted:
resources/texas/country_shapes.geojson, resources/texas/onshore_shapes.geojson, resources/texas/state_boundaries.geojson
Shutting down, this might take some time.
Exiting because a job execution failed. Look above for error message
Complete log: .snakemake/log/2023-12-05T214651.466462.snakemake.log

Anything else?

I think we just need to make sure the offshore wind shape is a geodataframe, rather than a geoseries, before passing into combine_offshore_shape()

trevorb1 commented 11 months ago

Just kidding. The offshore wind shape is empty before being passed into the combine_offshore_shapes function

image

trevorb1 commented 11 months ago

Okay, I guess this is happening because the ca osw shapes are for the western interconnect, however, the config file is specifying the eastern interconnect.

ktehranchi commented 11 months ago

I'll remove CA OSW from the config! This really would only be useful for my work.

ktehranchi commented 11 months ago

I moved the OSW config from config.default.yaml to config.osw.yaml in PR #142