diff --git a/sample-project/scripts/simcluster b/sample-project/scripts/simcluster index 93460f2..667c943 100644 --- a/sample-project/scripts/simcluster +++ b/sample-project/scripts/simcluster @@ -23,6 +23,8 @@ def main(argv): help='the x dimension (in pixels) of the image') parser.add_argument('-y', type=int, default=512, help='the y dimension (in pixels) of the image') + parser.add_argument('-sigma', type=float, default=1., + help='the std of the gaussian noise') # Add an argument to handle the output file. If we use argparse.FileType it will # handle opening a writeable file (and ensuring we can write to it). @@ -33,7 +35,7 @@ def main(argv): args = parser.parse_args(argv) - image = simulated_cluster(n_stars=args.stars, dimensions=(args.x, args.y)) + image = simulated_cluster(n_stars=args.stars, dimensions=(args.x, args.y), sigma=args.sigma) # For now the file writing is simple enough that we leave it in the main() function; in the future # we may want to break this out into its own routine that takes a filename and the image array diff --git a/sample-project/simcluster/simcluster.py b/sample-project/simcluster/simcluster.py index 6a66fd1..8ad593d 100644 --- a/sample-project/simcluster/simcluster.py +++ b/sample-project/simcluster/simcluster.py @@ -6,12 +6,14 @@ CLUSTER_DEFAULTS = { 'stars': 10000, - 'dimensions': (512, 512) + 'dimensions': (512, 512), + 'sigma': 1. } def simulated_cluster(n_stars=CLUSTER_DEFAULTS['stars'], - dimensions=CLUSTER_DEFAULTS['dimensions']): + dimensions=CLUSTER_DEFAULTS['dimensions'], + sigma=CLUSTER_DEFAULTS['sigma']): """ Generates an image simulating a cluster of stars, including a Gaussian filter and background noise. @@ -55,7 +57,7 @@ def simulated_cluster(n_stars=CLUSTER_DEFAULTS['stars'], image[y[idx], x[idx]] += fluxes[idx] # Convolve with a gaussian - image = gaussian_filter(image, sigma=1) + image = gaussian_filter(image, sigma=sigma) # Add noise image += np.random.normal(1., 0.001, image.shape)