Commit bd4eaf25 authored by skamann's avatar skamann
Browse files

Added check for negative variances.

parent b8906c7a
......@@ -562,6 +562,9 @@ class FitLayer(object):
# Determine initial weights for each pixel in the fit.
self.fit_weights = 1./self.variances
if (self.fit_weights < 0).any():
logger.error('Input data contain unphysical negative variances.')
self.fit_weights[self.fit_weights < 0] = 0.
# start iterations
for iteration in range(1, max_iterations + 1):
......@@ -1120,7 +1123,7 @@ class FitLayer(object):
# vmax=0.01)
# ax2 = fig.add_axes([0.12, 0.05, 0.83, 0.44])
# ax2.scatter(psf.x[used], psf.y[used], marker='o', s=50,
# c=self.current[used], cmap=plt.cm.hot, vmin=-1000, vmax=10000)
# c=data, cmap=plt.cm.hot) # , vmin=-1000, vmax=10000)
# plt.show()
# prior to fit, check if enough pixels available and source is actually detected
......
......@@ -447,7 +447,7 @@ class Maoppy(Profile):
theta = 0.
f = psf((r0, bck, amp, alpha, 1-e, theta, beta))[:15]
return np.sqrt(np.sum(f > (0.5*f.max()))/np.pi)
return 2.*np.sqrt(np.sum(f > (0.5*f.max()))/np.pi)
@property
def fwhm(self):
......@@ -457,7 +457,16 @@ class Maoppy(Profile):
fwhm : float
The FWHM of the MAOPPY PSF profile with the given parameters.
"""
return np.sqrt(np.sum(self.f > (0.5*np.max(self.f)))/np.pi)
from scipy.stats import binned_statistic
# get mean radii for fluxes for annuli of widths ~1 pixel
bstat = binned_statistic(self.r, [self.r, self.f], bins=self.maxrad)
r_bin, f_bin = bstat.statistic
# interpolate along flux axis to get FWHM. Note that flux values must be monotonically INCREASING
fwhm = 2.*np.interp(0.5*self.f.max(), f_bin[::-1], r_bin[::-1])
return fwhm
def fitter(self, psf, weights, parameters, fit_positions=True, fit_background=False, psf_padding=0, **kwargs):
"""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment