<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3ASandbox%2FRousseaulambertlp</id>
	<title>Module:Sandbox/Rousseaulambertlp - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3ASandbox%2FRousseaulambertlp"/>
	<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Sandbox/Rousseaulambertlp&amp;action=history"/>
	<updated>2026-07-29T05:33:02Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://stockhub.co/index.php?title=Module:Sandbox/Rousseaulambertlp&amp;diff=146138&amp;oldid=prev</id>
		<title>imported&gt;Rousseaulambertlp: try template</title>
		<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Sandbox/Rousseaulambertlp&amp;diff=146138&amp;oldid=prev"/>
		<updated>2018-01-22T13:52:00Z</updated>

		<summary type="html">&lt;p&gt;try template&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local p = {}&lt;br /&gt;
local getArgs = require(&amp;#039;Module:Arguments&amp;#039;).getArgs&lt;br /&gt;
local datePattern = &amp;quot;^(%d+)-(%d+)$&amp;quot;&lt;br /&gt;
-- local weatherTemplate = &amp;#039;Template:Weather box&amp;#039;&lt;br /&gt;
local weatherTemplate = &amp;#039;Template:Climat&amp;#039;&lt;br /&gt;
local wrapsTemplate = &amp;#039;User:Rousseaulambertlp/Weather box&amp;#039;&lt;br /&gt;
&lt;br /&gt;
function p.weatherbox( frame )&lt;br /&gt;
    local args = getArgs(frame, { wrappers = wrapsTemplate })&lt;br /&gt;
    local dataPage = assert(args.data, &amp;#039;Missing &amp;quot;data&amp;quot; parameter&amp;#039;)&lt;br /&gt;
    args.data = nil&lt;br /&gt;
&lt;br /&gt;
    local monthlyHigh, monthlyLow = {}, {}&lt;br /&gt;
    local highSum, highCount = {}, {}&lt;br /&gt;
    local lowSum, lowCount = {}, {}&lt;br /&gt;
    local avgHighSum, avgHighCount = {}, {}&lt;br /&gt;
    local avgLowSum, avgLowCount = {}, {}&lt;br /&gt;
    local precipSum, precipCount = {}, {}&lt;br /&gt;
    local snowfallSum, snowfallCount = {}, {}&lt;br /&gt;
&lt;br /&gt;
	-- There is currently no established way to specify sources, suggestions needed&lt;br /&gt;
	-- For now, prepend the link to edit box to the first source&lt;br /&gt;
	local source = args[&amp;#039;source&amp;#039;] or args[&amp;#039;source 1&amp;#039;]&lt;br /&gt;
	if source then source = &amp;#039;&amp;lt;br&amp;gt;&amp;#039; .. source end&lt;br /&gt;
	args[&amp;#039;source&amp;#039;] = &amp;#039;[[commons:Data:&amp;#039;.. dataPage ..&amp;#039;|edit data]]&amp;#039; .. source&lt;br /&gt;
	args[&amp;#039;source 1&amp;#039;] = nil&lt;br /&gt;
&lt;br /&gt;
    for key, row in pairs(mw.ext.data.get(dataPage).data) do&lt;br /&gt;
        local date, avgHighTemp, avgLowTemp, extHighTemp, extLowTemp, precipTotalRain, precipTotalSnow, precipTotal, snowGrndLastDay, windDirMaxGust, windSpeedMaxGust = unpack(row)&lt;br /&gt;
&lt;br /&gt;
        local year, month = date:match(datePattern)&lt;br /&gt;
        month = tonumber(month)&lt;br /&gt;
&lt;br /&gt;
        if extHighTemp ~= nil and (monthlyHigh[month] == nil or monthlyHigh[month] &amp;lt; extHighTemp) then monthlyHigh[month] = extHighTemp end&lt;br /&gt;
        if extLowTemp ~= nil and (monthlyLow[month] == nil or monthlyLow[month] &amp;gt; extLowTemp) then monthlyLow[month] = extLowTemp end&lt;br /&gt;
        recordAvg(highSum, highCount, month, extHighTemp)&lt;br /&gt;
        recordAvg(lowSum, lowCount, month, extLowTemp)&lt;br /&gt;
        recordAvg(avgHighSum, avgHighCount, month, avgHighTemp)&lt;br /&gt;
        recordAvg(avgLowSum, avgLowCount, month, avgLowTemp)&lt;br /&gt;
        recordAvg(precipSum, precipCount, month, precipTotal)&lt;br /&gt;
        recordAvg(snowfallSum, snowfallCount, month, precipTotalSnow)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    local months = {&amp;#039;Jan&amp;#039;,&amp;#039;Feb&amp;#039;,&amp;#039;Mar&amp;#039;,&amp;#039;Apr&amp;#039;,&amp;#039;May&amp;#039;,&amp;#039;Jun&amp;#039;,&amp;#039;Jul&amp;#039;,&amp;#039;Aug&amp;#039;,&amp;#039;Sep&amp;#039;,&amp;#039;Oct&amp;#039;,&amp;#039;Nov&amp;#039;,&amp;#039;Dec&amp;#039;}&lt;br /&gt;
    for i=1, 12 do args[months[i] .. &amp;#039;tmax-&amp;#039;] = monthlyHigh[i] end&lt;br /&gt;
    for i=1, 12 do args[months[i] .. &amp;#039;tmin-&amp;#039;] = monthlyLow[i] end&lt;br /&gt;
--    for i=1, 12 do args[months[i] .. &amp;#039;avg record high C&amp;#039;] = string.format(&amp;quot;%.1f&amp;quot;, highSum[i] / highCount[i]) end&lt;br /&gt;
--    for i=1, 12 do args[months[i] .. &amp;#039;avg record low C&amp;#039;] = string.format(&amp;quot;%.1f&amp;quot;, lowSum[i] / lowCount[i]) end&lt;br /&gt;
--    for i=1, 12 do args[months[i] .. &amp;#039;high C&amp;#039;] = string.format(&amp;quot;%.1f&amp;quot;, avgHighSum[i] / avgHighCount[i]) end&lt;br /&gt;
--    for i=1, 12 do args[months[i] .. &amp;#039;low C&amp;#039;] = string.format(&amp;quot;%.1f&amp;quot;, avgLowSum[i] / avgLowCount[i]) end&lt;br /&gt;
    for i=1, 12 do args[months[i] .. &amp;#039;prec-&amp;#039;] = string.format(&amp;quot;%.1f&amp;quot;, precipSum[i] / precipCount[i]) end&lt;br /&gt;
--    for i=1, 12 do args[months[i] .. &amp;#039; snow mm&amp;#039;] = string.format(&amp;quot;%.1f&amp;quot;, snowfallSum[i] / snowfallCount[i]) end&lt;br /&gt;
&lt;br /&gt;
    return frame:expandTemplate{ title = weatherTemplate, args = args }&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function recordAvg(sumTbl, countTbl, month, value)&lt;br /&gt;
    if value ~= nil then&lt;br /&gt;
        sumTbl[month] = (sumTbl[month] or 0) + value&lt;br /&gt;
        countTbl[month] = (countTbl[month] or 0) + 1&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>imported&gt;Rousseaulambertlp</name></author>
	</entry>
</feed>