我的C程序中的Heat_Index计算;关于公式的问题 [英] Heat_Index calculation in my C program; question about formula

查看:87
本文介绍了我的C程序中的Heat_Index计算;关于公式的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



问候!


我刚买了一台新的Peet Brothers Ultimeter 2100气象站。如果按两次露点

键,这个

的新方法可以显示热指数。


知道关于热指数的确切计算

的所有争议,我想要我自己的软件(我在1990年的
'中编程,当我拿到他们的Ultimeter 2000气象站时,那个显示它的那个

没有显示热量指数。住在佛罗里达州,当它很热的时候,特别是
,我不介意知道它是什么,即使我不是很接近

到安装在我办公室的实际气象站按下dp。钥匙

两次。 (我的软件显示所有当前和每日记录的天气

条件,每分钟更新两次。)


这是热指数公式:


<<>>

-42.379 + 2.04901523T + 10.14333127R - 0.22475541TR - 6.83783x10-3T2 - 5.481717x10-2R2 + 1.22874x10-3T2R + 8.5282x10-4TR2 - 1.99x10-6T2R2

<<>>


而且,这是我的C程序中的行:


<<>>

Heat_Index =( - 42.379)+(2.04901523 *温度)+

(10.14333127 *湿度) -

(0.22475541 *温度*湿度) -

(6.83783 * powf(10.0,-3)* powf(温度,2)) -

(5.481717 * powf(10.0,-2)* powf(湿度,2))+

(1.22874 * powf(10.0,-3)* powf(温度,2)*

湿度)+(8.5282 *粉末(10.0,-4)*温度*

powf(湿度,2)) - (1.99 * powf(10.0,-6) *

powf(温度,2)* powf(湿度,2));

& lt;<>>


别笑! :-


温度和湿度都是正确的,因为我在gdb中看过它。这可能并不奇怪,我没有得到气象站的东西

获得热量指数。 :-)


我没有受过数学教育,所以我敢打赌有些东西

我没有正确地从在我的C代码中的上述公式。


特别是它说1.99x10-6T2R2之类的东西。


我在想 ;时间温度平方和湿度时间

平方可能还可以,但那个x10-6部分,我不确定'

是对的。由于那里没有变量,为什么他们不会只修改

之前的数字x?


无论如何,如果有人没有我不介意极度耐心地谈论

一个真正不知道我拥有的是对的人(但我知道

它没有得到正确的金额),我该怎么办?


你不必重写整个陈述。如果你能告诉我如何处理像1.99x10-6T2R2这样的东西,我希望我能够用另一个x来做另一个xb。适当的部分! :-)


谢谢!


巴里

-

巴里L.邦德| http://home.cfl.rr.com/os9barry/

ITT公司软件工程师| (我的个人主页,最后

bbondATcfl.rr.com |更新于2005年2月17日)

解决方案

Barry L.邦德说:


>

问候!



< ;剪断>


>

这是热指数公式:


<<> ;>

-42.379 + 2.04901523T + 10.14333127R - 0.22475541TR - 6.83783x10-3T2 -

5.481717x10-2R2 + 1.22874x10-3T2R + 8.5282x10-4TR2 - 1.99x10-6T2R2<>>


而且,这是我的C程序中的一行:


< <>>

Heat_Index =( - 42.379)+(2.04901523 *温度)+

(10.14333127 *湿度) -

( 0.22475541 *温度*湿度) -

(6.83783 * powf(10.0,-3)* powf(温度,2)) -

(5.481717 * powf(10.0, - 2)* powf(湿度,2))+

(1.22874 * powf(10.0,-3)* powf(温度,2)*

湿度)+(8.5282 * powf(10.0,-4)*温度*

powf(湿度,2)) - (1.99 * powf(10.0,-6)*

powf(温度,2)* powf(湿度,2));



在我看来,这是对你给定方程式的合理翻译。


虽然我的系统没有powf功能,我认为它是浮动的

