This PR fixes an off-by-one bug in the YEARMMDD vs. MJD of the sunset, originally discovered with code like this:
from desisurvey.nightcal import getCalAll
from astropy.time import Time
from astropy import units
#- 19:00 UTC is noon Arizona
start = Time('2019-09-01T19:00:00')
end = Time('2019-10-01T19:00:00')
ephem = getCalAll(start, end, use_cache=False)
#- AZ local time of sunset
t = Time(ephem['MJDsunset'][0], format='mjd') - 7*units.hour
print(t.to_datetime(), 'vs', ephem['dirName'][0])
Which results in:
2019-09-02 18:50:34.175709 vs b'20190901'
Note: September 2 vs. September 1, i.e. the MJD of the sunset is being reported for the next day, not the current day.
I didn't fully discover why the original code didn't work, but this fix uses time conversions like
This PR includes unit tests that check the consistency of the MJD for the sunset, sunrise, and twilights compared to the YEARMMDD dirname in the ephemeris. These test fail on current master and pass with this fix.
This PR fixes an off-by-one bug in the YEARMMDD vs. MJD of the sunset, originally discovered with code like this:
Which results in:
Note: September 2 vs. September 1, i.e. the MJD of the sunset is being reported for the next day, not the current day.
I didn't fully discover why the original code didn't work, but this fix uses time conversions like
This PR includes unit tests that check the consistency of the MJD for the sunset, sunrise, and twilights compared to the YEARMMDD dirname in the ephemeris. These test fail on current master and pass with this fix.