#PH4100 Major Poject - Photometry - Star field simulation program (2) #Aaron Andrews #Last edited: 05/10/2016 #This program generates a set number of stars with random positions and max. grey values. #Stars are assumed to have 2d gaussian profiles. #The output is a 2d array representing an image of a star field - each cell stores a grey value calculated using the cumulative gaussian profiles for all stars generated. #The star field representation generated by this particular program is not accurate. import math import random as rm import numpy as np import matplotlib import matplotlib.pyplot as plt import matplotlib.image as mpimg def Gaussian(x,y,xStar,yStar,xSig,ySig,peak): #2d gaussian function, returns grey value contribution from a single star for any point in the star field return peak*math.exp(-((((x-xStar)**2)/(2*xSig**2))+(((y-yStar)**2)/(2*ySig**2)))) def SimStarField(nxPixel,nyPixel,MaxPixelValue,nStars): #Create empty arrays Image1=np.zeros((nxPixel,nyPixel)) #array to be output once filled - each cell contains grey values (no. of photons detected) PosX=np.zeros(nStars) #x coordinates PosY=np.zeros(nStars) #y coordinates Peak=np.zeros(nStars) #peak grey value for each star #Loop over all stars n=0 while n