Hi,
I’m following this tutorial: The LSST Science Pipelines — LSST Science Pipelines and I’ve ran the first step “single_frame” task a few times. Each time it runs it produces different results: if I go through all calexps in the output collection (butler.registry.queryDatasets("calexp", collections=collection)), and look at their sky coverage (calexp width, height and WCS mapping), and then find the total coverage of the whole collection (max and min ra, dec coordinates), I get different results each time it runs. And I’m starting it like this (verbatim what’s in the tutorial):
Can you define what you mean by “different results”? Do you mean that the number of outputs differ or that the number of outputs are the same but the pixel values differ?
fi = sys.float_info
minratot = mindectot = minmjdtot = fi.max
maxratot = maxdectot = maxmjdtot = fi.min
for ref in butler.registry.queryDatasets("calexp", collections=in_collection):
calexp = butler.get('calexp', dataId=ref.dataId.full, collections=in_collection)
mjd = calexp.getMetadata().toDict()['MJD']
if mjd < minmjdtot:
minmjdtot = mjd
if mjd > maxmjdtot:
maxmjdtot = mjd
w, h = calexp.width, calexp.height
p = calexp.wcs.pixelToSky(0, 0)
ra0 = p.getRa().asDegrees()
dec0 = p.getDec().asDegrees()
p = calexp.wcs.pixelToSky(w, h)
ra1 = p.getRa().asDegrees()
dec1 = p.getDec().asDegrees()
if ra0 > ra1 or dec0 > dec1:
ra0, ra1 = ra1, ra0
dec0, dec1 = dec1, dec0
if ra0 > ra1 or dec0 > dec1:
print("ACHTUNG!")
if ra0 < minratot:
minratot = ra0
if dec0 < mindectot:
mindectot = dec0
if ra1 > maxratot:
maxratot = ra0
if dec1 > maxdectot:
maxdectot = dec0
I get different values for maxratot, maxdectot (sky coverage) for different single_frame collections (minmjdtot, maxmjdtot are the same). In my case (minratot, mindectot, maxratot, maxdectot, minmjdtot, maxmjdtot):
Use calexp = butler.getDirect(ref) to get the actual dataset that the query has returned. Otherwise butler does a whole new query and so will very likely not return the thing that your ref is really associated with (because the query will return all matching datasets in those collections but the .get() will return the first match in the given collections). (you also should not need to use ref.dataid.full – ref.dataid should be sufficient).
The toDict is not needed. mjd = calexp.getMetadata()["MJD"] has worked for a few years now.
You should use getBBox() to get the bounding box and then use the upper and lower bounds from that rather than assuming 0,0.