diff --git a/AegeanTools/fitting.py b/AegeanTools/fitting.py index 41523563..e321f87c 100644 --- a/AegeanTools/fitting.py +++ b/AegeanTools/fitting.py @@ -847,85 +847,6 @@ def bias_correct(params, data, acf=None): return -def condon_errors(source, theta_n, psf=None): - """ - Calculate the parameter errors for a fitted source - using the description of Condon'97 - All parameters are assigned errors, assuming that all params were fit. - If some params were held fixed then these errors are overestimated. - - Parameters - ---------- - source : :class:`AegeanTools.models.SimpleSource` - The source which was fit. - - theta_n : float or None - A measure of the beam sampling. (See Condon'97). - - psf : :class:`AegeanTools.wcs_helpers.Beam` - The psf at the location of the source. - - Returns - ------- - None - - """ - - # indices for the calculation or rho - alphas = {'amp': (3. / 2, 3. / 2), - 'major': (5. / 2, 1. / 2), - 'xo': (5. / 2, 1. / 2), - 'minor': (1. / 2, 5. / 2), - 'yo': (1. / 2, 5. / 2), - 'pa': (1. / 2, 5. / 2)} - - major = source.a / 3600. # degrees - minor = source.b / 3600. # degrees - phi = np.radians(source.pa) # radians - if psf is not None: - a, b, _ = psf.get_psf_sky2sky(source.ra, source.dec) - theta_n = np.sqrt(a * b) - - if theta_n is None: - source.err_a = source.err_b = source.err_peak_flux = source.err_pa = source.err_int_flux = 0.0 - return - - smoothing = major * minor / (theta_n ** 2) - factor1 = (1 + (theta_n / major)**2) - factor2 = (1 + (theta_n / minor)**2) - snr = source.peak_flux / source.local_rms - # calculation of rho2 depends on the parameter being used so we lambda this into a function - def rho2(x): return smoothing / 4 * \ - factor1 ** alphas[x][0] * factor2 ** alphas[x][1] * snr ** 2 - - source.err_peak_flux = source.peak_flux * np.sqrt(2 / rho2('amp')) - source.err_a = major * np.sqrt(2 / rho2('major')) * 3600. # arcsec - source.err_b = minor * np.sqrt(2 / rho2('minor')) * 3600. # arcsec - - err_xo2 = 2. / rho2('xo') * major ** 2 / (8 * np.log(2)) # Condon'97 eq 21 - err_yo2 = 2. / rho2('yo') * minor ** 2 / (8 * np.log(2)) - source.err_ra = np.sqrt(err_xo2 * np.sin(phi) ** - 2 + err_yo2 * np.cos(phi)**2) - source.err_dec = np.sqrt(err_xo2 * np.cos(phi) ** - 2 + err_yo2 * np.sin(phi)**2) - - if (major == 0) or (minor == 0): - source.err_pa = ERR_MASK - # if major/minor are very similar then we should not be able to figure out what pa is. - elif abs(2 * (major-minor) / (major+minor)) < 0.01: - source.err_pa = ERR_MASK - else: - source.err_pa = np.degrees( - np.sqrt(4 / rho2('pa')) * (major * minor / (major ** 2 - minor ** 2))) - - # integrated flux error - err2 = (source.err_peak_flux / source.peak_flux) ** 2 - err2 += (theta_n ** 2 / (major * minor)) * \ - ((source.err_a / source.a) ** 2 + (source.err_b / source.b) ** 2) - source.err_int_flux = source.int_flux * np.sqrt(err2) - return - - def errors(source, model, wcshelper): """ Convert pixel based errors into sky coord errors diff --git a/AegeanTools/source_finder.py b/AegeanTools/source_finder.py index efcf000e..8ec928a4 100755 --- a/AegeanTools/source_finder.py +++ b/AegeanTools/source_finder.py @@ -594,7 +594,6 @@ def characterise_islands( 'best' - Uncertainties measured based on covariance matrix of the fit and of the data See Hancock et al. 2018 for a description of this process. - 'condon' - Uncertainties are *calculated* based on Condon'98 (?year) 'raw' - uncertainties directly from the covariance matrix only 'none' or None - No uncertainties, all will be set to -1. diff --git a/scripts/aegean b/scripts/aegean index 6532206f..b54aea1d 100755 --- a/scripts/aegean +++ b/scripts/aegean @@ -132,8 +132,6 @@ if __name__ == "__main__": help="Use this regions file to restrict source finding in this image.\nUse MIMAS region (.mim) files.") group4.add_argument('--nocov', dest='docov', action="store_false", default=True, help="Don't use the covariance of the data in the fitting proccess. [Default = False]") - group4.add_argument('--condon', dest='condon', action="store_true", default=False, - help="replace errors with those suggested by Condon'97. [Default = False]") # priorized fitting group5 = parser.add_argument_group( @@ -381,18 +379,6 @@ if __name__ == "__main__": progress=options.progress, regroup_eps=options.regroup_eps) sources = sf.sources - # if --condon is set then we replace all the errors with those described by Condon'97 - if options.condon: - # theta_N is the FWHM of the smoothing kernel (the noise correlation) - # which in this case is the same as the synthesized beam FWHM - if options.beam: - theta_n = np.sqrt(options.beam.a * options.beam.b) - psf = None - else: - psf = sf.global_data.psfhelper - theta_n = None - for s in sources: - fitting.condon_errors(s, theta_n=theta_n, psf=psf) log.info("found {0} sources total".format(len(sources))) if len(sources) > 0 and options.tables: diff --git a/tests/test_fitting.py b/tests/test_fitting.py index 875033f8..b9783824 100755 --- a/tests/test_fitting.py +++ b/tests/test_fitting.py @@ -178,40 +178,6 @@ def test_bias_correct(): fitting.bias_correct(model, data) -def test_condon_errs(): - """Test that we can create Condon errors""" - source = models.ComponentSource() - source.ra = 0 - source.dec = 1 - source.a = 10 - source.b = 10 - source.pa = 0 - source.local_rms = 0.1 - source.peak_flux = 1 - source.int_flux = 1 - - fitting.condon_errors(source, None) - if not (source.err_a == 0): - raise AssertionError( - "err_a should be zero but is {0}".format(source.err_a)) - - fitting.condon_errors(source, theta_n=8.) - if not (source.err_a > 0): - raise AssertionError("err_a should be non-zero") - - # test that we can get a PA error - source.a = 20 - fitting.condon_errors(source, None) - if source.err_pa < 0: - raise AssertionError("err_pa<0") - - psf = wcs_helpers.WCSHelper.from_file('tests/test_files/1904-66_SIN.fits') - try: - fitting.condon_errors(source, theta_n=8., psf=psf) - except AttributeError as e: - raise AssertionError("condon_errors failed with psf") - - if __name__ == "__main__": # introspect and run all the functions starting with 'test' for f in dir():