Temperature conversions.
971852
private static UnitValue temperature(UnitValue value, Unit target) {
    BigDecimal n = value.amount();
    if (target == Unit.TEMPERATURE_GENERIC) {
      return new UnitValue(n, Unit.TEMPERATURE_GENERIC);
    }

    switch (value.unit()) {
      case FAHRENHEIT:
        if (target == Unit.CELSIUS) {
            n = n.subtract(THIRTY_TWO);
            n = new Rational(n, BigDecimal.ONE).multiply(FIVE_NINTHS).compute(RoundingMode.HALF_EVEN);
        } else if (target == Unit.KELVIN) {
            n = n.add(KELVIN_FAHRENHEIT);
            n = new Rational(n, BigDecimal.ONE).multiply(FIVE_NINTHS).compute(RoundingMode.HALF_EVEN);
        }
        break;
        
      case CELSIUS:
        if (target == Unit.FAHRENHEIT) {
          Rational r = new Rational(n, BigDecimal.ONE);
          n = r.multiply(NINE_FIFTHS).compute(RoundingMode.HALF_EVEN).add(THIRTY_TWO);
        } else if (target == Unit.KELVIN) {
          n = n.add(KELVIN_CELSIUS);
        }
        break;
        
      case KELVIN:
        if (target == Unit.CELSIUS) {
          n = n.subtract(KELVIN_CELSIUS);
        } else if (target == Unit.FAHRENHEIT) {
          Rational r = new Rational(n, BigDecimal.ONE).multiply(NINE_FIFTHS);
          n = r.compute(RoundingMode.HALF_EVEN).subtract(KELVIN_FAHRENHEIT);
        }
        break;
        
      default:
        return new UnitValue(n, Unit.TEMPERATURE_GENERIC);
    }

    return new UnitValue(n.stripTrailingZeros(), target);
  }
949790
def XYZ_to_Lab(cobj, *args, **kwargs):
    
    illum = cobj.get_illuminant_xyz()
    temp_x = cobj.xyz_x / illum["X"]
    temp_y = cobj.xyz_y / illum["Y"]
    temp_z = cobj.xyz_z / illum["Z"]

    if temp_x > color_constants.CIE_E:
        temp_x = math.pow(temp_x, (1.0 / 3.0))
    else:
        temp_x = (7.787 * temp_x) + (16.0 / 116.0)

    if temp_y > color_constants.CIE_E:
        temp_y = math.pow(temp_y, (1.0 / 3.0))
    else:
        temp_y = (7.787 * temp_y) + (16.0 / 116.0)

    if temp_z > color_constants.CIE_E:
        temp_z = math.pow(temp_z, (1.0 / 3.0))
    else:
        temp_z = (7.787 * temp_z) + (16.0 / 116.0)

    lab_l = (116.0 * temp_y) - 16.0
    lab_a = 500.0 * (temp_x - temp_y)
    lab_b = 200.0 * (temp_y - temp_z)
    return LabColor(
        lab_l, lab_a, lab_b, observer=cobj.observer, illuminant=cobj.illuminant)
587942
def temperature(self, temperature):
        
        try:
            cmd = self.command_set.temperature(temperature)
            self.send(cmd)
            self._temperature = temperature
        except AttributeError:
            self._setter('_temperature', temperature,
                         self._warmest, self._coolest,
                         self._to_temperature)
