Extreme Minimum Design Temperature for a location.

    Degrees in Celcius

    Args:
        station_code (str): Weather Station Code

    Returns:
        float degrees Celcius
506219
def minimum(station_code):
    
    temp = None
    fin = None
    try:
        fin = open('%s/%s' % (env.WEATHER_DATA_PATH,
                              _basename(station_code, 'ddy')))
    except IOError:
        logger.info("File not found")
        download_extract(_eere_url(station_code))
        fin = open('%s/%s' % (env.WEATHER_DATA_PATH,
                              _basename(station_code, 'ddy')))
    for line in fin:
        value = re.search('Max Drybulb=(-?\\d+\\.\\d*)', line)
        if value:
            temp = float(value.groups()[0])
    if not temp:
        try:
            fin = open('%s/%s' % (env.WEATHER_DATA_PATH,
                                  _basename(station_code, 'stat')))
            for line in fin:
                if line.find('Minimum Dry Bulb') is not -1:
                    return float(line[37:-1].split('\xb0')[0])
        except IOError:
            pass
    if temp:
        return temp
    else:
        raise Exception("Error: Minimum Temperature not found")
465239
def temperature_offset(self, offset):
        """"""
        _LOGGER.debug("Setting offset: %s", offset)
        # [-3,5 .. 0  .. 3,5 ]
        # [00   .. 07 .. 0e ]
        if offset < -3.5 or offset > 3.5:
            raise TemperatureException("Invalid value: %s" % offset)

        current = -3.5
        values = {}
        for i in range(15):
            values[current] = i
            current += 0.5

        value = struct.pack('BB', PROP_OFFSET, values[offset])
        self._conn.make_request(PROP_WRITE_HANDLE, value)
939963
private function _temperature()
    {
        if (count($this->_values) == 14) {
            $dev1 = new SensorDevice();
            $dev1->setName('temp1');
            $dev1->setValue($this->_values[1]);
//            $dev1->setMax(70);
            $this->mbinfo->setMbTemp($dev1);
            $dev2 = new SensorDevice();
            $dev2->setName('temp1');
            $dev2->setValue($this->_values[2]);
//            $dev2->setMax(70);
            $this->mbinfo->setMbTemp($dev2);
            $dev3 = new SensorDevice();
            $dev3->setName('temp1');
            $dev3->setValue($this->_values[3]);
//            $dev3->setMax(70);
            $this->mbinfo->setMbTemp($dev3);
        }
    }
629315
def set_limit(self, param):
        
        # TODO: Is not having leading zeroes / 4 digits an error?
        limit = int(param)
        if -2000 <= limit <= 6000:
            self.device.temperature_limit = limit / 10.0
        return ""