相当于pow。所以我写了我自己的浮动等效的pow,并比较了

浮动计算与双重计算,温度范围为0到30

(变化0.1)和湿度范围0-100(变化1.0)。大多数时候,两者之间的差异非常小 -

在这一点之后相当多的零 - 但偶尔会有我的

表示微小差异 - 例如T = 5.2 H = 83给出了浮点数计算和上面

等式的双重计算之间的差值:$ block $ class =post_quotes >
温度和湿度是正确的,因为我已经在gdb中查看了它。



您可能想提供一些示例数据,并告诉我们

气象站获取这些数据的结果以及您的程序结果如何得到

相同的数据。


这是

我可能不会感到惊讶不知道气象站是什么

得到热量指数。 :-)



这个等式是否被普遍接受?你的版本是近似值吗?

他们的?这些常量是否被认为是规范的,或者它们只是

建议?


>

我是没有数学方面的教育,所以我敢打赌有一些东西

我在C代码中没有正确地从上面的公式中捕获。


特别是它说1.99x10-6T2R2之类的东西。


我想的是时间温度平方和湿度时间

平方可能还可以,但那个x10-6部分,我不确定'

是对的。由于那里没有变量,为什么他们不会在x之前修改

的数字?



不,这很好 - 这只是一种以一致的

格式表达数字的方式。这个想法是任何(实际)数字都可以用有限的小数表示,也可以用这种方式表示:


可选符号

在[1.0,10.0]范围内的值......这里的符号表示10.0本身

不属于范围

乘法符号

可选符号

指数


这是如此完善,C语言有一个符号。<例如,你可以只用

写(6.83783E-3),而不是写(6.83783 * powf(10.0,-3)),其中 - 在这种情况下 - E代表时间十到

的力量。


-

Richard Heathfield< http:/ /www.cpax.org.uk>

电子邮件:-http:// www。 + rjh @

谷歌用户:< http://www.cpax.org.uk/prg/writings/googly.php>

Usenet是一个奇怪的放置" - dmr 1999年7月29日


Barry L. Bond写道:


问候!


我刚买了一台新的Peet Brothers Ultimeter 2100气象站。如果按两次露点

键,这个

的新方法可以显示热指数。


知道关于热指数的确切计算

的所有争议,我想要我自己的软件(我在1990年的
'中编程,当我拿到他们的Ultimeter 2000气象站时,那个显示它的那个

没有显示热量指数。住在佛罗里达州,当它很热的时候,特别是
,我不介意知道它是什么,即使我不是很接近

到安装在我办公室的实际气象站按下dp。钥匙

两次。 (我的软件显示所有当前和每日记录的天气

条件,每分钟更新两次。)


这是热指数公式:


<<>>

-42.379 + 2.04901523T + 10.14333127R - 0.22475541TR - 6.83783x10-3T2 - 5.481717x10-2R2 + 1.22874x10-3T2R + 8.5282x10-4TR2 - 1.99x10-6T2R2

<<>>


而且,这是我的C程序中的行:


<<>>

Heat_Index =( - 42.379)+(2.04901523 *温度)+

(10.14333127 *湿度) -

(0.22475541 *温度*湿度) -

(6.83783 * powf(10.0,-3)* powf(温度,2)) -

(5.481717 * powf(10.0,-2)* powf(湿度,2))+

(1.22874 * powf(10.0,-3)* powf(温度,2)*

湿度)+(8.5282 *粉末(10.0,-4)*温度*

powf(湿度,2)) - (1.99 * powf(10.0,-6)*

powf(温度,2)* powf(湿度,2));

<<>>


别笑! :-


温度和湿度都是正确的,因为我在gdb中看过它。这可能并不奇怪,我没有得到气象站的东西

获得热量指数。 :-)


我没有受过数学教育,所以我敢打赌有些东西

我没有正确地从在我的C代码中的上述公式。


特别是它说1.99x10-6T2R2之类的东西。


我在想 ;时间温度平方和湿度时间