137965
function process(payload) {
  var batteryRaw = parseInt(payload.substr(2,2),16) % 64;
  var temperatureRaw = (parseInt(payload.substr(0,3),16) >> 2) % 256;
  var battery = ((batteryRaw / 34) + 1.8).toFixed(2) + "V";
  var temperature = ((temperatureRaw - 80) / 2).toFixed(1) + "C";
  return {
    battery: battery,
    temperature: temperature
  };
}
686460
private function _temperature()
    {
        if (CommonFunctions::executeProgram("snmpwalk", "-Ona -c public -v 1 -t ".PSI_SNMP_TIMEOUT_INT." -r ".PSI_SNMP_RETRY_INT." 127.0.0.1 .1.3.6.1.4.1.24681.1.2.5.0", $buffer, PSI_DEBUG)
           && preg_match('/^[\.\d]+ = STRING:\s\"?(\d+)\sC/', $buffer, $data)) {
            $dev = new SensorDevice();
            $dev->setName("CPU");
            $dev->setValue($data[1]);
            $this->mbinfo->setMbTemp($dev);
        }

        if (CommonFunctions::executeProgram("snmpwalk", "-Ona -c public -v 1 -t ".PSI_SNMP_TIMEOUT_INT." -r ".PSI_SNMP_RETRY_INT." 127.0.0.1 .1.3.6.1.4.1.24681.1.2.6.0", $buffer, PSI_DEBUG)
           && preg_match('/^[\.\d]+ = STRING:\s\"?(\d+)\sC/', $buffer, $data)) {
            $dev = new SensorDevice();
            $dev->setName("System");
            $dev->setValue($data[1]);
            $this->mbinfo->setMbTemp($dev);
        }

        if (CommonFunctions::executeProgram("snmpwalk", "-Ona -c public -v 1 -t ".PSI_SNMP_TIMEOUT_INT." -r ".PSI_SNMP_RETRY_INT." 127.0.0.1 .1.3.6.1.4.1.24681.1.2.11.1.3", $buffer, PSI_DEBUG)) {
            $lines = preg_split('/\r?\n/', $buffer);
            foreach ($lines as $line) if (preg_match('/^[\.\d]+\.(\d+) = STRING:\s\"?(\d+)\sC/', $line, $data)) {
                $dev = new SensorDevice();
                $dev->setName("HDD ".$data[1]);
                $dev->setValue($data[2]);
                $this->mbinfo->setMbTemp($dev);
            }
        }
    }
1012318
def correct(self, calib, temp, we_t, ae_t):
        
        if not A4TempComp.in_range(temp):
            return None

        if self.__algorithm == 1:
            return self.__eq1(temp, we_t, ae_t)

        if self.__algorithm == 2:
            return self.__eq2(temp, we_t, ae_t, calib.we_cal_mv, calib.ae_cal_mv)

        if self.__algorithm == 3:
            return self.__eq3(temp, we_t, ae_t, calib.we_cal_mv, calib.ae_cal_mv)

        if self.__algorithm == 4:
            return self.__eq4(temp, we_t, calib.we_cal_mv)

        raise ValueError("A4TempComp.conv: unrecognised algorithm: %d." % self.__algorithm)
791264
def f_cell_temp(poa_global, wind_speed, air_temp):
    
    temps = pvlib.pvsystem.sapm_celltemp(poa_global, wind_speed, air_temp)
    return temps['temp_cell'].values, temps['temp_module'].values
1205032
private function _temperature()
    {
        foreach ($this->_lines as $line) {
            $buffer = preg_split("/\s*\|\s*/", $line);
            if ($buffer[2] == "Temperature" && $buffer[11] != "N/A" && $buffer[4] == "C") {
                $dev = new SensorDevice();
                $dev->setName($buffer[1]);
                $dev->setValue($buffer[3]);
                if ($buffer[9] != "N/A") $dev->setMax($buffer[9]);
                if ($buffer[11] != "'OK'") $dev->setEvent(trim($buffer[11], "'"));
                $this->mbinfo->setMbTemp($dev);
            }
        }
    }
441064
def _get_temperature(self, data):
        ''''''
        temp = (data[2] & ~(1 << 7)) + (data[3] / 100)
        sign = (data[2] >> 7) & 1
        if sign == 0:
            return round(temp, 2)
        return round(-1 * temp, 2)
185182
def _to_temperature(self, temperature):
        
        self._to_value(self._temperature, temperature,
                       self.command_set.temperature_steps,
                       self._warmer, self._cooler)
533126
def get_temperature(self, channel, sensor='VNTC'):
        '''
        '''
