Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird values on heat index calculations #10

Closed
RobertDB59 opened this issue Jan 5, 2022 · 24 comments
Closed

Weird values on heat index calculations #10

RobertDB59 opened this issue Jan 5, 2022 · 24 comments
Assignees
Labels
bug Something isn't working

Comments

@RobertDB59
Copy link

When using the formula's given in the library temperature.h the value's I am getting are way off to the values when I use an online heat index calculator. This is for both formula's °C and °F. When I use the following formula:

HI = 0.5 * (T + 61.0 + ((T-68.0)*1.2) + (RH*0.094))

found at https://www.wpc.ncep.noaa.gov/html/heatindex_equation.shtml it returns imho a more correct value.

Maybe I am missing something?

@RobTillaart
Copy link
Owner

Hi Robert,
Thanks for pointing out, I did not test all formulas in that library so there might be a problem.
Will dive into it later this week.

Note: I move this issue to the repository of temperature as this is a bulk archive of released versions.

@RobTillaart RobTillaart transferred this issue from RobTillaart/Arduino Jan 5, 2022
@RobTillaart RobTillaart self-assigned this Jan 5, 2022
@RobTillaart RobTillaart added the bug Something isn't working label Jan 5, 2022
@RobTillaart RobTillaart changed the title Weird values on heat index calcultions Weird values on heat index calculations Jan 5, 2022
@RobTillaart
Copy link
Owner

A quick look shows I only implemented the first formula without the adjustments.

From the link
In practice, the simple formula is computed first and the result averaged with the temperature. If this heat index value is 80 degrees F or higher, the full regression equation along with any adjustment as described above is applied.

So code needs to be reworked.

Note: HeatIndexC() should become a wrapper around HeatIndex() to minimize footprint and reduce chance on errors.

@RobTillaart
Copy link
Owner

I got my formulas from - https://en.wikipedia.org/wiki/Heat_index which does not mention the NOAA adjustments.
As NOAA is the authority I follow them.
(found a small can of time, so I start on it now)

RobTillaart added a commit that referenced this issue Jan 5, 2022
@RobTillaart
Copy link
Owner

@RobertDB59
Created develop branch - https://github.com/RobTillaart/Temperature/tree/develop + PR

Can you verify if this works as expected?

RobTillaart added a commit that referenced this issue Jan 5, 2022
@RobTillaart
Copy link
Owner

@RobertDB59

Can you verify if this works as expected?

Checked the table generated with the example with the table at https://www.calculator.net/heat-index-calculator.html
and they matched quite well except the column for 80. Fixed a > to a >= and the 80 column matched too.

Will push the change today an merge the changes.

Thanks again for pointing out the issue,
Rob

@RobertDB59
Copy link
Author

Hi Rob,
Just verified the code and is working as expected.

Keep up the good work.
Robert

@RobertDB59
Copy link
Author

I think there is a minor typo

HI += ((13 - RH) / 4) * sqrt((17 - abs(TF - 95.0)) / 17);

Shouldn't this be subtracted instead of added to HI?

@RobTillaart
Copy link
Owner

RobTillaart commented Jan 7, 2022

I think there is a minor typo

HI += ((13 - RH) / 4) * sqrt((17 - abs(TF - 95.0)) / 17);

Shouldn't this be subtracted instead of added to HI?

Checked the website again and it is a major typo

where T is temperature in degrees F and RH is relative humidity in percent. HI is the heat index expressed as an apparent temperature in degrees F. If the RH is less than 13% and the temperature is between 80 and 112 degrees F, then the following adjustment is subtracted from HI:

ADJUSTMENT = [(13-RH)/4]*SQRT{[17-ABS(T-95.)]/17}

where ABS and SQRT are the absolute value and square root functions, respectively. On the other hand, if the RH is greater than 85% and the temperature is between 80 and 87 degrees F, then the following adjustment is added to HI:

ADJUSTMENT = [(RH-85)/10] * [(87-T)/5]

A 0.3.1 release is coming soon ...

@RobTillaart RobTillaart reopened this Jan 7, 2022
@RobTillaart
Copy link
Owner

RobTillaart commented Jan 7, 2022

updated, merged and released 0.3.1
added a few unit tests
please verify

@RobertDB59
Copy link
Author

RobertDB59 commented Jan 7, 2022

