Hi,
We are trying to get calexp images of a variable star. We could get the visited and the detector.
However, we are getting an error when we try to get a cutout around an RA, DEC using butler.get.
Here is our code:
def get_cutout_image(ra_deg,dec_deg,visit,detector,band,datasetType='calexp',cutoutSideLength=image_size):
"""
get the tract and patch of a source. currently retrieves i band only.
Parameters
----------
ra : ra of source in degrees
dec : dec of source in degrees
"""
cutoutSize = geom.ExtentI(cutoutSideLength, cutoutSideLength)
spherePoint = geom.SpherePoint(ra_deg*geom.degrees, dec_deg*geom.degrees)
tract = skymap.findTract(spherePoint)
patch = tract.findPatch(spherePoint)
xy = geom.PointI(tract.getWcs().skyToPixel(spherePoint))
bbox = geom.BoxI(xy - cutoutSize // 2, cutoutSize)
my_tract = tract.getId()
my_patch = tract.getSequentialPatchIndex(patch)
parameters = {'bbox': bbox}
dataId = {'band': band, 'tract': my_tract, 'patch': my_patch, 'visit': visit, 'detector':detector}
cutout_image = butler.get(datasetType, dataId=dataId, parameters=parameters)
#cutout_image = butler.get(datasetType, dataId=dataId)
return cutout_image
cutout_image = get_cutout_image(63.292031,-44.508647,466723,102, 'r',datasetType='calexp',cutoutSideLength=100)
We get the following error:
ValueError: Failure from formatter 'lsst.obs.base.formatters.fitsExposure.FitsExposureFormatter' for dataset 15c0c7f3-331a-4b8e-8b4c-62a4b868590c (calexp from file:///tmp/butler-cache-dir-si0gs3ov/exempt/986945d9-15c0c7f3-331a-4b8e-8b4c-62a4b868590c.fits):
File "src/image/ImageBaseFitsReader.cc", line 179, in ndarray::Array<T, 2, 2> lsst::afw::image::ImageBaseFitsReader::readArray(const lsst::geom::Box2I&, lsst::afw::image::ImageOrigin, bool) [with T = float]
Subimage box (10853,2706) 100x100 doesn't fit in image (0,0) 4072x4000 in HDU 1 {0}
lsst::pex::exceptions::LengthError: 'Subimage box (10853,2706) 100x100 doesn't fit in image (0,0) 4072x4000 in HDU 1'
We are referring to Melissa Graham’s notebook:
We also found a relevant community forum related to this topic:
Any help is appreciated.
Thanks!