DateTime not valid


When I try to get the date for an exposure with

import lsst.daf.persistence
butler = lsst.daf.persistence.Butler('./data/')
exp = butler.get('raw', dataId={'filter': 'VISTA-Ks', 'visit': 658653, 'dateObs':'2012-11-23', 'hdu':1})
from lsst.daf.base import DateTime

It throws an error:

File "include/lsst/daf/base/DateTime.h", line 231, in void lsst::daf::base::DateTime::_assertValid() const
    DateTime not valid {0}
lsst::pex::exceptions::RuntimeError: 'DateTime not valid'

Is this a problem with the format I am using for dateObs or dateTai during ingestion? I have experimented with various different formats and can’t remove the error. Looking at the cpp code in DateTime.h it may be because I am using ‘values that overlap DateSystem’ but I am not sure how to fix that.

Any help would be very welcome as it prevents me running processCcd with calibration presumably because it needs the date to correct for proper motions in the reference catalogue.

Many thanks,


I think I have answered this myself. I’ll leave the solution here for future searchers. The date must be set in the script. This is handled automatically by astro_metadata_translator in the gen3 obs packages. Otherwise you need to add something like:

    argDict["exposureTime"] = self.popFloat(md, 'EXPTIME')
    startDate = self.popIsoDate(md, "DATE-OBS")
    argDict["date"] = self.offsetDate(startDate, 0.5*argDict["exposureTime"])

to the modified MakeRawVisitInfo class.

1 Like

If you look at obs_lsst you will see that I use astro_metadata_translator for both gen2 and gen3 in that package.

1 Like