def psychrometrics (Tdb_in, w_in, P):
    """
    Modified version of Psychometrics by Tea Zakula
    MIT Building Technology Lab
    Input: Tdb_in, w_in, P
    Output: Tdb, w, phi, h, Tdp, v

    where:
    Tdb_in = [K] dry bulb temperature
    w_in = [kgv/kgda] Humidity Ratio
    P = [P] Atmospheric Station Pressure

    Tdb: [C] dry bulb temperature
    w: [kgv/kgda] Humidity Ratio
    phi: [Pw/Pws*100] relative humidity
    Tdp: [C] dew point temperature
    h: [J/kga] enthalpy
    v: [m3/kga] specific volume
    """
    # Change units
    c_air = 1006.   # [J/kg] air heat capacity, value from ASHRAE Fundamentals
    hlg = 2501000.  # [J/kg] latent heat, value from ASHRAE Fundamentals
    cw  = 1860.     # [J/kg] value from ASHRAE Fundamentals
    P = P/1000.     # convert from Pa to kPa

    Tdb = Tdb_in - 273.15
    w = w_in

    # phi (RH) calculation from Tdb and w
    Pw = (w*P)/(0.621945 + w)                             # partial pressure of water vapor
    Pws = saturation_pressure(Tdb)                        # Get saturation pressure for given Tdb
    phi = Pw/Pws*100.0

    # enthalpy calculation from Tdb and w
    h = c_air*Tdb + w*(hlg+cw*Tdb)                      # [J kga-1]

    # specific volume calculation from Tdb and w
    v = 0.287042 * (Tdb+273.15)*(1+1.607858*w)/P        # ?

    # dew point calculation from w
    _pw = (w*P)/(0.621945 + w) # water vapor partial pressure in kPa
    alpha = log(_pw)

    Tdp = 6.54 + 14.526*alpha + pow(alpha,2)*0.7389 + pow(alpha,3)*0.09486 + pow(_pw,0.1984)*0.4569  # valid for Tdp between 0 C and 93 C

    return  Tdb, w, phi, h, Tdp, v