measurement_images
¶
- class ByKeyword(key)¶
Bases:
object
Callable that can be used to split an ImageGroup by a keyword value (i.e. FILTER).
- Parameters
key (str) – FITS header keyword (i.e. FILTER)
See also
- class ByPattern(key, pattern)¶
Bases:
object
Callable that can be used to split an ImageGroup by a keyword value (i.e. FILTER), applying a regular expression and using the first matching group as key.
- Parameters
key (str) – FITS header keyword
pattern (str) – Regular expression. The first matching group will be used as grouping key.
See also
- class FitsFile(*args: Any, **kwargs: Any)¶
Bases:
_SourceXtractorPy.
- class ImageGroup(**kwargs)¶
Bases:
object
Models the grouping of images. Measurement can not be made directly on instances of this type. The configuration must be “frozen” before creating a MeasurementGroup
See also
- add_images(images)¶
Add new images to the group.
- Parameters
images (list of, or a single, MeasurementImage) –
- Raises
ValueError – If the group has been split, no new images can be added.
- add_subgroup(name, group)¶
Add a subgroup to a group.
- Parameters
name (str) – The new of the new group
group (ImageGroup) –
- is_leaf()¶
- Returns
True if the group is a leaf group
- Return type
bool
- print(prefix='', show_images=False, file=<_io.TextIOWrapper name='<stderr>' mode='w' encoding='UTF-8'>)¶
Print a human-readable representation of the group.
- Parameters
prefix (str) – Print each line with this prefix. Used internally for indentation.
show_images (bool) – Show the images belonging to a leaf group.
file (file object) – Where to print the representation. Defaults to sys.stderr
- split(grouping_method)¶
Splits the group in various subgroups, applying a filter on the contained images. If the group has already been split, applies the split to each subgroup.
- Parameters
grouping_method (callable) – A callable that receives as a parameter the list of contained images, and returns a list of tuples, with the grouping key value, and the list of grouped images belonging to the given key.
- Raises
ValueError – If some images have not been grouped by the callable.
- class MeasurementGroup(image_group, is_subgroup=False)¶
Bases:
object
Once an instance of this class is created from an ImageGroup, its configuration is “frozen”. i.e. no new images can be added, or no new grouping applied.
- Parameters
image_group (ImageGroup) –
- is_leaf()¶
- Returns
True if the group is a leaf group
- Return type
bool
- print(prefix='', show_images=False, file=<_io.TextIOWrapper name='<stderr>' mode='w' encoding='UTF-8'>)¶
Print a human-readable representation of the group.
- Parameters
prefix (str) – Print each line with this prefix. Used internally for indentation.
show_images (bool) – Show the images belonging to a leaf group.
file (file object) – Where to print the representation. Defaults to sys.stderr
- class MeasurementImage(*args: Any, **kwargs: Any)¶
Bases:
_SourceXtractorPy.
A MeasurementImage is the processing unit for SourceXtractor++. Measurements and model fitting can be done over one, or many, of them. It models the image, plus its associated weight file, PSF, etc.
- Parameters
fits_file (str or FitsFile object) – The path to a FITS image, or an instance of FitsFile
psf_file (str) – The path to a PSF. It can be either a FITS image, or a PSFEx model.
weight_file (str or FitsFile) – The path to a FITS image with the pixel weights, or an instance of FitsFile
gain (float) – Image gain. If None, gain_keyword will be used instead.
gain_keyword (str) – Keyword for the header containing the gain.
saturation (float) – Saturation value. If None, saturation_keyword will be used instead.
saturation_keyword (str) – Keyword for the header containing the saturation value.
flux_scale (float) – Flux scaling. Each pixel value will be multiplied by this. If None, flux_scale_keyword will be used instead.
flux_scale_keyword (str) – Keyword for the header containing the flux scaling.
weight_type (str) –
The type of the weight image. It must be one of:
- none
The image itself is used to compute internally a constant variance (default)
- background
The image itself is used to compute internally a variance map
- rms
The weight image must contain a weight-map in units of absolute standard deviations (in ADUs per pixel).
- variance
The weight image must contain a weight-map in units of relative variance.
- weight
The weight image must contain a weight-map in units of relative weights. The data are converted to variance units.
weight_absolute (bool) – If False, the weight map will be scaled according to an absolute variance map built from the image itself.
weight_scaling (float) – Apply an scaling to the weight map.
weight_threshold (float) – Pixels with weights beyond this value are treated just like pixels discarded by the masking process.
constant_background (float) – If set a constant background of that value is assumed for the image instead of using automatic detection
image_hdu (int) – For multi-extension FITS file specifies the HDU number for the image. Default 0 (primary HDU)
psf_hdu (int) – For multi-extension FITS file specifies the HDU number for the psf. Defaults to the same value as image_hdu
weight_hdu (int) – For multi-extension FITS file specifies the HDU number for the weight. Defaults to the same value as image_hdu
- load_fits_image(image, psf=None, weight=None, **kwargs)¶
Creates an image group with the images of a (possibly multi-HDU) single FITS file.
If image is multi-hdu, psf and weight can either be multi hdu or lists of individual files.
In any case, they are matched in order and HDUs not containing images (two dimensional arrays) are ignored.
- Parameters
image – The filename of the FITS file containing the image(s)
psf – psf file or list of psf files
weight – FITS file for the weight image or a list of such files
- Returns
A ImageGroup representing the images
- load_fits_images(images, psfs=None, weights=None, **kwargs)¶
Creates an image group for the given images.
- Parameters
images (list of str) –
- A list of relative paths to the images FITS files. Can also be single string in which case,
this function acts like load_fits_image
psfs (list of str) – A list of relative paths to the PSF FITS files (optional). It must match the length of image_list or be None.
weights (list of str) – A list of relative paths to the weight files (optional). It must match the length of image_list or be None.
- Returns
A ImageGroup representing the images
- Return type
- Raises
ValueError – In case of mismatched list of files
- print_measurement_images(file=<_io.TextIOWrapper name='<stderr>' mode='w' encoding='UTF-8'>)¶
Print a human-readable representation of the configured measurement images.
- Parameters
file (file object) – Where to print the representation. Defaults to sys.stderr