Advertisement
Matthen

Solstice

Jun 21st, 2013
367
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. lat = 55.95; long = -3.2;
  2. decl[d_: Integer,
  3. h_: Real](*declination of the sun in rad on day d after Jan 1 at h \
  4. hrs*):= .006918 - .399912 Cos[\[Gamma][d, h]] +
  5. 0.070257 Sin[\[Gamma][d, h]] - .006758 Cos[
  6. 2 \[Gamma][d, h]] + .000907 Sin[2 \[Gamma][d, h]] - .002697 Cos[
  7. 3 \[Gamma][d, h]] + .00148 Sin[3 \[Gamma][d, h]];
  8. hra[d_, h_,
  9. long_](*hour angle in rad*):= \[Pi] ((60 h + tcf[d, h, long])/4 -
  10. 180)/180;
  11. tcf[d_, h_, long_](*time correction factor in min*):=
  12. eot[d, h] - 4 long + 60 (Round[long/15](*theoretical timezone*) );
  13. eot[d_, h_](*equation of time in min*):=
  14. 229.18 (0.000075 + 0.001868 Cos[\[Gamma][d, h]] -
  15. 0.032077 Sin[\[Gamma][d, h]] - 0.014615 Cos[2 \[Gamma][d, h]] -
  16. 0.040849 Sin[2 \[Gamma][d, h]]);
  17. az[d_, h_, lat_, long_](*azimuth of the sun in rad*):=
  18. Module[{a},
  19. a = ArcTan[(Tan[decl[d, h]] Cos[lat Degree] -
  20. Sin[lat Degree] Cos[hra[d, h, long]]), -Sin[hra[d, h, long]]];
  21. If[a < 0, a + 2 \[Pi], a]];
  22. n = 8;
  23. psuns = Table[(\[Pi]/2 -
  24. alt[365 Floor[t]/n, Sign[lat] 12, Abs@lat, long]) {Sin[#],
  25. Cos[#]} &[az[Floor[t] 365/n, Sign[lat] 12, Abs@lat, long]], {t,
  26. 0, n}];
  27. Manipulate[
  28. Module[{psun, \[Tau]},
  29. \[Tau] = t - Floor[t];
  30. psun = (\[Pi]/2 -
  31. alt[365 Floor[t]/n, Sign[lat] 24 \[Tau], Abs@lat,
  32. long]) {Sin[#], Cos[#]} &[
  33. az[Floor[t] 365/n, Sign[lat] 24 \[Tau], Abs@lat, long]];
  34.  
  35. Show[
  36. Graphics[{White, Disk[{0, 0}, 1.65]
  37. },
  38. Background -> Black, PlotRange -> 1.66],
  39. ParametricPlot[
  40. With[{shr = Sign[lat] (hour)},
  41. (\[Pi]/2 - alt[d, shr, Abs@lat, long]) {Sin[#], Cos[#]} &[
  42. az[d, shr, Abs@lat, long]]
  43. ]
  44. , {d, 0, 365}, {hour, 0, 24}, PlotPoints -> 12,
  45. PlotStyle -> Directive[Opacity[0.1], Red], MeshStyle -> Orange],
  46. Graphics[{
  47. Yellow, Disk[psun, 0.05],
  48. Darker@Yellow,
  49. Table[Disk[p, 0.05], {p, psuns[[;; Floor[t + 0.5]]]}],
  50. Line[psuns[[;; Floor[t + 0.5]]]]
  51. }]
  52. ]
  53. ],
  54. {t, 0, n}]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement