As the next step, I have made kind of unit tests on the calculator functions with elm repl, taking the expect values of the results from NOAA Solar Calculator.
Below is a short example. First are the required functions imported from the file Main.elm:
> import Main exposing (Model, getCent, getNoon, sunRise, sunSet, getDayLength, mnToHrMn, sunDeclination, solAzimuth)
Next is the input data set into model structure for the city center Helsinki:
> helsinki = Model β2022β β9β β4β β10β β19β β29β β60.17β β24.94β β3β
{ day = β4β, hour = β10β, latitude = β60.17β, longitude = β24.94β, minute = β19β, month = β9β, second = β29β, timezone = β3β, year = β2022β }
: Model
Calculations are performed for the expected noon time according to the NOAA calculator, 10:19:29 UTC which should result the solar azimuth 180.0Β°.
> helsinki.latitude
β60.17β : String
> mnToHrMn <| 60*(getDayLength helsinki) β expect 13:55
β13:54:21β : String
> mnToHrMn <| getNoon helsinki β expect 13:19:29
β13:19:18β : String
> mnToHrMn <| sunRise helsinki β expect 06:21
β06:22:08β : String
> mnToHrMn <| sunSet helsinki β expect 20:16
β20:16:29β : String
> 90 - Main.solZenith helsinki β Altitude without refraction corr.
36.93729566691127 : Float
> Main.refractCorrectAltitude helsinki β expect 36.96Β°
36.958715879793985 : Float
> solAzimuth helsinki β expect 180.05Β°
180.0521205431728 : Float
> sunDeclination helsinki β expect 7.11Β°
7.107305165343985 : Float
Generally, it can be concluded, the elm version is about as accurate as NOAA calculator. However, NOAA gives the the noon time sligthly deviating from the right value for azimuth 180 degrees and my calculator repeats that for the same given time of course.
I have made the next example during the same session for the German City Hamburg.
The accuracy is here also pretty good. This time, I have adjusted the time of NOAA so that it results as near as possible the right azimuth 180 and now, both calculators give exactly the same values.
> hamburg = Model β2022β β9β β4β β11β β19β β9β β53.57β β9.98β β2β
{ day = β4β, hour = β11β, latitude = β53.57β, longitude = β9.98β, minute = β19β, month = β9β, second = β9β, timezone = β2β, year = β2022β }
: Model
hamburg.latitude
β53.57β : String
mnToHrMn <| 60*(getDayLength hamburg) β expect 13:29
β13:29:08β : String
mnToHrMn <| getNoon hamburg β expect 13:19:18
β13:19:08β : String
mnToHrMn <| sunRise hamburg β expect 06:34
β06:34:34β : String
mnToHrMn <| sunSet hamburg β expect 20:03
β20:03:42β : String
90 - Main.solZenith hamburg β Altitude without refraction correction
43.522008630661276 : Float
Main.refractCorrectAltitude hamburg β Altitude with refr. corr., expect 43.54Β°
43.538979722952796 : Float
solAzimuth hamburg β expect 180.00Β°
180.00283296569495 : Float
sunDeclination hamburg β expect 7.09Β°
7.0920086610518585 : Float
As the next thing, I could calculate the Sun altitude, just at the calculated sunrise or sunset time, for any location. How ever, I leave that for you interested in the topic