Beispiel #1
0
    args = parser.parse_args()

    # Check tracking DB is sqlite (and add as convenience if forgotten).
    trackingDb = args.trackingDb
    print('Using tracking database at %s' % (trackingDb))

    global startRunId
    startRunId = -666
    # If given a directory argument:
    if args.mafDir is not None:
        mafDir = os.path.realpath(args.mafDir)
        if not os.path.isdir(mafDir):
            print('There is no directory containing MAF outputs at %s.' % (mafDir))
            print('Just opening using tracking db at %s.' % (trackingDb))
        else:
            addRunToDatabase(mafDir, trackingDb, mafComment=args.mafComment)

    # Open tracking database and start visualization.
    global runlist
    runlist = MafTracking(trackingDb)
    if startRunId < 0:
        startRunId = runlist.runs[0]['mafRunId']
    # Set up path to template and favicon paths, and load templates.
    mafDir = os.getenv('SIMS_MAF_DIR')
    templateDir = os.path.join(mafDir, 'python/lsst/sims/maf/web/templates/')
    global faviconPath
    faviconPath = os.path.join(mafDir, 'python/lsst/sims/maf/web/')
    global jsPath
    jsPath = os.path.join(mafDir, 'python/lsst/sims/maf/web/')
    env = Environment(loader=FileSystemLoader(templateDir))
    # Add 'zip' to jinja templates.
    if args.db is None:
        if os.path.isfile('trackingDb_sqlite.db'):
            os.remove('trackingDb_sqlite.db')
        db_files = glob.glob('*.db')
    else:
        db_files = [args.db]
    run_names = [
        os.path.basename(name).replace('.db', '') for name in db_files
    ]

    for filename, name in zip(db_files, run_names):
        if os.path.isdir(name + '_glance'):
            shutil.rmtree(name + '_glance')
        opsdb = db.OpsimDatabaseV4(filename)
        colmap = batches.ColMapDict()

        bdict = {}
        bdict.update(batches.glanceBatch(colmap, name))
        bdict.update(batches.fOBatch(colmap, name))
        resultsDb = db.ResultsDb(outDir=name + '_glance')
        group = mb.MetricBundleGroup(bdict,
                                     opsdb,
                                     outDir=name + '_glance',
                                     resultsDb=resultsDb,
                                     saveEarly=False)
        group.runAll(clearMemory=True, plotNow=True)
        resultsDb.close()
        opsdb.close()
        db.addRunToDatabase(name + '_glance', 'trackingDb_sqlite.db', None,
                            name, '', '', name + '.db')
import glob
import shutil
import lsst.sims.maf.batches as batches
import lsst.sims.maf.db as db
import lsst.sims.maf.metricBundles as mb

if __name__ == "__main__":
    """
    Run the science batch on all .db files in a directory.
    """

    db_files = glob.glob('*.db')
    run_names = [name.replace('.db', '') for name in db_files]
    for name in run_names:
        opsdb = db.OpsimDatabaseV4(name + '.db')
        colmap = batches.ColMapDict('OpsimV4')
        if os.path.isdir('sci_' + name):
            shutil.rmtree('sci_' + name)
        bdict = batches.scienceRadarBatch()
        resultsDb = db.ResultsDb(outDir='sci_' + name)
        group = mb.MetricBundleGroup(bdict,
                                     opsdb,
                                     outDir='sci_' + name,
                                     resultsDb=resultsDb,
                                     saveEarly=False)
        group.runAll(clearMemory=True, plotNow=True)
        resultsDb.close()
        opsdb.close()
        db.addRunToDatabase('sci_' + name, 'trackingDb_sqlite.db', None, name,
                            '', '', name + '.db')
Beispiel #4
0
    # Check tracking DB is sqlite (and add as convenience if forgotten).
    trackingDb = args.trackingDb
    print('Using tracking database at %s' % (trackingDb))

    global startRunId
    startRunId = -666
    # If given a directory argument:
    if args.mafDir is not None:
        mafDir = os.path.realpath(args.mafDir)
        if not os.path.isdir(mafDir):
            print('There is no directory containing MAF outputs at %s.' %
                  (mafDir))
            print('Just opening using tracking db at %s.' % (trackingDb))
        else:
            addRunToDatabase(mafDir, trackingDb, mafComment=args.mafComment)

    # Open tracking database and start visualization.
    global runlist
    runlist = MafTracking(trackingDb)
    if startRunId < 0:
        startRunId = runlist.runs[0]['mafRunId']
    # Set up path to template and favicon paths, and load templates.
    mafDir = os.getenv('SIMS_MAF_DIR')
    templateDir = os.path.join(mafDir, 'python/lsst/sims/maf/web/templates/')
    global faviconPath
    faviconPath = os.path.join(mafDir, 'python/lsst/sims/maf/web/')
    global jsPath
    jsPath = os.path.join(mafDir, 'python/lsst/sims/maf/web/')
    env = Environment(loader=FileSystemLoader(templateDir))
    # Add 'zip' to jinja templates.
Beispiel #5
0
                        help="Comment on MAF analysis.")
    parser.add_argument("--group",
                        type=str,
                        default=None,
                        help="Opsim Group name.")
    parser.add_argument("--opsimRun",
                        type=str,
                        default=None,
                        help="Opsim Run Name.")
    parser.add_argument("--opsimComment",
                        type=str,
                        default=None,
                        help="Comment on OpSim run.")
    parser.add_argument("--dbFile",
                        type=str,
                        default='None',
                        help="Opsim Sqlite filename")
    defaultdb = 'trackingDb_sqlite.db'
    parser.add_argument(
        "-t",
        "--trackingDb",
        type=str,
        default=defaultdb,
        help=
        "Tracking database filename. Default is %s, in the current directory."
        % (defaultdb))
    args = parser.parse_args()

    addRunToDatabase(args.mafDir, args.trackingDb, args.group, args.opsimRun,
                     args.opsimComment, args.mafComment, args.dbFile)
    """

    parser = argparse.ArgumentParser()
    parser.add_argument("filename", type=str, help="OpSim database")
    args = parser.parse_args()
    filename = args.filename

    name = filename.replace('.db', '')

    outDir = 'radar_' + name

    if os.path.isdir(name):
        shutil.rmtree(name)

    opsdb = db.OpsimDatabaseV4(name + '.db')
    colmap = batches.ColMapDict('OpsimV4')

    bdict = {}
    bdict.update(batches.scienceRadarBatch(colmap, name))
    resultsDb = db.ResultsDb(outDir=outDir)
    group = mb.MetricBundleGroup(bdict,
                                 opsdb,
                                 outDir=outDir,
                                 resultsDb=resultsDb,
                                 saveEarly=False)
    group.runAll(clearMemory=True, plotNow=True)
    resultsDb.close()
    opsdb.close()
    db.addRunToDatabase(outDir, 'trackingDb_sqlite.db', None, name, '', '',
                        name + '.db')