Skip to content
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

Validation zhuzh-up: headway value checks #146

Merged
merged 24 commits into from
Oct 7, 2022

Conversation

KasiaKoz
Copy link
Collaborator

@KasiaKoz KasiaKoz commented Sep 9, 2022

Resolves #144 - Check PT headway values during validation

  • Adds what I consider a fix for headway stats computation. We compute headways by looking at the difference in departure time between consecutive trips. In our approach, the value for headway for the first trip is (now) an empty value. Previously it was infilled with zero, which affected the headway stats reported downstream. It's left as empty/NaN/NaT and is ignored when computing stats later on.
  • Exposes the methods to generate trip headways and headway stats DataFrames to Route and Service objects (originally only Schedule could produce these)
  • Adds info on headways to validation report and warns of zero headways. Looks like this:
    {'schedule_level': {
        'is_valid_schedule': False, 
        'invalid_stages': ['not_has_valid_services'],
        'has_valid_services': False, 
        'invalid_services': ['service'],
        'headways': {
            'has_zero_min_headways': True,
            'routes': {'number_of_affected': 1, 'ids': ['service_0']},
            'services': {'number_of_affected': 1, 'ids': ['service']}}}, 
     'service_level': ..., 
     'route_level': {'service': {
        'service_0': {
            'is_valid_route': False, 
            'invalid_stages': ['not_has_correctly_ordered_route'],
            'headway_stats': {'mean_headway_mins': 0.0, 'std_headway_mins': 0.0, 'max_headway_mins': 0.0, 'min_headway_mins': 0.0}}}},
     'vehicle_level': ...}}

Nb. Part of a wider validation upgrade series. I'm leaving updating the notebook: 6.1. Validating Network: MATSim Specific to last in the series.

'service_level': {
'service': {'is_valid_service': True, 'invalid_stages': [],
'has_valid_routes': True, 'invalid_routes': []}},
'route_level': {
'service': {'1': {'is_valid_route': True, 'invalid_stages': []},
'2': {'is_valid_route': True, 'invalid_stages': []}}},
'service': {'1': {'is_valid_route': True, 'invalid_stages': [],
Copy link
Contributor

@elizabethc-arup elizabethc-arup Sep 22, 2022

Choose a reason for hiding this comment

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

A quick note on an edge case that we ran into in the NZ ABM was with (inter-regional) buses which often only have one service / trip a day. Not sure how often this would occur in other geographies however, we ended up accounting for them by hardcoding all services with a service/trip length of 1 to a 24-hour headway as these would otherwise turn out to have a 0/ nan value.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah that's a very good point, in the old version those would default to a 0 headway. I settled on leaving the NaT/NaN because I didn't want to presume.. My thinking is, we could leave the empty for the user to interpret - I think it's not impossible there to be a service that shows up in the schedule but runs once a week and then the headway should ideally be 72460 right? But we can't know about it because we lost the part of GTFS that could tell us about it. All throughout the genet schedule though, we talk about gtfs DAY and the services are assumed to be running in a day, so a 24h default would make sense.

What do you think would make most sense / be the most convenient for a potential user?

Copy link
Contributor

@elizabethc-arup elizabethc-arup left a comment

Choose a reason for hiding this comment

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

This has been a very helpful function that we use to check whether schedules have been implemented sensibly. A quick note to consider is the edge case that we ran into in the NZ ABM of services with only 1 trip per day, which would result in a 0 or infinite headway rather than 24 hours. :)

Base automatically changed from lab-1249-validation-zhuzh-up to main September 23, 2022 09:50
@KasiaKoz KasiaKoz merged commit c611e80 into main Oct 7, 2022
@KasiaKoz KasiaKoz deleted the lab-1250-check-headway-values branch October 7, 2022 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Check PT headway values in validation
2 participants