示例#1
0
def run(bdict, opsdb, colmap, args):
    resultsDb = db.ResultsDb(outDir=args.outDir)
    group = mb.MetricBundleGroup(bdict, opsdb, outDir=args.outDir, resultsDb=resultsDb)
    group.runAll()
    group.plotAll()
    resultsDb.close()
    mafUtils.writeConfigs(opsdb, args.outDir)
示例#2
0
文件: run_slew.py 项目: lsst/sims_maf
def runSlew(opsdb, colmap, args):
    resultsDb = db.ResultsDb(outDir=args.outDir)
    bdict = batches.slewBasics(colmap, args.runName)
    dbTable = None
    group = mb.MetricBundleGroup(bdict, opsdb, outDir=args.outDir, resultsDb=resultsDb, dbTable=dbTable)
    group.runAll()
    group.plotAll()
    if 'slewStatesTable' in colmap:
        bdict = batches.slewAngles(colmap, args.runName)
        dbTable = colmap['slewStatesTable']
        group = mb.MetricBundleGroup(bdict, opsdb, outDir=args.outDir, resultsDb=resultsDb, dbTable=dbTable)
        group.runAll()
        group.plotAll()
    if 'slewSpeedsTable' in colmap:
        bdict = batches.slewSpeeds(colmap, args.runName)
        dbTable = colmap['slewSpeedsTable']
        group = mb.MetricBundleGroup(bdict, opsdb, outDir=args.outDir, resultsDb=resultsDb, dbTable=dbTable)
        group.runAll()
        group.plotAll()
    if 'slewActivitiesTable' in colmap:
        nslews = opsdb.fetchTotalSlewN()
        bdict = batches.slewActivities(colmap, args.runName, totalSlewN=nslews)
        dbTable = colmap['slewActivitiesTable']
        group = mb.MetricBundleGroup(bdict, opsdb, outDir=args.outDir, resultsDb=resultsDb, dbTable=dbTable)
        group.runAll()
        group.plotAll()
    resultsDb.close()
    mafUtils.writeConfigs(opsdb, args.outDir)
示例#3
0
def run(bdict, opsdb, colmap, args):
    resultsDb = db.ResultsDb(outDir=args.outDir)
    group = mb.MetricBundleGroup(bdict, opsdb, outDir=args.outDir, resultsDb=resultsDb)
    group.runAll()
    group.plotAll()
    resultsDb.close()
    mafUtils.writeConfigs(opsdb, args.outDir)
示例#4
0
def run(bdict, opsdb, colmap, args, save=True):
    resultsDb = db.ResultsDb(outDir=args.outDir)
    group = mb.MetricBundleGroup(bdict,
                                 opsdb,
                                 outDir=args.outDir,
                                 resultsDb=resultsDb,
                                 saveEarly=False)
    if save:
        group.runAll()
        group.plotAll()
    else:
        group.runAll(clearMemory=True, plotNow=True)
    resultsDb.close()
    mafUtils.writeConfigs(opsdb, args.outDir)
示例#5
0
def runSlew(opsdb, colmap, args):
    resultsDb = db.ResultsDb(outDir=args.outDir)
    bdict = batches.slewBasics(colmap, args.runName)
    dbTable = None
    group = mb.MetricBundleGroup(bdict,
                                 opsdb,
                                 outDir=args.outDir,
                                 resultsDb=resultsDb,
                                 dbTable=dbTable)
    group.runAll()
    group.plotAll()
    if 'slewStatesTable' in colmap:
        bdict = batches.slewAngles(colmap, args.runName)
        dbTable = colmap['slewStatesTable']
        group = mb.MetricBundleGroup(bdict,
                                     opsdb,
                                     outDir=args.outDir,
                                     resultsDb=resultsDb,
                                     dbTable=dbTable)
        group.runAll()
        group.plotAll()
    if 'slewSpeedsTable' in colmap:
        bdict = batches.slewSpeeds(colmap, args.runName)
        dbTable = colmap['slewSpeedsTable']
        group = mb.MetricBundleGroup(bdict,
                                     opsdb,
                                     outDir=args.outDir,
                                     resultsDb=resultsDb,
                                     dbTable=dbTable)
        group.runAll()
        group.plotAll()
    if 'slewActivitiesTable' in colmap:
        nslews = opsdb.fetchTotalSlewN()
        bdict = batches.slewActivities(colmap, args.runName, totalSlewN=nslews)
        dbTable = colmap['slewActivitiesTable']
        group = mb.MetricBundleGroup(bdict,
                                     opsdb,
                                     outDir=args.outDir,
                                     resultsDb=resultsDb,
                                     dbTable=dbTable)
        group.runAll()
        group.plotAll()
    resultsDb.close()
    mafUtils.writeConfigs(opsdb, args.outDir)
