pyklip.kpp.stat package
Submodules
pyklip.kpp.stat.statPerPix_utils module
- pyklip.kpp.stat.statPerPix_utils.get_image_stat_map_perPixMasking(image, image_without_planet=None, mask_radius=7, IOWA=None, N=None, centroid=None, N_threads=None, Dr=2, Dth=None, type='SNR')[source]
Calculate the SNR, the standard deviation or the probability (tail distribution) of a given image on a per pixel basis, which means that for each pixel the standard deviation is calculated after masking its surroundings.
- Parameters:
image – The image for which one wants the statistic.
image_without_planet – Same as image but where real signal has been masked out. The
image_without_planet – Same as image but where any real signal has been masked out. The code will use “image_without_planet” to calculate the standard deviation or the PDF. This can be a negatively derotated image in the context of ADI.
mask_radius – (default=7pix) Radius of the mask used around the current pixel.
IOWA – (IWA,OWA) inner working angle, outer working angle. It defines boundary to the zones in which the statistic is calculated. If None, kpp.utils.GPIimage.get_IOWA() is used.
N – Defines the width of the ring by the number of pixels it has to include. The width of the annuli will therefore vary with sepration.
centroid – (x_cen,y_cen) Define the center of the image. Default is x_cen = (nx-1)//2 ; y_cen = (ny-1)//2
N_threads – Number of threads to be used. If None run sequentially.
Dr – (default=2pix) Width of the annulus (in pixel).
Dth – Define the angular size of a sector in degree (will apply for either Dr or N)
type – Indicate the type of statistic to be calculated. If “SNR” (default) simple stddev calculation and returns SNR. If “stddev” returns the pure standard deviation map. If “proba” triggers proba calculation with pdf fitting.
- Returns:
The statistic map for image.
- pyklip.kpp.stat.statPerPix_utils.get_image_stat_map_perPixMasking_threadTask(row_indices, col_indices, image, image_without_planet, x_grid, y_grid, N, mask_radius, Dr=2, Dth=None, type='SNR')[source]
Helper function for get_image_stat_map_perPixMasking(). Calculate the SNR on the subset of pixels defined by row_indices,col_indices.
Calculate the SNR, the standard deviation or the probability (tail distribution) of a subset of an image on a per pixel basis, which means that for each pixel the standard deviation is calculated after masking its surroundings.
This function is used to ease parallelization.
- Parameters:
row_indices – The row indices of images for which we want the statistic.
col_indices – The column indices of images for which we want the statistic.
image – The image or cubes for which one wants the statistic.
image_without_planet – Same as image but where real signal has been masked out. The code will actually use map to calculate the standard deviation or the density function.
mask_radius – Radius of the mask used around the current pixel when use_mask_per_pixel = True.
IOWA – (IWA,OWA) inner working angle, outer working angle. It defines boundary to the zones in which the statistic is calculated.
N – Defines the width of the ring by the number of pixels it has to include. The width of the annuli will therefore vary with sepration.
centroid – Define the cente rof the image. Default is x_cen = (nx-1)//2 ; y_cen = (ny-1)//2
mute – Won’t print any logs.
N_threads – Number of threads to be used. If None run sequentially.
Dr – (default=2pix) Defines the width of the ring (in pixel). N is then ignored.
Dth – Define the angular size of a sector in degree (will apply for either Dr or N)
type – Indicate the type of statistic to be calculated. If “SNR” (default) simple stddev calculation and returns SNR. If “stddev” returns the pure standard deviation map. If “proba” triggers proba calculation with pdf fitting.
Return: The statistic map for image.
pyklip.kpp.stat.stat_utils module
- pyklip.kpp.stat.stat_utils.get_cdf_model(data, interupt_plot=False, pure_gauss=False)[source]
Calculate a model CDF for some data.
/!This function is for some reason still a work in progress. JB could never decide what the best option was. But it should work even if the code is a mess.
- Parameters:
data – arrays of samples from a random variable
interupt_plot – Plot the histogram and model fit. It
pure_gauss – Assume gaussian statistic. Do not fit exponential tails.
- Return: (cdf_model,new_sampling,im_histo, center_bins) with:
cdf_model: The cdf model = np.cumsum(pdf_model) pdf_model: The pdf model sampling: sampling of pdf/cdf_model im_histo: histogram from original data center_bins: bin centers for im_histo
- pyklip.kpp.stat.stat_utils.get_cube_stddev(cube, IOWA, N=2000, centroid=None, r_step=None, Dr=None)[source]
- pyklip.kpp.stat.stat_utils.get_image_PDF(image, IOWA=None, N=2000, centroid=None, r_step=None, Dr=None, image_wide=None)[source]
Calculate the PDF of a given image using annuli.
- Parameters:
image – The image for which one wants the statistic.
IOWA – (IWA,OWA) inner working angle, outer working angle. It defines boundary to the zones in which the statistic is calculated. If None, kpp.utils.GPIimage.get_IOWA() is used.
N – Defines the width of the ring by the number of pixels it has to include. The width of the annuli will therefore vary with sepration. Default is N=3000.
centroid – (x_cen,y_cen) Define the center of the image. Default is x_cen = (nx-1)//2 ; y_cen = (ny-1)//2
r_step – Distance between two consecutive annuli mean separation (in pixel).
Dr – Width of the annulus (in pixel).
image_wide – Don’t divide the image in annuli or sectors when computing the statistic. Use the entire image directly. Not available if “pixel based: is defined,
- Returns:
List of PDF values for each annulus. The sampling of each PDF can be found in sampling_list. cdf_list: CDF values for each annulus. The sampling of each CDF can be found in sampling_list. sampling_list: Sampling for the PDF and the CDF. annulus_radii_list: List of ((r_min+r_max)/2.,r_min,r_max) with r_min,r_max the boundaries of an annulus.
- Return type:
pdf_list
- pyklip.kpp.stat.stat_utils.get_image_stat(image, type, IOWA=None, N=None, centroid=None, r_step=2, Dr=2, image_wide=None)[source]
Calculate the standard deviation or the mean of a given image using annuli.
- Parameters:
image – The image or cubes for which one wants the statistic.
type – “stddev” or “mean” or “sum”
IOWA – (IWA,OWA) inner working angle, outer working angle. It defines boundary to the zones in which the statistic is calculated. If None, kpp.utils.GPIimage.get_IOWA() is used.
N – Defines the width of the ring by the number of pixels it has to include. The width of the annuli will therefore vary with sepration. Default is N=3000.
centroid – (x_cen,y_cen) Define the center of the image. Default is x_cen = (nx-1)//2 ; y_cen = (ny-1)//2
r_step – Distance between two consecutive annuli mean separation. Not available if “pixel based” is defined,
Dr – If not None defines the width of the ring as Dr. N is then ignored if Dth is defined.
image_wide – Don’t divide the image in annuli or sectors when computing the statistic. Use the entire image directly. Not available if “pixel based: is defined,
- Returns:
standard deviation values at the center of each annulus_radii_list: List of ((r_min+r_max)/2.,r_min,r_max) with r_min,r_max the boundaries of an annulus.
- Return type:
stddev_list
- pyklip.kpp.stat.stat_utils.get_image_stat_map(image, image_without_planet=None, IOWA=None, N=None, centroid=None, r_step=2, Dr=2, type='SNR', image_wide=None, azimuthal_sectors_for_masking=1)[source]
Calculate the SNR, the standard deviation or the probability (tail distribution) of a given image using concentric annuli.
- Parameters:
image – The image for which one wants the statistic.
image_without_planet – Same as image but where any real signal has been masked out. The code will use “image_without_planet” to calculate the standard deviation or the PDF. This can be a negatively derotated image in the context of ADI.
IOWA – (IWA,OWA) inner working angle, outer working angle. It defines boundary to the zones in which the statistic is calculated. If None, kpp.utils.GPIimage.get_IOWA() is used.
N – Defines the width of the ring by fixing the number of pixels of the annulus. The width of the annuli will therefore vary with sepration.
centroid – (x_cen,y_cen) Define the center of the image. Default is x_cen = (nx-1)//2 ; y_cen = (ny-1)//2
r_step – (default=2pix) Distance between two consecutive annuli mean separation (in pixel).
Dr – (default=2pix) Width of the annulus (in pixel).
type – Indicate the type of statistic to be calculated. If “SNR” (default) simple stddev calculation and returns SNR. If “stddev” returns the pure standard deviation map. If “mean” returns a map from the radial mean. If “sum” returns a map from the radial sum. If “proba” triggers proba calculation with pdf fitting.
image_wide – Don’t divide the image in annuli or sectors when computing the statistic. Use the entire image directly.
azimuthal_sectors_for_masking – if > 1, breaks up the image into this many azimuthal sectors, with pixels in the sector and half a sector outside all masked to compute the statistic in that sector. This is to avoid planet signals from downweighter their own SNR. Useful when no image without planet is available initially. Doesn’t work for proba.
- Returns:
The statistic map for image.
- pyklip.kpp.stat.stat_utils.get_image_stddev(image, IOWA=None, N=None, centroid=None, r_step=2, Dr=2, image_wide=None)[source]
Calculate the standard deviation of a given image using annuli.
- Parameters:
image – The image for which one wants the statistic.
IOWA – (IWA,OWA) inner working angle, outer working angle. It defines boundary to the zones in which the statistic is calculated. If None, kpp.utils.GPIimage.get_IOWA() is used.
N – Defines the width of the ring by the number of pixels it has to include. The width of the annuli will therefore vary with sepration. Default is N=3000.
centroid – (x_cen,y_cen) Define the center of the image. Default is x_cen = (nx-1)//2 ; y_cen = (ny-1)//2
r_step – (default=2pix) Distance between two consecutive annuli mean separation (in pixel).
Dr – (default=2pix) Width of the annulus (in pixel).
image_wide – Don’t divide the image in annuli or sectors when computing the statistic. Use the entire image directly. Not available if “pixel based: is defined,
- Returns:
standard deviation values at the center of each annulus_radii_list: List of ((r_min+r_max)/2.,r_min,r_max) with r_min,r_max the boundaries of an annulus.
- Return type:
stddev_list
- pyklip.kpp.stat.stat_utils.get_pdf_model(data, interupt_plot=False, pure_gauss=False)[source]
Calculate a model PDF for some data.
/!This function is for some reason still a work in progress. JB could never decide what the best option was. But it should work even if the code is a mess.
- Parameters:
data – arrays of samples from a random variable
interupt_plot – Plot the histogram and model fit. It
pure_gauss – Assume gaussian statistic. Do not fit exponential tails.
- Return: (pdf_model,new_sampling,im_histo, center_bins) with:
pdf_model: The pdf model new_sampling: sampling of pdf_model im_histo: histogram from original data center_bins: bin centers for im_histo