def time_slot_sensor(db): """Define sensor for time slot events.""" sensor = DBSensor(name="TimeSlot15MinSensor", event_resolution=timedelta(minutes=15)) session.add(sensor) session.flush() return sensor
def rolling_day_ahead_beliefs_about_time_slot_events( request, time_slot_sensor: DBSensor): """Define multiple day-ahead beliefs about an ex post time slot event.""" source = (session.query(DBBeliefSource).filter( DBBeliefSource.id == request.param).one_or_none()) beliefs = [] for i in range(1, 11): # ten events # Recent belief (horizon 48 hours) belief = DBTimedBelief( sensor=time_slot_sensor, source=source, value=10 + i, belief_time=datetime(2050, 1, 1, 10, tzinfo=utc) + timedelta(hours=i), event_start=datetime(2050, 1, 3, 10, tzinfo=utc) + timedelta(hours=i), ) session.add(belief) beliefs.append(belief) # Slightly older beliefs (belief_time an hour earlier) belief = DBTimedBelief( sensor=time_slot_sensor, source=source, value=100 + i, belief_time=datetime(2050, 1, 1, 10, tzinfo=utc) + timedelta(hours=i - 1), event_start=datetime(2050, 1, 3, 10, tzinfo=utc) + timedelta(hours=i), ) session.add(belief) beliefs.append(belief) return beliefs
def day_ahead_belief_about_ex_post_time_slot_event( ex_post_time_slot_sensor: DBSensor, test_source_a: DBBeliefSource): """Define day-ahead belief about an ex post time slot event.""" belief = DBTimedBelief( source=test_source_a, sensor=ex_post_time_slot_sensor, value=10, belief_time=datetime(2018, 1, 1, 10, tzinfo=utc), event_start=datetime(2018, 1, 2, 22, 45, tzinfo=utc), ) session.add(belief) return belief
def ex_post_time_slot_sensor(db): """Define sensor for time slot events known in advance (ex post).""" sensor = DBSensor( name="ExPostSensor", event_resolution=timedelta(minutes=15), knowledge_horizon=( timedelta_x_days_ago_at_y_oclock, dict(x=1, y=12, z="Europe/Amsterdam"), ), ) session.add(sensor) session.flush() return sensor
def multiple_day_ahead_beliefs_about_ex_post_time_slot_event( ex_post_time_slot_sensor: DBSensor, test_source_a: DBBeliefSource): """Define multiple day-ahead beliefs about an ex post time slot event.""" n = 10 event_start = datetime(2025, 1, 2, 22, 45, tzinfo=utc) beliefs = [] for i in range(n): belief = DBTimedBelief( source=test_source_a, sensor=ex_post_time_slot_sensor, value=10 + i, belief_time=ex_post_time_slot_sensor.knowledge_time(event_start) - timedelta(hours=i + 1), event_start=event_start, ) session.add(belief) beliefs.append(belief) return beliefs
def test_source_b(): """Define source for test beliefs.""" source = DBBeliefSource("Source B") session.add(source) return source
def instantaneous_sensor(db): """Define sensor for instantaneous events.""" sensor = DBSensor(name="InstantaneousSensor") session.add(sensor) session.flush() return sensor