<commit_before>"""One month being warmer than the other"""
import datetime
import calendar

import psycopg2.extras
import numpy as np
import matplotlib.patheffects as PathEffects
from pyiem.network import Table as NetworkTable
from pyiem.util import get_autoplot_context
import pandas as pd


def get_description():
    """ Return a dict describing how to call this plotter """
    desc = dict()
    desc['data'] = True
    desc['description'] = """This plot summarizes the frequency of one month
    being warmer than another month for that calendar year."""
    desc['arguments'] = [
        dict(type='station', name='station', default='IA0200',
             label='Select Station:', network='IACLIMATE'),
    ]
    return desc


def plotter(fdict):
    """ Go """
    import matplotlib
    matplotlib.use('agg')
    import matplotlib.pyplot as plt
    pgconn = psycopg2.connect(database='coop', host='iemdb', user='nobody')
    cursor = pgconn.cursor(cursor_factory=psycopg2.extras.DictCursor)
    ctx = get_autoplot_context(fdict, get_description())
    station = ctx['station']

    table = "alldata_%s" % (station[:2],)
    nt = NetworkTable("%sCLIMATE" % (station[:2],))

    cursor.execute("""
        SELECT year, month, avg((high+low)/2.) from """+table+"""
        WHERE station = %s and day < %s and year > 1892
        GROUP by year, month ORDER by year ASC
    """, (station, datetime.datetime.now().replace(day=1)))

    for rownum, row in enumerate(cursor):
        if rownum == 0:
            baseyear = row[0]
            avgs = np.ones((datetime.datetime.now().year - baseyear + 1,
                            12)) * -99.
        avgs[row[0]-baseyear, row[1]-1] = row[2]

    matrix = np.zeros((12, 12))
    lastyear = np.zeros((12, 12))
    rows = []
    for i in range(12):
        for j in range(12):
            # How many years was i warmer than j
            t = np.where(np.logical_and(avgs[:, j] > -99,
                                        np.logical_and(avgs[:, i] > avgs[:, j],
                                                       avgs[:, i] > -99)),<commit_msg>fix consideration of current month's data<commit_after>"""One month being warmer than the other"""
import datetime
import calendar

import psycopg2.extras
import numpy as np
import matplotlib.patheffects as PathEffects
from pyiem.network import Table as NetworkTable
from pyiem.util import get_autoplot_context
import pandas as pd


def get_description():
    """ Return a dict describing how to call this plotter """
    desc = dict()
    desc['data'] = True
    desc['description'] = """This plot summarizes the frequency of one month
    being warmer than another month for that calendar year."""
    desc['arguments'] = [
        dict(type='station', name='station', default='IA0200',
             label='Select Station:', network='IACLIMATE'),
    ]
    return desc


def plotter(fdict):
    """ Go """
    import matplotlib
    matplotlib.use('agg')
    import matplotlib.pyplot as plt
    pgconn = psycopg2.connect(database='coop', host='iemdb', user='nobody')
    cursor = pgconn.cursor(cursor_factory=psycopg2.extras.DictCursor)
    ctx = get_autoplot_context(fdict, get_description())
    station = ctx['station']

    table = "alldata_%s" % (station[:2],)
    nt = NetworkTable("%sCLIMATE" % (station[:2],))

    cursor.execute("""
        SELECT year, month, avg((high+low)/2.) from """+table+"""
        WHERE station = %s and day < %s and year > 1892
        GROUP by year, month ORDER by year ASC
    """, (station, datetime.date.today().replace(day=1)))

    for rownum, row in enumerate(cursor):
        if rownum == 0:
            baseyear = row[0]
            avgs = np.ones((datetime.datetime.now().year - baseyear + 1,
                            12)) * -99.
        avgs[row[0]-baseyear, row[1]-1] = row[2]

    matrix = np.zeros((12, 12))
    lastyear = np.zeros((12, 12))
    rows = []
    for i in range(12):
        for j in range(12):
            # How many years was i warmer than j
            t = np.where(np.logical_and(avgs[:, j] > -99,
                                        np.logical_and(avgs[:, i] > avgs[:, j],
                                                       avgs[:, i] > -99)),
{'fraction_non_alphanumeric': 0.13483412322274882, 'fraction_numerical': 0.01990521327014218, 'mean_word_length': 2.4884297520661156, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5306511', 'n_tokens_mistral': 1333, 'n_tokens_neox': 1260, 'n_words': 370}