Module:Infobox RT: Difference between revisions
testing out ploidnum |
added "arx" |
||
(8 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
local u = require("Module:Utils") | local u = require("Module:Utils") | ||
local infobox = require("Module:Infobox") | local infobox = require("Module:Infobox") | ||
function p.infobox_RT(frame) | function p.infobox_RT(frame) | ||
Line 91: | Line 19: | ||
local genfrac = frame.args["genfrac"] | local genfrac = frame.args["genfrac"] | ||
local method = frame.args["method"] | local method = frame.args["method"] | ||
local mapping = frame.args["mapping"] | |||
local mos = frame.args["mosses"] | local mos = frame.args["mosses"] | ||
local ploidacot = frame.args["ploidacot"] | local ploidacot = frame.args["ploidacot"] | ||
local pergen = frame.args["pergen"] | |||
local limit1 = frame.args["lim1"] | local limit1 = frame.args["lim1"] | ||
local comp1 = frame.args["comp1"] | local comp1 = frame.args["comp1"] | ||
Line 122: | Line 52: | ||
}) | }) | ||
-- autocalculating ploidacot | -- autocalculating ploidacot | ||
for num in mapping:gmatch("(%d+); ") do | for num in mapping:gmatch("(%d+); ") do | ||
table.insert(map, num) | table.insert(map, num) | ||
Line 143: | Line 73: | ||
cot = tonumber(lowermap[2]) | cot = tonumber(lowermap[2]) | ||
suffix = "gem" | suffix = "gem" | ||
else | |||
suffix = "arx" | |||
end | end | ||
elseif tonumber( | end | ||
if referent == "7" then | |||
suffix = "gem" | |||
elseif tonumber(referent) == 2 then -- edf | |||
equave_letter = "f" | equave_letter = "f" | ||
equave = "3/2" | equave = "3/2" | ||
referent = string.char(string.byte(subgroup, 5)) | referent = string.char(string.byte(subgroup, 5)) | ||
end | end | ||
elseif tonumber(equave) == 2 then | elseif tonumber(equave) == 2 then | ||
Line 166: | Line 98: | ||
suffix = referent .. suffix | suffix = referent .. suffix | ||
end | end | ||
local ploidnum = | local ploidnum = math.log(tonumber(equave))*(1200/math.log(2))/tonumber(ploid) | ||
local tuningnum = tonumber(tuning) | |||
if cot < 0 then | |||
tuningnum = math.log(tonumber(equave))*(1200/math.log(2)) - tuningnum | |||
cot = math.abs(cot) | |||
end | |||
local shear = math.floor(tuningnum*cot/ploidnum) | |||
shear = math.floor(cot*(shear/cot - math.floor(shear/cot))) | |||
if cot > 2 then | |||
if shear == cot-1 then | |||
shear = -1 | |||
end | |||
end | |||
suffix = p.num2greeklet(tostring(shear)) .. p.num2greek(tostring(cot), "cot") .. suffix | |||
if ploid ~= "1" then | |||
suffix = p.num2greek(ploid,"ploid") .. "ploid " .. suffix | |||
end | |||
if ploidacot == "0" then | |||
ploidacot = suffix | |||
end | |||
-- edo join | -- edo join | ||
Line 181: | Line 133: | ||
}) | }) | ||
table.insert(data, { | if mos ~= "0" then | ||
table.insert(data, { | |||
"MOS scales", | |||
mos | |||
}) | |||
end | |||
table.insert(data, { | table.insert(data, { | ||
"Ploidacot", | "Ploidacot", | ||
ploidacot | |||
}) | }) | ||
if pergen ~= "0" then | |||
table.insert(data, { | |||
"Pergen", | |||
pergen | |||
}) | |||
end | |||
-- error and stuff | |||
local oddlim | |||
if equave_letter == "o" then | |||
oddlim = "-[[odd limit]]) " | |||
elseif equave_letter == "t" then | |||
oddlim = "-[[throdd limit]]) " | |||
else | |||
oddlim = "-[[integer limit]]) " | |||
end | |||
local string1 = "(" .. limit1 .. oddlim .. acc1 .. "c" | |||
local string2 = "(" .. limit1 .. oddlim .. comp1 .. " notes" | |||
if limit2 ~= "0" then | |||
string1 = string1 .. "; <br> (" .. limit2 .. oddlim .. acc2 .. "c" | |||
string2 = string2 .. "; <br> (" .. limit2 .. oddlim .. comp2 .. " notes" | |||
end | |||
table.insert(data, { | table.insert(data, { | ||
"Minmax error", | "Minmax error", | ||
string1 | |||
}) | }) | ||
table.insert(data, { | table.insert(data, { | ||
"Target scale size", | "Target scale size", | ||
string2 | |||
}) | }) | ||
Line 207: | Line 184: | ||
return result | return result | ||
end | |||
function p.digit2greek(number, purpose) | |||
local greek | |||
if number == "1" then | |||
if purpose == "ploid" then | |||
greek = "ha" | |||
elseif purpose == "cot" then | |||
greek = "mono" | |||
elseif purpose == "decade" then | |||
greek = "deca" | |||
else | |||
greek = "hen" | |||
end | |||
elseif number == "2" then | |||
if purpose == "decade" then | |||
greek = "icosa" | |||
elseif purpose == "unit" then | |||
greek = "do" | |||
else | |||
greek = "di" | |||
end | |||
elseif number == "0" then | |||
if purpose == "unit" then | |||
greek = "" | |||
else | |||
greek = "a" | |||
end | |||
else | |||
if number == "3" then | |||
if purpose == "decade" then | |||
greek = "tria" | |||
else | |||
greek = "tri" | |||
end | |||
elseif number == "4" then | |||
if purpose == "decade" then | |||
greek = "tessera" | |||
else | |||
greek = "tetra" | |||
end | |||
elseif number == "5" then | |||
if purpose == "decade" then | |||
greek = "pente" | |||
else | |||
greek = "penta" | |||
end | |||
elseif number == "6" then | |||
if purpose == "decade" then | |||
greek = "hexe" | |||
else | |||
greek = "hexa" | |||
end | |||
elseif number == "7" then | |||
if purpose == "decade" then | |||
greek = "hebdome" | |||
else | |||
greek = "hepta" | |||
end | |||
elseif number == "8" then | |||
if purpose == "decade" then | |||
greek = "ogdoe" | |||
elseif purpose == "unit" then | |||
greek = "octo" | |||
else | |||
greek = "octa" | |||
end | |||
elseif number == "9" then | |||
if purpose == "decade" then | |||
greek = "enene" | |||
else | |||
greek = "ennea" | |||
end | |||
end | |||
if purpose == "decade" then | |||
greek = greek .. "conta" | |||
end | |||
end | |||
return greek | |||
end | |||
function p.num2greek(number, purpose) | |||
local greek | |||
if string.len(number) == 1 then | |||
greek = p.digit2greek(number, purpose) | |||
elseif string.len(number) == 2 then | |||
local unit = string.char(string.byte(number, 2)) | |||
local decade = string.char(string.byte(number, 1)) | |||
greek = p.digit2greek(unit, "unit") .. p.digit2greek(decade, "decade") | |||
end | |||
return greek | |||
end | |||
function p.digit2greeklet(number, purpose) | |||
local greek | |||
if number == "1" then | |||
if purpose == "decade" then | |||
greek = "iota-" | |||
elseif purpose == "unit" then | |||
greek = "alpha-" | |||
end | |||
elseif number == "2" then | |||
if purpose == "decade" then | |||
greek = "kappa-" | |||
elseif purpose == "unit" then | |||
greek = "beta-" | |||
end | |||
elseif number == "3" then | |||
if purpose == "decade" then | |||
greek = "lambda-" | |||
elseif purpose == "unit" then | |||
greek = "gamma-" | |||
end | |||
elseif number == "4" then | |||
if purpose == "decade" then | |||
greek = "mu-" | |||
elseif purpose == "unit" then | |||
greek = "delta-" | |||
end | |||
elseif number == "5" then | |||
if purpose == "decade" then | |||
greek = "nu-" | |||
elseif purpose == "unit" then | |||
greek = "epsilon-" | |||
end | |||
elseif number == "6" then | |||
if purpose == "decade" then | |||
greek = "xi-" | |||
elseif purpose == "unit" then | |||
greek = "wau-" | |||
end | |||
elseif number == "7" then | |||
if purpose == "decade" then | |||
greek = "omicron-" | |||
elseif purpose == "unit" then | |||
greek = "zeta-" | |||
end | |||
elseif number == "8" then | |||
if purpose == "decade" then | |||
greek = "pi-" | |||
elseif purpose == "unit" then | |||
greek = "eta-" | |||
end | |||
elseif number == "9" then | |||
if purpose == "decade" then | |||
greek = "qoppa-" | |||
elseif purpose == "unit" then | |||
greek = "theta-" | |||
end | |||
elseif number == "0" then | |||
greek = "" | |||
elseif number == "-1" then | |||
greek = "omega-" | |||
end | |||
return greek | |||
end | |||
function p.num2greeklet(number) | |||
local greek | |||
if string.len(number) == 1 then | |||
greek = p.digit2greeklet(number, "unit") | |||
elseif string.len(number) == 2 then | |||
local unit = string.char(string.byte(number, 2)) | |||
local decade = string.char(string.byte(number, 1)) | |||
greek = p.digit2greeklet(decade, "decade") .. p.digit2greeklet(unit, "unit") | |||
end | |||
return greek | |||
end | end | ||
return p | return p |