Untitled

 avatar
user_3839718
plain_text
a month ago
2.2 kB
2
Indexable
Never
import math

def compute_specific(observable_name, sensor_values):
    if observable_name == "effective_temperature":
        if sensor_values["temperature"].values[0] == 0 or sensor_values["humidity"].values[0] == 0 or sensor_values["airspeed"].values[0] == 0:
            return 0
        e = 1
        step1 = 0.794 * sensor_values["temperature"].values[0]
        step2 = 0.25 * ((sensor_values["temperature"].values[0] * math.atan(0.151977 * math.sqrt(sensor_values["humidity"].values[0] + 8.313659))) +
                        math.atan(sensor_values["temperature"].values[0] + sensor_values["humidity"].values[0]) - math.atan(sensor_values["humidity"].values[0] - 1.676331) +
                        (0.00391838 * math.pow(sensor_values["humidity"].values[0], 1.5) * math.atan(0.023101 * sensor_values["humidity"].values[0])) - 4.686035)
        step3 = 0.7
        step4 = -0.15 * (41 - sensor_values["temperature"].values[0]) * (math.pow(sensor_values["airspeed"].values[0], float(e)) - math.pow(0.2, float(e)))

        return step1 + step2 + step3 + step4
    elif observable_name == "humidex":
        if sensor_values["temperature"].values[0] == 0 or sensor_values["humidity"].values[0] == 0:
            return 0
        e = 6.112 * math.pow(10, (7.5 * sensor_values["temperature"].values[0]) / (237.7 + sensor_values["temperature"].values[0])) * (sensor_values["humidity"].values[0] / 100.0)
        humidex = sensor_values["temperature"].values[0] + (e - 10.0) * (5.0 / 9.0)
        return humidex
    elif observable_name == "digestion_index":
        if sensor_values["bad_droppings"].values[0] == 0 and sensor_values["good_droppings"].values[0] == 0:
            return 0
        dig_index = (sensor_values["good_droppings"].values[0] / (sensor_values["bad_droppings"].values[0] + sensor_values["good_droppings"].values[0])) * 100
        return dig_index
    elif observable_name == "heat_stress_index":
        if sensor_values["temperature"].values[0] == 0 or sensor_values["humidity"].values[0] == 0:
            return 0
        heat_stress_index = sensor_values["temperature"].values[0] + sensor_values["humidity"].values[0]
        return heat_stress_index
    else:
        return 0

Leave a Comment