#         NTC type SEMITEC 103KT1608 http://www.semitec.co.jp/english/products/pdf/KT_Thermistor.pdf
#
#         R_NTC = R_25 * exp(B_NTC * (1/T - 1/T_25))
#
#         R_NTC       measured NTC resistance
#         R_NTC_25    resistance @ 25C
#         B_NTC       temperature coefficient
#         Temperature current temperature (Kelvin)
#         T_25        298,15 K (25C)
#
#         B_NTC       NTC 'b' coefficient, NTC Semitec 103KT1608-1P
#         R_NTC_25    NTC 25C resistance, NTC Semitec 103KT1608-1P
#         R1          resistor value for NTC voltage divider
#         R2          value of R2 in the reference voltage divider
#         R4          value of R4 in the reference voltage divider
#         VREF        supply voltage of the resistor bridge
#

        kwargs = self._ch_map[channel][sensor]
        temp_raw = self._get_adc_value(**kwargs)

        v_adc = ((temp_raw - self._ch_cal.items()[0][1]['ADCV']['offset']) / self._ch_cal.items()[0][1]['ADCV']['gain'])  # voltage, VDDA1
        k = self._ch_cal[channel][sensor]['R4'] / (self._ch_cal[channel][sensor]['R2'] + self._ch_cal[channel][sensor]['R4'])  # reference voltage divider
        r_ntc = self._ch_cal[channel][sensor]['R1'] * (k - v_adc / self._ch_cal[channel][sensor]['VREF']) / (1 - k + v_adc / self._ch_cal[channel][sensor]['VREF'])  # NTC resistance

        return (self._ch_cal[channel][sensor]['B_NTC'] / (log(r_ntc) - log(self._ch_cal[channel][sensor]['R_NTC_25']) + self._ch_cal[channel][sensor]['B_NTC'] / self.T_KELVIN_25)) - self.T_KELVIN_0
511353
private function _temperature()
    {
        for ($intPosi = 3; $intPosi < 6; $intPosi++) {
            if ($this->_buf_value[$intPosi] == 0) {
                continue;
            }
            preg_match("/([0-9\.])*/", str_replace(",", ".", $this->_buf_value[$intPosi]), $hits);
            $dev = new SensorDevice();
            $dev->setName($this->_buf_label[$intPosi]);
            $dev->setValue($hits[0]);
//            $dev->setMax(70);
            $this->mbinfo->setMbTemp($dev);
        }
    }
1162580
def mangle(data_point):
    """"""
    temp_dict = {}
    temp_dict.update(data_point)
    temp_dict['utc_datetime'] = \
        datetime.datetime.utcfromtimestamp(temp_dict['time'])
    if 'solar' in data_point:
        temp_dict['GHI (W/m^2)'] = data_point['solar']['ghi']
        temp_dict['DNI (W/m^2)'] = data_point['solar']['dni']
        temp_dict['DHI (W/m^2)'] = data_point['solar']['dhi']
        temp_dict['ETR (W/m^2)'] = data_point['solar']['etr']
        del temp_dict['solar']
    else:
        temp_dict['GHI (W/m^2)'] = 0.0
        temp_dict['DNI (W/m^2)'] = 0.0
        temp_dict['DHI (W/m^2)'] = 0.0
        temp_dict['ETR (W/m^2)'] = 0.0
    return temp_dict
795722
public static double convertFromFarenheit (TemperatureScale to, double temperature) {

        switch(to) {

            case FARENHEIT:
                return temperature;
            case CELSIUS:
                return convertFarenheitToCelsius(temperature);
            case KELVIN:
                return convertFarenheitToKelvin(temperature);
            case RANKINE:
                return convertFarenheitToRankine(temperature);
            default:
                throw(new RuntimeException("Invalid termpature conversion"));
        }
    }
