skika.data.wind_sim_generator#
Functions
|
Classes
|
Helper class to model emitted pollution. |
|
Helper class to simulate a source of pollution. |
|
Generator simulating wood smoke pollution sensors. |
- class skika.data.wind_sim_generator.PollutionEmission(x, y, r, initial_strength, expansion)#
Helper class to model emitted pollution.
- Parameters
x (int) – X Position of source
y (int) – Y Position of source
r (int) – Initial radius
initial_strength (int) – Amount of pollution emitted initially
expansion (int) – How quickly pollution expands
- class skika.data.wind_sim_generator.PollutionSource(x, y, strength, expansion, random_state)#
Helper class to simulate a source of pollution.
- Parameters
x (int) – X Position of source
y (int) – Y Position of source
strength (int) – Amount of pollution emitted
expansion (int) – How quickly pollution expands
random_state (int or randomState) – Seed for randomisation
- class skika.data.wind_sim_generator.WindSimGenerator(concept=0, produce_image=False, num_sensors=8, sensor_pattern='circle', sample_random_state=None, x_trail=1)#
Generator simulating wood smoke pollution sensors.
This generator is modeled after experiments placing sensors over a town to capture wood pollution readings.
Pollution sources are distributed and generate an emission every few timesteps. Emission movement depends on wind speed and direction, as well as internal dissipation.
Feature sensors pick up readings to generate features, while a central target sensor records a target reading. This is transformed into a classification target.
- Parameters
concept (int (Default: 0)) – The initial concept
produce_image (bool (Default: False)) – Whether or not to produce an image for visualisation
num_sensors (int (Default: 8)) – The number of sensors to place
sensor_pattern ('circle', 'grid' (Default: circle)) – The pattern to place sensors
sample_random_state (int, randomState) – randomState to generate simulation
x_trail (int (Default: 1)) – The number of feature x lags to output
Examples
>>> # Imports >>> from skika.data.synthetic.wind_sim_generator import WindSimGenerator >>> # Setting up the stream >>> stream = WindSimGenerator(num_sensors = 16, sensor_pattern = 'grid') >>> stream.prepare_for_use() >>> # Retrieving one sample. >>> # First sample may be all 0 depending on pollution transmission. >>> stream.next_sample() (array([[ 0. , 134.78461727, 71.68383298, 0. , 0. , 104.90590932, 266.91631925, 0. , 0. , 51.31476312, 56.51469396, 0. , 0. , 0. , 11.0821078 , 0. , 0. , 153.24292292, 75.4566663 , 0. , 0. , 110.42727297, 296.14962106, 0. , 0. , 59.22154118, 68.89489498, 0. , 0. , 0. , 20.02603747, 0. , 199.49156743]]), array([4])) >>> # Simulate for some time steps. >>> for i in range(100): >>> _ = stream.next_sample() >>> stream.next_sample() (array([[ 0. , 119.28319232, 73.21440717, 0. , 0. , 105.7541374 , 254.93216371, 0. , 0. , 51.13375057, 54.91003902, 0. , 0. , 0. , 11.45964019, 0. , 0. , 136.27998587, 86.155855 , 0. , 0. , 120.36105135, 297.60813426, 0. , 0. , 68.54515689, 76.13336341, 0. , 0. , 0. , 20.32270414, 0. , 190.38410787]]), array([4])) >>> stream.n_remaining_samples() -1 >>> stream.has_more_samples() True >>> # The concept can be changed at any time. >>> # This will change wind speed and direction >>> # as well as the location of pollution sources. >>> stream.set_concept(6) >>> stream.next_sample() (array([[ 0. , 0. , 6.94576111, 0. , 96.21104249, 78.56179139, 68.90448328, 0. , 184.91552406, 119.25640506, 71.48302302, 24.73990969, 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 101.27478157, 82.69662251, 72.53103503, 0. , 215.61056166, 131.17070743, 78.0006768 , 21.47142214, 0. , 0. , 0. , 0. , 227.11417744]]), array([4]))
- get_direction_from_concept(concept)#
Get the wind direction from a set concept.
- set_concept(concept_seed, difficulty=3)#
- Set windspeed, direction and sources.
Randomized per concept, but given the same concept_seed will set to the same values.
- Parameters
concept_seed (int) – Seed for the concept
difficulty (int (Default: 3)) – How difficult a concept is
- set_wind(concept=0, direc=None, strength=None)#
Set wind parameters
- Parameters
concept (int) – The ID of the concept being set
direc (int) – The direction of wind in degrees
strength (int) – The strength of the wind in meters a second.
- update()#
Update simulation
To save time when checking if sensor is within an emission, we exclude check for emissions wholely contained in anouther emission.