Пример #1
0
 def testNoutliersNsigma(self):
     data = self.dv
     testmetric = metrics.NoutliersNsigmaMetric('testdata', nSigma=1.)
     med = np.mean(data['testdata'])
     shouldBe = np.size(np.where(data['testdata'] > med + data['testdata'].std())[0])
     self.assertEqual(shouldBe, testmetric.run(data))
     testmetric = metrics.NoutliersNsigmaMetric('testdata', nSigma=-1.)
     shouldBe = np.size(np.where(data['testdata'] < med - data['testdata'].std())[0])
     self.assertEqual(shouldBe, testmetric.run(data))
Пример #2
0
def standardSummary():
    """A set of standard summary metrics, to calculate Mean, RMS, Median, #, Max/Min, and # 3-sigma outliers.
    """
    standardSummary = [
        metrics.MeanMetric(),
        metrics.RmsMetric(),
        metrics.MedianMetric(),
        metrics.CountMetric(),
        metrics.MaxMetric(),
        metrics.MinMetric(),
        metrics.NoutliersNsigmaMetric(metricName='N(+3Sigma)', nSigma=3),
        metrics.NoutliersNsigmaMetric(metricName='N(-3Sigma)', nSigma=-3.)
    ]
    return standardSummary
Пример #3
0
def extendedMetrics(colname, replace_colname=None):
    """An extended set of simple metrics for some quantity. Typically applied with unislicer.

    Parameters
    ----------
    colname : str
        The column name to apply the metrics to.
    replace_colname: str or None, opt
        Value to replace colname with in the metricName.
        i.e. if replace_colname='' then metric name is Mean, instead of Mean Airmass, or
        if replace_colname='seeingGeom', then metric name is Mean seeingGeom instead of Mean seeingFwhmGeom.
        Default is None, which does not alter the metric name.

    Returns
    -------
    List of configured metrics.
    """
    extendedMetrics = standardMetrics(colname, replace_colname=None)
    extendedMetrics += [
        metrics.RmsMetric(colname),
        metrics.NoutliersNsigmaMetric(colname,
                                      metricName='N(+3Sigma) ' + colname,
                                      nSigma=3),
        metrics.NoutliersNsigmaMetric(colname,
                                      metricName='N(-3Sigma) ' + colname,
                                      nSigma=-3),
        metrics.PercentileMetric(colname, percentile=25),
        metrics.PercentileMetric(colname, percentile=75),
        metrics.CountMetric(colname)
    ]
    if replace_colname is not None:
        for m in extendedMetrics:
            if len(replace_colname) > 0:
                m.name = m.name.replace('%s' % colname, '%s' % replace_colname)
            else:
                m.name = m.name.rstrip(' %s' % colname)
    return extendedMetrics