Extracting the entire image from a Heavy Footprint

What is the canonical way to extract the flux from a HeavyFootprint as an image? The method getImageArray doesn’t actually return an image, it returns a 1D array with a pixel value for each index in a SpanSet.

The Following code works (with a HeavyFootprint called heavy):

xy0 = heavy.getSpans().getBBox().getBegin()
indices = heavy.getSpans().indices()
indices = (np.array(indices[0])-xy0.getY(), np.array(indices[1])-xy0.getX())
image = afwImage.ImageF(heavy.getBBox())
image.array[indices] = heavy.getImageArray()

but that seems clunky (partly due to API issues that @natelust and I have already discussed and will shortly be addressed in ). Any ideas @natelust or @jbosch, on the proper way to do this? I’m guessing that measurements must require similar code.

The following should do what you want:

image = afwImage.ImageF(heavy.getBBox())
heavy.insert(image)

This will also work if image is a MaskedImage.

1 Like

Great, thanks Jim!