平方可能还可以,但那个x10-6部分,我不确定'

是对的。由于那里没有变量,为什么他们不会只修改

之前的数字x?


无论如何,如果有人没有我不介意极度耐心地谈论

一个真正不知道我拥有的是对的人(但我知道

它没有得到正确的金额),我该怎么办?


你不必重写整个陈述。如果你能告诉我如何处理像1.99x10-6T2R2这样的东西,我希望我能够用另一个x来做另一个xb。适当的部分! :-)


谢谢!


Barry



Page 41等式。检查了TEMP和HUMIDITY单位的第二个文档。

http://gis.esri.com/library/userconf..._gis-based.pdf
http://www.srh.noaa.gov/ffc/html/studies/ta_htindx.PDF


假设没有转录错误,我就这样读了等式。


-42.40 +

(2.04901523 * TEMP)+

(10.14333127 *湿度) -

(0.22475541 * TEMP * HUMIDITY) -

(0.00683783 * TEMP * TEMP) -

(0.05481717 *湿度*湿度)+

(0.00122874 * TEMP * TEMP *湿度)+

(0.00085282 * TEMP *湿度*湿度) -

(0.00000199 * TEMP * TEMP *湿度*湿度)


TEMP =环境干球温度,单位为华氏度

湿度=相对湿度为int eger百分比0..100

如果它仍然不适合你,请加入样品(TEMP,HUMIDITY,HI)

结果所以那里是调试的东西。


HTH,

Paul




嗨理查德!


哇!谢谢你的快速回复!


>虽然我的系统没有powf函数,但我认为它是浮动的
相当于战俘。因此,我写了自己的浮动等效的pow,并将浮动计算与双重计算结果进行比较,温度范围为0到30
(变化0.1),湿度范围为0-100(变化范围为0) 1.0)。大多数时候,两者之间的差异非常小 - 在这一点之后有很多零 - 但偶尔也会出现我所说的微小差异 - 例如T = 5.2 H = 83给出上述方程的浮点数钙值和双重计算值之间的差值(0.000030517578125)。



是的。我发现了一个关于powf的手册页,就是这样。


>您可能想要提供一些示例数据,并告诉我们结果是什么?气象站获取这些数据以及您的程序获得相同数据的结果。



啊!好的。


刚刚运行它,温度为74.5999985 F,湿度为88.5%,热量指数为73.6352844。气象站目前显示

79 F.


(实际上,我只是注意到我正在进行一个小数点位置
$ b显示它时出现$ b错误,所以它实际上并不像我之前想象的那么多!:-)但是,它仍然与天气不同

站点热量指数报告。)


>等式是否被普遍接受?你的版本是近似值吗?是他们的吗?常量是否被认为是规范的,还是仅仅是建议?



是的。事实上,我从Peet Brothers获得了三个网址,其中一个网址与Paul的回复中的第二个链接完全相同。

文章。我打印了纸张的一面/两面,我正在看

完全相同的文字。


他们说他们使用了完全一样的计算在他们的Ultimeter 2100中计算

热量指数作为那个URL。


仅仅是建议,我会说。但是,我很想再次看到它,再次是
,特别是当它在95+和高湿度时,因为我们在佛罗里达州的夏季月份有很多。


>不,这很好 - 它只是一种以一致的格式表达数字的方式。这个想法是任何(实数)可以用有限小数表示的数字也可以用这种方式表示:


>可选符号
在[1.0,10.0]范围内的值......这里的符号表示10.0本身不是
乘法符号的一部分
可选符号
指数


>这是如此完善,C语言有一个符号。
写作(6.83783 * powf(10.0,-3)),例如,你可以写(6.83783E-3),其中 - 在这个上下文中 - E代表时间十
的力量



啊!那讲得通!感谢您的耐心和耐心的帮助! :-)


Barry

-

Barry L. Bond | http://home.cfl.rr.com/os9barry/

ITT公司软件工程师| (我的个人主页,最后一页

bbondATcfl.rr.com | 2005年2月17日更新)



