Skip to content

Update choropleth maps - #170

Open
clairehalloran wants to merge 30 commits into
mainfrom
ch/update-maps
Open

Update choropleth maps#170
clairehalloran wants to merge 30 commits into
mainfrom
ch/update-maps

Conversation

@clairehalloran

@clairehalloran clairehalloran commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds adjustText package to environment to avoid label overlap in maps and adds regional labels to some maps.

Before:
image

After:
image

Technical details

Added labels to net import, technology capacity, and H2 capacity maps in single_case_plots.py:

image image

Added labels to difference maps in compare_cases.py for both 2-case and multi-case comparison:
image

image

In hourly_plots.py, NaN values (such as for land-locked regions' offshore wind cf) are now colored light gray and unlabeled:
image

Implementation notes

I incorporated the adjust_text function into the existing reedsplots.label_region_value function for easy reuse.

Additional changes

  • Changes absolute color map from cmocean rain to tempo
image
  • Added outlines to sub-state regions in plot_diff_maps used for 2-case comparison in compare_cases.py
  • Squashed a bug that didn't simplify techs to their maptechs groups in plot_diff_maps function in reedsplots.py
  • Squashed small bugs in diagnostic_plots.py
    • Removed slashes from savenames that raised errors ("Oil/Gas Steam" tech)
    • Re-assigned dropped CRS

Validation, testing, and comparison report(s)

I compared USA_defaults run on this branch with a run from main. There were no changes in results, and a negligible increase in runtime (0.15 hours). Note that the difference in directory size is because I was saving vre_gen, max_cap, and load files from PRAS to run diagnostic_plots.py.

Full results here: results-main,update-maps.pptx

Checklist for author

Details to double-check

  • Charge code provided to reviewers
  • Included comparison reports for appropriate test cases
    - [ ] Documentation updated if necessary
  • Code formatting standardized
  • Reusable functions used where possible instead of copy/pasted code

General information to guide review

  • Zero impact on results of default case
  • No large data file(s) added/modified
  • No substantive impact on runtime for full-US reference case
  • No substantive impact on folder size for full-US reference case
  • No change to process flow (runreeds.py, reeds/core/solve/solve.py)
  • No change to code organization
  • No change to package requirements (environment.yml or Project.toml): adjustText package added

Did you use LLM tools (chatbot or copilot) in the preparation of this PR? If so, describe how

Yes, I used Copilot to simplify techs to their maptechs groups in plot_diff_maps function in reedsplots.py. I attempted this change manually and couldn't find a more elegant solution.

Tag points of contact here if you would like additional review of the relevant parts of the model

@pesap pesap mentioned this pull request Aug 21, 2026
7 tasks

@patrickbrown4 patrickbrown4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks Claire and sorry for the slow followup. Some high-level questions first and then I'll take another closer look.

Comment thread environment.yml
- scipy=1.18
- shapely=2.1
- tqdm=4.68
- adjustText

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

With the prevalence of LLM code I'm more wary of introducing dependencies on small / less-well-vetted packages; there are examples of them getting taken over and hosting malicious code. (That's not unique to LLM code but it is easier to do now, though I might be overreacting.) So I'm on the fence about introducing a new dependency for something that's not required for the model.

  • How hard do you think it would be to implement this functionality ourselves by tweaking reeds.plots.optimize_label_positions()?
  • Could this be an optional package (like seaborn or scikit-learn-extra; you can see examples of how we handle those here and here)? i.e., only used and imported within a single function, and bypassed if it isn't present?
  • If we keep it as is, we should at least pin the version number installed.

Comment thread reeds/plots.py

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What's the motivation behind the change from cmocean.cm.rain to cmocean.cm.tempo? I've been using cmocean.cm.rain since it has more of a color range while still being perceptually uniform, but it might just be what I'm used to.

In general, if we keep the change, I would suggest applying it via the existing global arguments at the top of compare_cases.py and single_case_plots.py (and making sure they're supplied to the called functions) rather than changing the argument defaults throughout the function definitions. Then if different users prefer different colormaps, they only need to change it in one place, and we avoid some churn in the code itself.

Comment thread reeds/reedsplots.py
dfbase[valcol] *= unitscaler
dfcomp[valcol] *= unitscaler

### Aggregate selected technologies to one value per region for the target year

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you say more about what these changes do? I've also been working on a rewrite of this function on the pb/mapdiff branch but I should have opened an issue to clarify.


for tech in plottechs:
savename = f"hourly_failure_rate-year,month-{aggfunc}-{tech.replace('-','')}-{sw['t']}"
savename = f"hourly_failure_rate-year,month-{aggfunc}-{tech.replace('-','').replace('/','')}-{sw['t']}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice, thanks

Comment thread environment.yml
@@ -1,4 +1,4 @@
name: reeds
name: reeds-at

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
name: reeds-at
name: reeds

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants