Update choropleth maps - #170
Conversation
patrickbrown4
left a comment
There was a problem hiding this comment.
Thanks Claire and sorry for the slow followup. Some high-level questions first and then I'll take another closer look.
| - scipy=1.18 | ||
| - shapely=2.1 | ||
| - tqdm=4.68 | ||
| - adjustText |
There was a problem hiding this comment.
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
seabornorscikit-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.
There was a problem hiding this comment.
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.
| dfbase[valcol] *= unitscaler | ||
| dfcomp[valcol] *= unitscaler | ||
|
|
||
| ### Aggregate selected technologies to one value per region for the target year |
There was a problem hiding this comment.
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']}" |
| @@ -1,4 +1,4 @@ | |||
| name: reeds | |||
| name: reeds-at | |||
There was a problem hiding this comment.
| name: reeds-at | |
| name: reeds |
Summary
Adds adjustText package to environment to avoid label overlap in maps and adds regional labels to some maps.
Before:

After:

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

compare_cases.pyfor both 2-case and multi-case comparison:In

hourly_plots.py, NaN values (such as for land-locked regions' offshore wind cf) are now colored light gray and unlabeled:Implementation notes
I incorporated the
adjust_textfunction into the existingreedsplots.label_region_valuefunction for easy reuse.Additional changes
plot_diff_mapsused for 2-case comparison incompare_cases.pyplot_diff_mapsfunction inreedsplots.pydiagnostic_plots.pyValidation, 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
- [ ] Documentation updated if necessaryGeneral information to guide review
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_mapsfunction inreedsplots.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