0
$\begingroup$

When I use Mathematica calls to WolframAlpha, it clearly knows about the motion of the sun, so I can request the solar declination at any date/time:

enter image description here

enter image description here

But I'm having great difficulty crafting a query that goes the other way. "What date and time does the solar declination exactly equal -18 degrees?"

Any thoughts would be greatly appreciated.

$\endgroup$

1 Answer 1

1
$\begingroup$

The solar declination for a given date d can be found with

SunPosition[d, CelestialSystem -> "Equatorial"]

as stated here.

We can use FindRoot to invert this like so:

t0 = AbsoluteTime[Now];

declination[t_?NumericQ] := QuantityMagnitude[
  SunPosition[DateObject[t0 + t], CelestialSystem -> "Equatorial"][[-1]], 
  "AngularDegrees"
]

toffset = t /. FindRoot[declination[t] == -18, {t, 0}, Method -> "Secant"]
748714.5223444804`
date = DateObject[t0 + toffset]

SunPosition[date, CelestialSystem -> "Equatorial"]

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.