diff --git a/backend/app/get_travel_time.py b/backend/app/get_travel_time.py index f8b4e77..245159e 100644 --- a/backend/app/get_travel_time.py +++ b/backend/app/get_travel_time.py @@ -1,6 +1,6 @@ from app.db import getConnection from app.get_links import get_links -import math, numpy, random +import math, numpy, random, numbers # the way we currently do it def mean_daily_mean(obs): @@ -75,6 +75,9 @@ def get_travel_time(start_node, end_node, start_time, end_time, start_date, end_ connection.close() tt_hourly = [ tt for (dt,tt) in sample ] + if len(sample) < 1: + return {'error': 'not enough data'} + # bootstrap for synthetic sample distribution sample_distribution = [] for i in range(0,100): diff --git a/frontend/src/travelTimeQuery.js b/frontend/src/travelTimeQuery.js index 9fd8865..84bbfd0 100644 --- a/frontend/src/travelTimeQuery.js +++ b/frontend/src/travelTimeQuery.js @@ -64,6 +64,8 @@ export class TravelTimeQuery { record.set('sample', this.#results.confidence.sample) record.set('mean_travel_time_minutes', this.#results.travel_time.minutes) record.set('mean_travel_time_seconds', this.#results.travel_time.seconds) + record.set('moe_lower_p95', this.#results.confidence.intervals['p=0.95'].lower.seconds) + record.set('moe_upper_p95', this.#results.confidence.intervals['p=0.95'].upper.seconds) if(type=='json'){ return Object.fromEntries(record) // can't JSONify maps