Hi Mark,
wrf requires some additional ancillary variables to be in the dataset (geopot height and perturbation), to run interp and interp3d .
Your dataset was deprived of these, as only the resulting variables of that operation was appended. Therefore the function is not working.
#Ouput when inspecting metadata, for P and Z
ds.P.description
Out[53]: 'Total pressure (P0+PB)'
ds.Z.description
Out[54]: 'Geopotential height (PH + PHB)/9.81' #you have all these fields in original wrf output netcdfs // but not in CONUS dataset!
What I would do is something along these lines:
1. for pressure dataset, find the indices (over dim='bottom_top') where P=target_p
2. with those same indices, target the Z matrix for geopot height.
3. Since Z is staggered, use indices and indices+1 to find the 2 z-layers (height) bounding/sandwiching P_500:
4. average them, over vertical dimension, to get corresponding height.
5. Plot the result: approximated p_500 and approximated Z_p500
The result is very Andy-Warhol-psychedelic, but paves the way for a more sophisticated/elaborated solution.
Python script attached. Hope that helps in some way.
Happy coding.
Marco