Verified and it seems to be all good. Just an idea, maybe you could use the celsius to fahrenheid calculation and vice versa already present in your library for the heat index calculation in a future release. Thanks again en een fijne dag verder.

@RobTillaart
Copy link
Owner

RobTillaart commented Jan 7, 2022

maybe you could use the celsius to fahrenheid calculation and vice versa already present in your library for the heat index calculation in a future release.

Already did that, but I left the code with all the constants in comments. I might consider a Celsius only heatindex once, that would safe some float math. On the other hand the gain would be most 10% as the float math is already pretty heavy.

Check in code

float heatIndexC(float celcius, float humidity)
{
  float TF = celcius * (9.0 / 5.0) + 32;
  float HI = (heatIndex(TF, humidity) - 32) * (5.0 / 9.0);
  return HI;
...

en een fijne dag verder.

Dank je wel !
(you speak Dutch? I live in East part of Brabant, near Helmond)

@RobertDB59
Copy link
Author

Born and raised in Eindhoven, close to Helmond, and I moved 12 years ago to the south of France. So yes I speak Dutch as well.

@RobertDB59
Copy link
Author

What I was trying to say is that you could use

float TF = Fahrenheid(celcius);

instead of

TF = celcius * (9.0 / 5.0) + 32;

Btw celcius is written with an S in the middle as celsius. Maybe you have done that on purpose.

@RobTillaart
Copy link
Owner

My daughter lives near the High Tech Campus, and I studied there so Eindhoven is very familiar.

Both Celcius and Celsius exist, see on this page - https://en.wikipedia.org/wiki/Talk%3ACelsius
But I agree as the man was called Celsius that should be it.

I will update it soon as I also wanted to add the Rankine and Reamure temperature scale conversions too.
(need to make an issue for that)

I close this issue, as the problem is solved. If there are other issues, please let me know.

@RobTillaart
Copy link
Owner

@RobertDB59

Bad weather over here so I am working on a update - #14
with a convertor class.

@RobertDB59
Copy link
Author

RobertDB59 commented Jan 9, 2022 via email

@RobTillaart
Copy link
Owner

RobTillaart commented Jan 9, 2022

Thank you for this function, I will add it to the temperature library.
My proposal is to change the name as that is more descriptive.

float baroToSeaLevelC( float pressure, float celsius, float altitude)
{
  float altitudeFactor = 0.0065 * altitude;
  float kelvin = celsius + 273.15;
  return pressure * pow( 1 - (altitudeFactor / (kelvin + altitudeFactor)), -5.257);
}

Q: Do you have a reference source (NOAA or so) for the code?

found this

update: added the function in upcoming 0.3.2 release

@RobertDB59
Copy link
Author

RobertDB59 commented Jan 9, 2022 via email

@RobTillaart
Copy link
Owner

OK, found some references and they match the equation (enough). So merged into the library.
thanks again.

@RobertDB59
Copy link
Author

RobertDB59 commented Jan 9, 2022 via email

@RobTillaart
Copy link
Owner

Hi Robert,

I am not very familiar with github to propose modifications or add stuff so
I keep using this thread for now.

You can always create a new issue if it concerns a new topic, or reopen an exiting one if related.

These are good remarks, I will add them for a new 0.3.3 release.
This is the way open source grows!

@RobTillaart RobTillaart reopened this Jan 9, 2022
@RobTillaart
Copy link
Owner

https://www.wpc.ncep.noaa.gov/html/heatindex_equation.shtml has some other definition about below 80F range.

I reread it

The Rothfusz regression is not appropriate when conditions of temperature and humidity warrant a heat index value below about 80 degrees F. In those cases, a simpler formula is applied to calculate values consistent with Steadman's results:

HI = 0.5 * {T + 61.0 + [(T-68.0)1.2] + (RH0.094)}

In practice, the simple formula is computed first and the result averaged with the temperature. If this heat index value is 80 degrees F or higher, the full regression equation along with any adjustment as described above is applied.

and I notice I do not compute this simple first so I have to fix this.
(good reading is so difficult, mea culpa)

@RobTillaart
Copy link
Owner

RobTillaart commented Jan 9, 2022

Changes implemented in develop branch and PR created - #15

update: After some failures the unit test run successful again.

@RobTillaart
Copy link
Owner

Merged PR and released 0.3.3 version.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants