I’m trying to run Louise Edward’s tutorial, delegate-contributions-dp01/Structure/StructureAroundCluster/StructureAroundCluster_090521.ipynb, at NCSA and encountering skymap issues. It wants me to specify which skymap in this routine, and I’m not sure how to do that:
def cutout_coadd(butler, ra, dec, band=‘r’, datasetType=‘deepCoadd’,
cutoutSideLength=51, **kwargs):
“”"
Produce a cutout from a coadd at the given ra, dec position.
Adapted from DC2 tutorial notebook by Michael Wood-Vasey.
Parameters
----------
butler: lsst.daf.persistence.Butler
Servant providing access to a data repository
ra: float
Right ascension of the center of the cutout, in degrees
dec: float
Declination of the center of the cutout, in degrees
band: string
Filter of the image to load
datasetType: string ['deepCoadd']
Which type of coadd to load. Doesn't support 'calexp'
skymap: lsst.afw.skyMap.SkyMap [optional]
Pass in to avoid the Butler read. Useful if you have lots of them.
cutoutSideLength: float [optional]
Size of the cutout region in pixels.
Returns
-------
MaskedImage
"""
radec = geom.SpherePoint(ra, dec, geom.degrees)
cutoutSize = geom.ExtentI(cutoutSideLength, cutoutSideLength)
if skymap is None:
skymap = butler.get("skyMap")
# Look up the tract, patch for the RA, Dec
tractInfo = skymap.findTract(radec)
patchInfo = tractInfo.findPatch(radec)
xy = geom.PointI(tractInfo.getWcs().skyToPixel(radec))
bbox = geom.BoxI(xy - cutoutSize // 2, cutoutSize)
patch = tractInfo.getSequentialPatchIndex(patchInfo)
coaddId = {'tract': tractInfo.getId(), 'patch': patch, 'band': band}
parameters = {'bbox': bbox}
cutout_image = butler.get(datasetType, parameters=parameters,
dataId=coaddId)
return cutout_image
Select a position at roughly the center of the galaxy cluster:
cutout_image = cutout_coadd(butler, ra, dec, datasetType=‘deepCoadd’,
cutoutSideLength=501)
print("The size of the cutout in pixels is: ", cutout_image.image.array.shape)
This returns
UnboundLocalError Traceback (most recent call last)
/tmp/ipykernel_3588/2834475231.py in
1 # Select a position at roughly the center of the galaxy cluster:
----> 2 cutout_image = cutout_coadd(butler, ra, dec, datasetType=‘deepCoadd’,
3 cutoutSideLength=501)
4 print("The size of the cutout in pixels is: ", cutout_image.image.array.shape)
/tmp/ipykernel_3588/3823562161.py in cutout_coadd(butler, ra, dec, band, datasetType, cutoutSideLength, **kwargs)
31 cutoutSize = geom.ExtentI(cutoutSideLength, cutoutSideLength)
32
—> 33 if skymap is None:
34 skymap = butler.get(“skyMap”)
35
UnboundLocalError: local variable ‘skymap’ referenced before assignment