Compute the linear-interpolated temperature compensation factor.
505547
def cf_t(self, temp):
        
        index = int((temp - A4TempComp.__MIN_TEMP) // A4TempComp.__INTERVAL)        # index of start of interval

        # on boundary...
        if temp % A4TempComp.__INTERVAL == 0:
            return self.__values[index]

        # all others...
        y1 = self.__values[index]                                                   # y value at start of interval
        y2 = self.__values[index + 1]                                               # y value at end of interval

        delta_y = y2 - y1

        delta_x = float(temp % A4TempComp.__INTERVAL) / A4TempComp.__INTERVAL       # proportion of interval

        cf_t = y1 + (delta_y * delta_x)

        # print("A4TempComp.cf_t: alg:%d, temp:%f y1:%f y2:%f delta_y:%f delta_x:%f cf_t:%f " %
        #       (self.__algorithm, temp, y1, y2, delta_y, delta_x, cf_t), file=sys.stderr)

        return cf_t
1035759
def correct(self, temp, we_t):
        
        if not PIDTempComp.in_range(temp):
            return None

        n_t = self.cf_t(temp)

        if n_t is None:
            return None

        we_c = we_t * n_t

        return we_c
770333
def annealing_linear(start:Number, end:Number, pct:float)->Number:
    ""
    return start + pct * (end-start)
1291806
def _compute_heating_rates(self):
        
        for varname in list(self.state.keys()):
            self.heating_rate[varname] = self.state[varname] * 0.
1373503
def _get_temperature(self, decoded):
        ''''''
        temp = (decoded[2] & 127) + decoded[3] / 100
        sign = (decoded[2] >> 7) & 1
        if sign == 0:
            return round(temp, 2)
        return round(-1 * temp, 2)
343923
def force_balanced_LP(self):
        

        """
        dummy, xiA1, xiA2, xiA3, xiA4 = self.xiA
        self.xiA = np.array([1, xiA1, 0, xiA3, 0], dtype=np.float64)
        self.calc_ABDE_from_lamination_parameters()
719271
def _compute_heating_rates(self):
        ''''''
        (ncol, nlay, icld, permuteseed, irng, idrv, cp,
                play, plev, tlay, tlev, tsfc,
                h2ovmr, o3vmr, co2vmr, ch4vmr, n2ovmr, o2vmr,
                cfc11vmr, cfc12vmr, cfc22vmr, ccl4vmr, emis,
                inflglw, iceflglw, liqflglw,
                cldfrac, ciwp, clwp, reic, relq, tauc, tauaer,) = self._prepare_lw_arguments()
        if icld == 0:  # clear-sky only
            cldfmcl = np.zeros((ngptlw,ncol,nlay))
            ciwpmcl = np.zeros((ngptlw,ncol,nlay))
            clwpmcl = np.zeros((ngptlw,ncol,nlay))
            reicmcl = np.zeros((ncol,nlay))
            relqmcl = np.zeros((ncol,nlay))
            taucmcl = np.zeros((ngptlw,ncol,nlay))
        else:
            #  Call the Monte Carlo Independent Column Approximation (McICA, Pincus et al., JC, 2003)
            (cldfmcl, ciwpmcl, clwpmcl, reicmcl, relqmcl, taucmcl) = \
                _rrtmg_lw.climlab_mcica_subcol_lw(
                            ncol, nlay, icld,
                            permuteseed, irng, play,
                            cldfrac, ciwp, clwp, reic, relq, tauc)
            #  Call the RRTMG_LW driver to compute radiative fluxes
        (uflx, dflx, hr, uflxc, dflxc, hrc, duflx_dt, duflxc_dt) = \
            _rrtmg_lw.climlab_rrtmg_lw(ncol, nlay, icld, idrv,
                 play, plev, tlay, tlev, tsfc,
                 h2ovmr, o3vmr, co2vmr, ch4vmr, n2ovmr, o2vmr,
                 cfc11vmr, cfc12vmr, cfc22vmr, ccl4vmr, emis,
                 inflglw, iceflglw, liqflglw, cldfmcl,
                 taucmcl, ciwpmcl, clwpmcl, reicmcl, relqmcl,
                 tauaer)
        #  Output is all (ncol,nlay+1) or (ncol,nlay)
        self.LW_flux_up = _rrtm_to_climlab(uflx) + 0.*self.LW_flux_up
        self.LW_flux_down = _rrtm_to_climlab(dflx) + 0.*self.LW_flux_down
        self.LW_flux_up_clr = _rrtm_to_climlab(uflxc) + 0.*self.LW_flux_up_clr
        self.LW_flux_down_clr = _rrtm_to_climlab(dflxc) + 0.*self.LW_flux_down_clr
        #  Compute quantities derived from fluxes, including OLR
        self._compute_LW_flux_diagnostics()
        #  calculate heating rates from flux divergence
        LWheating_Wm2 = np.array(np.diff(self.LW_flux_net, axis=-1)) + 0.*self.Tatm
        LWheating_clr_Wm2 = np.array(np.diff(self.LW_flux_net_clr, axis=-1)) + 0.*self.Tatm
        self.heating_rate['Ts'] = np.array(-self.LW_flux_net[..., -1, np.newaxis]) + 0.*self.Ts
        self.heating_rate['Tatm'] = LWheating_Wm2
        #  Convert to K / day
        Catm = self.Tatm.domain.heat_capacity
        self.TdotLW = LWheating_Wm2 / Catm * const.seconds_per_day
        self.TdotLW_clr = LWheating_clr_Wm2 / Catm * const.seconds_per_day
418326
def rigid_linear_interpolate(x_axis, y_axis, x_new_axis):
    
    f = interp1d(x_axis, y_axis)
    return f(x_new_axis)
282277
def _compute(self):
        """"""
        if self.xvals:
            if self.xrange:
                x_adapter = reduce(compose, self._x_adapters) if getattr(
                    self, '_x_adapters', None
                ) else ident

                xmin = x_adapter(self.xrange[0])
                xmax = x_adapter(self.xrange[1])

            else:
                xmin = min(self.xvals)
                xmax = max(self.xvals)
            xrng = (xmax - xmin)
        else:
            xrng = None

        if self.yvals:
            ymin = self._min
            ymax = self._max

            if self.include_x_axis:
                ymin = min(ymin or 0, 0)
                ymax = max(ymax or 0, 0)

            yrng = (ymax - ymin)
        else:
            yrng = None

        for serie in self.all_series:
            serie.points = serie.values
            if self.interpolate:
                vals = list(
                    zip(
                        *sorted(
                            filter(lambda t: None not in t, serie.points),
                            key=lambda x: x[0]
                        )
                    )
                )
                serie.interpolated = self._interpolate(vals[0], vals[1])

        if self.interpolate:
            self.xvals = [
                val[0] for serie in self.all_series
                for val in serie.interpolated
            ]
            self.yvals = [
                val[1] for serie in self.series for val in serie.interpolated
            ]
            if self.xvals:
                xmin = min(self.xvals)
                xmax = max(self.xvals)
                xrng = (xmax - xmin)
            else:
                xrng = None

        # these values can also be 0 (zero), so testing explicitly for None
        if xrng is not None:
            self._box.xmin, self._box.xmax = xmin, xmax

        if yrng is not None:
            self._box.ymin, self._box.ymax = ymin, ymax
531706
def interpolate_ck2004_ldcoeffs(self, Teff=5772., logg=4.43, abun=0.0, atm='ck2004', ld_func='power', photon_weighted=False):
        

        if 'ck2004_ld' not in self.content:
            print('Castelli & Kurucz (2004) limb darkening coefficients are not computed yet. Please compute those first.')
            return None

        if photon_weighted:
            table = self._ck2004_ld_photon_grid
        else:
            table = self._ck2004_ld_energy_grid

        if not hasattr(Teff, '__iter__'):
            req = np.array(((Teff, logg, abun),))
            ld_coeffs = libphoebe.interp(req, self._ck2004_intensity_axes[0:3], table)[0]
        else:
            req = np.vstack((Teff, logg, abun)).T
            ld_coeffs = libphoebe.interp(req, self._ck2004_intensity_axes[0:3], table).T

        if ld_func == 'linear':
            return ld_coeffs[0:1]
        elif ld_func == 'logarithmic':
            return ld_coeffs[1:3]
        elif ld_func == 'square_root':
            return ld_coeffs[3:5]
        elif ld_func == 'quadratic':
            return ld_coeffs[5:7]
        elif ld_func == 'power':
            return ld_coeffs[7:11]
        elif ld_func == 'all':
            return ld_coeffs
        else:
            print('ld_func=%s is invalid; please choose from [linear, logarithmic, square_root, quadratic, power, all].')
            return None
67429
def _interpolate_coefficients(self, alpha):
        """"""
        exact = False
        coef_idx = None
        for i, val in enumerate(self.alphas_):
            if val > alpha:
                coef_idx = i
            elif alpha - val < numpy.finfo(numpy.float).eps:
                coef_idx = i
                exact = True
                break

        if coef_idx is None:
            coef = self.coef_[:, 0]
        elif exact or coef_idx == len(self.alphas_) - 1:
            coef = self.coef_[:, coef_idx]
        else:
            # interpolate between coefficients
            a1 = self.alphas_[coef_idx + 1]
            a2 = self.alphas_[coef_idx]
            frac = (alpha - a1) / (a2 - a1)
            coef = frac * self.coef_[:, coef_idx] + (1.0 - frac) * self.coef_[:, coef_idx + 1]

        return coef
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)
566284
def T(self):
        
        paramTemp = self.getParam('temperature')

        if not paramTemp is np.nan:
            return paramTemp
        elif ed_params.estimateMissingValues:
            self.flags.addFlag('Calculated Temperature')
            return self.calcTemperature()
        else:
            return np.nan
265701
def get_temperature_single(self, device):
        """"""
        temp_str = self.__query_cmd('gettemperature', device)
        if temp_str.lstrip('-').isdigit():
            return float(temp_str) / 10.0
        return 'inval'
56400
def _compute_dlt(self):
        """"""
        res = super()._compute_dlt()
        for rec in self:
            ltaf_to_apply = self.env['ddmrp.adjustment'].search(
                rec._ltaf_to_apply_domain())
            if ltaf_to_apply:
                ltaf = 1
                values = ltaf_to_apply.mapped('value')
                for val in values:
                    ltaf *= val
                prev = rec.dlt
                rec.dlt *= ltaf
                _logger.debug(
                    "LTAF=%s applied to %s. DLT: %s -> %s" %
                    (ltaf, rec.name, prev, rec.dlt))
        return res
1225299
def _compute_heating_rates(self):
        ''''''
        self._compute_flux()
        self.heating_rate['Ts'] = -self._flux
        # Modify only the lowest model level
        self.heating_rate['Tatm'][..., -1, np.newaxis] = self._flux
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);
  }