Part One

Aim: Generate stars with gaussian profiles, using random positions and fluxes.

'Basic' simulation program (04/10/2016): Simulation_test1.py.txt

  • Simulation generates stars with random positions.
  • Canvas size and no. of stars are variable.
  • No gaussian profile for stars or grey values (pixel value is either 0 or 1).
  • Example output: (100x100 pixel canvas, 50 stars)
  • PositionSimTest2.png
Improvement - Gaussian star profiles (05/10/2016): Simulation_test2.py.txt
  • Generated stars now have 2d gaussian profiles:
 \begin{equation} f\left ( x,y;\sigma _{x},\sigma _{y} \right )=A e^{-\frac{\left ( x-x_0 \right )^2}{2{\sigma _{x}}^{2}}} e^{-\frac{\left ( y-y_0 \right )^2}{2{\sigma _{y}}^{2}}}  \end{equation}

  • Maximum grey values (gaussian peak values, 'A' in above equation) are randomized - can result in star not appearing in output.
  • Example output: (100x100 pixel canvas, 0-100 grey value range, 10 stars)
  • GaussianSimTest1.png
  • Example 2: (1530x1020 pixels, 0-65535 grey value range, 50 stars) (Same size of images taken by telescope system)
  • GaussianSimTest2.png
Notes on running Python programs/functions:
  1. Change working directory
  2. 'import [filename]' (without '.py')
  3. '[filename].[functionname](variables)'
If file is already imported, replace 'import' with 'reload' to load any changes.

To show an image produced by a function:

  1. 'a=[filename][functionname](variables)'
  2. 'imshow(a, cmap='Grey_r)' (use 'imshow(a)' for colourmap image instead of greyscale image)
Discussion of work so far: 20161007 meeting

Part Two

Aims:

  • For each pixel, determine mean value via integration of gaussian function over pixel area.
  • Use mean value to gain Poisson distributed value for each cell.
Pixel Integration (11/10/16): Simulation_test3.py.txt

  • Integration must be done via numerical method - multiple methods available within python (e.g 'scipy.integrate.quad()'). No indefinite integral exists for the gaussian function.
  • x and y components of gaussian can be integrated seperately. Limits of integration are +/- 0.5 of pixel position (midpoint):
 \begin{equation} N=A \int_{x_{p}-\frac{1}{2}}^{x_{p}+\frac{1}{2}} e^{-\frac{\left ( x-x_0 \right )^2}{2{\sigma _{x}}^{2}}} dx \int_{y_{p}-\frac{1}{2}}^{y_{p}+\frac{1}{2}} e^{-\frac{\left ( y-y_0 \right )^2}{2{\sigma _{y}}^{2}}}dy  \end{equation}

  • To demonstrate the importance of integrating to gain the pixel value instead of inputting the pixel coordinates to the gaussian, I have created the following plot simulating an 8x1 pixel grid with a star at x=3.75 (A=100, Sigma=1):
  • ValueComparison1.png
  • Important things to note: This is a projection for the 2d gaussian at y=0 (green line shows the 'maximum' profile on the x axis). Bin values are calculated using integration over both x and y axis, resulting in decreased bin heights, particularly near the peak.
  • Near the peak, measured values from integration is less than value of gaussian.
  • Position of integrated peak bin offset from actual gaussian peak position - could estimate position using relative heights of adjacent bins.
Poisson Distribution of pixel values: Simulation_test4.py.txt

  • Each pixel value consists of a summation of n random variables (e.g. y=x1+...+xn). Each random variable corresponds to the contribution of a particular star (out of n stars in the image).
  • Each random variable follows a Poisson distribution, with a mean value (E[x]) equal to the integrated value of a star's gaussian profile over the pixel area.
  • We can assume that these random variables are not correlated (correlation coefficient P=0), therefore the total mean value will be the sum of individual mean values (E[y]=E[x1]+...+E[xn]).
  • We can also assume that the summed pixel values (from star contributions only) also follow a Poisson distribution.
  • Therefore, we can simulate te 'counting' of photons in each pixel by using the total intgrated pixel value as the mean to gain a random poisson distributed value.
  • Example: projection (y=0) of a 16x1 pixel grid with a star generated at x=7.75 (A=100, sigma=2):
  • PoissonExample1.png
  • Test 1: 100x100 pixels, A=100, 10 stars
  • PoissonSimTest1.png
  • Small pixel value range results in very obvious variations in signal data.
  • Test 2: 100x100 pixels, A=65535 (pixel value range for camera), 10 stars
  • PoissonSimTest2.png
  • Larger pixel value range results in less obvious variations - almost indistinguishable from earlier gaussian simulation.

