def test_column_fit(): """Fit a Gaussian1D column to the data.""" plots = Imexamine() plots.set_data(test_data) fit = plots.column_fit(50, 50, form='Gaussian1D', genplot=False) amp = 2.8285560281694115 mean = 49.42625526973088 stddev = 12.791137635400535 assert_allclose(amp, fit.amplitude, 1e-6) assert_allclose(mean, fit.mean, 1e-6) assert_allclose(stddev, fit.stddev, 1e-6)
def test_column_fit(): """Fit a Gaussian1D column to the data.""" plots = Imexamine() in_amp = 3. in_mean = 50. in_stddev = 2. in_const = 20. # Set all the columns to be Gaussians col_gauss = in_const + in_amp * np.exp(-0.5 * ((yy - in_mean) / in_stddev)**2) plots.set_data(col_gauss) fit = plots.column_fit(50, 50, form='Gaussian1D', genplot=False) assert_allclose(in_amp, fit.amplitude_0, 1e-6) assert_allclose(in_mean, fit.mean_0, 1e-6) assert_allclose(in_stddev, fit.stddev_0, 1e-6) assert_allclose(in_const, fit.c0_1, 1e-6)
region_name = sorted(rfile.glob('indiir1_*.coo')) plots = Imexamine() for names, stars in zip(images, region_name): data = fits.getdata(names) plots.set_data(data) starlist = ascii.read(stars, data_start=3) plots.line_fit_pars['func'] = ['Moffat1D'] plots.column_fit_pars['func'] = ['Moffat1D'] results = dict() yresults = dict() for star in starlist: sid, x, y, a4, a5, a6, a7 = star moff = plots.line_fit(x, y, genplot=False) ymoff = plots.column_fit(x, y, genplot=False) # print(moff) results[x] = mfwhm(alpha=moff.alpha_0, gamma=moff.gamma_0) yresults[y] = mfwhm(alpha=ymoff.alpha_0, gamma=ymoff.gamma_0) # gresults[x] = gfwhm(moff.stddev_0)[0] # gyresults[y] = gfwhm(ymoff.stddev_0)[1] print(names, np.median(list(results.values())), np.median(list(yresults.values()))) # plt.figure() # plt.subplot(121) # plt.hist(yresults.values(), bins='auto', alpha=.7, range=(3.,7.5)) # plt.hist(results.values(), bins='auto', alpha=.7, range=(3.,7.5)) # plt.subplot(122) # plt.hist(gyresults.values(), bins='auto', alpha=.7, range=(3.,7.5)) # plt.hist(gresults.values(), bins='auto', alpha=.7, range=(3.,7.5))