Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion sample-project/scripts/simcluster
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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
Expand Down
8 changes: 5 additions & 3 deletions sample-project/simcluster/simcluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down