Skip to content

transitlos.day_check

Is a day a typical day of a GTFS feed? A day is EITHER a holiday OR a normal day, never a mix: a feed is scored on a shared analysis date only when that date runs the feed's normal volume of trips for that weekday.

day_volume_ratio(gtfs_dir, day): trips active on day / median trips active on the same weekday 1-3 weeks before and after (inside the feed's calendar). is_typical_day(...): ratio within [0.8, 1.25] (a feed's own holiday removing service, or a holiday running the Sunday service on top of the weekday one, falls outside). Reads only calendar.txt, calendar_dates.txt and trips.txt (fast, no stop_times).

day_volume_ratio(gtfs_dir, day, weeks=3)

Trips on day over the median of the same weekday weeks weeks before / after (days with no trips at all ignored); None if the neighbours have no service either (nothing to compare with).

Parameters:

Name Type Description Default
gtfs_dir

Unzipped GTFS folder.

required
day date

The day checked.

required
weeks int

Weeks before and after to compare with.

3

Returns:

Type Description
Optional[float]

The ratio, or None.

is_typical_day(gtfs_dir, day, lo=0.8, hi=1.25)

Whether day has a normal amount of service: its trips are between lo and hi times the same weekday of the weeks around it (True when there is nothing to compare with).

Parameters:

Name Type Description Default
gtfs_dir

Unzipped GTFS folder.

required
day date

The day checked.

required
lo float

Lowest accepted ratio.

0.8
hi float

Highest accepted ratio.

1.25

Returns:

Type Description
bool

True for a typical day.