Table Of Contents

Previous topic

Data reduction tools

Next topic

Supporting Methods

VIS data analysis tools

Object finding and measuring ellipticity

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
class analysis.analyse.analyseVISdata(filename, log, **kwargs)

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:
  • filename (string) – name of the FITS file to be analysed.
  • log (instance) – logger
  • kwargs (dict) – additional keyword arguments

Settings dictionary contains all parameter values needed for source finding and analysis.

doAll()

Run all class methods sequentially.

findSources()

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.

measureEllipticity()

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.

plotEllipticityDistribution()

Creates a simple plot showing the derived ellipticity distribution.

readSources()

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.

writeResults()

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}
analysis.analyse.processArgs(printHelp=False)

Processes command line arguments.

class analysis.analyse.analyseVISdata(filename, log, **kwargs)

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:
  • filename (string) – name of the FITS file to be analysed.
  • log (instance) – logger
  • kwargs (dict) – additional keyword arguments

Settings dictionary contains all parameter values needed for source finding and analysis.

doAll()

Run all class methods sequentially.

findSources()

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.

measureEllipticity()

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.

plotEllipticityDistribution()

Creates a simple plot showing the derived ellipticity distribution.

readSources()

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.

writeResults()

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}

Measuring a shape of an object

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
class analysis.shape.TestShape(methodName='runTest')

Unit tests for the shape class.

class analysis.shape.shapeMeasurement(data, log, **kwargs)

Provides methods to measure the shape of an object.

Parameters:
  • data (ndarray) – name of the FITS file to be analysed.
  • log (instance) – logger
  • kwargs (dict) – additional keyword arguments

Settings dictionary contains all parameter values needed.

Gaussian2D(x, y, sigmax, sigmay)

Create a two-dimensional Gaussian centered on x, y.

Parameters:
  • x (float) – x coordinate of the centre
  • y (float) – y coordinate of the centre
  • sigmax (float) – standard deviation of the Gaussian in x-direction
  • sigmay (float) – standard deviation of the Gaussian in y-direction
Returns:

circular Gaussian 2D profile and x and y mesh grid

Return type:

dict

circular2DGaussian(x, y, sigma)

Create a circular symmetric Gaussian centered on x, y.

Parameters:
  • x (float) – x coordinate of the centre
  • y (float) – y coordinate of the centre
  • sigma (float) – standard deviation of the Gaussian, note that sigma_x = sigma_y = sigma
Returns:

circular Gaussian 2D profile and x and y mesh grid

Return type:

dict

measureRefinedEllipticity()

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
quadrupoles(img)

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
writeFITS(data, output)

Write out a FITS file using PyFITS.

Parameters:
  • data (ndarray) – data to write to a FITS file
  • output (string) – name of the output file
Returns:

None

class analysis.shape.shapeMeasurement(data, log, **kwargs)

Provides methods to measure the shape of an object.

Parameters:
  • data (ndarray) – name of the FITS file to be analysed.
  • log (instance) – logger
  • kwargs (dict) – additional keyword arguments

Settings dictionary contains all parameter values needed.

Gaussian2D(x, y, sigmax, sigmay)

Create a two-dimensional Gaussian centered on x, y.

Parameters:
  • x (float) – x coordinate of the centre
  • y (float) – y coordinate of the centre
  • sigmax (float) – standard deviation of the Gaussian in x-direction
  • sigmay (float) – standard deviation of the Gaussian in y-direction
Returns:

circular Gaussian 2D profile and x and y mesh grid

Return type:

dict

circular2DGaussian(x, y, sigma)

Create a circular symmetric Gaussian centered on x, y.

Parameters:
  • x (float) – x coordinate of the centre
  • y (float) – y coordinate of the centre
  • sigma (float) – standard deviation of the Gaussian, note that sigma_x = sigma_y = sigma
Returns:

circular Gaussian 2D profile and x and y mesh grid

Return type:

dict

measureRefinedEllipticity()

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
quadrupoles(img)

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
writeFITS(data, output)

Write out a FITS file using PyFITS.

Parameters:
  • data (ndarray) – data to write to a FITS file
  • output (string) – name of the output file
Returns:

None

