def test_line_fit(): """Fit a Gaussian1D line to the data.""" plots = Imexamine() plots.set_data(test_data) fit = plots.line_fit(50, 50, form='Gaussian1D', genplot=False) amp = 2.8152269683542137 mean = 49.45671107821953 stddev = 13.051081779478146 assert_allclose(amp, fit.amplitude, 1e-6) assert_allclose(mean, fit.mean, 1e-6) assert_allclose(stddev, fit.stddev, 1e-6)
def test_line_fit(): """Fit a Gaussian1D line to the data.""" plots = Imexamine() in_amp = 3. in_mean = 50. in_stddev = 2. in_const = 20. # Set all the lines to be Gaussians line_gauss = in_const + in_amp * np.exp(-0.5 * ((xx - in_mean) / in_stddev)**2) plots.set_data(line_gauss) fit = plots.line_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)
images = sorted(filename.glob('indiir1_20*.fits')) 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))