Greetings!

I just got a new Peet Brothers Ultimeter 2100 Weather Station. This
new one has a way to display the heat index, if you press the "dew point"
key twice.

Being aware of all the controversy surrounding the exact calculation
of the heat index, I would like my own software (which I programmed in the
1990''s, when I got their Ultimeter 2000 weather station, but that one
didn''t show heat index) to display it. Living in Florida, when it''s hot,
in particular, I wouldn''t mind knowing what it is, even if I''m not close
to the actual weather station mounted in my office to press the "d.p." key
twice. (My software shows all the current and daily record weather
conditions, updated twice a minute.)

Here is the heat index formula:

<<>>
-42.379 + 2.04901523T + 10.14333127R - 0.22475541TR - 6.83783x10-3T2 - 5.481717x10-2R2 + 1.22874x10-3T2R + 8.5282x10-4TR2 - 1.99x10-6T2R2
<<>>

And, here is the line in my C program:

<<>>
Heat_Index = (-42.379) + (2.04901523 * Temperature) +
(10.14333127 * Humidity) -
(0.22475541 * Temperature * Humidity) -
(6.83783 * powf (10.0, -3) * powf (Temperature, 2)) -
(5.481717 * powf (10.0, -2) * powf (Humidity, 2)) +
(1.22874 * powf (10.0, -3) * powf (Temperature, 2) *
Humidity) + (8.5282 * powf (10.0, -4) * Temperature *
powf (Humidity, 2)) - (1.99 * powf (10.0, -6) *
powf (Temperature, 2) * powf (Humidity, 2));
<<>>

Don''t laugh! :-D

Temperature and Humidity are correct, as I''ve viewed it in gdb. It''s
probably not surprising that I''m NOT getting what the weather station is
getting for the heat index. :-)

I''m not mathematically educated, so I''ll bet there is something that
I''m not properly capturing from the above formula in my C code.

Especially where it says things like "1.99x10-6T2R2".

I am thinking the "times Temperature squared and times humidity
squared" is probably okay, but that "x10-6" part, I''m not sure that''s
right. Since there is no variable there, why wouldn''t they just modify
the number before the "x"?

Anyway, if anyone doesn''t mind talking with extreme patience to
someone who truly doesn''t know whether what I have is right (but I know
it''s not getting the correct amount), what should I do?

You don''t have to rewrite the whole statement. If you could just tell
me how I handle things like the "1.99x10-6T2R2", I expect I would be able
to do the other "x" portions appropriate! :-)

Thank you!

Barry
--
Barry L. Bond | http://home.cfl.rr.com/os9barry/
Software Engineer, ITT Corporation | (My personal home web page, last
bbondATcfl.rr.com | updated February 17, 2005)

解决方案

Barry L. Bond said:

>
Greetings!

<snip>

>
Here is the heat index formula:

<<>>
-42.379 + 2.04901523T + 10.14333127R - 0.22475541TR - 6.83783x10-3T2 -
5.481717x10-2R2 + 1.22874x10-3T2R + 8.5282x10-4TR2 - 1.99x10-6T2R2 <<>>

And, here is the line in my C program:

<<>>
Heat_Index = (-42.379) + (2.04901523 * Temperature) +
(10.14333127 * Humidity) -
(0.22475541 * Temperature * Humidity) -
(6.83783 * powf (10.0, -3) * powf (Temperature, 2)) -
(5.481717 * powf (10.0, -2) * powf (Humidity, 2)) +
(1.22874 * powf (10.0, -3) * powf (Temperature, 2) *
Humidity) + (8.5282 * powf (10.0, -4) * Temperature *
powf (Humidity, 2)) - (1.99 * powf (10.0, -6) *
powf (Temperature, 2) * powf (Humidity, 2));

That looks to me like a reasonable translation of your given equation.

