Exemplo n.º 1
0
 def _alt2ROC(prop, alt):
     """
     calculate ROC for an altitude
     """
     temp = SA.isa2temp(isa_dev, alt)
     calc_pwr = alt2pwr(alt, rpm = rpm, MP_max = MP_max, temp = temp) * pwr_factor
     cas = alt2roc_speed(alt, climb_speed = climb_speed)
     eas = A.cas2eas(cas, alt)
     ROC = roc(prop, alt, eas, weight, calc_pwr, rpm, rv = rv, \
         wing_area = wing_area)
     
     return ROC
Exemplo n.º 2
0
    def _alt2ROC(prop, alt):
        """
        calculate ROC for an altitude
        """
        temp = SA.isa2temp(isa_dev, alt)
        calc_pwr = alt2pwr(alt, rpm=rpm, MP_max=MP_max, temp=temp) * pwr_factor
        cas = alt2roc_speed(alt, climb_speed=climb_speed)
        eas = A.cas2eas(cas, alt)
        ROC = roc(prop, alt, eas, weight, calc_pwr, rpm, rv = rv, \
            wing_area = wing_area)

        return ROC
Exemplo n.º 3
0
def cas2cl(
    cas,
    altitude,
    weight,
    wing_area,
    load_factor=1,
    speed_units=default_speed_units,
    alt_units=default_alt_units,
    weight_units=default_weight_units,
    area_units=default_area_units,
):
    """
    Returns the coefficient of lift, given calibrated airspeed, altitude, 
    weight, and wing area.  
    
    Load factor is an optional input.  The load factor, if not provided, 
    defaults to 1.

    Example:
    if the wing area is 15 square meters,
    and the weight is 1500 kg,
    and the cas is 200 km/h,
    at 3,000 meter altitude
    in a stabilized 45 degree bank turn (so the load factor = 2**0.5),

    >>> S = 15
    >>> W = 1500
    >>> CAS = 200
    >>> Alt = 3000
    >>> cas2cl(CAS, Alt, W, S, load_factor = 2**0.5, speed_units='km/h',\
    alt_units='m', weight_units='kg', area_units='m**2') 
    0.7357813111713088
    
    """

    eas = A.cas2eas(cas, altitude, speed_units, alt_units)

    Cl = eas2cl(
        eas,
        weight,
        wing_area,
        load_factor,
        speed_units,
        weight_units,
        area_units,
    )

    return Cl
Exemplo n.º 4
0
def cas2cl(
    cas,
    altitude,
    weight,
    wing_area,
    load_factor=1,
    speed_units=default_speed_units,
    alt_units=default_alt_units,
    weight_units=default_weight_units,
    area_units=default_area_units,
    ):
    """
    Returns the coefficient of lift, given calibrated airspeed, altitude, 
    weight, and wing area.  
    
    Load factor is an optional input.  The load factor, if not provided, 
    defaults to 1.

    Example:
    if the wing area is 15 square meters,
    and the weight is 1500 kg,
    and the cas is 200 km/h,
    at 3,000 meter altitude
    in a stabilized 45 degree bank turn (so the load factor = 2**0.5),

    >>> S = 15
    >>> W = 1500
    >>> CAS = 200
    >>> Alt = 3000
    >>> cas2cl(CAS, Alt, W, S, load_factor = 2**0.5, speed_units='km/h',\
    alt_units='m', weight_units='kg', area_units='m**2') 
    0.73578131117130885
    
    """

    eas = A.cas2eas(cas, altitude, speed_units, alt_units)

    Cl = eas2cl(
        eas,
        weight,
        wing_area,
        load_factor,
        speed_units,
        weight_units,
        area_units,
        )

    return Cl
Exemplo n.º 5
0
def roc_vs_temp(prop, alt_max = 20000, alt_interval=2000, weight=1800, temps=[-20,0,20,40], pwr='max', \
    pwr_factor=1.0, climb_speed='max', output='raw'):
    """
    Returns the rates of climb at various temperatures
    """
    if pwr == 'max':
        rpm = 2650
        MP_max = 30
    elif pwr == 'cc':
        rpm = 2500
        MP_max = 25
    elif pwr == 2500:
        rpm = 2500
        MP_max = 30
    else:
        raise ValueError, "pwr must be on of 'max', 'cc', or 2500"

    alt = 0
    while alt<alt_max:
        press = SA.alt2press(alt)
        MP = press - (29.9213 - 28.6)

        cas = alt2roc_speed(alt, climb_speed = climb_speed)
        eas = A.cas2eas(cas, alt)

#        for temp  in temps:
#            print temp, '\t\t\t',
#        print '\n',
        print '%.0f\t%.0f\t%.0f\t' % (weight, alt, cas),
        for temp in temps:
            # power = IO.pwr(rpm, MP, alt, temp) * pwr_factor
            power = alt2pwr(alt, rpm = rpm, MP_max = MP_max, temp = temp)
            ROC = roc(prop, alt, eas, weight, power, rpm, temp) /10
            ROC = int('%.0f' % (ROC)) * 10
            print '%.0f\t' % (ROC), 
        print '\n'
        alt += alt_interval
Exemplo n.º 6
0
def roc_vs_temp(prop, alt_max = 20000, alt_interval=2000, weight=1800, temps=[-20,0,20,40], pwr='max', \
    pwr_factor=1.0, climb_speed='max', output='raw'):
    """
    Returns the rates of climb at various temperatures
    """
    if pwr == 'max':
        rpm = 2650
        MP_max = 30
    elif pwr == 'cc':
        rpm = 2500
        MP_max = 25
    elif pwr == 2500:
        rpm = 2500
        MP_max = 30
    else:
        raise ValueError("pwr must be on of 'max', 'cc', or 2500")

    alt = 0
    while alt < alt_max:
        press = SA.alt2press(alt)
        MP = press - (29.9213 - 28.6)

        cas = alt2roc_speed(alt, climb_speed=climb_speed)
        eas = A.cas2eas(cas, alt)

        #        for temp  in temps:
        #            print temp, '\t\t\t',
        #        print '\n',
        print('%.0f\t%.0f\t%.0f\t' % (weight, alt, cas), end=' ')
        for temp in temps:
            # power = IO.pwr(rpm, MP, alt, temp) * pwr_factor
            power = alt2pwr(alt, rpm=rpm, MP_max=MP_max, temp=temp)
            ROC = roc(prop, alt, eas, weight, power, rpm, temp) / 10
            ROC = int('%.0f' % (ROC)) * 10
            print('%.0f\t' % (ROC), end=' ')
        print('\n')
        alt += alt_interval
Exemplo n.º 7
0
#!/sw/bin/python

import airspeed as A

alts = range(39000, -1, -1000)
Ms = range(30, 79, 2) + [79] + [80, 82, 84, 85]

print " EAS |                                                                                        Mach                                                                                       |"
print " hp  |",
for M in Ms:
    print "%0.2f|" % (M / 100.),
print "\n",
for alt in alts:
    print "%5i|" % (alt),
    for M in Ms:
        CAS = A.mach_alt2cas(M / 100., alt)
        print "%4.0f|" % (A.cas2eas(CAS, alt)),
    print "\n",
Exemplo n.º 8
0
#! /sw/bin/python2.7
"""Return EAS given CAS and Pressure Altitude"""

import airspeed
import argparse

parser = argparse.ArgumentParser(
    description='Return EAS for a given CAS and pressure altitude')
parser.add_argument('CAS', type=float, help='Calibrated Airspeed')
parser.add_argument('HP', type=float, help='Pressure Altitude')
parser.add_argument(
    '--speed_units',
    required=False,
    default='kt',
    help=
    'airspeed units - one of "kt", "mph", "km/h", "ft/s" or "m/s".  Defaults to "kt".'
)
parser.add_argument(
    '--alt_units',
    required=False,
    default='ft',
    help=
    'altitude units - one of feet ("ft"), metres ("m"), kilometres ("km"), statute miles, ("sm") or nautical miles ("nm").  Defaults to "ft".'
)

args = parser.parse_args()
print(
    airspeed.cas2eas(args.CAS,
                     args.HP,
                     speed_units=args.speed_units,
                     alt_units=args.alt_units))
Exemplo n.º 9
0
#!/sw/bin/python

import airspeed as A

alts=range(39000,-1,-1000)
Ms=range(30, 79, 2) + [79] + [80, 82, 84, 85]

print "Mach |                                                                         EAS"
print " hp  |",
for M in Ms:
    print "%0.2f|" % (M / 100.),
print "\n",
for alt in alts:
    print "%5i|" % (alt),
    for M in Ms:
        CAS = A.mach_alt2cas(M/100., alt)
        print "%4.0f|" % (A.cas2eas(CAS, alt)),
    print "\n",
Exemplo n.º 10
0
def climb_data(prop, weight = 1800., alt_max = 20000., TO_fuel = 0, TO_dist = 0, \
    fuel_units = 'USG', alt_interval = 500., isa_dev = 0, temp_units = 'C', \
    rv = '8', wing_area = 110., pwr = 'max', pwr_factor=1.0, \
    climb_speed = 'max', output = 'raw'):
    """
    Returns a table of climb performance vs altitude.

    The items in each row of the table are altitude, time, fuel burned and distance.
    Time is in units of minutes, rounded to the nearest half minute.
    Fuel units are selectable, with a default of USG.
    Distances are in nm.
    
    The output may be specified as raw, latex (a LaTeX table for the POH), or array.
    
    pwr may be 'max', 'cc' (cruise climb = 2500 rpm and 25") or 2500 (2500 rpm and full throttle)
    climb_speed may be 'max' (Vy), 'cc' (120 kt to 10,000 ft, then reducing by 4 kt/1000 ft) or
                'norm' (100 kt to 10,000 ft, then reducing by 2 kt/1000 ft)
                
    Note: compared cruise range for all climb speed and power.  The predicted results are all 
          within 1.5 nm of range.  Thus there is no advantage to using anything but Vy and max
          power.
    """
    def _alt2ROC(prop, alt):
        """
        calculate ROC for an altitude
        """
        temp = SA.isa2temp(isa_dev, alt)
        calc_pwr = alt2pwr(alt, rpm = rpm, MP_max = MP_max, temp = temp) * pwr_factor
        cas = alt2roc_speed(alt, climb_speed = climb_speed)
        eas = A.cas2eas(cas, alt)
        ROC = roc(prop, alt, eas, weight, calc_pwr, rpm, rv = rv, \
            wing_area = wing_area)
        
        return ROC
    
    alt = 0
    time = 0
    fuel_used = U.avgas_conv(TO_fuel, from_units = fuel_units, to_units = 'lb')
    weight = weight - fuel_used
    dist = TO_dist
    if pwr == 'max':
        # rpm = 2700
        rpm = 2650
        MP_max = 30
    elif pwr == 'cc':
        rpm = 2500
        MP_max = 25
    elif pwr == 2500:
        rpm = 2500
        MP_max = 30
    else:
        raise ValueError, "pwr must be one of 'max', 'cc', or 2500"
    

    if output == 'raw':
        print S.center('Altitude', 10),
        print S.center('ROC', 10),
        print S.center('Time', 10),
        print S.center('Fuel Used', 10),
        print S.center('Dist', 10),
        print S.center('Speed', 10)
        
        print S.center('(ft)', 10),
        print S.center('(ft/mn)', 10),
        print S.center('(mn)', 10),
        f_units = '(' + fuel_units + ')'
        print S.center(f_units, 10),
        print S.center('(nm)', 10),
        print S.center('(KCAS)', 10)
        
        # data for MSL
        print S.rjust(locale.format('%.0f', 0, True), 7),
        # calculate ROC at MSL
        print S.rjust(locale.format('%.0f', round(_alt2ROC(prop, 0) / 10.) * 10, \
            True), 10),
        print S.rjust('%.1f' % (0), 10),
        print S.rjust('%.1f' % (TO_fuel), 10),
        print S.rjust('%.1f' % (TO_dist), 10),
        print S.rjust('%3d' % (alt2roc_speed(0, climb_speed = climb_speed)), 10)

    elif output == 'latex':
        temp = 15 + isa_dev
        MSL_line = []
        MSL_line.append(str(locale.format('%.0f', weight, True)))
        MSL_line.append('0')
        MSL_line.append(str(locale.format('%.0f', temp)))
        MSL_line.append(str(locale.format('%.0f', alt2roc_speed(0, \
            climb_speed = climb_speed))))
        MSL_line.append(str(locale.format('%.0f', round(_alt2ROC(prop, 0) / 10.)\
          * 10, True)))
        MSL_line.append('0')
        MSL_line.append(str(TO_fuel))
        MSL_line.append(str(TO_dist))
        
        print '&'.join(MSL_line) + '\\\\'
        print '\\hline'
    elif output == 'array':
        # no header rows, but make blank array
        array = [[0,0,TO_fuel,0]]
        
    calc_alt = alt_interval / 2.
    while calc_alt < alt_max:
        temp = SA.isa2temp(isa_dev, calc_alt)
        pwr = alt2pwr(calc_alt, rpm = rpm, MP_max = MP_max, temp = temp)
        calc_pwr = pwr * pwr_factor
        cas = alt2roc_speed(calc_alt, climb_speed = climb_speed)
        eas = A.cas2eas(cas, calc_alt)
        tas = A.cas2tas(cas, calc_alt, temp = temp, temp_units = temp_units)
        tas_fts = U.speed_conv(tas, from_units = 'kt', to_units = 'ft/s')
        ROC = roc(prop, calc_alt, eas, weight, calc_pwr, rpm, rv = rv, \
            wing_area = wing_area)
        roc_fts = ROC / 60
        fuel_flow = IO.pwr2ff(pwr, rpm, ff_units = 'lb/hr')
        slice_time = alt_interval / roc_fts
        slice_dist = tas_fts * slice_time
        slice_fuel = fuel_flow * slice_time / 3600
        fuel_used += slice_fuel
        fuel_out = (U.avgas_conv(fuel_used, from_units = 'lb', \
            to_units = fuel_units))
        weight -= slice_fuel
        alt += alt_interval
        cas_out = alt2roc_speed(alt, climb_speed = climb_speed)
        temp_out = SA.isa2temp(isa_dev, alt)
        ROC = _alt2ROC(prop, alt)
        time += slice_time / 60
        dist += slice_dist / 6076.115

        if output == 'raw':
            print S.rjust(locale.format('%.0f', alt, True), 7),
            # calculate ROC at the displayed altitude
            print S.rjust(locale.format('%.0f', ROC, True), 10),
            print S.rjust('%.1f' % (time), 10),
            print S.rjust('%.1f' % (fuel_out), 10),
            print S.rjust('%.1f' % (dist), 10),
            print S.rjust('%3d' % (int(cas_out)), 10)
        elif output == 'latex':
            line = []
            line.append(str(locale.format('%.0f', alt, True)))
            line.append(str(locale.format('%.0f', round(temp_out))))
            line.append(str(locale.format('%.0f', cas_out)))
            line.append(str(locale.format('%.0f', round(ROC / 10.) * 10, True)))
            line.append(str(locale.format('%.0f', time)))
            line.append(str(locale.format('%.1f', fuel_out)))
            line.append(str(locale.format('%.0f', dist)))
            print '&' + '&'.join(line) + '\\\\'
            print '\\hline'
        elif output == 'array':
            array.append([alt, time, fuel_out, dist])
        calc_alt += alt_interval
    if output == 'array':
        return array
Exemplo n.º 11
0
#! /sw/bin/python2.7

"""Return EAS given CAS and Pressure Altitude"""

import airspeed
import argparse

parser = argparse.ArgumentParser(description='Return EAS for a given CAS and pressure altitude')
parser.add_argument('CAS', type=float, 
                    help='Calibrated Airspeed')
parser.add_argument('HP', type=float, 
                    help='Pressure Altitude')
parser.add_argument('--speed_units', required=False, default='kt',
                    help='airspeed units - one of "kt", "mph", "km/h", "ft/s" or "m/s".  Defaults to "kt".')
parser.add_argument('--alt_units', required=False, default='ft',
                    help='altitude units - one of feet ("ft"), metres ("m"), kilometres ("km"), statute miles, ("sm") or nautical miles ("nm").  Defaults to "ft".')


args = parser.parse_args()
print(airspeed.cas2eas(args.CAS, args.HP, speed_units=args.speed_units, alt_units=args.alt_units))
Exemplo n.º 12
0
def climb_data(prop, weight = 1800., alt_max = 20000., TO_fuel = 0, TO_dist = 0, \
    fuel_units = 'USG', alt_interval = 500., isa_dev = 0, temp_units = 'C', \
    rv = '8', wing_area = 110., pwr = 'max', pwr_factor=1.0, \
    climb_speed = 'max', output = 'raw'):
    """
    Returns a table of climb performance vs altitude.

    The items in each row of the table are altitude, time, fuel burned and distance.
    Time is in units of minutes, rounded to the nearest half minute.
    Fuel units are selectable, with a default of USG.
    Distances are in nm.
    
    The output may be specified as raw, latex (a LaTeX table for the POH), or array.
    
    pwr may be 'max', 'cc' (cruise climb = 2500 rpm and 25") or 2500 (2500 rpm and full throttle)
    climb_speed may be 'max' (Vy), 'cc' (120 kt to 10,000 ft, then reducing by 4 kt/1000 ft) or
                'norm' (100 kt to 10,000 ft, then reducing by 2 kt/1000 ft)
                
    Note: compared cruise range for all climb speed and power.  The predicted results are all 
          within 1.5 nm of range.  Thus there is no advantage to using anything but Vy and max
          power.
    """
    def _alt2ROC(prop, alt):
        """
        calculate ROC for an altitude
        """
        temp = SA.isa2temp(isa_dev, alt)
        calc_pwr = alt2pwr(alt, rpm=rpm, MP_max=MP_max, temp=temp) * pwr_factor
        cas = alt2roc_speed(alt, climb_speed=climb_speed)
        eas = A.cas2eas(cas, alt)
        ROC = roc(prop, alt, eas, weight, calc_pwr, rpm, rv = rv, \
            wing_area = wing_area)

        return ROC

    alt = 0
    time = 0
    fuel_used = U.avgas_conv(TO_fuel, from_units=fuel_units, to_units='lb')
    weight = weight - fuel_used
    dist = TO_dist
    if pwr == 'max':
        # rpm = 2700
        rpm = 2650
        MP_max = 30
    elif pwr == 'cc':
        rpm = 2500
        MP_max = 25
    elif pwr == 2500:
        rpm = 2500
        MP_max = 30
    else:
        raise ValueError("pwr must be one of 'max', 'cc', or 2500")

    if output == 'raw':
        print(S.center('Altitude', 10), end=' ')
        print(S.center('ROC', 10), end=' ')
        print(S.center('Time', 10), end=' ')
        print(S.center('Fuel Used', 10), end=' ')
        print(S.center('Dist', 10), end=' ')
        print(S.center('Speed', 10))

        print(S.center('(ft)', 10), end=' ')
        print(S.center('(ft/mn)', 10), end=' ')
        print(S.center('(mn)', 10), end=' ')
        f_units = '(' + fuel_units + ')'
        print(S.center(f_units, 10), end=' ')
        print(S.center('(nm)', 10), end=' ')
        print(S.center('(KCAS)', 10))

        # data for MSL
        print(S.rjust(locale.format('%.0f', 0, True), 7), end=' ')
        # calculate ROC at MSL
        print(S.rjust(locale.format('%.0f', round(_alt2ROC(prop, 0) / 10.) * 10, \
            True), 10), end=' ')
        print(S.rjust('%.1f' % (0), 10), end=' ')
        print(S.rjust('%.1f' % (TO_fuel), 10), end=' ')
        print(S.rjust('%.1f' % (TO_dist), 10), end=' ')
        print(S.rjust('%3d' % (alt2roc_speed(0, climb_speed=climb_speed)), 10))

    elif output == 'latex':
        temp = 15 + isa_dev
        MSL_line = []
        MSL_line.append(str(locale.format('%.0f', weight, True)))
        MSL_line.append('0')
        MSL_line.append(str(locale.format('%.0f', temp)))
        MSL_line.append(str(locale.format('%.0f', alt2roc_speed(0, \
            climb_speed = climb_speed))))
        MSL_line.append(str(locale.format('%.0f', round(_alt2ROC(prop, 0) / 10.)\
          * 10, True)))
        MSL_line.append('0')
        MSL_line.append(str(TO_fuel))
        MSL_line.append(str(TO_dist))

        print('&'.join(MSL_line) + '\\\\')
        print('\\hline')
    elif output == 'array':
        # no header rows, but make blank array
        array = [[0, 0, TO_fuel, 0]]

    calc_alt = alt_interval / 2.
    while calc_alt < alt_max:
        temp = SA.isa2temp(isa_dev, calc_alt)
        pwr = alt2pwr(calc_alt, rpm=rpm, MP_max=MP_max, temp=temp)
        calc_pwr = pwr * pwr_factor
        cas = alt2roc_speed(calc_alt, climb_speed=climb_speed)
        eas = A.cas2eas(cas, calc_alt)
        tas = A.cas2tas(cas, calc_alt, temp=temp, temp_units=temp_units)
        tas_fts = U.speed_conv(tas, from_units='kt', to_units='ft/s')
        ROC = roc(prop, calc_alt, eas, weight, calc_pwr, rpm, rv = rv, \
            wing_area = wing_area)
        roc_fts = ROC / 60
        fuel_flow = IO.pwr2ff(pwr, rpm, ff_units='lb/hr')
        slice_time = alt_interval / roc_fts
        slice_dist = tas_fts * slice_time
        slice_fuel = fuel_flow * slice_time / 3600
        fuel_used += slice_fuel
        fuel_out = (U.avgas_conv(fuel_used, from_units = 'lb', \
            to_units = fuel_units))
        weight -= slice_fuel
        alt += alt_interval
        cas_out = alt2roc_speed(alt, climb_speed=climb_speed)
        temp_out = SA.isa2temp(isa_dev, alt)
        ROC = _alt2ROC(prop, alt)
        time += slice_time / 60
        dist += slice_dist / 6076.115

        if output == 'raw':
            print(S.rjust(locale.format('%.0f', alt, True), 7), end=' ')
            # calculate ROC at the displayed altitude
            print(S.rjust(locale.format('%.0f', ROC, True), 10), end=' ')
            print(S.rjust('%.1f' % (time), 10), end=' ')
            print(S.rjust('%.1f' % (fuel_out), 10), end=' ')
            print(S.rjust('%.1f' % (dist), 10), end=' ')
            print(S.rjust('%3d' % (int(cas_out)), 10))
        elif output == 'latex':
            line = []
            line.append(str(locale.format('%.0f', alt, True)))
            line.append(str(locale.format('%.0f', round(temp_out))))
            line.append(str(locale.format('%.0f', cas_out)))
            line.append(str(locale.format('%.0f',
                                          round(ROC / 10.) * 10, True)))
            line.append(str(locale.format('%.0f', time)))
            line.append(str(locale.format('%.1f', fuel_out)))
            line.append(str(locale.format('%.0f', dist)))
            print('&' + '&'.join(line) + '\\\\')
            print('\\hline')
        elif output == 'array':
            array.append([alt, time, fuel_out, dist])
        calc_alt += alt_interval
    if output == 'array':
        return array