Useful tips#
The API documentation does not give credits to some useful features find in prose. Here is a non exausthive demonstartion of some of them:
In what follows we will make examples from a random set of images
[1]:
import numpy as np
from prose import Image, Sequence
np.random.seed(42)
images = [Image(data=np.random.randn(100,100)) for i in range(5)]
Accessing blocks#
When a Sequence is defined there are few ways to access its blocks. Letβs define one for example
[2]:
from prose.blocks import Set, Pass, SegmentedPeaks
sequence = Sequence([
Pass(name="named_block"),
Set(example=True),
SegmentedPeaks(),
])
The list of blocks is returned by
[3]:
sequence.blocks
[3]:
[<prose.blocks.utils.Pass at 0x29442ecd0>,
<prose.blocks.utils.Set at 0x29442ec10>,
<prose.blocks.detection.SegmentedPeaks at 0x105803dc0>]
but specific blocks can also be accessed by name (if they have one)
[4]:
sequence.named_block
[4]:
<prose.blocks.utils.Pass at 0x29442ecd0>
Plotting in Sequence#
The Plot Block can be used to record any plotting function applied to an Image, like
[5]:
import matplotlib.pyplot as plt
# This function plot the image, its max and an histogram of it
def show(image):
plt.figure(figsize=(8,4))
plt.subplot(121)
plt.title("image data", loc="left")
plt.imshow(image.data, origin="lower", cmap="Greys")
plt.plot(*np.unravel_index(np.argmax(image.data), image.data.shape), "o",
ms=10, fillstyle="none", c="w", markeredgewidth=3, label="max")
plt.text(5, 5, image.i if hasattr(image, "i") else "--", color="white", fontsize=14)
plt.legend()
plt.subplot(122)
plt.hist(image.data.flatten(), bins=100, color="k")
plt.xlim(-5, 5)
plt.ylim(0, 500)
plt.title("image histogram", loc="left")
plt.tight_layout()
# for example
show(images[0])
This can be used within a Sequence through the use of Plot to create a video/gif of it
[6]:
from prose.blocks.vizualisation import PlotVideo
# we define our block
plot_block = PlotVideo(show, "static/plots.gif")
# adding to the sequence and running
sequence = Sequence([plot_block])
sequence.run(images)
RUN 100%|βββββββββββββββββββββββββββββββββββββ| 5/5 [00:00<00:00, 8.89images/s]

Custom apertures#
Letβs start by loading the phot originated from the photometry tutorial and detect som stars on it
[7]:
from prose import blocks, Observation
obs = Observation("static/example.phot")
im = obs.stack
im.show()
[7]:
<AxesSubplot:>
Target is 0, we plot its PSF and define some adapted aperture(s)
[8]:
import numpy as np
# defining aperture(s)
rin = 10
rout = 20
apertures = np.linspace(3, rin, 10) # multiple apertures
obs.plot_radial_psf(0, aperture=apertures[0], rin=rin, rout=rout, n=15)
This looks reasonable enough for aperture photometry to be performed (see the photometry tutorial)