1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| class DegreeC(float): '''摄氏温度对象''' pass
def __caculateInterval(Ta: DegreeC): ''' 测算区间 ''' if Ta <= 25: Tf_low = 32.66 + 0.186 * ( Ta - 25 ) Tf_high = 34.84 + 0.148 * (Ta - 25) else: Tf_low = 32.66 + 0.086 * (Ta - 25) Tf_high=34.84 + 0.100*(Ta - 25) return Tf_low, Tf_high
def getBodyTemp(Tf: DegreeC, Ta: DegreeC): ''' 计算身体温度 :param Tf: 测量温度,体表温度 :param Ta: 环境温度 :type Tf: DegreeC :type TaL DegreeC :return: 身体温度 :rtype: DegreeC ''' Tf_low,Tf_high = __caculateInterval(Ta) if Tf_low <= Tf <= Tf_high: Tbody = 36.3 + 0.5 / (Tf_high - Tf_low) * (Tf-Tf_low) elif Tf > Tf_high: Tbody = 36.8 + ( 0.829320618 + 0.002364434 * Ta) * (Tf - Tf_high) elif Tf < Tf_low: Tbody = 36.3 + ( 0.551658273 + 0.021525068 * Ta) * (Tf - Tf_low) return Tbody
if __name__ == '__main__': Tb = getBodyTemp(Tf=34.5, Ta=25) print(Tb)
|