@@ -0,0 +1,2510 @@
+%22%22%22%0A Check over the database and make sure we have what we need there to%0A make the climodat reports happy...%0A%22%22%22%0Aimport sys%0Astate = sys.argv%5B1%5D%0Aimport mx.DateTime%0Aimport network%0Ant = network.Table(%22%25sCLIMATE%22 %25 (state,))%0A%0Aimport constants%0Aimport iemdb%0ACOOP = iemdb.connect('coop', bypass=True)%0Accursor = COOP.cursor()%0A%0Atoday = mx.DateTime.now()%0A%0Adef fix_year(station, year):%0A    sts = mx.DateTime.DateTime(year, 1, 1)%0A    ets = mx.DateTime.DateTime(year+1,1,1)%0A    interval = mx.DateTime.RelativeDateTime(days=1)%0A    now = sts%0A    while now %3C ets:%0A        ccursor.execute(%22%22%22SELECT count(*) from alldata_%25s where%0A        station = '%25s' and day = '%25s' %22%22%22 %25 (state, station, %0A                                             now.strftime(%22%25Y-%25m-%25d%22)))%0A        row = ccursor.fetchone()%0A        if row%5B0%5D == 0:%0A            print 'Adding Date: %25s station: %25s' %25 (now, station)%0A            ccursor.execute(%22%22%22INSERT into alldata_%25s (station, day, sday, %0A            year, month) VALUES ('%25s', '%25s', '%25s', %25s, %25s)%22%22%22 %25 (%0A                        state, station, now.strftime(%22%25Y-%25m-%25d%22),%0A                        now.strftime(%22%25m%25d%22), now.year, now.month ))        %0A        now += interval%0A%0Afor station in nt.sts.keys():%0A    sts = mx.DateTime.DateTime( constants.startyear(station), 1, 1)%0A    ets = constants._ENDTS%0A    now = sts%0A    interval = mx.DateTime.RelativeDateTime(months=1)%0A    while now %3C ets:%0A        ccursor.execute(%22%22%22SELECT * from r_monthly WHERE %0A        station = '%25s' and monthdate = '%25s' %22%22%22 %25 (station, %0A                                                   now.strftime(%22%25Y-%25m-%25d%22)))%0A        row = ccursor.fetchone()%0A        if row%5B0%5D == 0:%0A            print 'Adding station: %25s month: %25s' %25 (station, now)%0A            ccursor.execute(%22%22%22INSERT into r_monthly(station, monthdate)%0A            values ('%25s','%25s')%22%22%22 %25 (station, now.strftime(%22%25Y-%25m-%25d%22)))%0A        now += interval%0A    %0A    # Check for obs total%0A    now = sts%0A    interval = mx.DateTime.RelativeDateTime(years=1)%0A    while now %3C (ets - interval):%0A        days = int(((now + interval) - now).days)%0A        ccursor.execute(%22%22%22SELECT count(*) from alldata_%25s WHERE%0A        year = %25s and station = '%25s'%22%22%22 %25 (state, now.year, station))%0A        row = ccursor.fetchone()%0A        if row%5B0%5D != days:%0A            print 'Mismatch station: %25s year: %25s count: %25s days: %25s' %25 (station,%0A                                                    now.year, row%5B0%5D, days)%0A            fix_year(station, now.year)%0A        now += interval%0Accursor.close()%0ACOOP.commit()

add simple script to QC database