Although my system doesn''t have a powf function, I presume it''s a float
equivalent of pow. So I wrote my own float equivalent of pow, and compared
float calcs against double calcs, for temperatures in the range 0 to 30
(varying by 0.1) and humidities in the range 0-100 (varying by 1.0). Most
of the time, there was remarkably little difference between the two -
quite a few zeros after the point - but occasionally there were what I
would term minor discrepancies - e.g. T=5.2 H=83 gives a difference of
0.000030517578125 between a float calc and a double calc of the above
equation.

Temperature and Humidity are correct, as I''ve viewed it in gdb.

You might want to give some example data, and tell us what results the
weather station gets for those data and what results your program gets for
the same data.

It''s
probably not surprising that I''m NOT getting what the weather station is
getting for the heat index. :-)

Is the equation generally accepted? Is your version an approximation? Is
theirs? Are the constants considered canonical, or are they merely
suggestions?

>
I''m not mathematically educated, so I''ll bet there is something that
I''m not properly capturing from the above formula in my C code.

Especially where it says things like "1.99x10-6T2R2".

I am thinking the "times Temperature squared and times humidity
squared" is probably okay, but that "x10-6" part, I''m not sure that''s
right. Since there is no variable there, why wouldn''t they just modify
the number before the "x"?

No, that''s fine - it''s just a way of expressing numbers in a consistent
format. The idea is that any (real) number that can be expressed in a
finite number of decimals can also be expressed in this way:

optional sign
value in the range [1.0, 10.0)... the notation here means that 10.0 itself
isn''t part of the range
multiplication sign
optional sign
exponent

This is so well-established that the C language has a notation for it.
Instead of writing (6.83783 * powf (10.0, -3)), for example, you can just
write (6.83783E-3), where - in this context - E stands for "times ten to
the power of".

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999


Barry L. Bond wrote:

Greetings!

I just got a new Peet Brothers Ultimeter 2100 Weather Station. This
new one has a way to display the heat index, if you press the "dew point"
key twice.

Being aware of all the controversy surrounding the exact calculation
of the heat index, I would like my own software (which I programmed in the
1990''s, when I got their Ultimeter 2000 weather station, but that one
didn''t show heat index) to display it. Living in Florida, when it''s hot,
in particular, I wouldn''t mind knowing what it is, even if I''m not close
to the actual weather station mounted in my office to press the "d.p." key
twice. (My software shows all the current and daily record weather
conditions, updated twice a minute.)

Here is the heat index formula:

<<>>
-42.379 + 2.04901523T + 10.14333127R - 0.22475541TR - 6.83783x10-3T2 - 5.481717x10-2R2 + 1.22874x10-3T2R + 8.5282x10-4TR2 - 1.99x10-6T2R2
<<>>

And, here is the line in my C program:

<<>>
Heat_Index = (-42.379) + (2.04901523 * Temperature) +
(10.14333127 * Humidity) -
(0.22475541 * Temperature * Humidity) -
(6.83783 * powf (10.0, -3) * powf (Temperature, 2)) -
(5.481717 * powf (10.0, -2) * powf (Humidity, 2)) +
(1.22874 * powf (10.0, -3) * powf (Temperature, 2) *
Humidity) + (8.5282 * powf (10.0, -4) * Temperature *
powf (Humidity, 2)) - (1.99 * powf (10.0, -6) *
powf (Temperature, 2) * powf (Humidity, 2));
<<>>

Don''t laugh! :-D

Temperature and Humidity are correct, as I''ve viewed it in gdb. It''s
probably not surprising that I''m NOT getting what the weather station is
getting for the heat index. :-)

I''m not mathematically educated, so I''ll bet there is something that
I''m not properly capturing from the above formula in my C code.

Especially where it says things like "1.99x10-6T2R2".

I am thinking the "times Temperature squared and times humidity
squared" is probably okay, but that "x10-6" part, I''m not sure that''s
right. Since there is no variable there, why wouldn''t they just modify
the number before the "x"?

