main_randEvents.py

This application demonstrates a simulation of a set of randomly generated observable events.

This is the entry point script for the random global events, meaning that this is the one you need to execute. This is a managed application, so you need to execute this code before starting up the NOS-T Manager application. The application contains a single EventGenerator class which generates the random events for the simulation in a DataFrame and listens to the time status published by the manager application and publishes event information at the specified start datetime, sunrise/sunset datetime, and event finish datetime.

class EventGenerator(app, event_count, max_event_duration, scenario_start, scenario_length, seed)

Bases: Observer

The EventGenerator object class inherits properties from the Observer object class in the NOS-T tools library

This object class initializes an array of events randomized by location, start-time, and duration. The observer watches the simulation clock and publishes EventStarted, EventDayChange, and EventFinished messages at the appropriate scenario times.

app

An application containing a test-run namespace, a name and description for the app, client credentials, and simulation timing instructions

Type:

ManagedApplication

event_count

An integer specifying the number of events to be generated

Type:

int

max_event_duration

An upper bound for any random draw setting the duration of an event in hours

Type:

float

scenario_start

A datetime specifying the start date and time of the simulation

Type:

datetime

scenario_length

A float specifying the length of the simulation in hours

Type:

float

seed

A value specifying the seed used for pseudorandom number generation for event locations and start times

Type:

any

generate_events()

A method called during object initialization to generate events with ID, start time, finish time, latitude and longitude, list of sunrise/sunset times, and indicator of initial day/night status.

on_change(source, property_name, old_value, new_value)

Standard on_change callback function format inherited from Observer object class

In this instance, the callback function checks the simulation datetime against each scheduled event start datetime, sunrise/sunset datetime, and finish datetime for the scenario. If immediately past any of these event times, an EventStarted, EventDayChange, or EventFinished message is sent to PREFIX/event/start, PREFIX/event/dayChange, PREFIX/event/finish, respectively.