|
@@ 390-417 (lines=28) @@
|
| 387 |
|
bound_height = pressure_to_height_std(bound_pressure) |
| 388 |
|
|
| 389 |
|
# Bound is given in length |
| 390 |
|
elif bound.dimensionality == {'[length]': 1.0}: |
| 391 |
|
# If there is height data, see if we have the bound or need to interpolate/find nearest |
| 392 |
|
if heights is not None: |
| 393 |
|
if bound in heights: # Bound is in the height data |
| 394 |
|
bound_height = bound |
| 395 |
|
idx = np.where(heights == bound) |
| 396 |
|
bound_pressure = pressure[idx] |
| 397 |
|
else: # Bound is not in the data |
| 398 |
|
if interpolate: |
| 399 |
|
bound_height = bound |
| 400 |
|
bound_pressure = height_to_pressure_std(bound_height) |
| 401 |
|
else: |
| 402 |
|
idx = (np.abs(heights - bound)).argmin() |
| 403 |
|
bound_pressure = pressure[idx] |
| 404 |
|
bound_height = heights[idx] |
| 405 |
|
else: # Don't have heights, so assume a standard atmosphere |
| 406 |
|
bound_height = bound |
| 407 |
|
bound_pressure = height_to_pressure_std(bound) |
| 408 |
|
# If interpolation is on, this is all we need, if not, we need to go back and |
| 409 |
|
# find the pressure closest to this and refigure the bounds |
| 410 |
|
if interpolate is False: |
| 411 |
|
idx = (np.abs(pressure - bound_pressure)).argmin() |
| 412 |
|
bound_pressure = pressure[idx] |
| 413 |
|
bound_height = pressure_to_height_std(bound_pressure) |
| 414 |
|
|
| 415 |
|
# Bound has invalid units |
| 416 |
|
else: |
| 417 |
|
raise ValueError('Bound must be specified in units of length or pressure.') |
| 418 |
|
|
| 419 |
|
return bound_pressure, bound_height |
| 420 |
|
|
|
@@ 364-387 (lines=24) @@
|
| 361 |
|
# Bound is given in pressure |
| 362 |
|
if bound.dimensionality == {'[length]': -1.0, '[mass]': 1.0, '[time]': -2.0}: |
| 363 |
|
# If the bound is in the pressure data, we know the pressure bound exactly |
| 364 |
|
if bound in pressure: |
| 365 |
|
bound_pressure = bound |
| 366 |
|
# If we have heights, we know the exact height value, otherwise return standard |
| 367 |
|
# atmosphere height for the pressure |
| 368 |
|
if heights is not None: |
| 369 |
|
idx = np.where(pressure == bound_pressure) |
| 370 |
|
bound_height = heights[idx] |
| 371 |
|
else: |
| 372 |
|
bound_height = pressure_to_height_std(bound_pressure) |
| 373 |
|
# If bound is not in the data, return the nearest or interpolated values |
| 374 |
|
else: |
| 375 |
|
if interpolate: |
| 376 |
|
bound_pressure = bound # Use the user specified bound |
| 377 |
|
if heights is not None: # Interpolate heights from the height data |
| 378 |
|
bound_height = log_interp(bound_pressure, pressure, heights) |
| 379 |
|
else: # If not heights given, use the standard atmosphere |
| 380 |
|
bound_height = pressure_to_height_std(bound_pressure) |
| 381 |
|
else: # No interpolation, find the closest values |
| 382 |
|
idx = (np.abs(pressure - bound)).argmin() |
| 383 |
|
bound_pressure = pressure[idx] |
| 384 |
|
if heights is not None: |
| 385 |
|
bound_height = heights[idx] |
| 386 |
|
else: |
| 387 |
|
bound_height = pressure_to_height_std(bound_pressure) |
| 388 |
|
|
| 389 |
|
# Bound is given in length |
| 390 |
|
elif bound.dimensionality == {'[length]': 1.0}: |