Beispiel #1
0
def beam_invalid(semibmaj, semibmin, oversampled_x=30, elliptical_x=2.0):
    """ Are the beam shape properties ok?

    :param semibmaj/semibmin: size of the beam in pixels

    :returns: True/False
    """

    formatted = "bmaj=%s and bmin=%s (pixels)" % (nice_format(semibmaj),
                                                 nice_format(semibmin))

    if tkp.quality.restoringbeam.undersampled(semibmaj, semibmin):
        return "Beam undersampled. %s" % formatted
    elif tkp.quality.restoringbeam.oversampled(semibmaj, semibmin,
        oversampled_x):
        return "Beam oversampled. %s" % formatted
    elif tkp.quality.restoringbeam.highly_elliptical(semibmaj, semibmin, elliptical_x):
        return "Beam too elliptical. %s" % formatted

    #TODO: this test has been disabled untill antonia solves issue discribed in #3802
    #elif not tkp.quality.restoringbeam.full_fieldofview(nx, ny, cellsize, fov):
    #    return "Full field of view not imaged. Imaged FoV=XXdegrees, Observed FoV=XXdegrees"

    else:
        return False
Beispiel #2
0
def reject_check_lofar(accessor, job_config):

    lofar_quality_params = job_config['quality_lofar']

    low_bound = lofar_quality_params['low_bound']
    high_bound = lofar_quality_params['high_bound']
    oversampled_x = lofar_quality_params['oversampled_x']
    elliptical_x = lofar_quality_params['elliptical_x']
    min_separation = lofar_quality_params['min_separation']

    if accessor.tau_time == 0:
        logger.info("image %s REJECTED: tau_time is 0, should be > 0" %
                    accessor.url)
        return tkp.db.quality.reason['tau_time'], "tau_time is 0"

    rms_est_sigma = job_config.persistence.rms_est_sigma
    rms_est_fraction = job_config.persistence.rms_est_fraction
    rms_qc = rms_with_clipped_subregion(accessor.data,
                                        rms_est_sigma=rms_est_sigma,
                                        rms_est_fraction=rms_est_fraction)

    noise = noise_level(accessor.freq_eff, accessor.freq_bw, accessor.tau_time,
                        accessor.antenna_set, accessor.ncore, accessor.nremote,
                        accessor.nintl)
    rms_check = rms_invalid(rms_qc, noise, low_bound, high_bound)
    if not rms_check:
        logger.info("image %s accepted: rms: %s, theoretical noise: %s" % \
                        (accessor.url, nice_format(rms_qc),
                         nice_format(noise)))
    else:
        logger.info("image %s REJECTED: %s " % (accessor.url, rms_check))
        return (tkp.db.quality.reason['rms'].id, rms_check)

    # beam shape check
    (semimaj, semimin, theta) = accessor.beam
    beam_check = beam_invalid(semimaj, semimin, theta, oversampled_x,
                              elliptical_x)

    if not beam_check:
        logger.info("image %s accepted: semimaj: %s, semimin: %s" %
                    (accessor.url, nice_format(semimaj), nice_format(semimin)))
    else:
        logger.info("image %s REJECTED: %s " % (accessor.url, beam_check))
        return (tkp.db.quality.reason['beam'].id, beam_check)

    # Bright source check
    bright = tkp.quality.brightsource.is_bright_source_near(
        accessor, min_separation)
    if bright:
        logger.info("image %s REJECTED: %s " % (accessor.url, bright))
        return (tkp.db.quality.reason['bright_source'].id, bright)
