-
-
Notifications
You must be signed in to change notification settings - Fork 145
Open
Labels
Description
We’re having an issue with EPSFBuilder where our resultant epsf appears to not be resampling properly when we have an oversampling greater than 1. We are inputing 32 stars, and have an oversampling of 5. When looking at the 3d and top down view, it is clear that pixel to pixel is not continuous. We’ve tried increasing the number of stars to as many as 123, but the ending epsf has the same issue.
Here is the code making the epsf and the 3d and 2d plots:
from astropy.io import fits
import matplotlib.pyplot as plt
import numpy as np
from astropy.nddata import NDData
from astropy.wcs import WCS
from astropy import units as u
from astropy.coordinates import SkyCoord
from photutils.psf import EPSFBuilder
from photutils.psf import extract_stars
from astropy.table import Table
obj_filepath ='cpt1m013-fa14-20210412-0125-e91.fits'
hdu = fits.open(obj_filepath)
data = hdu[0].data
cat_data = hdu[1].data
cat_header = hdu[1].header
header = hdu[0].header
hdu.close()
wcs = WCS(header)
cat_ra = cat_data['ra']
cat_dec = cat_data['dec']
cat_fwhm = cat_data['fwhm']
cat_peak = cat_data['peak']
stars_wcscoords = SkyCoord(ra=cat_ra*u.degree, dec=cat_dec*u.degree, frame='icrs')
stars_pixcoords_x = wcs.world_to_pixel(stars_wcscoords)[0]
stars_pixcoords_y = wcs.world_to_pixel(stars_wcscoords)[1]
size = 25
hsize = (size - 1) / 2
mask = ((stars_pixcoords_x > hsize) & (stars_pixcoords_x < (data.shape[1] -1 - hsize)) &
(stars_pixcoords_y > hsize) & (stars_pixcoords_y < (data.shape[0] -1 - hsize)) &
(cat_fwhm > 4) & (cat_fwhm < 5) & (cat_peak > 250) & (cat_peak < 100000))
stars_tbl = Table()
stars_tbl['x'] = stars_pixcoords_x[mask]
stars_tbl['y'] = stars_pixcoords_y[mask]
nddata = NDData(data=data)
stars = extract_stars(nddata, stars_tbl, size=25)
epsf_builder = EPSFBuilder(oversampling=5, maxiters=1, progress_bar=False)
epsf, fitted_stars = epsf_builder.build_epsf(stars)
x = np.arange(epsf.shape[1])
y = np.arange(epsf.shape[0])
x, y = np.meshgrid(x, y)
fig = plt.figure(1)
ax = fig.add_subplot(111, projection='3d')
ax.plot_surface(x, y, epsf.data, cmap='viridis')
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_title('32 stars')
plt.show()
fig = plt.figure(2)
plt.imshow(epsf.data, origin='lower')
plt.title('32 stars')
plt.colorbar()
plt.show()



