Beispiel #1
0
def height_to_pressure(x,
                       p0=1013.25,
                       t0=288.15):
    if isinstance(x, np.ndarray):
        func = np.vectorize(height_to_pressure)
        return func(x, p0=p0, t0=t0)

    g = con.g()  # m/s2
    R = con.rd()  # J/kg/K
    dt = 0.0065  # K/m
    a = g / (R * dt)

    # h to p
    p = p0 * (1 - (dt * x / t0)) ** a
    return np.where(x > 11000, (226.32 * np.exp((-g * (x - 11000)) / (R * 216.65))), p)
Beispiel #2
0
def pressure_to_height(x,
                       p0=1013.25,
                       t0=288.15):
    if isinstance(x, np.ndarray):
        func = np.vectorize(pressure_to_height)
        return func(x, p0=p0, t0=t0)

    g = con.g()  # m/s2
    R = con.rd()  # J/kg/K
    dt = 0.0065  # K/m
    a = g / (R * dt)

    # p to h
    h = (t0 / dt) * (1 - (x / p0) ** (1 / a))
    return np.where(x < 226.32, (11000 + np.log(x / 226.32) * (R * 216.65) / -g), h)