<commit_before>"""
Dump a day's worth of METAR data out and generate a 
GEMPAK surface file, hopefully!
"""
import mx.DateTime
import iemdb
ASOS = iemdb.connect('asos', bypass=True)
acursor = ASOS.cursor()
acursor.execute("SET TIME ZONE 'GMT'")
import os, sys

def run(ts):
    output = open("%s.metar" % (ts.strftime("%Y%m%d"),), 'w')

    acursor.execute("""
    SELECT metar, valid from t%s WHERE valid BETWEEN '%s 00:00+00' and '%s 23:59+00' and 
    metar is not null and metar != '' ORDER by valid ASC
   """ % (ts.year, ts.strftime("%Y-%m-%d"), ts.strftime("%Y-%m-%d")))
    oldhr = 23
    for row in acursor:
        if row[1].hour != oldhr:
            output.write('\003\001\r\r\n000\r\r\n') 
            output.write("SAUS70 KXXX %02i%02i59\r\r\n" % (ts.day, row[1].hour))
            output.write("METAR\r\r\n")
            oldhr = row[1].hour
        output.write("%s=\r\r\n" % (row[0].replace("METAR ", ""),))
    output.write('\003')
    output.close()
    
    cmd = "cat %s.metar | dcmetr -v 8 -c %s/0000 -b 24 -d %s.log -s /mesonet/TABLES/azos.stns -m 72 %s.gem" % (
                    ts.strftime("%Y%m%d"), (ts + mx.DateTime.RelativeDateTime(days=1)).strftime("%Y%m%d"),
                    ts.strftime("%Y%m%d"),  ts.strftime("%Y%m%d"))
    os.system( cmd )
    
    # GEMPAK plotting time!
    
    
if __name__ == '__main__':
    run( mx.DateTime.DateTime(int(sys.argv[1]), int(sys.argv[2]), int(sys.argv[3])))<commit_msg>add plotting script as well<commit_after>"""
Dump a day's worth of METAR data out and generate a 
GEMPAK surface file, hopefully!
"""
import mx.DateTime
import iemdb
ASOS = iemdb.connect('asos', bypass=True)
acursor = ASOS.cursor()
acursor.execute("SET TIME ZONE 'GMT'")
import os, sys

def run(ts):
    output = open("%s.metar" % (ts.strftime("%Y%m%d"),), 'w')

    acursor.execute("""
    SELECT metar, valid from t%s WHERE valid BETWEEN '%s 00:00+00' and '%s 23:59+00' and 
    metar is not null and metar != '' ORDER by valid ASC
   """ % (ts.year, ts.strftime("%Y-%m-%d"), ts.strftime("%Y-%m-%d")))
    oldhr = 23
    for row in acursor:
        if row[1].hour != oldhr:
            output.write('\003\001\r\r\n000\r\r\n') 
            output.write("SAUS70 KXXX %02i%02i59\r\r\n" % (ts.day, row[1].hour))
            output.write("METAR\r\r\n")
            oldhr = row[1].hour
        output.write("%s=\r\r\n" % (row[0].replace("METAR ", ""),))
    output.write('\003')
    output.close()
    
    cmd = "cat %s.metar | dcmetr -v 8 -c %s/0000 -b 24 -d %s.log -s /mesonet/TABLES/azos.stns -m 72 %s.gem" % (
                    ts.strftime("%Y%m%d"), (ts + mx.DateTime.RelativeDateTime(days=1)).strftime("%Y%m%d"),
                    ts.strftime("%Y%m%d"),  ts.strftime("%Y%m%d"))
    os.system( cmd )
    
    # GEMPAK plotting time!
    for hr in range(0,24):
        now = ts + mx.DateTime.RelativeDateTime(hours=hr)
        cmd = "csh MW_mesonet.csh %s" % (now.strftime("%Y %m %d %H"),)
        os.system( cmd )
    
if __name__ == '__main__':
    run( mx.DateTime.DateTime(int(sys.argv[1]), int(sys.argv[2]), int(sys.argv[3])))
{'fraction_non_alphanumeric': 0.20116807268007786, 'fraction_numerical': 0.03406878650227125, 'mean_word_length': 2.6485207100591714, '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': '7233204', 'n_tokens_mistral': 1304, 'n_tokens_neox': 1204, 'n_words': 264}