Beispiel #3
0
def reject_check_lofar(accessor, job_config):

    lofar_quality_params = job_config['quality_lofar']

    low_bound = lofar_quality_params['low_bound']
    high_bound = lofar_quality_params['high_bound']
    oversampled_x = lofar_quality_params['oversampled_x']
    elliptical_x = lofar_quality_params['elliptical_x']
    min_separation = lofar_quality_params['min_separation']

    if accessor.tau_time == 0:
        logger.info("image %s REJECTED: tau_time is 0, should be > 0" % accessor.url)
        return tkp.db.quality.reason['tau_time'], "tau_time is 0"

    rms_est_sigma = job_config.persistence.rms_est_sigma
    rms_est_fraction = job_config.persistence.rms_est_fraction
    rms_qc = rms_with_clipped_subregion(accessor.data,
                                        rms_est_sigma=rms_est_sigma,
                                        rms_est_fraction=rms_est_fraction)

    noise = noise_level(accessor.freq_eff, accessor.freq_bw, accessor.tau_time,
        accessor.antenna_set, accessor.ncore, accessor.nremote, accessor.nintl
    )
    rms_check = rms_invalid(rms_qc, noise, low_bound, high_bound)
    if not rms_check:
        logger.info("image %s accepted: rms: %s, theoretical noise: %s" % \
                        (accessor.url, nice_format(rms_qc),
                         nice_format(noise)))
    else:
        logger.info("image %s REJECTED: %s " % (accessor.url, rms_check))
        return (tkp.db.quality.reason['rms'].id, rms_check)

    # beam shape check
    (semimaj, semimin, theta) = accessor.beam
    beam_check = beam_invalid(semimaj, semimin, theta, oversampled_x, elliptical_x)

    if not beam_check:
        logger.info("image %s accepted: semimaj: %s, semimin: %s" % (accessor.url,
                                             nice_format(semimaj),
                                             nice_format(semimin)))
    else:
        logger.info("image %s REJECTED: %s " % (accessor.url, beam_check))
        return (tkp.db.quality.reason['beam'].id, beam_check)

    # Bright source check
    bright = tkp.quality.brightsource.is_bright_source_near(accessor, min_separation)
    if bright:
        logger.info("image %s REJECTED: %s " % (accessor.url, bright))
        return (tkp.db.quality.reason['bright_source'].id, bright)
Beispiel #4
0
def rms_invalid(rms, noise, low_bound=1, high_bound=50):
    """
    Is the RMS value of an image outside the plausible range?

    :param rms: RMS value of an image, can be computed with
                tkp.quality.statistics.rms
    :param noise: Theoretical noise level of instrument, can be calculated with
                  tkp.lofar.noise.noise_level
    :param low_bound: multiplied with noise to define lower threshold
    :param high_bound: multiplied with noise to define upper threshold
    :returns: True/False
    """
    if (rms < noise * low_bound) or (rms > noise * high_bound):
        ratio = rms / noise
        return "rms value (%s) is %s times theoretical noise (%s)" % \
                    (nice_format(rms), nice_format(ratio), nice_format(noise))
    else:
        return False
Beispiel #5
0
def rms_invalid(rms, noise, low_bound=1, high_bound=50):
    """
    Is the RMS value of an image outside the plausible range?

    :param rms: RMS value of an image, can be computed with
                tkp.quality.statistics.rms
    :param noise: Theoretical noise level of instrument, can be calculated with
                  tkp.lofar.noise.noise_level
    :param low_bound: multiplied with noise to define lower threshold
    :param high_bound: multiplied with noise to define upper threshold
    :returns: True/False
    """
    if (rms < noise * low_bound) or (rms > noise * high_bound):
        ratio = rms / noise
        return "rms value (%s) is %s times theoretical noise (%s)" % \
                    (nice_format(rms), nice_format(ratio), nice_format(noise))
    else:
        return False
Beispiel #6
0
def reject_check_lofar(accessor, parset):
    sigma = parset['sigma']
    f = parset['f']
    low_bound = parset['low_bound']
    high_bound = parset['high_bound']
    oversampled_x = parset['oversampled_x']
    elliptical_x = parset['elliptical_x']
    min_separation = parset['min_separation']

    # RMS value check
    rms = rms_with_clipped_subregion(accessor.data, sigma, f)
    lofar_metadata = accessor.extra_metadata
    noise = noise_level(accessor.freq_eff, accessor.freq_bw, accessor.tau_time,
                    lofar_metadata['antenna_set'], lofar_metadata['ncore'],
                    lofar_metadata['nremote'], lofar_metadata['nintl'])
    rms_check = rms_invalid(rms, noise, low_bound, high_bound)
    if not rms_check:
        logger.info("image %s accepted: rms: %s, theoretical noise: %s" % \
                        (accessor.url, nice_format(rms),
                         nice_format(noise)))
    else:
        logger.info("image %s REJECTED: %s " % (accessor.url, rms_check))
        return (tkp.db.quality.reason['rms'].id, rms_check)

    # beam shape check
    (semimaj, semimin, theta) = accessor.beam
    beam_check = beam_invalid(semimaj, semimin, oversampled_x, elliptical_x)

    if not beam_check:
        logger.info("image %s accepted: semimaj: %s, semimin: %s" % (accessor.url,
                                             nice_format(semimaj),
                                             nice_format(semimin)))
    else:
        logger.info("image %s REJECTED: %s " % (accessor.url, beam_check))
        return (tkp.db.quality.reason['beam'].id, beam_check)

    # Bright source check
    bright = tkp.quality.brightsource.is_bright_source_near(accessor, min_separation)
    if bright:
        logger.info("image %s REJECTED: %s " % (accessor.url, bright))
        return (tkp.db.quality.reason['bright_source'].id, bright)