You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello! I'm using the CCD Guide in my class this semester, and we've run into an issue with image_sim.py. The Guide is written using an older version of photutils, and the latest release no longer includes two of the functions used for simulating fake stars: photutils.datasets.make_random_gaussians_table and photutils.datasets.make_gaussian_sources_image. They've been superceded by the more general functions photutils.datasets.make_model_image and photutils.datasets.make_model_params.
For most of us with relatively recent anaconda installations (using Python 3.12), conda could not find an environment solution to install the necessary packages with an older version of photutils. Two of my students had older anaconda installations that used Python 3.9, and it installed the older photutils (and compatible packages) just fine. For some reason conda would not find a solution on our newer installations even if we requested Python 3.9, so that doesn't seem to be a universal solution.
I found a workaround for using the latest photutils with an updated version of image_sim.py. I'm pasting in my updated lines below for reference. I can make a pull request if desired, but since this version won't work with an older version of photutils, I didn't want to do so just yet.
The import line (currently lines 6-7) becomes
from photutils.datasets import make_model_image, make_model_params
And then the new stars function becomes
def stars(image, number, max_counts=10000, gain=1, fwhm=4):
"""
Add some stars to the image.
"""
# 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')
return star_im
So now params is the output of make_model_params, and is passed directly into make_model_image rather than the intermediate step of the sources table.
The text was updated successfully, but these errors were encountered:
Hi @stephtdouglas, thanks for reporting this. If you could open a PR that would be great. I'll add a bit of code to the PR that ensures it works with older or new versions of stellarphot.
If you don't have a chance before then, I can open the PR on Tuesday of this week.
Hi @mwcraig - unfortunately I didn't end up having time to open a PR today, sorry! I did also want to note that this issue affects notebook 01-03-Construction..., which duplicates the stars function.
Hello! I'm using the CCD Guide in my class this semester, and we've run into an issue with image_sim.py. The Guide is written using an older version of photutils, and the latest release no longer includes two of the functions used for simulating fake stars:
photutils.datasets.make_random_gaussians_table
andphotutils.datasets.make_gaussian_sources_image
. They've been superceded by the more general functionsphotutils.datasets.make_model_image
andphotutils.datasets.make_model_params
.For most of us with relatively recent anaconda installations (using Python 3.12), conda could not find an environment solution to install the necessary packages with an older version of photutils. Two of my students had older anaconda installations that used Python 3.9, and it installed the older photutils (and compatible packages) just fine. For some reason conda would not find a solution on our newer installations even if we requested Python 3.9, so that doesn't seem to be a universal solution.
I found a workaround for using the latest photutils with an updated version of image_sim.py. I'm pasting in my updated lines below for reference. I can make a pull request if desired, but since this version won't work with an older version of photutils, I didn't want to do so just yet.
The import line (currently lines 6-7) becomes
And then the new stars function becomes
So now params is the output of
make_model_params
, and is passed directly intomake_model_image
rather than the intermediate step of the sources table.The text was updated successfully, but these errors were encountered: