Skip to content
Juan Luis Cano Rodríguez edited this page May 15, 2014 · 8 revisions

Here are some thoughts about how the package should be (actually taken from the features) and what consequences they have.

  • Pythonic interface - It should be intuitive and simple to use
  • Use of SI units - Perhaps astropy.units should be used! I tried in poliastro successfully
  • Support of NumPy arrays - Vectorization is a must! The very first use case is obtaining an array of properties in a domain of altitudes. This is perfect for plotting, but complicates library code.
  • Support for both Python 2 and 3 - Probably some continuous integration server is needed! Travis CI works very well.
  • Fully tested and documented - I need full coverage and better docs. API references are not enough.

Standard atmosphere

Use cases

Retrieve an array of properties

import astropy.units as u
from skaero.atmosphere import coesa

h = np.linspace(0 * u.km, 20 * u.km)
T = coesa.temperature(h)  # Notice vectorization is needed here
assert T.shape == h.shape   # An array is returned
assert T.unit == u.Kelvin  # With proper units

Retrieve all properties

Warnings:

  • A single array can contain a single unit. Therefore I cannot mix them.
  • Using pandas DataFrames won't fix the problem: they don't get on well with astropy.units.
  • Inverse calculations should only be possible if the variable is monotonic. Perhaps just altitude and pressure. Pressure altitude is a widely used quantity and should be taken into account. -- I wouldn't call them inverse calculations anymore.
# Slow
T = coesa.temperature(h)
p = coesa.pressure(h)
pass
# Ugly
T = coesa.alt2temp(h)
p = coesa.alt2press(h)
# Good?
h, T, p, rho = coesa.table(h)  # Four vectors are returned
# Using pressure altitude
h, T, p, rho = coesa.table(p=101325 * u.Pascal)

Ideas

Action for out-of-range values

Taken from the MATLAB Aerospace Toolbox. Either an error, a warning or a NaN value are possible. Options:

  • Argument to the function. Doesn't feel very Pythonic, but how do you vectorize and exception?
  • Choose one of those and stick with it.
  • Some kind of global state or context manager, similar to numpy.seterr.

Perhaps the most sensible thing is to raise an exception for scalar calls and a warning + nan values when using arrays, to not ruin all the output.

See http://www.mathworks.es/es/help/aerotbx/ug/atmoscoesa.html

Return altitude

Notice that I'm already returning the altitude - this is because I might use the altitude pressure as an argument. I prefer to have a redundant output value (which can be discarded anyway) than two functions or two possibilities of return values.

Plus, what happens to atmosphere.pressure getting pressure altitude or even atmosphere.altitude? Two options:

  • Be homogeneous, predictable: always admit both options (altitude and pressure altitude) even if it makes little sense.
  • Differentiate atmosphere.pressure not admitting pressure altitude and atmosphere.altitude admitting only pressure altitude.

Return speed of sound

Also taken from the MATLAB Aerospace Toolbox. However if this only depends on temperature and one can just use the corresponding isentropic formula perhaps this could live somewhere else.

Clone this wiki locally