Skip to content

Update choropleth maps - #170

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

clairehalloran wants to merge 40 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 as an optional package 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 done

@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 Outdated
- 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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I lean towards either the first or third bullet. I think labeling maps without overlap is a helpful feature for many existing figures, so it would be harder to use as an optional package.

I'll look further into how adjustText and reeds.plots.optimize_label_positions are implemented to see if it would be easy to tweak the latter function.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

We discussed this a bit yesterday, but I'm confirming that adjustText uses a pretty different algorithm than the LP in reeds.plots.optimize_label_positions. Per the docstring:

First "explodes" all texts to move them apart.
Then in each iteration pushes all texts away from each other, and any specified
points or objects. At the same time slowly tries to pull the texts closer to their
original locations that they label (this reduces chances that a text ends up super
far away). In the end adds arrows connecting the texts to the respective points.

I'll work on making this package optional as we discussed.

Comment thread reeds/plots.py
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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The current behavior plots all technologies in the titles list without combining into a single i_plot value (so 'DPV' and 'UPV 'capacity are plotted on top of each other on the same map, rather than being combined into a single 'Solar' capacity for each region).

These changes combine all technologies in the value list titles into a single total capacity for the i_plot category. This sum occurs prior to calculating differences so a single i_plot difference between cases can be calculated. This change fixes a bug that made the absolute and difference plots misleading.

The difference calculation now calculates both absolute and percent differences so that there's only one conditional like this:

    elif plot in ['absdiff', 'abs_diff', 'diffabs', 'diff_abs']:

This change is less important.

Comment thread reeds/resource_adequacy/diagnostic_plots.py
Comment thread environment.yml Outdated

This branch has not been deployed

No deployments
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