def AAG_heater_algorithm(self, target, last_entry):
        '''
        Uses the algorithm described in RainSensorHeaterAlgorithm.pdf to
        determine PWM value.

        Values are for the default read cycle of 10 seconds.
        '''
        deltaT = last_entry['Rain Sensor Temp (C)'] - target
        scaling = 0.5
        if deltaT > 8.:
            deltaPWM = -40 * scaling
        elif deltaT > 4.:
            deltaPWM = -20 * scaling
        elif deltaT > 3.:
            deltaPWM = -10 * scaling
        elif deltaT > 2.:
            deltaPWM = -6 * scaling
        elif deltaT > 1.:
            deltaPWM = -4 * scaling
        elif deltaT > 0.5:
            deltaPWM = -2 * scaling
        elif deltaT > 0.3:
            deltaPWM = -1 * scaling
        elif deltaT < -0.3:
            deltaPWM = 1 * scaling
        elif deltaT < -0.5:
            deltaPWM = 2 * scaling
        elif deltaT < -1.:
            deltaPWM = 4 * scaling
        elif deltaT < -2.:
            deltaPWM = 6 * scaling
        elif deltaT < -3.:
            deltaPWM = 10 * scaling
        elif deltaT < -4.:
            deltaPWM = 20 * scaling
        elif deltaT < -8.:
            deltaPWM = 40 * scaling
        return int(deltaPWM)
dataset/ETHPy150Open panoptes/POCS/scripts/read_weather.py/AAGCloudSensor.AAG_heater_algorithm/original