Sun position
The position of the sun in the sky is given by the azimuth and its elevation. The definition of the elevation is clear (the angular distance between the horizontal plane and the sun). On the other hand there are several conventions for the azimuth. In the NSPOC conventions, the azimuth is measured counterclockwise from the north, so west is 90 degrees, south is 180 degrees and east is 270 degrees.
This also defines the solar plant coordinate system (S=XYZ), where the positive X axes points towards the north, the positive Y axis towards the west and the Z is the height.
SunPosition is a convenient data structure to store the position of the sun. It is initialized using the latitude and a DateTime as arguments.
NSPOC.Sun.SunPosition — TypeSunPosition(lat, t::DateTime; correct=true)Structure to store the position of the Sun. The constructor performs the neccesary calculations.
Here is an example of its use
Activating project at `~/code/julia/NSPOC`julia> nit = 18*6108julia> let lat = 43*pi/180, pl = plot(xlabel="Azimuth", ylabel="Elevation") for t in (DateTime(2023,6,21,2,00,00), DateTime(2023,9,21,2,00,00), DateTime(2023,12,21,2,00,00)) xv = Vector{Float64}(undef, nit) yv = Vector{Float64}(undef, nit) for i in 1:nit t = t + Minute(10) sp = SunPosition(lat, t, correct=true) xv[i] = sp.azm*180/pi yv[i] = sp.alt*180/pi end pl = plot!(xv,yv,label=Dates.format(t, "dd u")) end endQStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-alberto'

In this plot the path of the sun on the sky is plotted at several moments of three different days: 21st of June (blue), 21st of September (red) and 21st of December (green). The sun travels these curves from the right to the left (i.e. at sunrise the azimuth angle is larger than 180 degrees).
Other methods
NSPOC.Sun.declination — Functiondeclination(nd::Union{Integer,Date,DateTime})Returns the declination in radians of the sun for day of the year nd. The first day of the year (January the 1st) is day zero by convention.
NSPOC.Sun.lightdir — Functionlightdir(sp::SunPosition)
lightdir(lat, t::DateTime; correct=true)Given a certain sun position, returns a unit vector pointing from the sun to earth.