Anyway, if anyone doesn''t mind talking with extreme patience to
someone who truly doesn''t know whether what I have is right (but I know
it''s not getting the correct amount), what should I do?

You don''t have to rewrite the whole statement. If you could just tell
me how I handle things like the "1.99x10-6T2R2", I expect I would be able
to do the other "x" portions appropriate! :-)

Thank you!

Barry

Page 41 has the equation. Checked second doc for units for TEMP and HUMIDITY.

http://gis.esri.com/library/userconf..._gis-based.pdf
http://www.srh.noaa.gov/ffc/html/studies/ta_htindx.PDF

Assuming no transcription errors, I read the equation this way.

-42.40 +
(2.04901523 * TEMP) +
(10.14333127 * HUMIDITY) -
(0.22475541 * TEMP * HUMIDITY) -
(0.00683783 * TEMP * TEMP) -
(0.05481717 * HUMIDITY * HUMIDITY) +
(0.00122874 * TEMP * TEMP * HUMIDITY) +
(0.00085282 * TEMP * HUMIDITY * HUMIDITY) -
(0.00000199 * TEMP * TEMP * HUMIDITY * HUMIDITY)

TEMP = ambient dry bulb temperature in degrees Farenheit
HUMIDITY = relative humidity as integer percentage 0..100

If it still doesn''t work for you, include a sample (TEMP, HUMIDITY, HI)
result so there is something to debug with.

HTH,
Paul



Hi Richard!

Wow! Thank you for your fast reply!

>Although my system doesn''t have a powf function, I presume it''s a float
equivalent of pow. So I wrote my own float equivalent of pow, and compared
float calcs against double calcs, for temperatures in the range 0 to 30
(varying by 0.1) and humidities in the range 0-100 (varying by 1.0). Most
of the time, there was remarkably little difference between the two -
quite a few zeros after the point - but occasionally there were what I
would term minor discrepancies - e.g. T=5.2 H=83 gives a difference of
0.000030517578125 between a float calc and a double calc of the above
equation.

Yes. I found a man page for powf, that''s what it is.

>You might want to give some example data, and tell us what results the
weather station gets for those data and what results your program gets for
the same data.

Ah! Okay.

Running it just now, with 74.5999985 F as the temp and 88.5% as the
humidity, the Heat_Index is 73.6352844. The Weather Station currently shows
79 F.

(Actually, I just noticed I''m making a one decimal point placement
error in the displaying of it, so it actually isn''t as far off as I
thought earlier! :-) But, it is still different from what the weather
station reports for Heat Index.)

>Is the equation generally accepted? Is your version an approximation? Is
theirs? Are the constants considered canonical, or are they merely
suggestions?

Yes. In fact, I was given three URLs from Peet Brothers, and one of
the URLs is the exact same page as the second link in Paul''s reply to my
article. I printed that one side/both sides of paper, and I''m looking at
exactly that same text.

They said they used exactly the same calculation to calculate the
heat index in their Ultimeter 2100 as that very URL.

Merely suggestions, I''d say. But, I was rather wanting to see it,
again, especially when it was 95+ and high humidity, as we have a lot in
our summer months in Florida.

>No, that''s fine - it''s just a way of expressing numbers in a consistent
format. The idea is that any (real) number that can be expressed in a
finite number of decimals can also be expressed in this way:

>optional sign
value in the range [1.0, 10.0)... the notation here means that 10.0 itself
isn''t part of the range
multiplication sign
optional sign
exponent

>This is so well-established that the C language has a notation for it.
Instead of writing (6.83783 * powf (10.0, -3)), for example, you can just
write (6.83783E-3), where - in this context - E stands for "times ten to
the power of".

Ah! That makes sense! Thank you for your kind and patient help! :-)

Barry
--
Barry L. Bond | http://home.cfl.rr.com/os9barry/
Software Engineer, ITT Corporation | (My personal home web page, last
bbondATcfl.rr.com | updated February 17, 2005)


这篇关于我的C程序中的Heat_Index计算;关于公式的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