Source finding

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
class analysis.sourceFinder.sourceFinder(image, log, **kwargs)

This class provides methods for source finding.

Parameters:
  • image (numpy.ndarray) – 2D image array
  • log (instance) – logger
  • kwargs (dictionary) – additional keyword arguments
cleanSample()

Cleans up small connected components and large structures.

doAperturePhotometry(pixel_based=True)

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()

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.

generateOutput()

Outputs the found positions to an ascii and a DS9 reg file.

Returns:None
getCenterOfMass()

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
getContours()

Derive contours using the diskStructure function.

getFluxes()

Derive fluxes or counts.

getSizes()

Derives sizes for each object.

plot()

Generates a diagnostic plot.

Returns:None
runAll()

Performs all steps of source finding at one go.

Returns:source finding results such as positions, sizes, fluxes, etc.
Return type:dictionary
writePhotometry()

Outputs the photometric results to an ascii file.

Returns:None
class analysis.sourceFinder.sourceFinder(image, log, **kwargs)

This class provides methods for source finding.

Parameters:
  • image (numpy.ndarray) – 2D image array
  • log (instance) – logger
  • kwargs (dictionary) – additional keyword arguments
cleanSample()

Cleans up small connected components and large structures.

doAperturePhotometry(pixel_based=True)

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()

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.

generateOutput()

Outputs the found positions to an ascii and a DS9 reg file.

Returns:None
getCenterOfMass()

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
getContours()

Derive contours using the diskStructure function.

getFluxes()

Derive fluxes or counts.

getSizes()

Derives sizes for each object.

plot()

Generates a diagnostic plot.

Returns:None
runAll()

Performs all steps of source finding at one go.

Returns:source finding results such as positions, sizes, fluxes, etc.
Return type:dictionary
writePhotometry()

Outputs the photometric results to an ascii file.

Returns:None

CCD Spot Measurements

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
analysis.analyseSpotMeasurements.analyseSpotsDeconvolution(files)

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
analysis.analyseSpotMeasurements.analyseSpotsFitting(files, gaussian=False, pixelvalues=False, bessel=True, maxfev=10000)

Analyse spot measurements using different fitting methods.

Parameters:
  • files – names of the FITS files to analyse (should match the IDs)
  • gaussian – whether or not to do a simple Gaussian fitting analysis
  • pixelvalues – whether or not to plot pixel values on a grid
  • bessel – whether or not to do a Bessel + Gaussian convolution analysis
  • maxfev – maximum number of iterations in the least squares fitting
Returns:

None

analysis.analyseSpotMeasurements.examples()

Simple convolution-deconvolution examples.

Returns:None
analysis.analyseSpotMeasurements.fitf(height, center_x, center_y, width_x, width_y)

Fitting function: 2D gaussian

analysis.analyseSpotMeasurements.gaussianFit(ydata, xdata=None, initials=None)

Fits a single Gaussian to a given data. Uses scipy.optimize.leastsq for fitting.

Parameters:
  • ydata – to which a Gaussian will be fitted to.
  • xdata – if not given uses np.arange
  • initials – initial guess for Gaussian parameters in order [amplitude, mean, sigma, floor]
Returns:

coefficients, best fit params, success

Return type:

dictionary

analysis.analyseSpotMeasurements.generateBessel(radius=1.5, oversample=500, size=1000, cx=None, cy=None, debug=False)

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:
  • radius – radius of the disc [default=1.5]
  • oversample – oversampling factor [default=500]
  • size – size of the output array
  • cx – centre of the disc in x direction
  • cy – centre of the disc in y direction
  • debug – whether or not to generate FITS files
Returns:

analysis.analyseSpotMeasurements.plotGaussianResults(data, ids, output, vals=[0, 2])
Parameters:
  • res – results
  • ids – file identifiers
Returns:

None

analysis.analyseSpotMeasurements.readData(filename, crop=True)
Parameters:
  • filename
  • crop
Returns:

analysis.analyseSpotMeasurements.weinerFilter(data, kernel, reqularization=0.01, normalize=True)

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:
  • data – data to be deconvolved (either 1D or 2D array)
  • kernel – kernel that is used for the deconvolution
  • reqularization – reqularization parameter
  • normalize – whether or not the peak value should be normalized to unity
