示例#1
0
def psych_chart(T, W=None, RH=None, heatplot=False, lims = (0, 90, 0, 0.02), **kwargs):
    if (W==None) & (RH==None):
        return None # TODO exception?
    elif W==None:
        W = humidity_ratio(RH, T)
    fig = plt.figure()
    if heatplot:
        plt.hexbin(T, W, extent=lims, **kwargs)
    else:
        plt.scatter(T, W, **kwargs)
    ts = np.linspace(lims[0],lims[1],21)
    if heatplot:
        linecolor = 'w'
    else:
        linecolor = 'k'
    for rh in np.linspace(0.1,1,10):
        plt.plot(ts, humidity_ratio(rh, ts), linecolor)
    plt.xlabel('Temperature [degF]')
    plt.ylabel('Humidity Ratio')
    plt.ylim(lims[2], lims[3])
    plt.xlim(lims[0], lims[1])
    # RH labels on right hand side
    ax1 = plt.axes()
    ax2 = ax1.twinx()
    ax2.get_yaxis().set_major_locator(ticker.FixedLocator(humidity_ratio(np.linspace(0,1,11), lims[1])/(lims[3]-lims[2])))
    ax2.get_yaxis().set_major_formatter(ticker.FixedFormatter(np.linspace(0,100,11)))
    plt.ylabel('Relative Humidity [%]')
    return ax1
示例#2
0
def plot_daily_psychrometric(hourly, name='', interactive=False):
    fig = plt.figure()
    ti = daily_mean(hourly.Ti)
    wi = daily_mean(hourly.Wi)
    rt = daily_total(hourly.RTFc) # cooling runtime
    cd = np.where(rt > 0)[0] # cooling days
    ncd = np.where(rt <= 0)[0] # non-cooling days
    plt.scatter(ti[cd], wi[cd], color='b')
    plt.scatter(ti[ncd], wi[ncd], color='r')
    # plot some lines of constant RH
    ts = np.linspace(65,85,5)
    for rh in np.linspace(0.1, 1, 10):
        plt.plot(ts, humidity_ratio(rh, ts), 'k')
    plt.xlabel('Indoor Temperature [degF]')
    plt.ylabel('Indoor Humidity Ratio')
    plt.title('{0}: Psychrometric Chart'.format(name))
    # RH labels on right hand side
    ax1 = plt.axes()
    ax2 = ax1.twinx()
    ax2.get_yaxis().set_major_locator(ticker.FixedLocator(humidity_ratio(np.linspace(0,1,11), 85)/0.030)) # TODO don't hardcode limits
    ax2.get_yaxis().set_major_formatter(ticker.FixedFormatter(np.linspace(0,100,11)))
    plt.ylabel('Indoor RH [%]')
#    ax2.get_yaxis().set_major_locator(ticker.FixedLocator(np.linspace(0,1,11)))
    if name:
        fig.savefig('{1}/{0}-psychrometric.png'.format(name, summary_path))
        if not interactive:
            plt.close()