<commit_before>"""
Create a plot of the X Hour interval precipitation
"""

import netCDF3
import mx.DateTime
import iemplot
import numpy
import os, sys

def make_fp(ts):
    """
    Return a string for the filename expected for this timestamp
    """
    return "/mnt/a4/data/%s/nmq/tile2/data/QPESUMS/grid/q2rad_hsr_nc/short_qpe/%s00.nc" % (
        ts.strftime("%Y/%m/%d"), 
        ts.strftime("%Y%m%d-%H%M") )

def doit(ts, hours):
    """
    Create a plot of precipitation stage4 estimates for some day
    """
    # Mod the minute down
    remain = ts.minute % 5
    ts -= mx.DateTime.RelativeDateTime(minutes=(ts.minute%5))
    
    lons = numpy.arange(-110., -89.99, 0.01) 
    lats = numpy.arange(55.0, 39.99, -0.01)

    limit = 20
    while not os.path.isfile(make_fp(ts)):
        ts -= mx.DateTime.RelativeDateTime(minutes=5)
        if limit == 0:
            print "NO Q2 Files Found!"
            return
        limit -= 1
    total = None
    for hr in range(hours):
        lts = ts - mx.DateTime.RelativeDateTime(hours=hr)
        nc = netCDF3.Dataset(make_fp(lts))
        if hr == 0:
            total = nc.variables["rad_hsr_1h"][:]
        else:
            total += nc.variables["rad_hsr_1h"][:]
        nc.close()
    # Put some bad values in just to make the plot happy
    total[1350,1610] = 100.0
    total[1410,1675] = 15.
        
    # Now we dance
    cfg = { 
    'cnLevelSelectionMode': "ExplicitLevels",
    'cnLevels' : [0.01,0.05,0.1,0.25,0.5,0.75,1,1.25,1.5,2.0,3,4,5,7,10],<commit_msg>prevent bug with missing data ;(<commit_after>"""
Create a plot of the X Hour interval precipitation
"""

import netCDF3
import mx.DateTime
import iemplot
import numpy
import os, sys

def make_fp(ts):
    """
    Return a string for the filename expected for this timestamp
    """
    return "/mnt/a4/data/%s/nmq/tile2/data/QPESUMS/grid/q2rad_hsr_nc/short_qpe/%s00.nc" % (
        ts.strftime("%Y/%m/%d"), 
        ts.strftime("%Y%m%d-%H%M") )

def doit(ts, hours):
    """
    Create a plot of precipitation stage4 estimates for some day
    """
    # Mod the minute down
    remain = ts.minute % 5
    ts -= mx.DateTime.RelativeDateTime(minutes=(ts.minute%5))
    
    lons = numpy.arange(-110., -89.99, 0.01) 
    lats = numpy.arange(55.0, 39.99, -0.01)

    limit = 20
    while not os.path.isfile(make_fp(ts)):
        ts -= mx.DateTime.RelativeDateTime(minutes=5)
        if limit == 0:
            print "NO Q2 Files Found!"
            return
        limit -= 1
    total = None
    for hr in range(hours):
        lts = ts - mx.DateTime.RelativeDateTime(hours=hr)
        fp = make_fp(lts)
        if not os.path.isfile(fp):
            continue
        nc = netCDF3.Dataset( fp )
        if hr == 0:
            total = nc.variables["rad_hsr_1h"][:]
        else:
            total += nc.variables["rad_hsr_1h"][:]
        nc.close()
    # Put some bad values in just to make the plot happy
    total[1350,1610] = 100.0
    total[1410,1675] = 15.
        
    # Now we dance
    cfg = { 
    'cnLevelSelectionMode': "ExplicitLevels",
    'cnLevels' : [0.01,0.05,0.1,0.25,0.5,0.75,1,1.25,1.5,2.0,3,4,5,7,10],
{'fraction_non_alphanumeric': 0.14444797963728923, 'fraction_numerical': 0.05790645879732739, 'mean_word_length': 2.264797507788162, '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': '2856042', 'n_tokens_mistral': 1247, 'n_tokens_neox': 1149, 'n_words': 267}