I am excited to announce the release of my first public Julia package, SolarPosition.jl.
TLDR
SolarPosition.jl is a common interface to a variety of solar positioning algorithms which have been rewritten from scratch in Julia.
Example usage
julia> using SolarPosition, Dates, TimeZones, DataFrames
julia> timezone = tz"Asia/Kolkata"
Asia/Kolkata (UTC+05:30)
julia> obs = Observer(28.6, 77.2, 0.0)
Observer(latitude=28.6ยฐ, longitude=77.2ยฐ, altitude=0.0m)
julia> times = collect(ZonedDateTime(DateTime(2019), tz):Hour(1):ZonedDateTime(DateTime(2020), timezone))
julia> positions = solar_position(obs, times)
julia> df = DataFrame(positions)
8761ร3 DataFrame
Row โ azimuth elevation zenith
โ Float64 Float64 Float64
โโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
1 โ 314.042 -82.2189 172.219
2 โ 57.3871 -80.2452 170.245
3 โ 81.0308 -67.8108 157.811
4 โ 90.0973 -54.6909 144.691
5 โ 96.4595 -41.5545 131.555
6 โ 102.165 -28.5678 118.568
โฎ โ โฎ โฎ โฎ
8757 โ 258.871 -31.0619 121.062
8758 โ 264.625 -44.0833 134.083
8759 โ 271.261 -57.2304 147.23
8760 โ 281.445 -70.3099 160.31
8761 โ 314.092 -82.2513 172.251
8750 rows omitted
Features
- Supports PSA, NOAA, Walraven, USNO and the gold standard SPA algorithm.
- Support for more algorithms can be added as PRs by following the supplied guide.
- All algorithms are implemented in Julia, so no interfaces to C or python are required.
- All algorithms are validated using reference implementations.
- Tables.jl interface so you can easily work with solar positions in dataframes or any other container that supports the tables interface.
- Efficient caching of time-independent quantities through the
Observerstruct. - Refraction models are abstracted from the base algorithms so you can mix and match refraction and positioning models as you see fit. By default, each algorithm will use the refraction model defined by its accompanying paper reference.
Extensions
- Full multithreading support for all algorithms via OhMyThreads.jl extension.
- Can be intergrated into symbolic workflows through a ModelingToolkit.jl extension that supplies a
SolarPositionBlockcomponent. - Makie.jl extension for making some basic plots.
Why SolarPosition.jl?
The primary application I had in mind when writing this package is solar photovoltaics engineering, but it can be used in any application where you need to know something about the position of the sun.
A second reason is that almost every programming language has a similar package offering solar positioning algorithms, and Julia didnโt have one yet (that I could find, I did find a few scripts scattered here and there). Python has solposx and pvlib, R has solarPos, Rust has spa-rs and so on. Now Julia has one too!
Feedback
As this is my first โseriousโ Julia package, I am looking for feedback. Anything is welcome. You can either put a comment in this thread, or just make a PR or an issue on the GH repository.
