Repository navigation
Enable global applicability #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ekatef
wants to merge
54
commits into
main
Choose a base branch
from
integrate-composite-features
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
54 commits
Select commit
Hold shift + click to select a range
2579c25
Restore country field
ekatef cdfe34e
Polish LLMish wording
ekatef 07e58b7
Removing excessive details which stem from agentic testing
ekatef 918107d
Bringing in global mappings
ekatef e4816fa
Add human TODOs to OSM corrections
ekatef fd923da
Add OSM features to config validator
ekatef 37bf53f
Add treatment of country codes for cross-border elements
ekatef d683649
Clarify docstring
ekatef b997f1b
Restore under_construction values
ekatef 69f9d48
Maintain output structure for empty entries
ekatef 9cf45ee
Correct citation
ekatef 932fad7
Sketch custom data functionality
ekatef e2a2db9
Fix LMM artifacts in README
ekatef f42224b
Fix LLM artifacts in config/README
ekatef a7edddd
Add TODO for CRS hardcoding in schema
ekatef 544cfda
Increase quality of README
ekatef 5e2c23f
Fix refuse
ekatef 7f55d29
Quick fix of interactive frontend
ekatef 35a4d35
Port frequency correction mappings
ekatef b1c1dab
Generalize treatment of frequency
ekatef 0d4f431
Enhance cleanup
ekatef a26a6c7
Improve treatment of cables
ekatef d17ec65
Refactor output for clean script
ekatef b6fffa6
Add frequency-related parameters to config and schema
ekatef d1d1628
Bug-fix to enable customization of voltage filtering threshold
ekatef a403ac2
Integrate PyPSA-Earth approach for processing DC lines
ekatef 53e2c99
Integrate DC field into filtering
ekatef 1a9c19f
Implement relationships into DC treatment
ekatef b3b9db5
Amend power field for HVDC
ekatef 2ba595d
Define function for force_ac treatment
ekatef 23b2788
Improve voltage filtering
ekatef 4055f76
Improve treatment of empty geometries
ekatef 922f240
Add cables-to-underground transformation
ekatef 035520e
Minor polishes
ekatef 5dec475
Integrate DC treatment into network build
ekatef 57aae73
Implement adding converters
ekatef 8b46d6c
Add DC part into script validation schema
ekatef 92dea8c
Add voltage threshold into script validation schema
ekatef f04e049
Add converters to plotting
ekatef 9d4bf91
Document DC and frequency treatment
ekatef a29aaa5
Fetch power field for DC lines
ekatef ae2c1f0
Add processing of empty converters
ekatef 1098f50
Improve clarity of docstring
ekatef 765b537
Add converters to plotting
ekatef 00b7bc9
Minor clean-up
ekatef d659cc1
Add details to description of buffer radius
ekatef 6cdbb66
Fix hardcoding
ekatef 43950b9
Minor style fixes
ekatef 2fe33e8
Apply formatting fixes
ekatef 14caf00
Revise README
ekatef 78fac48
Add minimal testing config for Colombia
ekatef fdcc6cd
Enhance test config
ekatef 07d7d24
Sketch integration of newly introduced features
ekatef 9745dfa
Externalize custom files input functionality
ekatef File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # Colombia run used for the main vs integrate-composite-features comparison. | ||
| # Everything else is left at the shipped defaults, so the two branches differ | ||
| # only by code. Run with: | ||
| # snakemake --cores 2 --configfile config.CO.yaml | ||
| countries: [CO] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,49 +1,45 @@ | ||
| Set `countries` to the ISO country codes that define the retrieval scope. The | ||
| workflow first loads the default `config/config.yaml`, then an optional | ||
| `config/regions/config.<ISO>.yaml` file for every selected country. A `regions` | ||
| mapping in the calling configuration overrides values from those regional files. | ||
|
|
||
| `retrieve.source` picks the retrieval backend: `geofabrik` reads a cached local | ||
| PBF extract (`retrieve_osm_pbf.py`), `overpass` queries the live Overpass API | ||
| (`retrieve_osm_overpass.py`). Both produce the same output shape, so | ||
| `clean` doesn't need to know which one ran. `network.include_relations` | ||
| decides whether the network should consider `route=power`/`power=circuit` | ||
| relations, grouping their member ways into one line per real-world circuit; | ||
| retrieval respects this too, so relations aren't fetched at all when it's off. | ||
| `network` also controls the minimum retained AC voltage, station merge buffer | ||
| radius, construction filtering, and planned-asset cutoff date. | ||
|
|
||
| The [BE+NL example](./examples/config.BE-NL.yaml) is a small European development | ||
| scope. Country files under `config/regions` are intentionally small defaults for | ||
| now; community-maintained local corrections belong there rather than in workflow | ||
| code. | ||
|
|
||
| `interactive_map` controls the size of `map.html`: `coordinate_decimals` rounds | ||
| embedded coordinates, and `simplify_geometries` sets per-geometry-type | ||
| Douglas-Peucker tolerances (in metres) for station polygons, bus polygons, and | ||
| lines, or disables simplification entirely via `simplify_geometries.enable`. | ||
| Set `countries` to the ISO country codes that define the retrieval scope. The workflow first loads the default `config/config.yaml`, then an optional `config/regions/config.<ISO>.yaml` file for every selected country. A `regions` mapping in the calling configuration overrides values from those regional files. | ||
|
|
||
| `retrieve.source` picks the retrieval backend: `geofabrik` reads a cached local PBF extract (`retrieve_osm_pbf.py`), `overpass` queries the live Overpass API (`retrieve_osm_overpass.py`). Retrieven data are transferred to the cleaning phase and after that are used to build a topologically-clean network model. | ||
|
|
||
| A parameter `network.include_relations` defines whether the network should consider OSM relations `route=power`/`power=circuit` , grouping their member ways into one line per real-world circuit. In the network-building phase, `network` scripts accepts custom values the minimum retained AC voltage, station merge buffer radius and a construction status. | ||
|
|
||
| `network.station_merge_radius_m` is a buffer radius with the merge distance being *twice* as high.E.g.the default value of 500 m merges substations up to one kilometre apart. | ||
|
|
||
| ### Frequencies and DC lines | ||
|
|
||
| Frequency tags are matched numerically within `network.frequency_tolerance_hz`, so `50.0` counts as 50 Hz and `0.0` as DC. Values in `network.accepted_ac_frequencies_hz` are treated as frequencies of a public-grid alternated current (AC) and normalised to the region's nominal AC frequency. Any other value, such as 16.7 Hz corresponding railway traction, is dropped, since it belongs to a separate grid. Where a line lists several circuits, e.g. `voltage=380000;110000` with `frequency=50;16.7`, each frequency is paired with the voltage in the same position. | ||
|
|
||
| `network.dc_lines` controls DC lines and cables. With `keep`, the default, they carry `dc: true` and get their own buses at each station. `drop` removes DC lines, and `force_ac` keeps them relabelled as AC. DC has its own voltage floor, `network.minimum_voltage_dc_kv`, since HVDC links often run below the AC floor. | ||
|
|
||
| HVDC links combine two approaches. As in PyPSA-Eur, a DC `route=power` relation becomes a single link: parallel poles collapse into one line, the member ways are replaced by it, and its `rating` tag is kept as `p_nom_mw`. DC ways outside any relation are kept too, as in PyPSA-Earth. Converters are written to `converters.csv` by two rules. A station holding both AC and DC buses pairs each DC bus with its AC bus of the closest voltage, as in PyPSA-Earth. A station tagged `substation=converter` with no AC bus of its own pairs with the highest-voltage bus of the nearest AC station within `network.converter_search_radius_m`, as in PyPSA-Eur. The `pairing` column records which rule applied. | ||
|
|
||
| The [BE+NL example](./examples/config.BE-NL.yaml) is a small European development scope. Country files under `config/regions` are intentionally small defaults for now; community-maintained local corrections belong there rather than in workflow code. | ||
|
|
||
| ### Adding custom data | ||
|
|
||
| The workflow provides an option to add custom data which can be handy to deal with inputs which are out of scope for OpenStreetMap, such as planned lines. To inject custom files into the worklow, a filed `custom_data.files` can be used: | ||
|
|
||
| ```yaml | ||
| custom_data: | ||
| files: | ||
| - data/custom/BE_lines_way.json | ||
| ``` | ||
|
|
||
| Enabling this functionality makes `clean` read the custom files alongside the retrieved ones. The expected format correspond to raw elements and must be named `{country}_{feature}.json`. The feature has to be one the retrieval step produces: `lines_way`, `cables_way`, `substations_way`, `substations_node`, `substations_relation`, or `routes_relation`. | ||
|
|
||
| `interactive_map` controls the parameters of `map.html` with `coordinate_decimals` for displayed precision of coordinates, and `simplify_geometries` in meteres applied to station polygons, bus polygons, and lines. | ||
|
|
||
| ### Personal settings and Overpass fair use | ||
|
|
||
| Keep `config/config.yaml` as pure defaults — a test enforces that it matches the | ||
| schema, and it's tracked in git, so it's not the place for anything | ||
| environment- or person-specific. For local overrides (a custom Overpass | ||
| endpoint, contact details, a smaller `countries` scope for development), create | ||
| an untracked `config/config.local.yaml` and pass it alongside the default: | ||
| Keep a git-tracked `config/config.yaml` as pure defaults. A test enforces that this file matches the schema. For local overrides, such as a custom Overpass endpoint, contact details, a smaller `countries` scope, please create an untracked `config/config.local.yaml` and pass it alongside the default: | ||
|
|
||
| ```shell | ||
| snakemake --configfile config/config.local.yaml ... | ||
| ``` | ||
|
|
||
| Snakemake deep-merges it on top of `config/config.yaml`, so you only need to | ||
| list the keys you're overriding. | ||
| Snakemake deep-merges it on top of `config/config.yaml`, so you only need to list the keys you're overriding. | ||
|
|
||
| If you use `retrieve.source: overpass`, set `retrieve.overpass_api.user_agent` | ||
| to your own project name, contact email, and website. The [Overpass API fair | ||
| use policy](https://wiki.openstreetmap.org/wiki/Overpass_API#Fair_use_policy) | ||
| expects automated queries to be identifiable and reachable; a generic or | ||
| missing user agent risks being rate-limited or blocked. `retrieve.overpass_api.url` | ||
| also lets you point at your own or a faster mirror instance instead of the | ||
| shared public endpoint, without touching the checked-in default. | ||
| If you use `retrieve.source: overpass`, set `retrieve.overpass_api.user_agent` to your own project name, contact email, and website. The [Overpass API fair use policy](https://wiki.openstreetmap.org/wiki/Overpass_API#Fair_use_policy) expects automated queries to be identifiable and reachable; a generic or missing user agent risks being rate-limited or blocked. `retrieve.overpass_api.url` also lets you point at your own or a faster mirror instance instead of the shared public endpoint, without touching the checked-in default. | ||
|
|
||
| The generated [schema](./config.schema.json) describes every option. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove please