I am having issues on how to calculate precipitable water using some of metpy's commands. Here's what I have so far for my code:
EDITED
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
import scipy.ndimage as ndimage
from scipy.ndimage.filters import minimum_filter, maximum_filter
from mpl_toolkits.basemap import cm
import metpy.calc as mcalc
from metpy.units import units
filename='totalprecipitablewater'
title ='Total Precipitable Water'
cbarlabel = 'Millimeters (mm)'
boundaryColor = 'gray'
frequency = 3 # frequency in hrs
ticks = np.arange(-10,120,10)
time = 0
pressure = []
vapor_pressure = []
dew_point = []
def plot(variables,prev_vars,pltenv):
cont_int = 10
cont_smooth = 0.5
x = pltenv['x']
y = pltenv['y']
m = pltenv['map']
bbox = dict(boxstyle="square",ec='None',fc=(1,1,1,0.75))
mixing_ratio = variables['QVAPOR'][time]
pressure = (variables['PB'][time] * units.pascals + variables['P'][time] * units.pascals)
e = mcalc.vapor_pressure(pressure, mixing_ratio)
td = mcalc.dewpoint(e)
i = 0
while i < 300:
j = 0
while j < 211:
tpw = mcalc.precipitable_water(td[:,i,j], pressure[:,i,j], bottom=None, top=None)
j+=1
i+=1
print(tpw)
"variables" calls the WRF model for my data. "tpw" represents the total precipitable water, which is what I am attempting to calculate.