Extracting the entire image from a Heavy Footprint

Tags: #<Tag:0x00007f7f6f0b48e8>

(Fred3m) #1

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.

(Jim Bosch) #2

The following should do what you want:

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

This will also work if image is a MaskedImage.

(Fred3m) #3

Great, thanks Jim!