Beispiel #1
0
def setupMetrics(opsimName, metadata, plotlabel='', t0=0, tStep=40./24./60./60., years=0,
                 onlyFilterColors=False, verbose=False):
    # Set up metrics and plotDicts (they will be bundled with the appropriate opsim slicers below).
    t = time.time()
    nvisitsMax = 90*(years+1)
    colorMax = int(nvisitsMax/4)
    metricList = []
    plotDictList = []
    figsize = (8, 6)
    if not onlyFilterColors:
        metricList.append(metrics.CountMetric('observationStartMJD', metricName='Nvisits'))
        plotDictList.append({'colorMin': 0, 'colorMax': nvisitsMax,
                             'xlabel': 'Number of visits', 'title': 'Cumulative visits (all bands)',
                             'label': plotlabel, 'metricIsColor': False, 'figsize': figsize})
        for f in (['u', 'g', 'r', 'i', 'z', 'y']):
            metricList.append(metrics.CountSubsetMetric('filter', subset=f, metricName='Nvisits_'+f))
            plotDictList.append({'colorMin': 0, 'colorMax': colorMax, 'cbarFormat': '%d',
                                 'xlabel': 'Number of Visits', 'title': '%s band' %(f),
                                 'label': plotlabel, 'metricIsColor': False, 'figsize': figsize})
    metricList.append(metrics.FilterColorsMetric(t0=t0, tStep=tStep))
    plotDictList.append({'title': 'Simulation %s: %s' %(opsimName, metadata), 'bgcolor': None,
                         'metricIsColor': True, 'figsize': figsize})
    dt, t = dtime(t)
    if verbose:
        print('Set up metrics %f s' %(dt))
    return metricList, plotDictList
 def testCountSubsetMetric(self):
     """Test countsubset metric."""
     testmetric = metrics.CountSubsetMetric('testdata', subset=0)
     self.assertEqual(testmetric.run(self.dv), 1)