I am trying to use a metpy.calc function however every time I attempt to assign units using metpy.units, it will not run. It will sit there and continue running for hours if I let it. The metpy function has worked perfectly fine for me in the past with the same dataset, but for some reason will no longer work. I have tried updating metpy and spyder and have also used multiple laptops to ensure it wasn't just occurring on one. I also tried the metpy.units two different ways. It runs using units('kg/kg') however won't actually assign the units to the array. Any thoughts on how to get this to work?
This is my code:
import numpy as np
import matplotlib.pyplot as plt
from netCDF4 import Dataset
import metpy
import metpy.calc as mpcalc
from metpy.units import units
f = Dataset('C:/Users/hkenward/Desktop/MS/cm1out.nc', mode = 'r', format="NETCDF4")
mrv=f.variables['qv'][:]
pt=f.variables['th'][:]
p=f.variables['prs'][:]
p=p/100.
mrv=mrv*units('kg/kg')
p=p * units.hPa
pt=pt*units.kelvin
e=mpcalc.vapor_pressure(p,mrv)
Td=mpcalc.dewpoint(e)
T=mpcalc.temperature_from_potential_temperature(p, pt)
Te=mpcalc.equivalent_potential_temperature(p, T, Td)