Example #1
0
    vq_group.add_argument('-q', '--quiet', action='count', default=0, dest='quietness')
    parser.add_argument('-o', '--overwrite', action='store_true', dest='overwrite',
                        default=False, help='Destroy everything.')

    parser.add_argument('--db', dest='db_path', required=True,
                        type=str, help='Path to sqllite database file.')
    parser.add_argument('--run', dest='run_root_path', required=True,
                        type=str, help='Path to root observing run path.')
    parser.add_argument('--drop-all', action='store_true', dest='drop_all',
                        default=False, help='Destroy all tables.')

    args = parser.parse_args()

    # Set logger level based on verbose flags
    if args.verbosity != 0:
        if args.verbosity == 1:
            logger.setLevel(logging.DEBUG)
        else: # anything >= 2
            logger.setLevel(1)

    elif args.quietness != 0:
        if args.quietness == 1:
            logger.setLevel(logging.WARNING)
        else: # anything >= 2
            logger.setLevel(logging.ERROR)

    else: # default
        logger.setLevel(logging.INFO)

    main(**vars(args))
Example #2
0
    session = Session()

    credentials = dict(user='******', password='******')
    Gaia.login(**credentials)

    for obs in session.query(Observation).all():
        q = session.query(Photometry).join(Observation).filter(Observation.id == obs.id).count()
        if q > 0:
            logger.debug('Photometry already exists')
            continue

        if obs.tgas_source is None:
            continue

        tgas_source_id = obs.tgas_source.source_id
        res = get_photometry(tgas_source_id)

        phot_kw = dict()
        for col in result_columns:
            phot_kw[col] = res[col]

        phot = Photometry(**phot_kw)
        phot.observation = obs
        session.add(phot)
        session.commit()

if __name__ == '__main__':
    import logging
    logger.setLevel(logging.DEBUG)
    main()