Function Repository Resource:

SolarAzimuthTime

Source Notebook

Compute the time when the Sun passes a certain azimuth

Contributed by: Sander Huisman

ResourceFunction["SolarAzimuthTime"][loc, date, azimuth]

calculates at what point on the day date the sun has the azimuth azimuth at the location loc.

Details

The calculation is independent of the altitude ("height") of the sun. Therefore it can be that the sun is below the horizon in the calculation.
Location loc can be specified as an Entity object, assuming it represents an object with geographic coordinates, or it can be a latitude/longitude pair, assuming degrees as units.
The azimuth azimuth should be in degrees.

Examples

Basic Examples (1) 

Determine when the facade of the author's building gets sunlight on July 2nd, 2023:

In[1]:=
ResourceFunction["SolarAzimuthTime"][
 Entity["City", {"Enschede", "Overijssel", "Netherlands"}], {2023, 7, 2}, 193]
Out[1]=

Applications (3) 

Compare the time when the sun is exactly south for Amsterdam and 100 km east of Amsterdam:

In[2]:=
loc = Entity["City", {"Amsterdam", "NoordHolland", "Netherlands"}];
date = {2023, 7, 2};
azimuth = 180;
{
 ResourceFunction["SolarAzimuthTime"][loc, date, azimuth],
 ResourceFunction["SolarAzimuthTime"][
  GeoDestination[loc, GeoDisplacement[{Quantity[100, "Kilometers"], "E"}]], date, azimuth]
 }
Out[5]=

Calculate the difference:

In[6]:=
UnitConvert[DateDifference @@ %, "Hours"]
Out[6]=

This is roughly what you expect for this latitude:

In[7]:=
Quantity[100, "Kilometers"]/(2 Pi Entity["Planet", "Earth"][
    EntityProperty["Planet", "Radius"]] Cos[Latitude[loc]]/24)
Out[7]=

Possible Issues (1) 

Though the sun might have a certain azimuth, it does not mean that the sun is above the horizon. This especially holds for places that have periods of extended darkness:

In[8]:=
loc = Entity["Island", "Spitsbergen"];
date = {2022, 12, 15};
azimuth = 180;
DaylightQ[loc, ResourceFunction["SolarAzimuthTime"][loc, date, azimuth]]
Out[11]=

Neat Examples (1) 

Plot the yearly variation of the time when the sun is perfectly south in Paris:

In[12]:=
loc = Entity["City", {"Paris", "IleDeFrance", "France"}];
azimuth = 180;
data = Table[{d, DateValue[ResourceFunction["SolarAzimuthTime"][loc, d, azimuth], "HourExact"]}, {d, DateRange[{2023, 1, 1}, {2023, 12, 31}, "Week"]}];
DateListPlot[data, FrameLabel -> {"Month", "Time during the day [Hour]"}]
Out[15]=

Publisher

SHuisman

Requirements

Wolfram Language 13.0 (December 2021) or above

Version History

  • 1.0.0 – 13 July 2023

Related Resources

License Information