Trouble calculating wind chill


#1
  1. Give a description of the problem

Formula is not giving correct value
1 What is the expected behavior?
Value returned and set to variable chill should be 10.5

2 What is happening/not happening?
Something wrong with calculations

  1. Post a Green Snapshot of the pistonimage
  2. Attach any logs (From ST IDE and by turning logging level to Full)

Any suggestions what I am missing in the algorithm?


#2

what is the expected value of windchill? have you already compared the formula to whatever the source for it is to confirm the expression itself is correct?


#3

Here is what I am using for formula: The new formula for winds in mph and Fahrenheit temperatures is:

Wind chill temperature = 35.74 + 0.6215T - 35.75V (**0.16) + 0.4275TV(**0.16)

In the formula, V is in the wind speed in statute miles per hour, and T is the temperature in degrees Fahrenheit.

Note: In the formula, ** means the following term is an exponent (i.e. 10**(0.5 ) means 10 to the 0.5 power, or the square root of V), - means to subtract, + means to add. A letter next to a number means to multiply that quantity represented by the letter by the number. The standard rules of algebra apply.

The result should be 10.5 F


#4

i am not checking the formula for you … you dont want me checking it … too late on a friday night :slight_smile:

if you are sure of the expression already, could it be a operator precedence issue? may be try grouping them to set the precedence and check if that changes anything?


#5

your expression is using vtmp instead of vtemp


#6

Good catch. However now returns -4.92… not 10.5


#7

Make the wind and temperature variables decimal instead of dynamic and don’t read the _string options, read those that are numeric, you really want numbers. Unfortunatelly a lot of times string + string gives a string, even if they contain numbers. For instance ‘1’ + ‘0’ will give you ‘10’.


#8

Thanks @ady624 and @bangali. I was actually missing a variable in my expression. Did change whe wind speed and temp to decimal too. Palm to the face!

If anyone wants to use what I have started


#9

Welcome back @ady624. Hope all fared well with Irma


#10

Is there a way to incorporate 2 restrictions into a single line for this.

If temperature is <= 50
And
If wind speed is >= 3

Then windchill = round((35.74 + 0.6215 * { $weather.conditions.current_observation.temp_f }- 35.75 * power($weather.conditions.current_observation.wind_mph ,.16)+ 0.4275 * { $weather.conditions.current_observation.temp_f " F"}*power($weather.conditions.current_observation.wind_mph ,.16)),1)

The calculation portion is correct but I don’t want it to set the windchill var if the conditions are not met. Would prefer an expression to define the windchill variable


#11

You can use ternary operators:

(something == true ? wind *100 : 0)

If something is true you get wind*100, else you get 0. Then you can combine that further in your expression


#12

glad you got it figured out.

so everything that was dynamic, still works by leaving it as dynamic?

thanks.


#13

Trying to use ternary statement. But this is not working? What am I doing wrong?

decimal( $weather.conditions.current.observation.wind_mph)<=3?(decimal($weather.conditions.current_observation.temp_f " F")>=50)? ‘Windchill calculated’:‘windchill not calculated’

I know temp is suppose to be less than 50. But right now temps are all above and just trying to get it to process correctly then I will correct it


#14

(decimal($weather.conditions.current.observation.wind_mph) <=3 && decimal($weather.conditions.current_observation.temp_f) >= 50 ? 'Windchill calculated' : 'windchill not calculated')


#15

Didn’t seem to work correctly. Ended up doing this and seems to work right now.

If(decimal($weather.conditions.current_observation.temp_f)<50.0,if(decimal($weather.conditions.current_observation.wind_mph)>3.0,round((35.74 + 0.6215 * { $weather.conditions.current_observation.temp_f }- 35.75 * power($weather.conditions.current_observation.wind_mph ,.16)+ 0.4275 * { $weather.conditions.current_observation.temp_f }*power($weather.conditions.current_observation.wind_mph ,.16)),1) ,“NA”),“NA”)