Hi there I am getting this error: ValueError: setting an array element with a sequence. When I run this code:
import metpy.calc as mpcalc
from metpy.units import units
import cartopy.crs as ccrs
import cartopy.feature as cfeat
import os
from netCDF4 import Dataset as netcdf_dataset
fname = os.path.join(config["repo_data_dir"],
'netcdf', "nam_218_20170625_1200_031.nc"
)
dataset = netcdf_dataset(fname)
lat = dataset.variables['gridlat_0'][:]
lon = dataset.variables['gridlon_0'][:]
sfct=units.degC*(np.mean(dataset.variables['TMP_P0_L103_GLC0'][:,:,:],0)-273.15)
dp=units.degC*(dataset.variables['DPT_P0_L103_GLC0'][:]-273.15)
sfcp=units.hPa*(dataset.variables['PRES_P0_L103_GLC0'][:]/100.0)
lcl_pressure=np.empty(((428),(614)))
lcl_temperature=np.empty(((428),(614)))
lclht=np.empty(((428),(614)))
for i in range(428):
for j in range(614):
lcl_pressure[i,j], lcl_temperature[i,j] = mpcalc.lcl(sfcp[i,j],sfct[i,j],dp[i,j])
lclht[i,j]=mpcalc.pressure_to_height_std(lcl_pressure[i,j]).to('feet')
The line in question is this:
lcl_pressure[i,j], lcl_temperature[i,j] = mpcalc.lcl(sfcp[i,j],sfct[i,j],dp[i,j])
since I am unsure as to how that's causing it as the line in question works for a different code where it says
lcl_pressure[i,j], lcl_temperature[i,j] = mpcalc.lcl(p[0],t[0],dp[0])
as the p,t, and dp in that 2nd version are also arrays