chama.impact module¶
The impact module contains methods to extract detection times from a set of simulations and sensor technologies along with methods to convert detection times to impact and coverage metrics.
Contents
|
Returns detection times from a signal and group of sensors. |
|
Returns detection times statistics (min, mean, median, max, and count). |
|
Coverts detection time to an impact/damage metric. |
|
Converts a detection times DataFrame to a coverage DataFrame |
|
Convert an impact DataFrame to a coverage DataFrame |
- chama.impact.extract_detection_times(signal, sensors, interp_method=None, min_distance=10.0)[source]¶
Returns detection times from a signal and group of sensors.
- Parameters:
signal (pandas DataFrame) – Signal data from the simulation. The DataFrame can be in XYZ format (with columns named ‘X’,’Y’,’Z’,’T’) or Node format (with columns named ‘Node’,’T’) along with one column for each scenario (user defined names).
sensors (dict) – A dictionary of sensors with key:value pairs containing {‘sensor name’: chama
Sensor
object}interp_method ('linear', 'nearest', or None) – Method used to interpolate the signal if needed. A value of ‘linear’ will use griddata to interpolate missing sample points. A value of ‘nearest’ will set the sample point to the nearest signal point within a minimum distance of min_distance. If there are no signal points within this distance then the signal will be set to zero at the sample point. Note that interpolation is not used when the signal is in Node format.
min_distance (float) – The minimum distance when using the ‘nearest’ interp_method
- Returns:
det_times (pandas DataFrame) – DataFrame with columns ‘Scenario’, ‘Sensor’, and ‘Detection Times’.
- chama.impact.detection_time_stats(detection_times)[source]¶
Returns detection times statistics (min, mean, median, max, and count).
The minimum detection time is often used as input to an impact-based sensor placement solver.
- Parameters:
detection_times (pandas DataFrame) – Detection times for each scenario-sensor pair. The DataFrame has columns ‘Scenario’, ‘Sensor’, and ‘Detection Times’, see
detection_times
.- Returns:
det_t (pandas DataFrame) – DataFrame with columns ‘Scenario’, ‘Sensor’, ‘Min’, ‘Mean’, ‘Median’, ‘Max’, and ‘Count’.
- chama.impact.detection_time_to_impact(detection_time, impact_data)[source]¶
Coverts detection time to an impact/damage metric.
The impact DataFrame returned from this function can be used as input to
ImpactFormulation
.- Parameters:
detection_time (pandas DataFrame) – Detection time for each scenario-sensor pair. The DataFrame has columns ‘Scenario’, ‘Sensor’, and ‘T’. Note the ‘T’ column here is a single time and not a list of detection times.
impact_data (pandas DataFrame) – Impact data for each scenario and time. The DataFrame has columns ‘T’ and one column for each scenario (user defined names) containing the impact/damage if each scenario was first detected at the times in ‘T’.
- Returns:
det_damage (pandas DataFrame) – DataFrame with columns ‘Scenario’, ‘Sensor’, and ‘Impact’.
- chama.impact.detection_times_to_coverage(detection_times, coverage_type='scenario', scenario=None)[source]¶
Converts a detection times DataFrame to a coverage DataFrame
The returned coverage DataFrame can be used for input to a
CoverageFormulation
.- Parameters:
detection_times (pandas DataFrame) – Detection times for each scenario-sensor pair. The DataFrame has columns ‘Scenario’, ‘Sensor’, and ‘Detection Times’, see
detection_times
.coverage_type ('scenario' or 'scenario-time') – Sets the coverage type: ‘scenario’ (the default value) builds lists of which scenarios are detected/covered by each sensor ignoring the time it was detected, ‘scenario-time’ treats every scenario-time pair as a new scenario and builds lists of which of these new scenarios are detected/covered by each sensor thereby calculating coverage over all scenarios and times.
scenario (pandas DataFrame) – This is an optional argument which should be provided only if the coverage_type is ‘scenario-time’ and the user wants to propagate a scenario’s undetected impact and probability to the new ‘scenario-time’ scenarios. This DataFrame contains three columns, ‘Scenario` is the name of the scenarios, ‘Undetected Impact’ is the impact if the scenario goes undetected and ‘Probability’ is the probability or weighting of each scenario.
- Returns:
coverage (pandas DataFrame) – DataFrame with columns ‘Sensor’ and ‘Coverage’ where the ‘Coverage’ column contains a list of the scenarios/entities detected by a sensor.
new_scenario (pandas DataFrame) – DataFrame returned if coverage_type is ‘scenario-time’ and a ‘scenario’ DataFrame was provided. The columns in this DataFrame match those in the provided ‘scenario’ DataFrame
- chama.impact.impact_to_coverage(impact, impact_col_name='Impact')[source]¶
Convert an impact DataFrame to a coverage DataFrame
The returned coverage DataFrame can be used for input to a
CoverageFormulation
.- Parameters:
impact (pandas DataFrame) – DataFrame containing three columns. ‘Scenario’ is the name of the scenarios, ‘Sensor’ is the name of the sensors, and a third column (called impact_col_name) contains an impact value.
impact_col_name (str) – The name of the column containing the impact data (default = ‘Impact’)
- Returns:
coverage (pandas DataFrame) – DataFrame with columns ‘Sensor’ and ‘Coverage’ to be used as input to a coverage-based sensor placement solver.