Skip to content

Commit adbe8bd

Browse files
author
fredshone
authored
Merge pull request #30 from arup-group/fix-stop-bm-for-new-bench-format
Updates Elara for new London RODS benchmark.
2 parents 65a6c40 + d389e56 commit adbe8bd

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

elara/benchmark_data/london/london-GLA/london-subway-board-alight-2017.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

elara/benchmark_data/test_town/pt_interactions/test_interaction_counter.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"bus": {
33
"test1": {
44
"boardings": {
5-
"nodes": [
5+
"stop_ids": [
66
"home_stop_out"
77
],
88
"counts": {
@@ -34,7 +34,7 @@
3434
},
3535

3636
"alightings": {
37-
"nodes": [
37+
"stop_ids": [
3838
"home_stop_in"
3939
],
4040
"counts": {
@@ -67,7 +67,7 @@
6767
},
6868
"test2": {
6969
"boardings": {
70-
"nodes": [
70+
"stop_ids": [
7171
"work_stop_out"
7272
],
7373
"counts": {
@@ -134,7 +134,7 @@
134134
},
135135

136136
"alightings": {
137-
"nodes": [
137+
"stop_ids": [
138138
"home_stop_in"
139139
],
140140
"counts": {

elara/benchmarking.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ def build(self, resource: dict, write_path: Optional[str] = None) -> dict:
453453
results_df = pd.read_csv(results_path, index_col=0)
454454
results_df = results_df.groupby(results_df.index).sum() # remove class dis-aggregation
455455
results_df = results_df[[str(h) for h in range(24)]] # just keep hourly counts
456-
results_df.index.name = 'link_id'
456+
results_df.index.name = 'stop_id'
457457
model_results[direction] = results_df
458458

459459
# build benchmark results
@@ -467,7 +467,7 @@ def build(self, resource: dict, write_path: Optional[str] = None) -> dict:
467467

468468
for direction, counter in counter_location.items():
469469

470-
stops = counter['nodes']
470+
stops = counter['stop_ids']
471471
bm_hours = list(counter['counts'])
472472
counts_array = np.array(list(counter['counts'].values()))
473473

@@ -479,12 +479,12 @@ def build(self, resource: dict, write_path: Optional[str] = None) -> dict:
479479
f"Hours: {bm_hours} not available in "
480480
f"results.columns: {model_results[direction].columns}")
481481

482-
# combine mode link counts
482+
# combine mode stop counts
483483
for stop_id in stops:
484484
if stop_id not in model_results[direction].index:
485485
failed_snaps += 1
486486
self.logger.warning(
487-
f" Missing model node: {stop_id}, zero filling count for benchmark: "
487+
f" Missing model stop: {stop_id}, zero filling count for benchmark: "
488488
f"{counter_id}"
489489
)
490490
else:
@@ -506,7 +506,7 @@ def build(self, resource: dict, write_path: Optional[str] = None) -> dict:
506506
else:
507507
counter_score = 1
508508
self.logger.warning(
509-
f"Zero size benchmark: {counter_id} link: {stop_id}, returning 1"
509+
f"Zero size benchmark: {counter_id} stop: {stop_id}, returning 1"
510510
)
511511
bm_scores.append(counter_score)
512512

@@ -516,7 +516,7 @@ def build(self, resource: dict, write_path: Optional[str] = None) -> dict:
516516
'found': found,
517517
'counter_id': counter_id,
518518
'direction': direction,
519-
'links': ','.join(stops),
519+
'stops': ','.join(stops),
520520
'score': counter_score,
521521

522522
}
@@ -577,7 +577,7 @@ def build(self, resource: dict, write_path: Optional[str] = None) -> dict:
577577

578578
if failed_snaps:
579579
report = 100 * failed_snaps / (snaps + failed_snaps)
580-
self.logger.warning(f" {report}% of links not found for bm: {self.name}")
580+
self.logger.warning(f" {report}% of stop_ids not found for bm: {self.name}")
581581

582582
# build results df
583583
bm_results_df = pd.DataFrame(bm_results)
@@ -603,6 +603,7 @@ def build(self, resource: dict, write_path: Optional[str] = None) -> dict:
603603

604604
return {'counters': sum(bm_scores) / len(bm_scores)}
605605

606+
606607
class TestPTInteraction(TransitInteraction):
607608

608609
name = 'test_pt_interaction_counter'
@@ -621,7 +622,7 @@ class LondonRODS(TransitInteraction):
621622

622623
name = 'london_rods'
623624
benchmark_data_path = get_benchmark_data(
624-
os.path.join('london', 'london-GLA', 'board_alight.json')
625+
os.path.join('london', 'london-GLA', 'london-subway-board-alight-2017.json')
625626
)
626627

627628
requirements = ['stop_interactions']

0 commit comments

Comments
 (0)