Ejemplo n.º 1
0
def test_annual_count():
    # Does the cumulative count match the annual count?
    db = kpub.PublicationDB()
    annual = db.get_annual_publication_count()
    cumul = db.get_annual_publication_count_cumulative()
    assert annual['k2'][2010] == 0  # K2 didn't exist in 2010
    # The first K2 papers started appearing in 2014; the cumulative counts should reflect that:
    assert (annual['k2'][2014] + annual['k2'][2015]) == cumul['k2'][2015]
    assert (annual['k2'][2014] + annual['k2'][2015] + annual['k2'][2016]) == cumul['k2'][2016]
    # Are the values returned by get_metrics consistent?
    for year in range(2009, 2019):
        metrics = db.get_metrics(year=year)
        assert metrics['publication_count'] == annual['both'][year]
        assert metrics['kepler_count'] == annual['kepler'][year]
        assert metrics['k2_count'] == annual['k2'][year]
    # Can we pass multiple years to get_metrics?
    metrics = db.get_metrics(year=[2011, 2012])
    assert metrics['publication_count'] == annual['both'][2011] + annual['both'][2012]
Ejemplo n.º 2
0
        """SELECT COUNT(*) FROM pubs 
                            WHERE mission = ? 
                            AND month >= ?
                            AND month < ?;""", [mission, start, stop])
    rows = list(cur.fetchall())
    return rows[0][0]


if __name__ == "__main__":
    barwidth = 0.75
    output_fn = "kpub-first-quarters.pdf"
    dpi = 200
    ymax = 35
    yticks = [0, 10, 20, 30]

    db = kpub.PublicationDB()

    # First collect the data
    k1_labels = [
        "2009/1", "2009/2", "2009/3", "2009/4", "2010/1", "2010/2", "2010/3",
        "2010/4"
    ]
    k1_start = [
        "2009-01", "2009-04", "2009-07", "2009-10", "2010-01", "2010-04",
        "2010-07", "2010-10"
    ]
    k1_stop = [
        "2009-04", "2009-07", "2009-10", "2010-01", "2010-04", "2010-07",
        "2010-10", "2011-01"
    ]
    k1_counts = []
Ejemplo n.º 3
0
def get_publication_metrics():
    """Returns a dict containing Kepler/K2 literature metrics."""
    import kpub
    print('Retrieving publication metrics...')
    return kpub.PublicationDB().get_metrics()