示例#6
0
                        help="Can be 'design' or 'requested'")
    parser.add_argument('--plotOnly', dest='plotOnly', action='store_true',
                        default=False, help="Reload the metric values from disk and re-plot them.")

    parser.set_defaults()
    args, extras = parser.parse_known_args()

    # Build metric bundles.
    bundleDict = makeBundleList(args.dbFile, nside=args.nside,
                                lonCol=args.lonCol, latCol=args.latCol,
                                benchmark=args.benchmark)

    # Set up / connect to resultsDb.
    resultsDb = db.ResultsDb(outDir=args.outDir)
    # Connect to opsimdb.
    opsdb = utils.connectOpsimDb(args.dbFile)

    # Set up metricBundleGroup.
    group = metricBundles.MetricBundleGroup(bundleDict, opsdb,
                                            outDir=args.outDir, resultsDb=resultsDb)
    # Read or run to get metric values.
    if args.plotOnly:
        group.readAll()
    else:
        group.runAll()
    # Make plots.
    group.plotAll()

    # Get config info and write to disk.
    utils.writeConfigs(opsdb, args.outDir)
示例#7
0
    opsdb = db.OpsimDatabaseV4(args.dbFile)

    if args.runNoSave:
        group = metricBundles.MetricBundleGroup(noSaveBundleDict, opsdb, saveEarly=False,
                                                outDir=args.outDir, resultsDb=resultsDb)
        group.runAll(clearMemory=True, plotNow=True)
        del group, noSaveBundleDict

    # Set up metricBundleGroup.
    group = metricBundles.MetricBundleGroup(bundleDict, opsdb,
                                            outDir=args.outDir, resultsDb=resultsDb)
    # Read or run to get metric values.
    if args.plotOnly:
        group.readAll()
    else:
        group.runAll()
    # Make plots.
    group.plotAll()
    # Make merged plots.
    for key in mergedHistDict:
        if len(mergedHistDict[key].bundleList) > 0:
            mergedHistDict[key].incrementPlotOrder()
            mergedHistDict[key].plot(outDir=args.outDir, resultsDb=resultsDb, closeFigs=True)
        else:
            warnings.warn('Empty bundleList for %s, skipping merged histogram' % key)
    # Get config info and write to disk.
    utils.writeConfigs(opsdb, args.outDir)
    opsdb.close()

    print("Finished sciencePerformance metric calculations.")
示例#8
0
    
    hAcadence = np.median(c[high_accuracy])
    results['hA_cadence'] = hAcadence
    hAseason = np.median(s[high_accuracy])
    results['hA_season'] = hAseason
    hAcampaign = np.median(y[high_accuracy])
    results['hA_campaign'] = hAcampaign
    
    precision_per_lens = np.array([np.mean(P[high_accuracy]), 4.0])
    precision_per_lens = np.sqrt(np.sum(precision_per_lens * precision_per_lens))
    results['precision_per_lens'] = precision_per_lens
    
    fraction_found = np.mean(f[high_accuracy])
    results['hA_rate'] = fraction_found
    n_lenses = int((hAarea / 18000.0) * (fraction_found / 30.0) * 400)
    results['N_lenses'] = n_lenses
    
    distance_precision = precision_per_lens / np.sqrt(n_lenses)
    results['distance_precision'] = distance_precision
    # Write these summary values to the resultsDb
    metricId = resultsDb.updateMetric(bundle.metric.name, bundle.slicer.slicerName,
                                      args.runName, bundle.constraint, bundle.metadata, None)
    for k in results:
        resultsDb.updateSummaryStat(metricId, summaryName=k, summaryValue=results[k])
        
    # Write config to disk.
    mafUtils.writeConfigs(opsdb, args.outDir)

    resultsDb.close()
    opsdb.close()