1199768
def check_weather(self):
        '''
        
        '''
        if self.station_id is None:
            # Failed to get the nearest station ID when first launched, so
            # retry it.
            self.get_station_id()

        self.data['update_error'] = ''
        try:
            query_url = STATION_QUERY_URL % (self.api_key,
                                             'conditions',
                                             self.station_id)
            try:
                response = self.api_request(query_url)['current_observation']
                self.forecast_url = response.pop('ob_url', None)
            except KeyError:
                self.logger.error('No weather data found for %s', self.station_id)
                self.data['update_error'] = self.update_error
                return

            if self.forecast:
                query_url = STATION_QUERY_URL % (self.api_key,
                                                 'forecast',
                                                 self.station_id)
                try:
                    forecast = self.api_request(query_url)['forecast']
                    forecast = forecast['simpleforecast']['forecastday'][0]
                except (KeyError, IndexError, TypeError):
                    self.logger.error(
                        'No forecast data found for %s', self.station_id)
                    # This is a non-fatal error, so don't return but do set the
                    # error flag.
                    self.data['update_error'] = self.update_error

                unit = 'celsius' if self.units == 'metric' else 'fahrenheit'
                low_temp = forecast.get('low', {}).get(unit, '')
                high_temp = forecast.get('high', {}).get(unit, '')
            else:
                low_temp = high_temp = ''

            if self.units == 'metric':
                temp_unit = 'c'
                speed_unit = 'kph'
                distance_unit = 'km'
                pressure_unit = 'mb'
            else:
                temp_unit = 'f'
                speed_unit = 'mph'
                distance_unit = 'mi'
                pressure_unit = 'in'

            def _find(key, data=None, default=''):
                if data is None:
                    data = response
                return str(data.get(key, default))

            try:
                observation_epoch = _find('observation_epoch') or _find('local_epoch')
                observation_time = datetime.fromtimestamp(int(observation_epoch))
            except (TypeError, ValueError):
                log.debug(
                    'Observation time \'%s\' is not a UNIX timestamp',
                    observation_epoch
                )
                observation_time = datetime.fromtimestamp(0)

            self.data['city'] = _find('city', response['observation_location'])
            self.data['condition'] = _find('weather')
            self.data['observation_time'] = observation_time
            self.data['current_temp'] = _find('temp_' + temp_unit).split('.')[0]
            self.data['low_temp'] = low_temp
            self.data['high_temp'] = high_temp
            self.data['temp_unit'] = '°' + temp_unit.upper()
            self.data['feelslike'] = _find('feelslike_' + temp_unit)
            self.data['dewpoint'] = _find('dewpoint_' + temp_unit)
            self.data['wind_speed'] = _find('wind_' + speed_unit)
            self.data['wind_unit'] = speed_unit
            self.data['wind_direction'] = _find('wind_dir')
            self.data['wind_gust'] = _find('wind_gust_' + speed_unit)
            self.data['pressure'] = _find('pressure_' + pressure_unit)
            self.data['pressure_unit'] = pressure_unit
            self.data['pressure_trend'] = _find('pressure_trend')
            self.data['visibility'] = _find('visibility_' + distance_unit)
            self.data['visibility_unit'] = distance_unit
            self.data['humidity'] = _find('relative_humidity').rstrip('%')
            self.data['uv_index'] = _find('UV')
        except Exception:
            # Don't let an uncaught exception kill the update thread
            self.logger.error(
                'Uncaught error occurred while checking weather. '
                'Exception follows:', exc_info=True
            )
            self.data['update_error'] = self.update_error
1343667
def parse_temperature_response(
        temperature_string: str) -> Mapping[str, Optional[float]]:
    '''
    
    '''
    err_msg = 'Unexpected argument to parse_temperature_response: {}'.format(
        temperature_string)
    if not temperature_string or \
            not isinstance(temperature_string, str):
        raise ParseError(err_msg)
    parsed_values = temperature_string.strip().split(' ')
    if len(parsed_values) < 2:
        log.error(err_msg)
        raise ParseError(err_msg)

    data = {
        parse_key_from_substring(s): parse_number_from_substring(s)
        for s in parsed_values[:2]
    }
    if 'C' not in data or 'T' not in data:
        raise ParseError(err_msg)
    data = {
        'current': data['C'],
        'target': data['T']
    }
    return data
416454
def check_xups_env_ambient_temp(the_session, the_helper, the_snmp_value, the_unit=1):
    
    
    the_helper.add_metric(
        label=the_helper.options.type,
        value=the_snmp_value,
        uom='degree')

    the_helper.set_summary("Environment Temperature is {} degree".format(the_snmp_value))
202988
def _compensate_temperature(self, adc_t):
        
        var_1 = ((adc_t / 16384.0 - self._calibration_t[0] / 1024.0)
                 * self._calibration_t[1])
        var_2 = ((adc_t / 131072.0 - self._calibration_t[0] / 8192.0)
                 * (adc_t / 131072.0 - self._calibration_t[0] / 8192.0)
                 * self._calibration_t[2])
        self._temp_fine = var_1 + var_2
        if self._delta_temp != 0.:  # temperature correction for self heating
            temp = self._temp_fine / 5120.0 + self._delta_temp
            self._temp_fine = temp * 5120.0
        else:
            temp = self._temp_fine / 5120.0
        return temp
655066
def temperature(self):
        
        if not self.awake:
            raise Exception("MPU6050 is in sleep mode, use wakeup()")

        raw = self.i2c_read_register(0x41, 2)
        raw = struct.unpack('>h', raw)[0]
        return round((raw / 340) + 36.53, 2)
1221236
def temperature(self, temperature):
        
        if temperature < 0 or temperature > 1:
            raise ValueError("Temperature must be a percentage "
                             "represented as decimal 0-1.0")
        self._temperature = temperature
        cmd = self.command_set.temperature(temperature)
        self.send(cmd)
1046918
def target_temperature(self, temperature):
        """"""
        dev_temp = int(temperature * 2)
        if temperature == EQ3BT_OFF_TEMP or temperature == EQ3BT_ON_TEMP:
            dev_temp |= 0x40
            value = struct.pack('BB', PROP_MODE_WRITE, dev_temp)
        else:
            self._verify_temperature(temperature)
            value = struct.pack('BB', PROP_TEMPERATURE_WRITE, dev_temp)

        self._conn.make_request(PROP_WRITE_HANDLE, value)
312888
private function _temperature()
    {
        foreach ($this->_lines as $line) {
            $buffer = preg_split("/\s*\|\s*/", $line);
            if (isset($buffer[2]) && $buffer[2] == "Temperature"
               && $buffer[1] == "Full"
               && isset($buffer[6]) && preg_match("/^(\S+)\sC$/", $buffer[6], $value)
               && $buffer[5] !== "Init") {
                $dev = new SensorDevice();
                $dev->setName($buffer[4]);
                $dev->setValue($value[1]);
                if (isset($buffer[7]) && $buffer[7] == "Thresholds") {
                    if ((isset($buffer[8]) && preg_match("/^hi-crit\s(\S+)\s*$/", $buffer[8], $limits))
                        ||(isset($buffer[9]) && preg_match("/^hi-crit\s(\S+)\s*$/", $buffer[9], $limits))
                        ||(isset($buffer[10]) && preg_match("/^hi-crit\s(\S+)\s*$/", $buffer[10], $limits))
                        ||(isset($buffer[11]) && preg_match("/^hi-crit\s(\S+)\s*$/", $buffer[11], $limits))) {
                        $dev->setMax($limits[1]);
                    }
                }
                if ($buffer[5] != "OK") $dev->setEvent($buffer[5]);
                $this->mbinfo->setMbTemp($dev);
            }
        }
    }
1197924
def set_temperature(self, zone, temperature, until=None):
        """"""
        if until is None:
            data = {"Value": temperature, "Status": "Hold", "NextTime": None}
        else:
            data = {"Value": temperature,
                    "Status": "Temporary",
                    "NextTime": until.strftime('%Y-%m-%dT%H:%M:%SZ')}

        self._set_heat_setpoint(zone, data)
1223983
def closest_eere(latitude, longitude):
    
    with open(env.SRC_PATH + '/eere_meta.csv') as eere_meta:
        stations = csv.DictReader(eere_meta)
        d = 9999
        station_code = ''
        station_name = ''
        for station in stations:
            new_dist = great_circle((latitude, longitude),
                                    (float(station['latitude']),
                                     float(station['longitude']))).miles
            if new_dist <= d:
                d = new_dist
                station_code = station['station_code']
                station_name = station['weather_station']
        return station_code, station_name
    raise KeyError('station not found')
211297
def _apply_features_filter(self, station_codes):
        
        # apply features filter
        if hasattr(self, "features") and self.features is not None:
            station_codes = set(station_codes)
            station_codes = list(
                station_codes.intersection(set(self.features))
            )

        return station_codes
1367646
def temperature(temp: Number, unit: str = 'C') -> str:
    
    unit = unit.upper()
    if not (temp and unit in ('C', 'F')):
        return ''
    if unit == 'C':
        converted = temp.value * 1.8 + 32
        converted = str(int(round(converted))) + '°F'  # type: ignore
    elif unit == 'F':
        converted = (temp.value - 32) / 1.8
        converted = str(int(round(converted))) + '°C'  # type: ignore
    return f'{temp.value}°{unit} ({converted})'
646545
def get_current_goal_temperature(self, refresh=False):
        """"""
        if refresh:
            self.refresh()
        try:
            return float(self.get_value('setpoint'))
        except (TypeError, ValueError):
            return None