191668
def _compute_heating_rates(self):
        ''''''
        (ncol, nlay, icld, iaer, permuteseed, irng,
         play, plev, tlay, tlev, tsfc,
         h2ovmr, o3vmr, co2vmr, ch4vmr, n2ovmr, o2vmr,
         aldif, aldir, asdif, asdir, coszen, adjes, dyofyr, scon, isolvar,
         indsolvar, bndsolvar, solcycfrac,
         inflgsw, iceflgsw, liqflgsw,
         cldfrac, ciwp, clwp, reic, relq, tauc, ssac, asmc, fsfc,
         tauaer, ssaaer, asmaer, ecaer,) = self._prepare_sw_arguments()
        if icld == 0:  # clear-sky only
            cldfmcl = np.zeros((ngptsw,ncol,nlay))
            ciwpmcl = np.zeros((ngptsw,ncol,nlay))
            clwpmcl = np.zeros((ngptsw,ncol,nlay))
            reicmcl = np.zeros((ncol,nlay))
            relqmcl = np.zeros((ncol,nlay))
            taucmcl = np.zeros((ngptsw,ncol,nlay))
            ssacmcl = np.zeros((ngptsw,ncol,nlay))
            asmcmcl = np.zeros((ngptsw,ncol,nlay))
            fsfcmcl = np.zeros((ngptsw,ncol,nlay))
        else:
            #  Call the Monte Carlo Independent Column Approximation (McICA, Pincus et al., JC, 2003)
            (cldfmcl, ciwpmcl, clwpmcl, reicmcl, relqmcl, taucmcl,
            ssacmcl, asmcmcl, fsfcmcl) = _rrtmg_sw.climlab_mcica_subcol_sw(
                            ncol, nlay, icld, permuteseed, irng, play,
                            cldfrac, ciwp, clwp, reic, relq, tauc, ssac, asmc, fsfc)
        #  Call the RRTMG_SW driver to compute radiative fluxes
        (swuflx, swdflx, swhr, swuflxc, swdflxc, swhrc) = \
            _rrtmg_sw.climlab_rrtmg_sw(ncol, nlay, icld, iaer,
                play, plev, tlay, tlev, tsfc,
                h2ovmr, o3vmr, co2vmr, ch4vmr, n2ovmr, o2vmr,
                asdir, asdif, aldir, aldif,
                coszen, adjes, dyofyr, scon, isolvar,
                inflgsw, iceflgsw, liqflgsw, cldfmcl,
                taucmcl, ssacmcl, asmcmcl, fsfcmcl,
                ciwpmcl, clwpmcl, reicmcl, relqmcl,
                tauaer, ssaaer, asmaer, ecaer,
                bndsolvar, indsolvar, solcycfrac)
        #  Output is all (ncol,nlay+1) or (ncol,nlay)
        self.SW_flux_up = _rrtm_to_climlab(swuflx) + 0.*self.SW_flux_up
        self.SW_flux_down = _rrtm_to_climlab(swdflx) + 0.*self.SW_flux_down
        self.SW_flux_up_clr = _rrtm_to_climlab(swuflxc) + 0.*self.SW_flux_up_clr
        self.SW_flux_down_clr = _rrtm_to_climlab(swdflxc) + 0.*self.SW_flux_down_clr
        #  Compute quantities derived from fluxes, including ASR
        self._compute_SW_flux_diagnostics()
        #  calculate heating rates from flux divergence
        SWheating_Wm2 = np.array(-np.diff(self.SW_flux_net, axis=-1)) + 0.*self.Tatm
        SWheating_clr_Wm2 = np.array(-np.diff(self.SW_flux_net_clr, axis=-1)) + 0.*self.Tatm
        self.heating_rate['Ts'] = np.array(self.SW_flux_net[..., -1, np.newaxis]) + 0.*self.Ts
        self.heating_rate['Tatm'] = SWheating_Wm2
        #  Convert to K / day
        Catm = self.Tatm.domain.heat_capacity
        self.TdotSW = SWheating_Wm2 / Catm * const.seconds_per_day
        self.TdotSW_clr = SWheating_clr_Wm2 / Catm * const.seconds_per_day
637195
def temperature(self):
        
        with io.open(self.sensor_file, 'r') as f:
            return float(f.readline().strip()) / 1000
34635
private function _temperature()
    {
        foreach ($this->_buf as $sensor) {
            if (((isset($sensor['Sensor Type (Threshold)']) && ($sensor['Sensor Type (Threshold)'] == 'Temperature'))
                ||(isset($sensor['Sensor Type (Analog)']) && ($sensor['Sensor Type (Analog)'] == 'Temperature')))
               && isset($sensor['Unit']) && ($sensor['Unit'] == 'degrees C')
               && isset($sensor['Value'])) {
                $dev = new SensorDevice();
                $dev->setName($sensor['Sensor']);
                $dev->setValue($sensor['Value']);
                if (isset($sensor['Upper Critical']) && (($max = $sensor['Upper Critical']) != "na")) {
                    $dev->setMax($max);
                }
                if (isset($sensor['Status']) && (($status = $sensor['Status']) != "ok")) {
                    $dev->setEvent($status);
                }
                $this->mbinfo->setMbTemp($dev);
            }
        }
    }