I'm back. I figured out how to fix the other problems I had, but now I want to add another function to the temperature display which would show what the temperature currently feels like.
You need to look through the source code for the Yahoo weather webpage you are using, look for that information buried in the HTML code, then add the proper code to your webparser regexp to capture that info...
Of course as soon as Yahoo makes a change to that page design, your skin is going to stop working.
That is the main reason why it has been suggested to start with a working weather skin that uses a reliable data feed!
Alrighty, I'll start looking through the html for "feels like".
I modified another one that had feels like implemented, but it's too high by ten degrees even though it's coming from yahoo weather, so I'll look and try some changes to see if I can make it more accurate.
function Initialize()
MeasureTemp = SKIN:GetMeasure("MeasureNowWeatherTemp")
MeasureHumidity = SKIN:GetMeasure("MeasureNowHumidity")
MeasureWind = SKIN:GetMeasure("MeasureNowWind")
MeasureConditions = SKIN:GetMeasure("MeasureNowWeatherConditions")
StartingUnit = SKIN:GetVariable("Unit")
end -->Initialize
function Update()
SkinTemp = MeasureTemp:GetValue()
SkinWind = MeasureWind:GetValue()
Humid = MeasureHumidity:GetValue()
if string.upper(StartingUnit) == "C" then
TempF = Round((9/5)*SkinTemp+32)
WindM = Round(SkinWind * 1.60934400061)
else
TempF = SkinTemp
WindM = SkinWind
end
--Uncomment to test with different inputs
--SkinTemp = 95
--TempF = 95
--Humid = 50
--WindM = 14
if TempF > 80 and Humid > 40 then
Feels = -42.379 + 2.04901523 * TempF + 10.14333127 * Humid - 0.22475541 * TempF * Humid - 6.83783 * 10^(-3)*(TempF^(2)) - 5.481717 * 10^(-2)*(Humid^(2)) + 1.22874 * 10^(-3)*(TempF^(2))*(Humid) + 8.5282 * 10^(-4)*(TempF)*(Humid^(2)) - 1.99 * 10^(-6)*(TempF^(2))*(Humid^(2))
elseif TempF < 41 and WindM > 4 then
Feels = 35.74 + 0.6215 * TempF - 35.75 * WindM ^ 0.16 + 0.4275 * TempF * WindM ^ 0.16
else
Feels = TempF
end
if string.upper(StartingUnit) == "C" then
Feels = Round((5/9)*(Feels-32))
else
Feels = Round(Feels)
end
SKIN:Bang("!SetOption MeterNowFeels Text \""..Feels.."°\"")
CurrConditions = MeasureConditions:GetStringValue()
if string.len(CurrConditions) > 15 then
SKIN:Bang("!SetOption MeterNowConditions FontSize 12")
else
SKIN:Bang("!SetOption MeterNowConditions FontSize 14")
end
return Feels
end -->Update
function Round(num, idp)
assert(tonumber(num), 'Round expects a number.')
local mult = 10^(idp or 0)
if num >= 0 then
return math.floor(num * mult + 0.5) / mult
else
return math.ceil(num * mult - 0.5) / mult
end
end
This is from the National Oceanic and Atmospheric Administration (NOAA). What it is really is two formulas, one that calculates a "heat index" if the temperature and percent humidity is above a certain point, and one that calculates a "wind chill" if the temperature is below a certain point and the wind speed is above a certain point. The net result will be very similar to what you see as "feels like" on weather sites.
These formulas are based on Fahrenheit and MPH, so if you are returning Celsius and KPH, you have to convert back and forth before and after the formula.
I have no earthly idea what these formulas are doing or what the static values represent, so don't bother asking me... I only know that they work.
I have to say that since weather.com's wxdata feed returns "feels like" in the feed, I have a hard time justifying this... I used to use it when I was getting the now-dead Yahoo feed, which didn't have a "feels like" data value.
Using Yahoo data of ANY KIND today is a lot like buying stock in Toys 'R Us...
jsmorley wrote:
I have no earthly idea what these formulas are doing or what the static values represent, so don't bother asking me... I only know that they work.
I'll have to play around with that sometime, I'm sure I could make a cool weather skin with this if I ever decide to use a different wallpaper