Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- lat = 55.95; long = -3.2;
- decl[d_: Integer,
- h_: Real](*declination of the sun in rad on day d after Jan 1 at h \
- hrs*):= .006918 - .399912 Cos[\[Gamma][d, h]] +
- 0.070257 Sin[\[Gamma][d, h]] - .006758 Cos[
- 2 \[Gamma][d, h]] + .000907 Sin[2 \[Gamma][d, h]] - .002697 Cos[
- 3 \[Gamma][d, h]] + .00148 Sin[3 \[Gamma][d, h]];
- hra[d_, h_,
- long_](*hour angle in rad*):= \[Pi] ((60 h + tcf[d, h, long])/4 -
- 180)/180;
- tcf[d_, h_, long_](*time correction factor in min*):=
- eot[d, h] - 4 long + 60 (Round[long/15](*theoretical timezone*) );
- eot[d_, h_](*equation of time in min*):=
- 229.18 (0.000075 + 0.001868 Cos[\[Gamma][d, h]] -
- 0.032077 Sin[\[Gamma][d, h]] - 0.014615 Cos[2 \[Gamma][d, h]] -
- 0.040849 Sin[2 \[Gamma][d, h]]);
- az[d_, h_, lat_, long_](*azimuth of the sun in rad*):=
- Module[{a},
- a = ArcTan[(Tan[decl[d, h]] Cos[lat Degree] -
- Sin[lat Degree] Cos[hra[d, h, long]]), -Sin[hra[d, h, long]]];
- If[a < 0, a + 2 \[Pi], a]];
- n = 8;
- psuns = Table[(\[Pi]/2 -
- alt[365 Floor[t]/n, Sign[lat] 12, Abs@lat, long]) {Sin[#],
- Cos[#]} &[az[Floor[t] 365/n, Sign[lat] 12, Abs@lat, long]], {t,
- 0, n}];
- Manipulate[
- Module[{psun, \[Tau]},
- \[Tau] = t - Floor[t];
- psun = (\[Pi]/2 -
- alt[365 Floor[t]/n, Sign[lat] 24 \[Tau], Abs@lat,
- long]) {Sin[#], Cos[#]} &[
- az[Floor[t] 365/n, Sign[lat] 24 \[Tau], Abs@lat, long]];
- Show[
- Graphics[{White, Disk[{0, 0}, 1.65]
- },
- Background -> Black, PlotRange -> 1.66],
- ParametricPlot[
- With[{shr = Sign[lat] (hour)},
- (\[Pi]/2 - alt[d, shr, Abs@lat, long]) {Sin[#], Cos[#]} &[
- az[d, shr, Abs@lat, long]]
- ]
- , {d, 0, 365}, {hour, 0, 24}, PlotPoints -> 12,
- PlotStyle -> Directive[Opacity[0.1], Red], MeshStyle -> Orange],
- Graphics[{
- Yellow, Disk[psun, 0.05],
- Darker@Yellow,
- Table[Disk[p, 0.05], {p, psuns[[;; Floor[t + 0.5]]]}],
- Line[psuns[[;; Floor[t + 0.5]]]]
- }]
- ]
- ],
- {t, 0, n}]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement