I have a netCDF file of stream function (psi) having dimension (latitude, level), level is pressure level. There are 5 pressure levels (700,600,500,400,300 hPa). I need to compute the mass weighted vertical average, i.e. before averaging I need to know the atmospheric mass at each pressure level which will be their weights and after that, average of psi will be computed. The final output will be one dimensional i.e. (latitude,). How to compute this weight and how to do it in Python?