<commit_before>"""GDD Fun"""
import datetime

import psycopg2.extras
import numpy as np
import pandas as pd
from pyiem import network
from pyiem.util import get_autoplot_context


def get_description():
    """ Return a dict describing how to call this plotter """
    desc = dict()
    desc['data'] = True
    desc['description'] = """This plot presents the period over which growing
    degree days were accumulated between the two thresholds provided by
    the user.  The colors represent the number of days for the period shown."""
    desc['arguments'] = [
        dict(type='station', name='station', default='IA0200',
             label='Select Station:', network='IACLIMATE'),
        dict(type='year', name='year', default=datetime.date.today().year,
             label='Select Year', min=1893),
        dict(type='int', name='gdd1', default='1135',
             label='Growing Degree Day Start'),
        dict(type='int', name='gdd2', default='1660',
             label='Growing Degree Day End'),
    ]
    return desc


def plotter(fdict):
    """ Go """
    import matplotlib
    matplotlib.use('agg')
    import matplotlib.pyplot as plt
    import matplotlib.dates as mdates
    import matplotlib.colors as mpcolors
    pgconn = psycopg2.connect(database='coop', host='iemdb', user='nobody')
    ccursor = pgconn.cursor(cursor_factory=psycopg2.extras.DictCursor)

    ctx = get_autoplot_context(fdict, get_description())
    station = ctx['station']
    year = ctx['year']
    gdd1 = ctx['gdd1']
    gdd2 = ctx['gdd2']
    table = "alldata_%s" % (station[:2],)
    nt = network.Table("%sCLIMATE" % (station[:2],))

    ccursor.execute("""
    SELECT day, gdd50(high,low) as gdd
    from """+table+""" WHERE year = %s and station = %s
    ORDER by day ASC
    """, (year, station))
    days = []
    gdds = []
    for row in ccursor:
        gdds.append(float(row['gdd']))
        days.append(row['day'])

    yticks = []
    yticklabels = []
    jan1 = datetime.datetime(year, 1, 1)
    for i in range(110, 270):
        ts = jan1 + datetime.timedelta(days=i)
        if ts.day == 1 or ts.day % 12 == 1:
            yticks.append(i)
            yticklabels.append(ts.strftime("%-d %b"))

    gdds = np.array(gdds)
    sts = datetime.datetime(year, 4, 1)
    ets = datetime.datetime(year, 6, 1)
    now = sts
    sz = len(gdds)

    days2 = []<commit_msg>label more dates on gdd plot<commit_after>"""GDD Fun"""
import datetime

import psycopg2.extras
import numpy as np
import pandas as pd
from pyiem import network
from pyiem.util import get_autoplot_context


def get_description():
    """ Return a dict describing how to call this plotter """
    desc = dict()
    desc['data'] = True
    desc['description'] = """This plot presents the period over which growing
    degree days were accumulated between the two thresholds provided by
    the user.  The colors represent the number of days for the period shown."""
    desc['arguments'] = [
        dict(type='station', name='station', default='IA0200',
             label='Select Station:', network='IACLIMATE'),
        dict(type='year', name='year', default=datetime.date.today().year,
             label='Select Year', min=1893),
        dict(type='int', name='gdd1', default='1135',
             label='Growing Degree Day Start'),
        dict(type='int', name='gdd2', default='1660',
             label='Growing Degree Day End'),
    ]
    return desc


def plotter(fdict):
    """ Go """
    import matplotlib
    matplotlib.use('agg')
    import matplotlib.pyplot as plt
    import matplotlib.dates as mdates
    import matplotlib.colors as mpcolors
    pgconn = psycopg2.connect(database='coop', host='iemdb', user='nobody')
    ccursor = pgconn.cursor(cursor_factory=psycopg2.extras.DictCursor)

    ctx = get_autoplot_context(fdict, get_description())
    station = ctx['station']
    year = ctx['year']
    gdd1 = ctx['gdd1']
    gdd2 = ctx['gdd2']
    table = "alldata_%s" % (station[:2],)
    nt = network.Table("%sCLIMATE" % (station[:2],))

    ccursor.execute("""
    SELECT day, gdd50(high,low) as gdd
    from """+table+""" WHERE year = %s and station = %s
    ORDER by day ASC
    """, (year, station))
    days = []
    gdds = []
    for row in ccursor:
        gdds.append(float(row['gdd']))
        days.append(row['day'])

    yticks = []
    yticklabels = []
    jan1 = datetime.datetime(year, 1, 1)
    for i in range(110, 330):
        ts = jan1 + datetime.timedelta(days=i)
        if ts.day == 1 or ts.day % 12 == 1:
            yticks.append(i)
            yticklabels.append(ts.strftime("%-d %b"))

    gdds = np.array(gdds)
    sts = datetime.datetime(year, 4, 1)
    ets = datetime.datetime(year, 6, 1)
    now = sts
    sz = len(gdds)

    days2 = []
{'fraction_non_alphanumeric': 0.14270679856872237, 'fraction_numerical': 0.0202062723637129, 'mean_word_length': 2.946843853820598, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5506031', 'n_tokens_mistral': 1619, 'n_tokens_neox': 1508, 'n_words': 417}