Returns:

deconvolved data

Properties of the Point Spread Function

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
analysis.PSFproperties.encircledEnergy(file='data/psf12x.fits')

Calculates the encircled energy from a PSF. The default input PSF is 12 times over-sampled with 1 micron pixel.

analysis.PSFproperties.generatePlots(filedata, interactive=False)

Generate a simple plot showing some results.

analysis.PSFproperties.measureChars(data, info, log)

Measure ellipticity, R2, FWHM etc.

analysis.PSFproperties.parseName(file)

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
analysis.PSFproperties.peakFraction(file='data/psf12x.fits', radius=0.65, oversample=12)

Calculates the fraction of energy in the peak pixel for a given PSF compared to an aperture of a given radius.

analysis.PSFproperties.plotEncircledEnergy(radius, energy, scale=12)
analysis.PSFproperties.readData(file)

Reads in the data from a given FITS file.

analysis.PSFproperties.shapeComparisonToAST(oversample=3.0)

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.

Generating PSF Basis Sets

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
analysis.PSFbasisSets.deriveBasisSetsICA(data, cut, outfolder, components=10)

Derives a basis set from input data using Perform Fast Independent Component Analysis. Saves the basis sets to a FITS file for further processing.

http://scikit-learn.org/stable/modules/generated/sklearn.decomposition.fastica.html#sklearn.decomposition.fastica

analysis.PSFbasisSets.deriveBasisSetsPCA(data, cut, outfolder, components=10, whiten=False)

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:
  • data (ndarray) – input data from which the basis set are derived from. The input data must be an array of arrays. Each array should describe an independent data set that has been flatted to 1D.
  • cut (int) – size of the cutout region that has been used
  • outfolder (str) – name of the output folder e.g. ‘output’
  • components (int) – the number of basis set function components to derive
  • whiten (bool) – When True (False by default) the components_ vectors are divided by n_samples times singular values to ensure uncorrelated outputs with unit component-wise variances.
Returns:

PCA components

analysis.PSFbasisSets.deriveBasisSetsRandomizedPCA(data, cut, outfolder, components=10, whiten=False)

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:
  • data (ndarray) – input data from which the basis set are derived from. The input data must be an array of arrays. Each array should describe an independent data set that has been flatted to 1D.
  • cut (int) – size of the cutout region that has been used
  • outfolder (str) – name of the output folder e.g. ‘output’
  • components (int) – the number of basis set function components to derive
  • whiten (bool) – When True (False by default) the components_ vectors are divided by n_samples times singular values to ensure uncorrelated outputs with unit component-wise variances.
Returns:

Randomized PCA components

analysis.PSFbasisSets.generateMovie(files, output, outputfolder, title)

Generates a movie from the basis set files.

Returns:None
analysis.PSFbasisSets.processArgs(printHelp=False)

Processes command line arguments.

analysis.PSFbasisSets.visualiseBasisSets(files, output, outputfolder, big3d=False)

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
analysis.PSFcentroidingEffects.Gaussian2D(x, y, sigmax, sigmay, xsize=512, ysize=512)

Create a two-dimensional Gaussian centered on x, y.

Parameters:
  • x (float) – x coordinate of the centre
  • y (float) – y coordinate of the centre
  • sigmax (float) – standard deviation of the Gaussian in x-direction
  • sigmay (float) – standard deviation of the Gaussian in y-direction
  • xsize (int) – number of pixels in xdirection
  • ysize (int) – number of pixels in ydirection
Returns:

circular Gaussian 2D profile and x and y mesh grid

Return type:

dict

analysis.PSFcentroidingEffects.frebin(image, nsout, nlout=1, total=False)

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:
  • image – input image, 1-d or 2-d ndarray
  • nsout – number of samples in the output image, numeric scalar
  • nlout – number of lines (ydir) in the output image, numeric scalar
  • total – Use of the total conserves surface flux. If True, the output pixels will be the sum of pixels within the appropriate box of the input image. Otherwise they will be the average.
Returns:

binned array

Return type:

ndarray

