You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SolarPosition.jl provides a plotting extension for [Makie.jl](https://makie.juliaplots.org/stable/).
4
8
9
+
The main plotting function is [`analemmas!`](@ref).
10
+
5
11
To use it, simply import both the `SolarPosition` and `Makie` packages:
6
12
7
13
```@example plotting
@@ -11,72 +17,61 @@ using CairoMakie
11
17
# supporting packages
12
18
using Dates
13
19
using TimeZones
14
-
using DataFrames
15
20
```
16
21
17
22
This example notebook is based on the [pvlib sun path example](https://pvlib-python.readthedocs.io/en/stable/gallery/solar-position/plot_sunpath_diagrams.html).
18
23
19
24
## Basic Sun Path Plotting
20
25
21
-
Let's start by defining an observer location and calculating solar positions for a whole year:
26
+
The plotting functions generate analemmas (figure-8 patterns showing the sun's position at
27
+
each hour of the day throughout the year). You simply provide an observer location and
28
+
the year you want to visualize:
22
29
23
30
```@example plotting
24
31
# Define observer location (New Delhi, India)
25
32
# Parameters: latitude, longitude, altitude in meters
26
-
tz = tz"Asia/Kolkata"
27
33
obs = Observer(28.6, 77.2, 0.0)
28
-
29
-
# Generate hourly timestamps for a whole year
30
-
times = collect(ZonedDateTime(DateTime(2019), tz):Hour(1):ZonedDateTime(DateTime(2020), tz))
31
-
32
-
# This returns a StructVector with solar position data
33
-
positions = solar_position(obs, times)
34
-
35
-
# For plotting, we need to create a DataFrame that includes the timestamps
36
-
df = DataFrame(positions)
37
-
df.datetime = times
38
-
39
-
# We can inspect the first few entries
40
-
first(df, 5)
34
+
tz = TimeZone("Asia/Kolkata")
35
+
year = 2019
41
36
```
42
37
43
38
## Simple Sun Path Plot in Cartesian Coordinates
44
39
45
-
We can visualize solar positions in cartesian coordinates using the `sunpathplot`
46
-
function:
40
+
We can visualize solar positions in cartesian coordinates using the `analemmas!`
41
+
function. The function automatically generates analemmas for all 24 hours of the day:
0 commit comments