This script provides a class that can be used to analyse VIS data. One can either choose to use a Python based source finding algorithm or give a SExtractor catalog as an input. If an input catalog is provided then the program assumes that X_IMAGE and Y_IMAGE columns are present in the input file.
requires: | PyFITS |
---|---|
requires: | NumPy |
requires: | matplotlib |
author: | Sami-Matias Niemi |
contact: | smn2@mssl.ucl.ac.uk |
version: | 0.2 |
Simple class that can be used to find objects and measure their ellipticities.
One can either choose to use a Python based source finding algorithm or give a SExtractor catalog as an input. If an input catalog is provided then the program assumes that X_IMAGE and Y_IMAGE columns are present in the input file.
Parameters: |
|
---|
Settings dictionary contains all parameter values needed for source finding and analysis.
Run all class methods sequentially.
Finds sources from data that has been read in when the class was initiated. Saves results such as x and y coordinates of the objects to self.sources. x and y coordinates are also available directly in self.x and self.y.
Measures ellipticity for all objects with coordinates (self.x, self.y).
Ellipticity is measured using Guassian weighted quadrupole moments. See shape.py and especially the ShapeMeasurement class for more details.
Creates a simple plot showing the derived ellipticity distribution.
Reads in a list of sources from an external file. This method assumes that the input source file is in SExtractor format. Input catalog is saves to self.sources. x and y coordinates are also available directly in self.x and self.y.
Outputs results to an ascii file defined in self.settings. This ascii file is in SExtractor format and contains the following columns:
1. X coordinate
2. Y coordinate
3. ellipticity
4. R_{2}
Processes command line arguments.
Simple class that can be used to find objects and measure their ellipticities.
One can either choose to use a Python based source finding algorithm or give a SExtractor catalog as an input. If an input catalog is provided then the program assumes that X_IMAGE and Y_IMAGE columns are present in the input file.
Parameters: |
|
---|
Settings dictionary contains all parameter values needed for source finding and analysis.
Run all class methods sequentially.
Finds sources from data that has been read in when the class was initiated. Saves results such as x and y coordinates of the objects to self.sources. x and y coordinates are also available directly in self.x and self.y.
Measures ellipticity for all objects with coordinates (self.x, self.y).
Ellipticity is measured using Guassian weighted quadrupole moments. See shape.py and especially the ShapeMeasurement class for more details.
Creates a simple plot showing the derived ellipticity distribution.
Reads in a list of sources from an external file. This method assumes that the input source file is in SExtractor format. Input catalog is saves to self.sources. x and y coordinates are also available directly in self.x and self.y.
Outputs results to an ascii file defined in self.settings. This ascii file is in SExtractor format and contains the following columns:
1. X coordinate
2. Y coordinate
3. ellipticity
4. R_{2}
Simple class to measure quadrupole moments and ellipticity of an object.
requires: | NumPy |
---|---|
requres: | PyFITS |
author: | Sami-Matias Niemi |
contact: | s.niemi@ucl.ac.uk |
version: | 0.47 |
Unit tests for the shape class.
Provides methods to measure the shape of an object.
Parameters: |
|
---|
Settings dictionary contains all parameter values needed.
Create a two-dimensional Gaussian centered on x, y.
Parameters: |
|
---|---|
Returns: | circular Gaussian 2D profile and x and y mesh grid |
Return type: | dict |
Create a circular symmetric Gaussian centered on x, y.
Parameters: |
|
---|---|
Returns: | circular Gaussian 2D profile and x and y mesh grid |
Return type: | dict |
Derive a refined iterated polarisability/ellipticity measurement for a given object.
By default polarisability/ellipticity is defined in terms of the Gaussian weighted quadrupole moments. If self.settings[‘weighted’] is False then no weighting scheme is used.
The number of iterations is defined in self.settings[‘iterations’].
Returns: | centroids [indexing stars from 1], ellipticity (including projected e1 and e2), and R2 |
---|---|
Return type: | dict |
Derive quadrupole moments and ellipticity from the input image.
Parameters: | img (ndarray) – input image data |
---|---|
Returns: | quadrupoles, centroid, and ellipticity (also the projected components e1, e2) |
Return type: | dict |
Write out a FITS file using PyFITS.
Parameters: |
|
---|---|
Returns: | None |
Provides methods to measure the shape of an object.
Parameters: |
|
---|
Settings dictionary contains all parameter values needed.
Create a two-dimensional Gaussian centered on x, y.
Parameters: |
|
---|---|
Returns: | circular Gaussian 2D profile and x and y mesh grid |
Return type: | dict |
Create a circular symmetric Gaussian centered on x, y.
Parameters: |
|
---|---|
Returns: | circular Gaussian 2D profile and x and y mesh grid |
Return type: | dict |
Derive a refined iterated polarisability/ellipticity measurement for a given object.
By default polarisability/ellipticity is defined in terms of the Gaussian weighted quadrupole moments. If self.settings[‘weighted’] is False then no weighting scheme is used.
The number of iterations is defined in self.settings[‘iterations’].
Returns: | centroids [indexing stars from 1], ellipticity (including projected e1 and e2), and R2 |
---|---|
Return type: | dict |
Derive quadrupole moments and ellipticity from the input image.
Parameters: | img (ndarray) – input image data |
---|---|
Returns: | quadrupoles, centroid, and ellipticity (also the projected components e1, e2) |
Return type: | dict |
Write out a FITS file using PyFITS.
Parameters: |
|
---|---|
Returns: | None |
Simple source finder that can be used to find objects from astronomical images.
reqiures: | NumPy |
---|---|
requires: | SciPy |
requires: | matplotlib |
author: | Sami-Matias Niemi |
contact: | s.niemi@ucl.ac.uk |
version: | 0.6 |
This class provides methods for source finding.
Parameters: |
|
---|
Cleans up small connected components and large structures.
Perform aperture photometry and calculate the shape of the object based on quadrupole moments. This method also calculates refined centroid for each object.
Warning
Results are rather sensitive to the background subtraction, while the errors depend strongly on the noise estimate from the background. Thus, great care should be exercised when applying this method.
Parameters: | pixel_based (boolean) – whether to do a global or pixel based background subtraction |
---|---|
Returns: | photometry, error_in_photometry, ellipticity, refined_x_pos, refined_y_pos |
Returns: | ndarray, ndarray, ndarray, ndarray, ndarray |
Find all pixels above the median pixel after smoothing with a Gaussian filter.
Note
maybe one should use mode instead of median?
Warning
The background estimation is very crude and should not be trusted. One should probably write an iterative scheme were the background is recalculated after identifying the objects.
Outputs the found positions to an ascii and a DS9 reg file.
Returns: | None |
---|
Finds the center-of-mass for all objects using numpy.ndimage.center_of_mass method.
Note
these positions are zero indexed!
Returns: | xposition, yposition, center-of-masses |
---|---|
Return type: | list |
Derive contours using the diskStructure function.
Derive fluxes or counts.
Derives sizes for each object.
Generates a diagnostic plot.
Returns: | None |
---|
Performs all steps of source finding at one go.
Returns: | source finding results such as positions, sizes, fluxes, etc. |
---|---|
Return type: | dictionary |
Outputs the photometric results to an ascii file.
Returns: | None |
---|
This class provides methods for source finding.
Parameters: |
|
---|
Cleans up small connected components and large structures.
Perform aperture photometry and calculate the shape of the object based on quadrupole moments. This method also calculates refined centroid for each object.
Warning
Results are rather sensitive to the background subtraction, while the errors depend strongly on the noise estimate from the background. Thus, great care should be exercised when applying this method.
Parameters: | pixel_based (boolean) – whether to do a global or pixel based background subtraction |
---|---|
Returns: | photometry, error_in_photometry, ellipticity, refined_x_pos, refined_y_pos |
Returns: | ndarray, ndarray, ndarray, ndarray, ndarray |
Find all pixels above the median pixel after smoothing with a Gaussian filter.
Note
maybe one should use mode instead of median?
Warning
The background estimation is very crude and should not be trusted. One should probably write an iterative scheme were the background is recalculated after identifying the objects.
Outputs the found positions to an ascii and a DS9 reg file.
Returns: | None |
---|
Finds the center-of-mass for all objects using numpy.ndimage.center_of_mass method.
Note
these positions are zero indexed!
Returns: | xposition, yposition, center-of-masses |
---|---|
Return type: | list |
Derive contours using the diskStructure function.
Derive fluxes or counts.
Derives sizes for each object.
Generates a diagnostic plot.
Returns: | None |
---|
Performs all steps of source finding at one go.
Returns: | source finding results such as positions, sizes, fluxes, etc. |
---|---|
Return type: | dictionary |
Outputs the photometric results to an ascii file.
Returns: | None |
---|
This scripts can be used to study CCD spot measurements.
requires: | PyFITS |
---|---|
requires: | NumPy |
requires: | SciPy |
requires: | matplotlib |
requires: | VISsim-Python |
version: | 0.1 |
author: | Sami-Matias Niemi |
contact: | s.niemi@ucl.ac.uk |
Analyse spot measurements using deconvolutions.
Note: does not really work... perhaps an issue with sizes.
Parameters: | files (list) – a list of input files |
---|---|
Returns: | None |
Analyse spot measurements using different fitting methods.
Parameters: |
|
---|---|
Returns: | None |
Simple convolution-deconvolution examples.
Returns: | None |
---|
Fitting function: 2D gaussian
Fits a single Gaussian to a given data. Uses scipy.optimize.leastsq for fitting.
Parameters: |
|
---|---|
Returns: | coefficients, best fit params, success |
Return type: | dictionary |
Generates a 2D Bessel function by taking a Fourier transform of a disk with a given radius. The real image and the subsequent power spectrum is oversampled with a given factor. The peak value of the generated Bessel function is normalized to unity.
Parameters: |
|
---|---|
Returns: |
Parameters: |
|
---|---|
Returns: | None |
Parameters: |
|
---|---|
Returns: |
Performs Wiener deconvolution on data using a given kernel. The input can be either 1D or 2D array.
For further information: http://en.wikipedia.org/wiki/Wiener_deconvolution
Parameters: |
|
---|---|
Returns: | deconvolved data |
This script can be used to plot some PSF properties such as ellipticity and size as a function of the focal plane position.
requires: | PyFITS |
---|---|
requires: | NumPy |
requires: | SciPy |
requires: | matplotlib |
requires: | VISsim-Python |
author: | Sami-Matias Niemi |
contact: | smn2@mssl.ucl.ac.uk |
Calculates the encircled energy from a PSF. The default input PSF is 12 times over-sampled with 1 micron pixel.
Generate a simple plot showing some results.
Measure ellipticity, R2, FWHM etc.
Parse information from the input file name.
Example name:
detector_jitter-1_TOL05_MC_T0074_50arcmin2_grid_Nim=16384x16384_pixsize=1.000um_lbda=800nm_fieldX=-0.306_fieldY=1.042.fits
Calculates the fraction of energy in the peak pixel for a given PSF compared to an aperture of a given radius.
Reads in the data from a given FITS file.
To calculate shapes from AST PSFs.
One of the actions from the PLM-SRR was 8941 (RID No: ENG-219), with the following wording: ASFT shall provide to the VIS team a PSF profile with associated R2 with the sampling set to 4 microns and the VIS team will check that when applying the R2 processing the result is identical, to double check that the process is correct.
This script can be used to derive a basis set for point spread functions.
requires: | Scikit-learn |
---|---|
requires: | PyFITS |
requires: | NumPy |
requires: | SciPy |
requires: | matplotlib |
requires: | VISsim-Python |
version: | 0.3 |
author: | Sami-Matias Niemi |
contact: | smn2@mssl.ucl.ac.uk |
Derives a basis set from input data using Perform Fast Independent Component Analysis. Saves the basis sets to a FITS file for further processing.
Derives a basis set from input data using Principal component analysis (PCA). Saves the basis sets to a FITS file for further processing.
Information about PCA can be found from the scikit-learn website: http://scikit-learn.org/stable/modules/generated/sklearn.decomposition.PCA.html#sklearn.decomposition.PCA
Parameters: |
|
---|---|
Returns: | PCA components |
Derives a basis set from input data using Randomized Principal component analysis (PCA). Saves the basis sets to a FITS file for further processing.
Information about PCA can be found from the scikit-learn website: http://scikit-learn.org/stable/modules/generated/sklearn.decomposition.RandomizedPCA.html#sklearn.decomposition.RandomizedPCA
Parameters: |
|
---|---|
Returns: | Randomized PCA components |
Generates a movie from the basis set files.
Returns: | None |
---|
Processes command line arguments.
Generate visualisation of the basis sets.
Parameters: | files – a list of file names that should be visualised |
---|---|
Returns: | None |
Simple script to test the impact of centroiding on PSF ellipticity and size.
requires: | PyFITS |
---|---|
requires: | NumPy |
requires: | SciPy |
requires: | matplotlib |
requires: | VISsim-Python |
version: | 0.1 |
author: | Sami-Matias Niemi |
contact: | s.niemi@ucl.ac.uk |
Create a two-dimensional Gaussian centered on x, y.
Parameters: |
|
---|---|
Returns: | circular Gaussian 2D profile and x and y mesh grid |
Return type: | dict |
Shrink or expand the size of an array an arbitary amount using interpolation. Conserves flux by ensuring that each input pixel is equally represented in the output array.
Todo
one could do the binning faster if old and new outputs are modulo 0
Note
modelled after the IDL code frebin.pro, so this may not be the fastest solution
Parameters: |
|
---|---|
Returns: | binned array |
Return type: | ndarray |
Parameters: | results – |
---|---|
Returns: |
Returns: |
---|
Returns: |
---|
This script can be used to fit a set of basis functions to a point spread function.
requires: | Scikit-learn |
---|---|
requires: | PyFITS |
requires: | NumPy |
requires: | SciPy |
requires: | matplotlib |
requires: | VISsim-Python |
version: | 0.2 |
author: | Sami-Matias Niemi |
contact: | smn2@mssl.ucl.ac.uk |
Perform PCA basis set fitting using Bayesian Markov Chain Monte Carlo fitting technique.
Requires: | pyMC |
---|---|
Returns: | None |
Perform least squares fitting using ICA basis set.
Returns: | None |
---|
Perform least squares fitting using PCA basis set.
Returns: | None |
---|
A simple function returning a linear combination of 20 input parameters.
Parameters: |
|
---|---|
Returns: | a linear combination of the data given the coefficients |
Return type: | ndarray |
Simple test using both least squares and Bayesian MCMC fitting. Includes Poisson noise to the PSF prior fitting. The PSF is build randomly from the the mean PSF and the PCA components are being fitted.
Returns: | None |
---|
Plot the fitting results, residuals and coefficients
Parameters: |
|
---|---|
Returns: | None |
A simple script to study the effects of CTI trailing to weak lensing shear power spectrum.
requires: | NumPy |
---|---|
requires: | SciPy |
requires: | matplotlib |
version: | 0.1 |
author: | Sami-Matias Niemi |
contact: | s.niemi@ucl.ac.uk |
Calculates the azimuthally averaged radial profile.
Parameters: |
|
---|
A simple algorithm to calculate the azimuthally averaged radial profile.
Parameters: |
|
---|---|
Returns: | radial profile |
Parameters: |
|
---|---|
Returns: |
This function plots the CTI impact on shear. The Data is assumed to be in the following format:
x [deg] y [deg] g1_parallel g1_serial g1_total g2_total
Parameters: | data – |
---|---|
Returns: |
Parameters: | data – |
---|---|
Returns: |
This script can be used to compare SNRs of SExtracted pointed sources to the radiometric calculations.
A simple plot to compare input and extracted magnitudes.
Compare SExtracted SNR to radiometric model from ETC module.
Reads in a SExtractor type catalog using the sextutils module.
This scripts can be used to study the imaging area that is impacted by bright stars.
requires: | NumPy |
---|---|
requires: | matplotlib |
requires: | VISsim-Python |
version: | 0.2 |
author: | Sami-Matias Niemi |
contact: | s.niemi@ucl.ac.uk |
This potentially overestimates because does not consider the fact that bleeding is along the column and hence some saturated pixels may be double counted.
This scripts derives simple cosmic ray statististics from Gaia BAM data. Note that the Gaia BAM data are binned 4 x 1 leading to pixel geometries that are 120 x 10 microns. One can derive a statistical correction to take into account the binning. Further corrections are needed to scale e.g. to VIS CCD273 pixels, which are 12 x 12 microns. Thus, the results will necessarily contain some uncertainties.
requires: | pyfits (tested with 3.3) |
---|---|
requires: | numpy (tested with 1.9.2) |
requires: | scipy (tested with 0.15.1) |
requires: | matplotlib (tested with 1.4.3) |
requires: | skimage (scikit-image, tested with 0.10.1) |
requires: | sklearn (scikit-learn, tested with 0.15.2) |
requires: | statsmodels (tested with 0.6.1) |
requires: | vissim-python |
author: | Sami-Matias Niemi |
contact: | s.niemi@icloud.com |
version: | 1.0 |
Analyse all BAM data held in files.
Parameters: |
|
---|---|
Parama info: | a list of meta data dictionaries |
Returns: | None |
Because the original BAM data are binned 4 x 1, we do not know the track lengths. One can try to derive a statistical correction by randomizing the position and the angle a cosmic ray may have arrived. This function derives a probability density function for the track lengths by Monte Carloing over the random locations and angles.
Parameters: |
|
---|
:param ysize:how many binned pixels to use in the derivation :type ysize: int :param mc: number of random realisations to generate :type mc: int :param dx: size of the steps to adopt when deriving CDF :type dx: float
Returns: | None |
---|
Find all files that match the ID.
Parameters: |
|
---|---|
Returns: | a list containing all files matching the wild card. |
Return type: | lst |
Generates an example plot showing the Gaia BAM detector geometry and binning used. A simple illustration.
Returns: | None |
---|
Removes the first line, transposes the array, and subtracts the median (derived ADC offset).
Parameters: |
|
---|---|
Returns: | list of pixel data arrays |
Return type: | lst |
Read data and gather information from the header from all files given.
Parameters: |
|
---|---|
Returns: | NumPy array contaning pixel data and a list containing dictionaries that hold header information |
Return type: | ndarray, lst |
Run all steps from finding suitable Gaia BAM files to analysing them.
Returns: | None |
---|