def test_get_alt_for_pressure(self): """tests ``get_alt_for_pressure``""" alt_targets = [0., 10., 20., 30., 40., 50.] for alt_target in alt_targets: pressure1 = atm_pressure(alt_target * 1000.) #alt1 = get_alt_for_pressure(pressure1, tol=5., SI=False, nmax=20) alt1 = get_alt_for_pressure(pressure1, nmax=20) #self.assertAlmostEqual(alt, alt_target) assert np.allclose( alt1, alt_target * 1000, atol=1.), 'alt1=%s alt_target=%s' % (alt1, alt_target * 1000) pressure2 = atm_pressure(alt_target, alt_units='kft', pressure_units='Pa') tol = 0.005 # 5 feet alt2 = get_alt_for_pressure(pressure2, pressure_units='Pa', alt_units='kft', tol=tol) assert np.allclose( alt2, alt_target, atol=1e-3), 'alt2=%s alt_target=%s' % (alt2, alt_target)
def test_pressure(self): """tests pressure at various altitudes""" self.assertEqual(atm_pressure(alt=10 * 1000.), 1456.3074319943232) self.assertEqual(atm_pressure(alt=60 * 1000.), 151.20878913237249) self.assertEqual(atm_pressure(alt=120 * 1000.), 9.8627955961437763) self.assertEqual(atm_pressure(alt=165 * 1000.), 1.7725806687593277) self.assertEqual(atm_pressure(alt=230 * 1000.), 0.13023784776280109) self.assertEqual(atm_pressure(alt=270 * 1000.), 0.017353278750799964) self.assertEqual(atm_pressure(alt=350 * 1000.), 0.00028114006933161638) self.assertEqual( atm_pressure2(alt=0., alt_units='ft', pressure_units='psf'), 2116.2247459927403) self.assertEqual( atm_pressure2(alt=0., alt_units='m', pressure_units='psf'), 2116.2247459927403) units = { 'alt_units': 'ft', 'pressure_units': 'psf', } self.assertEqual(atm_pressure2(alt=10 * 1000., **units), 1456.3074319943232) self.assertEqual(atm_pressure2(alt=60 * 1000., **units), 151.20878913237249) self.assertEqual(atm_pressure2(alt=120 * 1000., **units), 9.8627955961437763) self.assertEqual(atm_pressure2(alt=165 * 1000., **units), 1.7725806687593277) self.assertEqual(atm_pressure2(alt=230 * 1000., **units), 0.13023784776280109) self.assertEqual(atm_pressure2(alt=270 * 1000., **units), 0.017353278750799964) self.assertEqual(atm_pressure2(alt=350 * 1000., **units), 0.00028114006933161638) units = { 'alt_units': 'kft', 'pressure_units': 'psf', } self.assertEqual(atm_pressure2(alt=10, **units), 1456.3074319943232) self.assertEqual(atm_pressure2(alt=60, **units), 151.20878913237249) self.assertEqual(atm_pressure2(alt=120, **units), 9.8627955961437763) self.assertEqual(atm_pressure2(alt=165, **units), 1.7725806687593277) self.assertEqual(atm_pressure2(alt=230, **units), 0.13023784776280109) self.assertEqual(atm_pressure2(alt=270, **units), 0.017353278750799964) self.assertEqual(atm_pressure2(alt=350, **units), 0.00028114006933161638)
def test_pressure(self): self.assertEqual(atm_pressure(alt=10 * 1000.), 1456.3074319943232) self.assertEqual(atm_pressure(alt=60 * 1000.), 151.20878913237249) self.assertEqual(atm_pressure(alt=120 * 1000.), 9.8627955961437763) self.assertEqual(atm_pressure(alt=165 * 1000.), 1.7725806687593277) self.assertEqual(atm_pressure(alt=230 * 1000.), 0.13023784776280109) self.assertEqual(atm_pressure(alt=270 * 1000.), 0.017353278750799964) self.assertEqual(atm_pressure(alt=350 * 1000.), 0.00028114006933161638) self.assertEqual(atm_pressure2(alt=10 * 1000., alt_units='ft'), 1456.3074319943232) self.assertEqual(atm_pressure2(alt=60 * 1000., alt_units='ft'), 151.20878913237249) self.assertEqual(atm_pressure2(alt=120 * 1000., alt_units='ft'), 9.8627955961437763) self.assertEqual(atm_pressure2(alt=165 * 1000., alt_units='ft'), 1.7725806687593277) self.assertEqual(atm_pressure2(alt=230 * 1000., alt_units='ft'), 0.13023784776280109) self.assertEqual(atm_pressure2(alt=270 * 1000., alt_units='ft'), 0.017353278750799964) self.assertEqual(atm_pressure2(alt=350 * 1000., alt_units='ft'), 0.00028114006933161638) self.assertEqual(atm_pressure2(alt=10, alt_units='kft'), 1456.3074319943232) self.assertEqual(atm_pressure2(alt=60, alt_units='kft'), 151.20878913237249) self.assertEqual(atm_pressure2(alt=120, alt_units='kft'), 9.8627955961437763) self.assertEqual(atm_pressure2(alt=165, alt_units='kft'), 1.7725806687593277) self.assertEqual(atm_pressure2(alt=230, alt_units='kft'), 0.13023784776280109) self.assertEqual(atm_pressure2(alt=270, alt_units='kft'), 0.017353278750799964) self.assertEqual(atm_pressure2(alt=350, alt_units='kft'), 0.00028114006933161638)
def test_pressure(self): self.assertEqual(atm_pressure(alt=10 *1000.), 1456.3074319943232) self.assertEqual(atm_pressure(alt=60 *1000.), 151.20878913237249) self.assertEqual(atm_pressure(alt=120*1000.), 9.8627955961437763) self.assertEqual(atm_pressure(alt=165*1000.), 1.7725806687593277) self.assertEqual(atm_pressure(alt=230*1000.), 0.13023784776280109) self.assertEqual(atm_pressure(alt=270*1000.), 0.017353278750799964) self.assertEqual(atm_pressure(alt=350*1000.), 0.00028114006933161638) self.assertEqual(atm_pressure2(alt=10*1000., alt_units='ft'), 1456.3074319943232) self.assertEqual(atm_pressure2(alt=60*1000., alt_units='ft'), 151.20878913237249) self.assertEqual(atm_pressure2(alt=120*1000., alt_units='ft'), 9.8627955961437763) self.assertEqual(atm_pressure2(alt=165*1000., alt_units='ft'), 1.7725806687593277) self.assertEqual(atm_pressure2(alt=230*1000., alt_units='ft'), 0.13023784776280109) self.assertEqual(atm_pressure2(alt=270*1000., alt_units='ft'), 0.017353278750799964) self.assertEqual(atm_pressure2(alt=350*1000., alt_units='ft'), 0.00028114006933161638) self.assertEqual(atm_pressure2(alt=10, alt_units='kft'), 1456.3074319943232) self.assertEqual(atm_pressure2(alt=60, alt_units='kft'), 151.20878913237249) self.assertEqual(atm_pressure2(alt=120, alt_units='kft'), 9.8627955961437763) self.assertEqual(atm_pressure2(alt=165, alt_units='kft'), 1.7725806687593277) self.assertEqual(atm_pressure2(alt=230, alt_units='kft'), 0.13023784776280109) self.assertEqual(atm_pressure2(alt=270, alt_units='kft'), 0.017353278750799964) self.assertEqual(atm_pressure2(alt=350, alt_units='kft'), 0.00028114006933161638)
def test_pressure(self): """tests pressure at various altitudes""" self.assertEqual( atm_pressure(alt=0., alt_units='ft', pressure_units='psf'), 2116.2247459927403) self.assertEqual( atm_pressure(alt=0., alt_units='m', pressure_units='psf'), 2116.2247459927403) units = { 'alt_units': 'ft', 'pressure_units': 'psf', } self.assertEqual(atm_pressure(alt=10 * 1000., **units), 1456.3074319943232) self.assertEqual(atm_pressure(alt=60 * 1000., **units), 151.20878913237249) self.assertEqual(atm_pressure(alt=120 * 1000., **units), 9.8627955961437763) self.assertEqual(atm_pressure(alt=165 * 1000., **units), 1.7725806687593277) self.assertEqual(atm_pressure(alt=230 * 1000., **units), 0.13023784776280109) self.assertEqual(atm_pressure(alt=270 * 1000., **units), 0.017353278750799964) self.assertEqual(atm_pressure(alt=350 * 1000., **units), 0.00028114006933161638) units = { 'alt_units': 'kft', 'pressure_units': 'psf', } self.assertEqual(atm_pressure(alt=10, **units), 1456.3074319943232) self.assertEqual(atm_pressure(alt=60, **units), 151.20878913237249) self.assertEqual(atm_pressure(alt=120, **units), 9.8627955961437763) self.assertEqual(atm_pressure(alt=165, **units), 1.7725806687593277) self.assertEqual(atm_pressure(alt=230, **units), 0.13023784776280109) self.assertEqual(atm_pressure(alt=270, **units), 0.017353278750799964) self.assertEqual(atm_pressure(alt=350, **units), 0.00028114006933161638) self.assertEqual( atm_pressure(alt=0., alt_units='m', pressure_units='Pa'), 101325.20482878872) self.assertAlmostEqual(atm_pressure(alt=0., alt_units='m', pressure_units='kPa'), 101.32520482878872, delta=0.001) self.assertAlmostEqual(atm_pressure(alt=0., alt_units='m', pressure_units='MPa'), 0.10132520482878872, delta=0.000001) with self.assertRaises(RuntimeError): atm_pressure(alt=0., alt_units='m', pressure_units='bar')