Remove deprecated spatial mapping and aggregation code and inputs#123
Conversation
|
@pesap Is |
patrickbrown4
left a comment
There was a problem hiding this comment.
Thanks a ton for all the cleanup and tests; it looks great, and I'm excited to get it in. I tried it with GSw_ZoneSet=z90 and it worked (at least for the Pacific region), so we're super close.
This PR will also fix #125, since I forgot to update the hierarchy_from134.csv files in #121 and they're out of sync with state_groups.csv (which will no longer be a problem since hierarchy_from134.csv is being removed).
It's up to you how you want to implement the zoneset config we discussed; I added a few suggestions, but if you think a different file format would be clearer, we can go with that. Happy to approve once that's settled.
There was a problem hiding this comment.
There are a couple more references to hierarchy_from134.csv:
-
docs/source/faq.md, under "How do I change the spatial resolution of a ReEDS case?": change tohierarchy.csv -
reeds.inputs.validate_zoneset(): Can delete the bottom check under "TEMPORARY 20260402" and thecheck_aggreg_unique()function
There was a problem hiding this comment.
Oops thanks; I also updated part of that section of the FAQ to make some things a little clearer but let me know if any of my edits don't work
| counties = get_county_zones(case) | ||
| else: | ||
| counties = [] | ||
| if len(counties): |
There was a problem hiding this comment.
Here's where the new config would be applied:
| if len(counties): | |
| if len(counties) and zoneconfig.get('drop_single_county_reinforcement_cost', 0): |
Using .get() so that you can just provide the switch if it needs to be applied, so the file could be formatted as something like
z3109:
drop_single_county_reinforcement_cost: 1
reeds2pras_unitsize_unconstrain_counties: 1
drop_interfaces_missing_cost: 1
PJMcounty:
drop_single_county_reinforcement_cost: 1
reeds2pras_unitsize_unconstrain_counties: 1
drop_interfaces_missing_cost: 1
UTcounty:
drop_single_county_reinforcement_cost: 1
reeds2pras_unitsize_unconstrain_counties: 1
drop_interfaces_missing_cost: 1
z2972:
drop_single_county_reinforcement_cost: 1
reeds2pras_unitsize_unconstrain_counties: 1And then you could read it like:
with open(fpath_zoneconfig, 'r') as f:
zoneconfig = yaml.safe_load(f).get(sw.GSw_ZoneSet, {})(Or there could be one zoneconfig file in each inputs/zones/{GSw_ZoneSet} folder; I'm not sure which is easier but either works)
There was a problem hiding this comment.
On second thought, .get(switchname, 0) opens us up to the kind of switch-name typo bugs that have caused big problems in the past. So it's probably best to be explicit. So you could instead do something like:
GSw_ZoneSet,drop_single_county_reinforcement_cost,reeds2pras_unitsize_unconstrain_counties,drop_interfaces_missing_cost
z3109,1,1,1
PJMcounty,1,1,1
UTcounty,1,1,1
z2972,1,1,0
z90,0,0,0
z134,0,0,0
...and then
zoneconfig = pd.read_csv(fpath_zoneconfig, index_col='GSw_ZoneSet').loc[sw.GSw_ZoneSet]Or stick with yaml if you like; the point is that it's safer to explicitly define each switch for each zoneset and then just access them with zoneconfig[switchname] instead of the .get() with fallback I initially suggested.
There was a problem hiding this comment.
I ended up sticking with yaml but formatting it so that each switch/setting has a list of applicable zonesets rather than vice-versa. That felt more natural to me for some reason (probably just because the zoneset names are shorter), but let me know if you have any issues with that format
There was a problem hiding this comment.
Good call, yeah that's much easier to read. Thanks!
Co-authored-by: Patrick Brown <25125211+patrickbrown4@users.noreply.github.com>
Co-authored-by: Patrick Brown <25125211+patrickbrown4@users.noreply.github.com>
…g in zones/README.MD
I have already a branch for it. We can merge it today and bump the r2x-reeds version on the CI. |
Great, thanks! |
|
@kodiobika, we got the new tag. The runner should pick it right away. Let me know if not! https://github.com/NatLabRockies/r2x-reeds/releases/tag/v0.6.0 |
Sounds good, appreciate it! |
|
Tagging @ahamilton5 for visibility on the tableau visualization changes |
patrickbrown4
left a comment
There was a problem hiding this comment.
Looks great! I like your structure for the zoneset_config.yaml file; it's much more readable that way. I added a description of it to inputs/zones/README.md but otherwise it's all good to go from my end.
|
Confirmed with @ahamilton5 that the tableau visualization changes are okay to push. The script is already broken for county-level runs in the |
Summary
Spatial mapping and aggregation can now be done with just
county2zone.csvandhierarchy.csv, so this PR removes related switches, files, and functions that are no longer needed.Technical details
GSw_RegionResolutionswitchhierarchy_from134.csvfilesreeds.spatial.get_agglevel_variablesfunctionreeds.io.get_county_zonesandreeds.io.has_county_zonesfunctions, which are used in cases where we still need to know whether a zone set is at county/mixed resolution and/or what the county-level zones of the set areinputs_case:agglevels.csv,r_ba.csv,val_ba.csv,county.csv, andhierarchy_with_res.csvris now added to the generator database (unitdata.csv) ininput_processing/copy_files.pyin place of thereeds_bacolumn. Places where generators were being mapped to model zones in subsequent parts ofinput_processingorpostprocessingare now removed.Switches added/removed/changed
GSw_RegionResolutionswitchIssues resolved
Part of #16
Validation, testing, and comparison report(s)
I ran all of the non-github cases in
cases_test.csvand confirmed the changes are minimal or nonexistent. In the BA resolution national cases, there are small changes expected due to census divisions now following state boundaries. In county and mixed resolution cases, there are small changes expected due to the fact that inreeds/resource_adequacy/reeds2pras/src/utils/reeds_data_parsing.jlwe were previously reading thereeds_bacolumn fromunitdata.csv(which only contained BAs, even when model zones were at the county-level), whereas now we're reading thercolumn, which contains model zones.results-0615_Main_MonteCarlo_Random_MC0001,0615_SpatialCleanup_MonteCarlo_Random_MC0001.pptx
mainmainmainChecklist for author
Details to double-check
General information to guide review
Did you use LLM tools (chatbot or copilot) in the preparation of this PR? If so, describe how
No
Tag points of contact here if you would like additional review of the relevant parts of the model