- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
/sunpos.lua
r1 r3 1 1 local math, os = math, os 2 -- local timeutils = require "timeutils" 3 module (...) 2 4 3 5 -- … … 21 23 local function fractyear (date) 22 24 return (2*math.pi/365.25) * (date.yday + fractday (date)) 25 end 26 27 local function solartime(date) 28 return 23 29 end 24 30 … … 48 54 49 55 -- sun zenith angle 50 localfunction sunzenithangle (date, place)56 function sunzenithangle (date, place) 51 57 local d = sundeclin (date) 52 58 local sha = solarhourangle (date, place) … … 57 63 58 64 -- solar elevation (degrees) 59 localfunction sunelevation (date, place)65 function sunelevation (date, place) 60 66 return 90 - math.deg(sunzenithangle (date, place)) 61 67 end 62 68 63 localfunction sunazimuthangle (date, place)69 function sunazimuthangle (date, place) 64 70 local d = sundeclin (date) 65 71 local sza = sunzenithangle (date, place) … … 68 74 end 69 75 70 71 72 --73 testdate = {yday=319,hour=10,min=35,sec=0}74 testplace= {latitude = 48+49/60, longitude=2+17/60+23/3600}75 print ('g =',fractyear (testdate))76 print ('D =',sundeclin (testdate))77 print ('TC =',timecorrection (testdate))78 print ('SHA =',math.deg(solarhourangle (testdate, testplace)))79 print ('SZA =',math.deg(sunzenithangle (testdate, testplace)))80 print ('elev =',sunelevation (testdate, testplace))81 print ('AZ =',math.deg(sunazimuthangle(testdate, testplace)))82 83 print ('elev local = ',sunelevation (os.date('*t'), {longitude=77.05, latitude=-12.05})) -
/timeutils.lua
r1 r3 1 1 local type = type 2 2 local os = os 3 3 … … 7 7 function lastmidnight (time) 8 8 local d = os.date('*t', time) 9 return os.time ({year=d.year, month=d.month, day=d.day })9 return os.time ({year=d.year, month=d.month, day=d.day, hour=0}) 10 10 end 11 11 … … 16 16 end 17 17 18 function localtoUTC(time, timezone) 19 time = time or os.time() 20 if type(time) == "table" then 21 time = os.time(time) 22 end 23 24 local d = os.date('*t', time) 25 if d.isdst then timezone = timezone+1 end 26 d = os.date('*t', time - timezone*3600) 27 return d 28 end
Note: See TracChangeset
for help on using the changeset viewer.