Module:HostStars: Difference between revisions
From MicrasWiki
Jump to navigationJump to search
NewZimiaGov (talk | contribs) No edit summary |
NewZimiaGov (talk | contribs) No edit summary |
||
| Line 1: | Line 1: | ||
--------------------------------------------------------- | --------------------------------------------------------- | ||
-- Module: HostStars_AccurateMap | -- Module: HostStars_AccurateMap | ||
-- | -- This module checks star visibility at midnight (00:00) | ||
-- for Vaeringheim (~44°N) on a 183-day Micras year. | |||
-- | |||
-- | -- | ||
-- | -- Usage on a wiki page: | ||
-- | -- {{#invoke:HostStars_AccurateMap|starsForTonight}} | ||
-- | |||
-- Explanation: | |||
-- 1) We find dayOfYear (0..182) from an epoch. | |||
-- 2) If star's "chart latitude" >= 46°, treat as circumpolar => always up. | |||
-- 3) Otherwise, star is visible for about half the year (±45 days) around a | |||
-- "peak day" we define from starLat. Then we check if dayOfYear is in range. | |||
--------------------------------------------------------- | --------------------------------------------------------- | ||
| Line 25: | Line 30: | ||
local fracYear = totalDays / daysPerYear | local fracYear = totalDays / daysPerYear | ||
local psscYear= math.floor(fracYear) | local psscYear= math.floor(fracYear) | ||
local dayOfYear= math.floor((fracYear-psscYear)*daysPerYear) + 1 | local dayOfYear= math.floor((fracYear - psscYear)*daysPerYear) + 1 | ||
return dayOfYear | return dayOfYear | ||
end | end | ||
--------------------------------------------------------- | --------------------------------------------------------- | ||
-- 2. Our star data (N. hemisphere top image). | -- 2. Our star data (N. hemisphere "top image"). | ||
-- We'll | -- We'll store a "lat" (like declination). | ||
--------------------------------------------------------- | --------------------------------------------------------- | ||
local starDataNorth = { | local starDataNorth = { | ||
| Line 78: | Line 83: | ||
--------------------------------------------------------- | --------------------------------------------------------- | ||
-- 5. For non-circumpolar stars, | -- 5. For non-circumpolar stars, define a "peak day" | ||
-- | -- and a ±45-day window => half-year visible at midnight | ||
- | |||
--------------------------------------------------------- | --------------------------------------------------------- | ||
local function isStarUpAtMidnight(starLat, dayOfYear) | local function isStarUpAtMidnight(starLat, dayOfYear) | ||
-- | -- "peak day" = starLat * 2 mod 183 | ||
local peakDay = (starLat * 2) % 183 | |||
local peakDay = (starLat*2) % 183 | |||
-- | local halfWindow = 45 -- ~1/2 year | ||
local diff = dayOfYear - peakDay | local diff = dayOfYear - peakDay | ||
diff = (diff + 183) % 183 -- wrap around | |||
diff = (diff + 183) % 183 -- | |||
if diff>91.5 then | if diff>91.5 then | ||
diff = 183 - diff -- symmetrical | diff = 183 - diff -- symmetrical | ||
| Line 103: | Line 102: | ||
--------------------------------------------------------- | --------------------------------------------------------- | ||
-- 6. | -- 6. The main function: "starsForTonight" | ||
-- - Renamed from "starsForMidnight" to fix function error | |||
--------------------------------------------------------- | --------------------------------------------------------- | ||
function p. | function p.starsForTonight(frame) | ||
local dayOfYear = getDayOfYearForPSSC() | local dayOfYear = getDayOfYearForPSSC() | ||
local out = {} | local out = {} | ||
table.insert(out, "=== Stars Visible at Midnight in Vaeringheim (44°N) ===\n") | table.insert(out, "=== Stars Visible at Midnight in Vaeringheim (44°N) ===\n") | ||
table.insert(out, string.format("''Day %d of Micras Year | table.insert(out, string.format("''Day %d of Micras' 183-day Year''\n\n", dayOfYear)) | ||
table.insert(out, '{| class="wikitable" style="width:100%; text-align:left;"\n') | table.insert(out, '{| class="wikitable" style="width:100%; text-align:left;"\n') | ||
table.insert(out, "! Star Name !! Star Class !! Circumpolar? !! Visible | table.insert(out, "! Star Name !! Star Class !! Circumpolar? !! Visible @ 00:00? !! Note\n") | ||
for _, star in ipairs(starDataNorth) do | for _, star in ipairs(starDataNorth) do | ||
| Line 121: | Line 121: | ||
if circ then | if circ then | ||
isUp = true | isUp = true | ||
note="Circumpolar => | note = "Circumpolar => above horizon all year" | ||
else | else | ||
local val = isStarUpAtMidnight(star.lat, dayOfYear) | local val = isStarUpAtMidnight(star.lat, dayOfYear) | ||
isUp = val | isUp = val | ||
note=" | note = "Seasonal ~ half-year window" | ||
end | end | ||
Revision as of 06:58, 27 December 2024
Documentation for this module may be created at Module:HostStars/doc
---------------------------------------------------------
-- Module: HostStars_AccurateMap
-- This module checks star visibility at midnight (00:00)
-- for Vaeringheim (~44°N) on a 183-day Micras year.
--
-- Usage on a wiki page:
-- {{#invoke:HostStars_AccurateMap|starsForTonight}}
--
-- Explanation:
-- 1) We find dayOfYear (0..182) from an epoch.
-- 2) If star's "chart latitude" >= 46°, treat as circumpolar => always up.
-- 3) Otherwise, star is visible for about half the year (±45 days) around a
-- "peak day" we define from starLat. Then we check if dayOfYear is in range.
---------------------------------------------------------
local p = {}
---------------------------------------------------------
-- 1. dayOfYear (Micras-based):
-- 183-day orbit, epoch = 6 Aug 1999 => day=0
---------------------------------------------------------
local function getDayOfYearForPSSC()
local startDate = os.time({year=1999, month=8, day=6})
local secPerDay = 86400
local daysPerYear = 183
local currentTime = os.time()
local totalDays = math.floor((currentTime - startDate) / secPerDay)
local fracYear = totalDays / daysPerYear
local psscYear= math.floor(fracYear)
local dayOfYear= math.floor((fracYear - psscYear)*daysPerYear) + 1
return dayOfYear
end
---------------------------------------------------------
-- 2. Our star data (N. hemisphere "top image").
-- We'll store a "lat" (like declination).
---------------------------------------------------------
local starDataNorth = {
{ name="Agave", starClass="M", lat=29.5 },
{ name="Amaäz", starClass="K", lat=31 },
{ name="Amáenu", starClass="G", lat=45 },
{ name="Amap", starClass="A", lat=55 },
{ name="Amazä", starClass="F", lat=39 },
{ name="Atämios", starClass="F", lat=56 },
{ name="Aprobelle", starClass="A", lat=59 },
{ name="Azos", starClass="Galaxy", lat=60 },
{ name="Bebeakaus", starClass="K", lat=30.5 },
{ name="Bulhanu", starClass="A", lat=40 },
{ name="Crösacío", starClass="K", lat=17 },
{ name="Danaß", starClass="A", lat=67 },
{ name="Dilëtaz", starClass="G", lat=36 },
{ name="Dranamos", starClass="A", lat=58 },
{ name="Gaht", starClass="G", lat=29 },
{ name="Häpi", starClass="F", lat=78 },
{ name="Hazaméos", starClass="A", lat=72 },
{ name="Liléigos", starClass="F", lat=18 },
{ name="Nyama", starClass="F", lat=64 },
{ name="Ocananus", starClass="F", lat=60.5 },
{ name="Orebele", starClass="F", lat=22 },
{ name="Osiríos", starClass="G", lat=53 },
{ name="Pythe", starClass="A", lat=45 },
{ name="Sanashalo", starClass="G", lat=27 },
{ name="Tä", starClass="F", lat=39.5 },
{ name="Vï", starClass="A", lat=46 },
{ name="Wedíos", starClass="A", lat=54 },
}
---------------------------------------------------------
-- 3. Our location: Vaeringheim ~44°N
---------------------------------------------------------
local observerLat = 44
---------------------------------------------------------
-- 4. Check "circumpolar?"
-- For star-lat >= (90 - observerLat)=46 => circumpolar
---------------------------------------------------------
local function isCircumpolar(starLat)
local limit = 90 - observerLat
return (starLat >= limit)
end
---------------------------------------------------------
-- 5. For non-circumpolar stars, define a "peak day"
-- and a ±45-day window => half-year visible at midnight
---------------------------------------------------------
local function isStarUpAtMidnight(starLat, dayOfYear)
-- "peak day" = starLat * 2 mod 183
local peakDay = (starLat * 2) % 183
local halfWindow = 45 -- ~1/2 year
local diff = dayOfYear - peakDay
diff = (diff + 183) % 183 -- wrap around
if diff>91.5 then
diff = 183 - diff -- symmetrical
end
return (diff <= halfWindow)
end
---------------------------------------------------------
-- 6. The main function: "starsForTonight"
-- - Renamed from "starsForMidnight" to fix function error
---------------------------------------------------------
function p.starsForTonight(frame)
local dayOfYear = getDayOfYearForPSSC()
local out = {}
table.insert(out, "=== Stars Visible at Midnight in Vaeringheim (44°N) ===\n")
table.insert(out, string.format("''Day %d of Micras' 183-day Year''\n\n", dayOfYear))
table.insert(out, '{| class="wikitable" style="width:100%; text-align:left;"\n')
table.insert(out, "! Star Name !! Star Class !! Circumpolar? !! Visible @ 00:00? !! Note\n")
for _, star in ipairs(starDataNorth) do
local circ = isCircumpolar(star.lat)
local isUp
local note=""
if circ then
isUp = true
note = "Circumpolar => above horizon all year"
else
local val = isStarUpAtMidnight(star.lat, dayOfYear)
isUp = val
note = "Seasonal ~ half-year window"
end
local circStr = circ and "Yes" or "No"
local upStr = isUp and "Yes" or "No"
table.insert(out, "|-\n")
table.insert(out, string.format("| %s || %s || %s || %s || %s\n",
star.name, star.starClass, circStr, upStr, note
))
end
table.insert(out, "|}\n")
return table.concat(out)
end
return p