Ejemplo n.º 1
0
def tas2ssec(tas, alt, oat, ias, speed_units=default_speed_units, alt_units=default_alt_units, temp_units=default_temp_units, press_units = default_press_units):
    """
    Return static source position error as speed error, pressure error and altitude error at sea level.
    
    Returns delta_Vpc, delta_Ps, delta_Hpc and Vc
    
    delta_Vpc = error in airspeed = calibrated airspeed - indicated airspeed corrected for instrument error
    
    delta_Ps = error in the pressure sensed by the static system = pressure sensed in the static system - ambient pressure
    
    delta_Hpc = altitude error at sea level = actual altitude - altitude sensed by the static system
    
    Vc = calibrated airspeed at the test point
    """
    P0 = U.press_conv(constants.P0, from_units = 'pa', to_units = press_units)
    cas = A.tas2cas(tas, alt, oat, speed_units=speed_units, alt_units=alt_units, temp_units=temp_units)
    delta_Vpc = cas - ias
    
    qcic = A.cas2dp(ias, speed_units=speed_units, press_units =press_units)
    qc = A.cas2dp(cas, speed_units=speed_units, press_units = press_units)
    delta_Ps = qc - qcic

    delta_Hpc = SA.press2alt(P0 - delta_Ps, press_units  = press_units) 
    
#     print 'Vc = %.1f, delta_vpc = %.1f, delta_ps = %.1f, delta_hpc = %.0f' % (cas, delta_Vpc, delta_Ps, delta_Hpc)
    
    return delta_Vpc, delta_Ps, delta_Hpc, cas
Ejemplo n.º 2
0
def press2alt(P, press_units=default_press_units,
              alt_units=default_alt_units):
    """
    Return the altitude corresponding to the specified pressure, with
    pressure in inches of HG, mm of HG, psi, psf (lb per sq. ft), pa, hpa or
    mb. 
    
    The altitude is in units of feet ('ft'), metres ('m'), statute miles, 
    ('sm') or nautical miles ('nm')
    
    If the units are not specified, the units in default_units.py are used.
    
    Examples:
    
    Calculate the pressure altitude in feet for a pressure of 31.0185 inches
    of HG:
    >>> press2alt(31.0185)
    -999.98992888235091
    
    Calculate the pressure altitude in feet for a pressure of 
    1455.33 lb sq. ft:
    >>> press2alt(1455.33, press_units = 'psf')
    10000.002466564831
    
    Calculate the pressure altitude in metres for a pressure of 
    90.3415 mm HG:
    >>> press2alt(90.3415, press_units = 'mm HG', alt_units = 'm')
    15000.025465320754
    
    Calculate the pressure altitude in metres for a pressure of 
    1171.86 pascal:
    >>> press2alt(1171.86, press_units = 'pa', alt_units = 'm')
    30000.029510365184
    """

    # function tested in tests/test_std_atm.py

    P = U.press_conv(P, from_units=press_units, to_units='in HG')

    if P > P11:
        H = _press2alt_gradient(P, P0, 0, T0, L0)
    elif P > P20:
        H = _press2alt_isothermal(P, P11, 11, T11)
    elif P > P32:
        H = _press2alt_gradient(P, P20, 20, T20, L20)
    elif P > P47:
        H = _press2alt_gradient(P, P32, 32, T32, L32)
    elif P > P51:
        H = _press2alt_isothermal(P, P47, 47, T47)
    elif P > P71:
        H = _press2alt_gradient(P, P51, 51, T51, L51)
    else:
        H = _press2alt_gradient(P, P71, 71, T71, L71)

    if H > 84.852:
        raise ValueError, \
            'This function is only implemented for altitudes of 84.852 km and below.'

    return U.len_conv(H, from_units='km', to_units=alt_units)
def press2alt(P, press_units=default_press_units, alt_units=default_alt_units):
    """
    Return the altitude corresponding to the specified pressure, with
    pressure in inches of HG, mm of HG, psi, psf (lb per sq. ft), pa, hpa or
    mb. 
    
    The altitude is in units of feet ('ft'), metres ('m'), statute miles, 
    ('sm') or nautical miles ('nm')
    
    If the units are not specified, the units in default_units.py are used.
    
    Examples:
    
    Calculate the pressure altitude in feet for a pressure of 31.0185 inches
    of HG:
    >>> press2alt(31.0185)
    -999.98992888235091
    
    Calculate the pressure altitude in feet for a pressure of 
    1455.33 lb sq. ft:
    >>> press2alt(1455.33, press_units = 'psf')
    10000.002466564831
    
    Calculate the pressure altitude in metres for a pressure of 
    90.3415 mm HG:
    >>> press2alt(90.3415, press_units = 'mm HG', alt_units = 'm')
    15000.025465320754
    
    Calculate the pressure altitude in metres for a pressure of 
    1171.86 pascal:
    >>> press2alt(1171.86, press_units = 'pa', alt_units = 'm')
    30000.029510365184
    """

    # function tested in tests/test_std_atm.py

    P = U.press_conv(P, from_units=press_units, to_units='in HG')

    if P > P11:
        H = _press2alt_gradient(P, P0, 0, T0, L0)
    elif P > P20:
        H = _press2alt_isothermal(P, P11, 11, T11)
    elif P > P32:
        H = _press2alt_gradient(P, P20, 20, T20, L20)
    elif P > P47:
        H = _press2alt_gradient(P, P32, 32, T32, L32)
    elif P > P51:
        H = _press2alt_isothermal(P, P47, 47, T47)
    elif P > P71:
        H = _press2alt_gradient(P, P51, 51, T51, L51)
    else:
        H = _press2alt_gradient(P, P71, 71, T71, L71)

    if H > 84.852:
        print(
            'This function is only implemented for altitudes of 84.852 km and below.'
        )

    return U.len_conv(H, from_units='km', to_units=alt_units)
 def test_07(self):
     Value = U.press_conv(1, from_units='psi', to_units='cm H2O')
     Truth = 1 / .014198  # truth value from NASA RP 1046 Table A27.
     # Note that there is an inconsistency between
     # the stated conversions from psi to cm H2O
     # (70.376), and the conversion from cm H2O to
     # psi (.014198)
     print(('Truth=%.8f, Value=%.8f' % (Truth, Value)))
     self.assertTrue(RE(Value, Truth) <= 5e-5)
 def test_07(self):
     Value = U.press_conv(1, from_units='psi', to_units='cm H2O')
     Truth = 1/.014198 # truth value from NASA RP 1046 Table A27. 
                       # Note that there is an inconsistency between 
                       # the stated conversions from psi to cm H2O 
                       # (70.376), and the conversion from cm H2O to 
                       # psi (.014198)
     print('Truth=%.8f, Value=%.8f' % (Truth, Value))
     self.failUnless(RE(Value, Truth) <= 5e-5)
Ejemplo n.º 6
0
def pressure_alt(H, alt_setting, alt_units=default_alt_units):
    """
    Return the pressure altitude, given the barometric altitude and the
    altimeter setting. 
    
    Altimeter setting may have units of inches of HG, or hpa or mb.  If the
    altimeter setting value is less than 35, the units are assumed to be
    in HG, otherwise they are assumed to be hpa.  The altimeter setting must
    be in the range of 25 to 35 inches of mercury.
    
    The altitude may have units of feet ('ft'), metres ('m'), statute miles,
    ('sm') or nautical miles ('nm').

    If the units are not specified, the units in default_units.py are used.
    
    Examples:
    
    Calculate the pressure altitude for 1,000 (default altitude units) 
    barometric altitude with altimeter setting of 30.92 in HG:
    >>> pressure_alt(1000, 30.92)
    88.6424431787118
    
    Calculate the pressure altitude for 1,000 (default altitude units) 
    barometric altitude with altimeter setting of 1008 mb:
    >>> pressure_alt(1000, 1008)
    1143.679844292918
    
    Calculate the pressure altitude in metres for 304.8 m barometric 
    altitude with altimeter setting of 1008 mb:
    >>> pressure_alt(304.8, 1008, alt_units = 'm')
    348.59361654048143
    """

    H = U.length_conv(H, from_units=alt_units, to_units='ft')
    if alt_setting > 35:
        alt_setting = U.press_conv(alt_setting,
                                   from_units='hpa',
                                   to_units='in HG')
    if alt_setting < 25 or alt_setting > 35:
        raise ValueError('Altimeter setting out of range.')
    base_press = U.press_conv(P0, from_units='pa', to_units='in HG')
    HP = H + 145442.2 * (1 - (alt_setting / base_press)**0.190261)
    HP = U.length_conv(HP, from_units='ft', to_units=alt_units)
    return HP
Ejemplo n.º 7
0
def pressure_alt(H, alt_setting, alt_units=default_alt_units):
    """
    Return the pressure altitude, given the barometric altitude and the
    altimeter setting. 
    
    Altimeter setting may have units of inches of HG, or hpa or mb.  If the
    altimeter setting value is less than 35, the units are assumed to be
    in HG, otherwise they are assumed to be hpa.  The altimeter setting must
    be in the range of 25 to 35 inches of mercury.
    
    The altitude may have units of feet ('ft'), metres ('m'), statute miles,
    ('sm') or nautical miles ('nm').

    If the units are not specified, the units in default_units.py are used.
    
    Examples:
    
    Calculate the pressure altitude for 1,000 (default altitude units) 
    barometric altitude with altimeter setting of 30.92 in HG:
    >>> pressure_alt(1000, 30.92)
    88.642443178711801
    
    Calculate the pressure altitude for 1,000 (default altitude units) 
    barometric altitude with altimeter setting of 1008 mb:
    >>> pressure_alt(1000, 1008)
    1143.679844292918
    
    Calculate the pressure altitude in metres for 304.8 m barometric 
    altitude with altimeter setting of 1008 mb:
    >>> pressure_alt(304.8, 1008, alt_units = 'm')
    348.59361654048143
    """

    H = U.length_conv(H, from_units=alt_units, to_units='ft')
    if alt_setting > 35:
        alt_setting = U.press_conv(alt_setting, from_units='hpa',
                                   to_units='in HG')
    if alt_setting < 25 or alt_setting > 35:
        raise ValueError('Altimeter setting out of range.')
    base_press = U.press_conv(P0, from_units='pa', to_units='in HG')
    HP = H + 145442.2 * (1 - (alt_setting / base_press) ** 0.190261)
    HP = U.length_conv(HP, from_units='ft', to_units=alt_units)
    return HP
def QNH(
    HP,
    H,
    alt_units=default_alt_units,
    alt_setting_units='in HG',
):
    """
    Return the altimeter setting, given the pressure altitude (HP) and the 
    barometric altitude (H).
    """

    HP = U.len_conv(HP, from_units=alt_units, to_units='ft')
    H = U.len_conv(H, from_units=alt_units, to_units='ft')
    QNH = P0 * (1 - (HP - H) / 145442.2)**5.255594
    QNH = U.press_conv(QNH, from_units='in HG', to_units=alt_setting_units)

    return QNH
Ejemplo n.º 9
0
def QNH(
    HP,
    H,
    alt_units=default_alt_units,
    alt_setting_units='in HG',
    ):
    """
    Return the altimeter setting, given the pressure altitude (HP) and the 
    barometric altitude (H).
    """

    HP = U.length_conv(HP, from_units=alt_units, to_units='ft')
    H = U.length_conv(H, from_units=alt_units, to_units='ft')
    QNH = P0 * (1 - (HP - H) / 145442.2) ** 5.255594
    QNH = U.press_conv(QNH, from_units='in HG',
                       to_units=alt_setting_units)

    return QNH
Ejemplo n.º 10
0
def alt2press(H, 
              alt_units=default_alt_units,
              press_units=default_press_units):
    """
    Return the atmospheric pressure for a given altitude, with the 
    altitude in feet ('ft'), metres ('m'), statute miles, ('sm') or nautical
    miles ('nm'), and the pressure in inches of HG ('in HG'), mm of HG 
    ('mm HG'), psi, lb per sq. ft ('psf'), pa, hpa or mb.  
    
    If the units are not specified, the units in default_units.py are used.
    
    Examples:
    
    Calculate the pressure in inches of mercury at 5,000 (default altitude 
    units):
    >>> alt2press(5000)
    24.895961289464015
    
    Calculate the pressure in pounds per square foot at 10,000 (default 
    altitude units):
    >>> alt2press(10000, press_units = 'psf')
    1455.3301392981359
    
    Calculate the pressure in pascal at 20 km:
    >>> alt2press(20, press_units = 'pa', alt_units = 'km')
    5474.8827144576408
    """

    # uses meters, inches of HG and degrees K for the internal calculations

    # function tested in tests/test_std_atm.py

    H = U.len_conv(H, from_units=alt_units, to_units='m')

    press = P0 * alt2press_ratio(H, alt_units='m')
    press = U.press_conv(press, from_units='in HG',
                         to_units=press_units)

    return press
Ejemplo n.º 11
0
def tas2ssec(tas,
             alt,
             oat,
             ias,
             speed_units=default_speed_units,
             alt_units=default_alt_units,
             temp_units=default_temp_units,
             press_units=default_press_units):
    """
    Return static source position error as speed error, pressure error and altitude error at sea level.
    
    Returns delta_Vpc, delta_Ps, delta_Hpc and Vc
    
    delta_Vpc = error in airspeed = calibrated airspeed - indicated airspeed corrected for instrument error
    
    delta_Ps = error in the pressure sensed by the static system = pressure sensed in the static system - ambient pressure
    
    delta_Hpc = altitude error at sea level = actual altitude - altitude sensed by the static system
    
    Vc = calibrated airspeed at the test point
    """
    P0 = U.press_conv(constants.P0, from_units='pa', to_units=press_units)
    cas = A.tas2cas(tas,
                    alt,
                    oat,
                    speed_units=speed_units,
                    alt_units=alt_units,
                    temp_units=temp_units)
    delta_Vpc = cas - ias

    qcic = A.cas2dp(ias, speed_units=speed_units, press_units=press_units)
    qc = A.cas2dp(cas, speed_units=speed_units, press_units=press_units)
    delta_Ps = qc - qcic

    delta_Hpc = SA.press2alt(P0 - delta_Ps, press_units=press_units)

    #     print 'Vc = %.1f, delta_vpc = %.1f, delta_ps = %.1f, delta_hpc = %.0f' % (cas, delta_Vpc, delta_Ps, delta_Hpc)

    return delta_Vpc, delta_Ps, delta_Hpc, cas
Ejemplo n.º 12
0
def alt2press(H, alt_units=default_alt_units, press_units=default_press_units):
    """
    Return the atmospheric pressure for a given altitude, with the 
    altitude in feet ('ft'), metres ('m'), statute miles, ('sm') or nautical
    miles ('nm'), and the pressure in inches of HG ('in HG'), mm of HG 
    ('mm HG'), psi, lb per sq. ft ('psf'), pa, hpa or mb.  
    
    If the units are not specified, the units in default_units.py are used.
    
    Examples:
    
    Calculate the pressure in inches of mercury at 5,000 (default altitude 
    units):
    >>> alt2press(5000)
    24.895961289464015
    
    Calculate the pressure in pounds per square foot at 10,000 (default 
    altitude units):
    >>> alt2press(10000, press_units = 'psf')
    1455.3301392981359
    
    Calculate the pressure in pascal at 20 km:
    >>> alt2press(20, press_units = 'pa', alt_units = 'km')
    5474.8827144576408
    """

    # uses meters, inches of HG and degrees K for the internal calculations

    # function tested in tests/test_std_atm.py

    H = U.len_conv(H, from_units=alt_units, to_units='m')

    press = P0 * alt2press_ratio(H, alt_units='m')
    press = U.press_conv(press, from_units='in HG', to_units=press_units)

    return press
 def test_02(self):
     Value = U.press_conv(1, from_units='mm HG', to_units='psi')
     Truth = 0.01934543333
     self.failUnless(RE(Value, Truth) <= 5e-4)
 def test_05(self):
     Value = U.press_conv(1, from_units='cm H2O', to_units='in H2O')
     Truth = 1 / 2.54
     self.assertTrue(RE(Value, Truth) <= 4e-5)
Ejemplo n.º 15
0
def tas2ssec2(tas,
              ind_alt,
              oat,
              ias,
              std_alt=0,
              speed_units=default_speed_units,
              alt_units=default_alt_units,
              temp_units=default_temp_units,
              press_units=default_press_units):
    """
    Return static source position error as speed error, pressure error and 
    altitude error at sea level using speed course method.
    
    Returns delta_Vpc, delta_Ps and delta_Hpc
    
    tas = true airspeed determined by speed course method, or GPS
    
    ind_alt = pressure altitude, corrected for instrument error
    
    oat = outside air temperature, corrected for instrument error and ram temperature rise
    
    ias = indicated airspeed, corrected for instrument error
    
    std_alt = altitude to provide delta_Hpc for
    
    delta_Vpc = error in airspeed = calibrated airspeed - indicated airspeed 
    corrected for instrument error
    
    delta_Ps = error in the pressure sensed by the static system = pressure 
    sensed in the static system - ambient pressure
    
    delta_Hpc = altitude error at std_alt = actual altitude - altitude 
    sensed by the static system
    
    Uses analysis method from USAF Test Pilot School.  Unlike some other 
    methods (e.g.. that in FAA AC 23-8B, or NTPS GPS_PEC.xls), this method 
    provides an exact conversion from TAS to CAS (some other methods assume 
    CAS = EAS), and it accounts for the effect of position error of altitude 
    on the conversion from TAS to CAS (some  other methods assume pressure 
    altitude =  indicated pressure altitude).
    """
    tas = U.speed_conv(tas, speed_units, 'kt')
    ind_alt = U.length_conv(ind_alt, alt_units, 'ft')
    oat = U.temp_conv(oat, temp_units, 'C')
    M = A.tas2mach(tas, oat, temp_units='C', speed_units='kt')
    if M > 1:
        raise ValueError('This method only works for Mach < 1')
    delta_ic = SA.alt2press_ratio(ind_alt, alt_units='ft')
    qcic_over_Psl = A.cas2dp(ias, speed_units='kt',
                             press_units=press_units) / U.press_conv(
                                 constants.P0, 'pa', to_units=press_units)
    qcic_over_Ps = qcic_over_Psl / delta_ic
    Mic = A.dp_over_p2mach(qcic_over_Ps)
    delta_mach_pc = M - Mic
    if Mic > 1:
        raise ValueError('This method only works for Mach < 1')
    deltaPp_over_Ps = (1.4 * delta_mach_pc * (Mic + delta_mach_pc / 2)) / (
        1 + 0.2 * (Mic + delta_mach_pc / 2)**2)
    deltaPp_over_qcic = deltaPp_over_Ps / qcic_over_Ps
    delta_Hpc = SA.alt2temp_ratio(
        std_alt, alt_units='ft') * deltaPp_over_Ps / 3.61382e-5

    # experimental - alternate way to calculate delta_Hpc that gives same answer
    Ps = SA.alt2press(ind_alt, alt_units='ft', press_units=press_units)
    delta_Ps = deltaPp_over_Ps * Ps
    P_std = SA.alt2press(std_alt, alt_units='ft', press_units=press_units)
    deltaPs_std = deltaPp_over_Ps * P_std
    delta_Hpc2 = SA.press2alt(P_std - deltaPs_std,
                              press_units=press_units) - std_alt

    delta_std_alt = SA.alt2press_ratio(std_alt, alt_units='ft')
    asl = U.speed_conv(constants.A0, 'm/s', 'kt')
    delta_Vpc_std_alt = deltaPp_over_Ps * delta_std_alt * asl**2 / (
        1.4 * ias * (1 + 0.2 * (ias / asl)**2)**2.5)

    actual_alt = SA.press2alt(Ps + delta_Ps,
                              press_units=press_units,
                              alt_units='ft')
    cas = A.tas2cas(tas,
                    actual_alt,
                    oat,
                    speed_units='kt',
                    alt_units='ft',
                    temp_units='C')
    return delta_Vpc, delta_Ps, delta_Hpc, cas
 def test_05(self):
     Value = U.press_conv(1, from_units='cm H2O', to_units='in H2O')
     Truth = 1/2.54
     self.failUnless(RE(Value, Truth) <= 4e-5)
 def test_06(self):
     Value = U.press_conv(1, from_units='in H2O', to_units='mm HG')
     Truth = 1.865
     print('Truth=%.8f, Value=%.8f' % (Truth, Value))
     self.failUnless(RE(Value, Truth) <= 1e-5)
 def test_03(self):
     Value = U.press_conv(1, from_units='psi', to_units='lb/ft**2')
     Truth = 144
     self.failUnless(RE(Value, Truth) <= 1e-5)
 def test_04(self):
     Value = U.press_conv(1, from_units='lb/ft**2', to_units='mb')
     Truth = 0.4788
     self.failUnless(RE(Value, Truth) <= 1e-5)
 def test_01(self):
     Value = U.press_conv(1, from_units='in HG', to_units='mm HG')
     Truth = 25.4
     self.failUnless(RE(Value, Truth) <= 1e-5)
 def test_02(self):
     Value = U.press_conv(1, from_units='mm HG', to_units='psi')
     Truth = 0.01934543333
     self.failUnless(RE(Value, Truth) <= 5e-4)
 def test_06(self):
     Value = U.press_conv(1, from_units='in H2O', to_units='mm HG')
     Truth = 1.865
     print(('Truth=%.8f, Value=%.8f' % (Truth, Value)))
     self.assertTrue(RE(Value, Truth) <= 1e-5)
 def test_04(self):
     Value = U.press_conv(1, from_units='lb/ft**2', to_units='mb')
     Truth = 0.4788
     self.failUnless(RE(Value, Truth) <= 1e-5)
Ejemplo n.º 24
0
def tas2ssec2(tas, ind_alt, oat, ias, std_alt = 0, speed_units=default_speed_units, alt_units=default_alt_units, temp_units=default_temp_units, press_units = default_press_units):
    """
    Return static source position error as speed error, pressure error and 
    altitude error at sea level using speed course method.
    
    Returns delta_Vpc, delta_Ps and delta_Hpc
    
    tas = true airspeed determined by speed course method, or GPS
    
    ind_alt = pressure altitude, corrected for instrument error
    
    oat = outside air temperature, corrected for instrument error and ram temperature rise
    
    ias = indicated airspeed, corrected for instrument error
    
    std_alt = altitude to provide delta_Hpc for
    
    delta_Vpc = error in airspeed = calibrated airspeed - indicated airspeed 
    corrected for instrument error
    
    delta_Ps = error in the pressure sensed by the static system = pressure 
    sensed in the static system - ambient pressure
    
    delta_Hpc = altitude error at std_alt = actual altitude - altitude 
    sensed by the static system
    
    Uses analysis method from USAF Test Pilot School.  Unlike some other 
    methods (e.g.. that in FAA AC 23-8B, or NTPS GPS_PEC.xls), this method 
    provides an exact conversion from TAS to CAS (some other methods assume 
    CAS = EAS), and it accounts for the effect of position error of altitude 
    on the conversion from TAS to CAS (some  other methods assume pressure 
    altitude =  indicated pressure altitude).
    """
    tas = U.speed_conv(tas, speed_units, 'kt')
    ind_alt = U.length_conv(ind_alt, alt_units, 'ft')
    oat = U.temp_conv(oat, temp_units, 'C')
    M = A.tas2mach(tas, oat, temp_units='C', speed_units='kt')
    if M > 1:
        raise ValueError, 'This method only works for Mach < 1'
    delta_ic = SA.alt2press_ratio(ind_alt, alt_units='ft')
    qcic_over_Psl = A.cas2dp(ias, speed_units='kt', press_units=press_units) / U.press_conv(constants.P0, 'pa', to_units=press_units)
    qcic_over_Ps = qcic_over_Psl / delta_ic
    Mic = A.dp_over_p2mach(qcic_over_Ps)
    delta_mach_pc = M - Mic
    if Mic > 1:
        raise ValueError, 'This method only works for Mach < 1'
    deltaPp_over_Ps = (1.4 * delta_mach_pc * (Mic + delta_mach_pc / 2)) / (1 + 0.2 * (Mic + delta_mach_pc / 2 )**2)
    deltaPp_over_qcic = deltaPp_over_Ps / qcic_over_Ps
    delta_Hpc = SA.alt2temp_ratio(std_alt, alt_units='ft') * deltaPp_over_Ps / 3.61382e-5
    
    # experimental - alternate way to calculate delta_Hpc that gives same answer
    Ps = SA.alt2press(ind_alt, alt_units='ft', press_units=press_units)
    delta_Ps = deltaPp_over_Ps * Ps
    P_std = SA.alt2press(std_alt, alt_units='ft', press_units=press_units)
    deltaPs_std = deltaPp_over_Ps * P_std
    delta_Hpc2 = SA.press2alt(P_std  - deltaPs_std, press_units  = press_units) - std_alt

    delta_std_alt = SA.alt2press_ratio(std_alt, alt_units='ft')
    asl = U.speed_conv(constants.A0, 'm/s', 'kt')
    delta_Vpc_std_alt = deltaPp_over_Ps * delta_std_alt * asl**2 / (1.4 * ias * (1 + 0.2 * (ias / asl)**2)**2.5)

    actual_alt = SA.press2alt(Ps + delta_Ps, press_units = press_units, alt_units = 'ft')
    cas = A.tas2cas(tas, actual_alt, oat, speed_units='kt', alt_units='ft', temp_units='C')
    return delta_Vpc, delta_Ps, delta_Hpc, cas
Ejemplo n.º 25
0
def sat_press(
    T='FALSE',
    DP='FALSE',
    RH=0.0,
    temp_units=default_temp_units,
    press_units=default_press_units,
    ):
    """
    Return the saturated vapour pressure of water.  Either the dew point, or 
    the temperature and the relative humidity must be specified.  If both the
    dew point and relative humidity are specified, the relative humidity value
    is ignored.
    
    If the temperature and dew point are both specified, the dew point cannot
    be greater than the temperature:
    
    If the units are not specified, the units in default_units.py are used.

    >>> sat_press(T=10, DP=11)
    Traceback (most recent call last):
      File '<stdin>', line 1, in <module>
      File 'std_atm.py', line 795, in sat_press
        raise ValueError, 'The dew point cannot be greater than the temperature.'
    ValueError: The dew point cannot be greater than the temperature.
    
    Dew point is 11 deg (default temperature units).  Find the water vapour
    pressure in default pressure units:
    >>> sat_press(DP=11)
    0.38741015927568667
    
    Dew point is 65 deg F.  Find the water vapour pressure in default pressure units:
    >>> sat_press(DP=65, temp_units = 'F')
    0.62207710701956165
    
    Dew point is 212 deg F (the boiling point of water at sea level).
    Find the water vapour pressure in lb per sq. inch:
    >>> sat_press(DP=212, temp_units = 'F', press_units = 'psi')
    14.696764873564959

    Temperature is 30 deg C.  Find the water vapour pressure in default pressure units:
    for 50% relative humidity:
    >>> sat_press(T=30, RH = 0.5)
    0.62647666996057927
    """

    if DP != 'FALSE':

        # use dew point method

        if T != 'FALSE':
            if DP > T:
                raise ValueError('The dew point cannot be greater than the temperature.')

        DP = U.temp_conv(DP, from_units=temp_units, to_units='C')

    # calculate vapour pressure

        Pv = _sat_press(DP) * 100.
    else:

        if RH == 'FALSE':
            raise ValueError('Either DP (dew point) or RH (relative humidity) must be specified.')

    # relative humidity is specified
    # confirm relative humidity is in range

        if RH < 0 or RH > 1:
            raise ValueError('The relative humidity must be in the range of 0 to 1.')

        if T == 'FALSE':
            raise ValueError('If the relative humidity is specified, the temperature must also be specified.')

        T = U.temp_conv(T, from_units=temp_units, to_units='C')

        Pv = _sat_press(T) * 100.
        Pv *= RH

    Pv = U.press_conv(Pv, from_units='pa', to_units=press_units)

    return Pv
 def test_01(self):
     Value = U.press_conv(1, from_units='in HG', to_units='mm HG')
     Truth = 25.4
     self.failUnless(RE(Value, Truth) <= 1e-5)
Ejemplo n.º 27
0
def sat_press(
    T='FALSE',
    DP='FALSE',
    RH=0.0,
    temp_units=default_temp_units,
    press_units=default_press_units,
):
    """
    Return the saturated vapour pressure of water.  Either the dew point, or 
    the temperature and the relative humidity must be specified.  If both the
    dew point and relative humidity are specified, the relative humidity value
    is ignored.
    
    If the temperature and dew point are both specified, the dew point cannot
    be greater than the temperature:
    
    If the units are not specified, the units in default_units.py are used.

    >>> sat_press(T=10, DP=11)
    Traceback (most recent call last):
      File '<stdin>', line 1, in <module>
      File 'std_atm.py', line 795, in sat_press
        raise ValueError, 'The dew point cannot be greater than the temperature.'
    ValueError: The dew point cannot be greater than the temperature.
    
    Dew point is 11 deg (default temperature units).  Find the water vapour
    pressure in default pressure units:
    >>> sat_press(DP=11)
    0.38741015927568667
    
    Dew point is 65 deg F.  Find the water vapour pressure in default pressure units:
    >>> sat_press(DP=65, temp_units = 'F')
    0.62207710701956165
    
    Dew point is 212 deg F (the boiling point of water at sea level).
    Find the water vapour pressure in lb per sq. inch:
    >>> sat_press(DP=212, temp_units = 'F', press_units = 'psi')
    14.696764873564959

    Temperature is 30 deg C.  Find the water vapour pressure in default pressure units:
    for 50% relative humidity:
    >>> sat_press(T=30, RH = 0.5)
    0.62647666996057927
    """

    if DP != 'FALSE':

        # use dew point method

        if T != 'FALSE':
            if DP > T:
                print('The dew point cannot be greater than the temperature.')

        DP = U.temp_conv(DP, from_units=temp_units, to_units='C')

        # calculate vapour pressure

        Pv = _sat_press(DP) * 100
    else:

        if RH == 'FALSE':
            print(
                'Either DP (dew point) or RH (relative humidity) must be specified.'
            )

    # relative humidity is specified
    # confirm relative humidity is in range

        if RH < 0 or RH > 1:
            print('The relative humidity must be in the range of 0 to 1.')

        if T == 'FALSE':
            print(
                'If the relative humidity is specified, the temperature must also be specified.'
            )

        T = U.temp_conv(T, from_units=temp_units, to_units='C')

        Pv = _sat_press(T) * 100
        Pv *= RH

    Pv = U.press_conv(Pv, from_units='pa', to_units=press_units)

    return Pv
 def test_03(self):
     Value = U.press_conv(1, from_units='psi', to_units='lb/ft**2')
     Truth = 144
     self.failUnless(RE(Value, Truth) <= 1e-5)