Skip to content

Commit

Permalink
Make star code work on phutils 1 and 2
Browse files Browse the repository at this point in the history
  • Loading branch information
mwcraig committed Nov 23, 2024
1 parent afd0ceb commit 7d2d978
Showing 1 changed file with 25 additions and 11 deletions.
36 changes: 25 additions & 11 deletions notebooks/image_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,25 +168,39 @@ def stars(image, number, max_counts=10000, gain=1, fwhm=4):
# Most of the code below is a direct copy/paste from
# https://photutils.readthedocs.io/en/stable/_modules/photutils/datasets/make.html#make_100gaussians_image

model = Gaussian2D()

flux_range = [max_counts / 10, max_counts]

y_max, x_max = image.shape
xmean_range = [0.1 * x_max, 0.9 * x_max]
ymean_range = [0.1 * y_max, 0.9 * y_max]
xstddev_range = [fwhm, fwhm]
ystddev_range = [fwhm, fwhm]
params = make_model_params(image.shape, number, x_name='x_mean',
y_name='y_mean',
amplitude=flux_range, x_stddev=xstddev_range,
y_stddev=ystddev_range, theta=(0, 2*np.pi),
x_mean=xmean_range,y_mean=ymean_range)


star_im = make_model_image(image.shape, model, params,
x_name='x_mean', y_name='y_mean')

input_values = dict(
amplitude=flux_range,
x_mean=xmean_range,
y_mean=ymean_range,
x_stddev=xstddev_range,
y_stddev=ystddev_range,
theta=[0, 2 * np.pi]
)

if NEW_PHOTUTILS:
model = Gaussian2D()
params = make_model_params(image.shape, number, x_name='x_mean',
y_name='y_mean',
**input_values)


star_im = make_model_image(image.shape, model, params,
x_name='x_mean', y_name='y_mean')
else:
sources = make_random_gaussians_table(
number,
input_values,
seed=12345
)
star_im = make_gaussian_sources_image(image.shape, sources)
return star_im


Expand Down

0 comments on commit 7d2d978

Please sign in to comment.