Closed stefanengel closed 3 years ago
Oh that's a very good point. Indeed AstronomicalObject
conforms to the CelestialBody
protocol, which gives access to the riseTransitSetTimes
function. This is an inconsistency, and I thank you for pointing it out!
Now, the computation of Rise and Set times of a planet is based on an interpolation between 3 days where coordinates are not the same. This condition is not satisfied by an Astronomical object...
Hence, one must search a bit a solution.
@stefanengel I have implemented a solution (which also homogenize the return types of twilights).
But I would rather prefer make a release with unit tests validating the result. I couldn't find any reliable source so far. Do you have, for a given location on Earth, (fairly) precise of expected rise and set times (< 1 minute) of an object?
Note that I've pushed my code, and now the project includes a Swift Playground. Your example is inside it. You can use it to test the results.
@onekiloparsec thank you for the solution! :)
Unfortunately I do not have examples with highly accurate rise and set times, I use Stellarium most of the time. The playground example gives me plausible results as far as I can tell.
Testing a bit further I found that for polaris I do not get rise and set times for my current location (which is expected) but there is no transitError as well:
let polaris = AstronomicalObject(
name: "Polaris",
coordinates: EquatorialCoordinates(rightAscension: Hour(.plus, 2, 31, 47.08), declination: Degree(.plus, 89, 15, 50.9)
),
julianDay: JulianDay(year: 2020, month: 9, day: 6)
)
let results = polaris.riseTransitSetTimes(
for: GeographicCoordinates(
positivelyWestwardLongitude: Degree(.plus, 7, 46, 42),
latitude: Degree(.plus, 49, 9, 3),
altitude: 210)
)
If I understand the api correctly there should be a CelestialBodyTransitError of type alwaysAboveAltitude?
Hello @stefanengel You are perfectly right. This mistake is due to a inconsistency in using the RiseTransitSetTimes
in the Earth twilights
function. I have corrected the code. I've added a test, and will try to add some more, then I'll make a release with all these fixed.
SwiftAA v2.3 released, with updated interface for tiwlights and rise, set, times. As far as I can tell, I can now close this issue. Feel free to open a new one if you think something's still missing / incorrect.
Hi there,
thank you for this awesome framework! Is it possible to use SwiftAA to calculate when a star will rise and set for a given date and location on earth?
I tried the following:
Unfortunately it doesn't work since riseTransitSetTimes will call the unimplemented initializer of AstronomicalObject and cause a fatalError. Is there another way to get the rise and set times of a star?