# Calculating layer thickness in python

I have calculated the ∂θe/∂z with 'Height', 'Latitude', 'Longitude' dimensions.

import numpy as np
import xarray as xr
from wrf import (getvar)

eth = np.array(getvar(ncfile, "eth", timeidx=time))
z = np.array(getvar(ncfile, "z", timeidx=time, units="km"))

deth_dz = deth/dz

dthdz = xr.DataArray(data=deth_dz, dims=['Height', 'Latitude', 'Longitude'])


I would like to plot the horizontal depth or thickness (in km) of the dthdz. It is a bit similar to this question. But when I do dthdz.sum(dim='Height'), I get very low depth values. I just want to know where I'm doing it wrong. Thank you!

New contributor
Kas is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
• For programming related questions unless you provide the dataset very few here can help you Sep 14 at 7:44
• Why not use MetPy's thickness API - unidata.github.io/MetPy/latest/api/generated/… ? Sep 14 at 7:45
• thanks @gansub! this uses conventional wrfout data. i tried the thickness_hydrostatic but it outputs in 1D. i was hoping to make a horizontal plot of the depth
– Kas
Sep 14 at 8:36
• Suggest you take this over to MetPy gitter and then ask the question over there. Sep 14 at 8:49