code: def pseudoadiabat(T,p):
      
      esoverp = clausius_clapeyron(T) / p
      Tcel = T - tempCtoK
      L = (2.501 - 0.00237 * Tcel) * 1.E6   # Accurate form of latent heat of vaporization in J/kg
      ratio = L / T /  Rv
      dTdp = (T / p * kappa * (1 + esoverp * ratio) /
          (1 + kappa * (cpv / Rv + (ratio-1) * ratio) * esoverp))
      return dTdp
docs: Compute the local slope of the pseudoadiabat at given temperature and pressure
  
      Inputs:   p is pressure in hPa or mb
                T is local temperature in Kelvin
      Output:   dT/dp, the rate of temperature change for pseudoadiabatic ascent
                  in units of K / hPa
  
      The pseudoadiabat describes changes in temperature and pressure for an air
      parcel at saturation assuming instantaneous rain-out of the super-saturated water
  
      Formula consistent with eq. (2.33) from Raymond Pierrehumbert, "Principles of Planetary Climate"
      which nominally accounts for non-dilute effects, but computes the derivative
      dT/dpa, where pa is the partial pressure of the non-condensible gas.
  
      Integrating the result dT/dp treating p as total pressure effectively makes the dilute assumption.