def qa_image(im, mask=None, context="") -> QA: """Assess the quality of an image :param params: :param im: :return: QA """ assert isinstance(im, Image) if mask is None: data = { 'shape': str(im.data.shape), 'max': numpy.max(im.data), 'min': numpy.min(im.data), 'rms': numpy.std(im.data), 'sum': numpy.sum(im.data), 'medianabs': numpy.median(numpy.abs(im.data)), 'median': numpy.median(im.data) } else: mdata = im.data[mask.data > 0.0] data = { 'shape': str(im.data.shape), 'max': numpy.max(mdata), 'min': numpy.min(mdata), 'rms': numpy.std(mdata), 'sum': numpy.sum(mdata), 'medianabs': numpy.median(numpy.abs(mdata)), 'median': numpy.median(mdata) } qa = QA(origin="qa_image", data=data, context=context) return qa
def qa_image(im, mask=None, **kwargs) -> QA: """Assess the quality of an image :param params: :param im: :return: QA """ assert type(im) == Image if mask is None: data = {'shape': str(im.data.shape), 'max': numpy.max(im.data), 'min': numpy.min(im.data), 'rms': numpy.std(im.data), 'sum': numpy.sum(im.data), 'medianabs': numpy.median(numpy.abs(im.data)), 'median': numpy.median(im.data)} else: mdata = im.data[mask.data > 0.0] data = {'shape': str(im.data.shape), 'max': numpy.max(mdata), 'min': numpy.min(mdata), 'rms': numpy.std(mdata), 'sum': numpy.sum(mdata), 'medianabs': numpy.median(numpy.abs(mdata)), 'median': numpy.median(mdata)} qa = QA(origin="qa_image", data=data, context=get_parameter(kwargs, 'context', "")) return qa
def test_qa(self): qa = QA(origin='foo', data={ 'rms': 100.0, 'median': 10.0 }, context='test of qa') log.debug(str(qa))
def qa_gaintable(gt, context=None): """Assess the quality of a gaintable :param gt: :returns: AQ """ agt = numpy.abs(gt.gain) data = { 'maxabs': numpy.max(agt), 'minabs': numpy.min(agt), 'rms': numpy.std(agt), 'medianabs': numpy.median(agt), 'residual': numpy.max(gt.residual) } return QA(origin='qa_gaintable', data=data, context=context)
def qa_visibility(vis: Union[Visibility, BlockVisibility], context=None) -> QA: """Assess the quality of Visibility :param context: :param vis: Visibility to be assessed :return: QA """ avis = numpy.abs(vis.vis) data = { 'maxabs': numpy.max(avis), 'minabs': numpy.min(avis), 'rms': numpy.std(avis), 'medianabs': numpy.median(avis) } qa = QA(origin=None, data=data, context=context) return qa
def qa_image(im, context="") -> QA: """Assess the quality of an image :param im: :return: QA """ assert isinstance(im, Image), im data = {'shape': str(im.data.shape), 'max': numpy.max(im.data), 'min': numpy.min(im.data), 'rms': numpy.std(im.data), 'sum': numpy.sum(im.data), 'medianabs': numpy.median(numpy.abs(im.data)), 'median': numpy.median(im.data)} qa = QA(origin="qa_image", data=data, context=context) return qa
def qa_gaintable(gt: GainTable, context=None) -> QA: """Assess the quality of a gaintable :param gt: :return: AQ """ agt = numpy.abs(gt.gain) pgt = numpy.angle(gt.gain) data = { 'maxabs-amp': numpy.max(agt), 'minabs-amp': numpy.min(agt), 'rms-amp': numpy.std(agt), 'medianabs-amp': numpy.median(agt), 'maxabs-phase': numpy.max(pgt), 'minabs-phase': numpy.min(pgt), 'rms-phase': numpy.std(pgt), 'medianabs-phase': numpy.median(pgt), 'residual': numpy.max(gt.residual) } return QA(origin='qa_gaintable', data=data, context=context)