Part Three

Aims:

  • Implement correlated 2d gaussian function
  • Implement way to save simulated star fields as FITS files
Corelated gaussian (18/10/16): Simulation_test5.py.txt
  • Implemented a true 2D Gaussian with correlation between x and y (with correlation coefficient P (rho)):
 \begin{equation} f\left ( x,y\right )= \frac{1}{\pi \sigma _{x} \sigma _{y} \sqrt{1-\rho ^{2}}} \exp {\left [ - \frac{1}{2\left ( 1-\rho ^{2} \right )}\left ( \left (\frac{ x-x_0 }{2{\sigma _{x}}^{2}} \right )^2 + \left (\frac{ y-y_0 }{2{\sigma _{y}}^{2}}\right )^2 -2\rho \left (\frac{ x-x_0 }{2{\sigma _{x}}^{2}} \right )\left (\frac{ y-y_0 }{2{\sigma _{y}}^{2}}\right ) \right )\right ]}  \end{equation}
  • (Note: normalisation factor is ignored so far for programming purposes; maximum pixel value is being used in its place)
  • Integration of 2D Gaussian in this form is done numerically.
  • Tested for P =0, P =0.5, P =0.999 (sigma_x=sigma_y=3 in each case)
  • SkewTest2.png
  • (Note - image is rotated 90 degrees clockwise)
  • Also - found a way to save images as FITS files, similar to images gained from observations.
-- AaronAndrews - 09 Oct 2016
Topic attachments
I AttachmentSorted ascending History Action Size Date Who Comment
PNGpng GaussianSimTest1.png r1 manage 27.3 K 09 Oct 2016 - 10:15 AaronAndrews gaussian profile test 1 (100x100, 10 stars)
PNGpng GaussianSimTest2.png r1 manage 38.8 K 09 Oct 2016 - 10:15 AaronAndrews gaussian profile test 2 (1530x1020, 50 stars)
PNGpng PoissonExample1.png r1 manage 50.3 K 13 Oct 2016 - 11:33 AaronAndrews Example of poisson distributed pixel values on a 16x1 pixel grid
PNGpng PoissonSimTest1.png r1 manage 39.4 K 14 Oct 2016 - 12:54 AaronAndrews Poisson simulation test 1: 100x100 pixels, A=100, 10 stars
PNGpng PoissonSimTest2.png r1 manage 29.4 K 14 Oct 2016 - 12:54 AaronAndrews Poisson simulation test 2: 100x100 pixels, A=65535, 10 stars
PNGpng PositionSimTest2.png r1 manage 19.0 K 09 Oct 2016 - 10:14 AaronAndrews random position test (100x100, 50 stars)
Texttxt Simulation_test1.py.txt r1 manage 1.5 K 09 Oct 2016 - 10:15 AaronAndrews simulation test program 1
Texttxt Simulation_test2.py.txt r1 manage 2.4 K 09 Oct 2016 - 10:16 AaronAndrews simulation test program 2
Texttxt Simulation_test3.py.txt r1 manage 4.7 K 11 Oct 2016 - 22:55 AaronAndrews Simulation test program 3 - implemented integration
Texttxt Simulation_test4.py.txt r2 r1 manage 5.5 K 14 Oct 2016 - 12:53 AaronAndrews Simulation test 4 - added poisson variations
Texttxt Simulation_test5.py.txt r1 manage 7.6 K 19 Oct 2016 - 20:40 AaronAndrews simulation test 5
PNGpng SkewTest2.png r1 manage 18.6 K 19 Oct 2016 - 20:41 AaronAndrews Testing x and y correlation (P) for P=0, P=0.5, P=0.999
PNGpng ValueComparison1.png r1 manage 50.8 K 11 Oct 2016 - 22:46 AaronAndrews Demonstration of integrated pixel values for an 8x1 pixel grid with 1 star at x=3.75
Edit | Attach | Watch | Print version | History: r7 < r6 < r5 < r4 < r3 | Backlinks | Raw View | Raw edit | More topic actions

Physics WebpagesRHUL WebpagesCampus Connect • Royal Holloway, University of London, Egham, Surrey TW20 0EX; Tel/Fax +44 (0)1784 434455/437520

Topic revision: r7 - 19 Oct 2016 - AaronAndrews

 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2021 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding RHUL Physics Department TWiki? Send feedback