analysis.PSFcentroidingEffects.plotCentroids(results)
Parameters:results
Returns:
analysis.PSFcentroidingEffects.testCentroidingImpact(log, psf='/Users/sammy/EUCLID/vissim-python/data/psf12x.fits', xrange=12, yrange=12, zoom=12, iterations=50)
Returns:
analysis.PSFcentroidingEffects.testCentroidingImpactSingleDirection(log, psf='/Users/sammy/EUCLID/vissim-python/data/psf12x.fits', canvas=16, ran=13, zoom=12, iterations=50, sigma=0.75, gaussian=False, interpolation=False, save=True)
Returns:

PSF Fitting

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
analysis.fitPSF.BaysianPCAfitting()

Perform PCA basis set fitting using Bayesian Markov Chain Monte Carlo fitting technique.

Requires:pyMC
Returns:None
analysis.fitPSF.ICAleastSq()

Perform least squares fitting using ICA basis set.

Returns:None
analysis.fitPSF.PCAleastSQ()

Perform least squares fitting using PCA basis set.

Returns:None
analysis.fitPSF.leastSQfit(x, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20)

A simple function returning a linear combination of 20 input parameters.

Parameters:
  • x (mdarray) – data
  • a0 – first fitting coefficient
  • a0 – float
  • a1 – second fitting coefficient
  • a1 – float
  • a2 – third fitting coefficient
  • a2 – float
  • a3 – fourth fitting coefficient
  • a3 – float
  • a4 – fifth fitting coefficient
  • a4 – float
  • a5 – sixth fitting coefficient
  • a5 – float
  • a6 – seventh fitting coefficient
  • a6 – float
  • a7 – eight fitting coefficient
  • a7 – float
  • a8 – ninth fitting coefficient
  • a8 – float
  • a9 – tenth fitting coefficient
  • a9 – float
  • a10 – eleventh fitting coefficient
  • a10 – float
  • a11 – twelfth fitting coefficient
  • a0 – float
  • a12 – thirteenth fitting coefficient
  • a0 – float
  • a13 – fourteenth fitting coefficient
  • a0 – float
  • a14 – fifteenth fitting coefficient
  • a0 – float
  • a15 – sixteenth fitting coefficient
  • a0 – float
  • a16 – seventieth fitting coefficient
  • a0 – float
  • a17 – eighteenth fitting coefficient
  • a0 – float
  • a18 – nineteenth fitting coefficient
  • a0 – float
  • a19 – twentieth fitting coefficient
  • a0 – float
  • a20 – twentyfirst fitting coefficient
  • a0 – float
Returns:

a linear combination of the data given the coefficients

Return type:

ndarray

analysis.fitPSF.test()

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
analysis.fitPSF.visualise(popt, psf, modedata, output='PCA')

Plot the fitting results, residuals and coefficients

Parameters:
  • popt (ndarray) – fitting coefficients
  • psf (ndarray) – data to which the modes were fitted to
  • modedata (ndarray) – each of the basis set modes that were fit to the data
Returns:

None

Impact of CTI Trailing on Shear Power Spectrum

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
analysis.CTIpower.azimuthalAverage(image, center=None, stddev=False, returnradii=False, return_nr=False, binsize=0.5, weights=None, steps=False, interpnan=False, left=None, right=None)

Calculates the azimuthally averaged radial profile.

Parameters:
  • image (ndarray) – image
  • center (list or None) – The [x,y] pixel coordinates used as the centre. The default is None, which then uses the center of the image (including fractional pixels).
  • stddev – if specified, return the azimuthal standard deviation instead of the average
  • returnradii – if specified, return (radii_array, radial_profile)
  • return_nr – if specified, return number of pixels per radius and radius
  • binsize – size of the averaging bin. Can lead to strange results if non-binsize factors are used to specify the center and the binsize is too large.
  • weights – can do a weighted average instead of a simple average if this keyword parameter is set. weights.shape must = image.shape. weighted stddev is undefined, so don’t set weights and stddev.
  • steps – if specified, will return a double-length bin array and radial profile
  • interpnan – Interpolate over NAN values, i.e. bins where there is no data
  • left – passed to interpnan to set the extrapolated values
  • right – passed to interpnan to set the extrapolated values
analysis.CTIpower.azimuthalAverageSimple(image, center=None)

A simple algorithm to calculate the azimuthally averaged radial profile.

Parameters:
  • image (ndarray) – image
  • center (list or None) – The [x,y] pixel coordinates used as the centre. The default is None, which then uses the center of the image (including fractional pixels).
Returns:

radial profile

analysis.CTIpower.plot(data, fourier, radius, profile, xi, yi, output, title, log=False)
Parameters:
  • data
  • fourier
  • profile
  • output
  • title
  • log
Returns:

analysis.CTIpower.plotCTIeffect(data)

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:
analysis.CTIpower.plotPower(data)
Parameters:data
Returns:
class analysis.CTIpower.ps(g, step=48.0, size=10.0, nbin=20)

A class to calculate the power spectrum.

angavg()

Angular average of the spectrum

create()

Calculate the actual power spectrum

plot(title='Power Spectrum')

Plot it

setup()

Set up stuff like l ranges

This script can be used to compare SNRs of SExtracted pointed sources to the radiometric calculations.

analysis.compareSNRs.compareCounts(catalog, min=30, max=1610, timestamp=False)
analysis.compareSNRs.compareMagnitudes(catalog, min=22.9, max=26.1, timestamp=False)

A simple plot to compare input and extracted magnitudes.

analysis.compareSNRs.compareSNR(catalog, max=33, noNoise=False)

Compare SExtracted SNR to radiometric model from ETC module.

analysis.compareSNRs.readCatalog(file='mergedNoNoise.dat')

Reads in a SExtractor type catalog using the sextutils module.

Saturated Imaging Area

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
areaImpacted(magnitudes=array([ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10.,
11., 12., 13., 14., 15., 16., 17., 18., 19.]), offset=0.5, star=False)
analysis.saturatedArea.pixelsImpacted(magnitude, exptime=565, pixelFractions=(0.65, 0.4, 0.35, 0.18, 0.09, 0.05), star=False, lookup=True)

This potentially overestimates because does not consider the fact that bleeding is along the column and hence some saturated pixels may be double counted.

Cosmic Rays

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
analysis.analyseGaiaBAMCosmicRayData.analyseData(log, files, data, info)

Analyse all BAM data held in files.

Parameters:
  • log (instance) – a logger instance
  • files (lst) – a list of file names
  • data (lst) – a list of pixel data
Parama info:

a list of meta data dictionaries

Returns:

None

analysis.analyseGaiaBAMCosmicRayData.deriveCumulativeFunctionsforBinning(xbin=4, ybin=1, xsize=1, ysize=1, mc=100000, dx=0.1)

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:
  • xbin (int) – number of pixels binned in x-direction
  • ybin (int) – number of pixels binned in y-direction
  • xsize (int) – how many binned pixels to use in the derivation

: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
analysis.analyseGaiaBAMCosmicRayData.findFiles(log, fileID='/Users/sammy/EUCLID/CCD273/CR/data/BAM_0000*.fits')

Find all files that match the ID.

Parameters:
  • log (instance) – a logger instance
  • fileID (str) – identification with a wild card to find the files
Returns:

a list containing all files matching the wild card.

Return type:

lst

analysis.analyseGaiaBAMCosmicRayData.generateBAMdatagridImage()

Generates an example plot showing the Gaia BAM detector geometry and binning used. A simple illustration.

Returns:None
analysis.analyseGaiaBAMCosmicRayData.preProcessData(log, data, info)

Removes the first line, transposes the array, and subtracts the median (derived ADC offset).

Parameters:
  • log (instance) – a logger instance
  • data (lst) – a list of pixel data arrays to process
  • info (lst) – a list of dictionaries that contain the header information
Returns:

list of pixel data arrays

Return type:

lst

analysis.analyseGaiaBAMCosmicRayData.readData(log, files)

Read data and gather information from the header from all files given.

Parameters:
  • log (instance) – a logger instance
  • files (lst) – a list of FITS file names
Returns:

NumPy array contaning pixel data and a list containing dictionaries that hold header information

Return type:

ndarray, lst

analysis.analyseGaiaBAMCosmicRayData.runAll(deriveCDF=True, examplePlot=True)

Run all steps from finding suitable Gaia BAM files to analysing them.

Returns:None