mirror of
https://github.com/cosinekitty/astronomy.git
synced 2026-05-24 16:56:39 -04:00
Throw an exception for invalid refraction option.
In JavaScript and Python, throw an exception if provided an invalid refraction option. Especially in JavaScript, it was too easy to pass in a value like 'true', which did not calculate refraction as expected.
This commit is contained in:
@@ -1757,7 +1757,7 @@ due to lensing of the Earth's atmosphere.
|
||||
|
||||
| Type | Parameter | Description |
|
||||
| --- | --- | --- |
|
||||
| [`Refraction`](#Refraction) | `refraction` | The option for selecting whether to correct for atmospheric lensing. If `Refraction.Normal`, a well-behaved refraction model is used. If `Refraction.Airless`, no refraction correct is performed. `Refraction.JplHorizons` is used only for compatibility testing with the JPL Horizons online tool. |
|
||||
| [`Refraction`](#Refraction) | `refraction` | The option for selecting whether to correct for atmospheric lensing. If `Refraction.Normal`, a well-behaved refraction model is used. If `Refraction.Airless`, no refraction correct is performed. `Refraction.JplHorizons` is used only for compatibility testing with the JPL Horizons online tool. Any other value raises an exception. |
|
||||
| `float` | `altitude` | The number of degrees above (positive) or below (negative) the horizon an object is, before being corrected for refraction. |
|
||||
|
||||
### Returns: `float`
|
||||
|
||||
@@ -4662,6 +4662,7 @@ def RefractionAngle(refraction, altitude):
|
||||
If `Refraction.Airless`, no refraction correct is performed.
|
||||
`Refraction.JplHorizons` is used only for compatibility testing
|
||||
with the JPL Horizons online tool.
|
||||
Any other value raises an exception.
|
||||
altitude : float
|
||||
The number of degrees above (positive) or below (negative) the
|
||||
horizon an object is, before being corrected for refraction.
|
||||
@@ -4694,9 +4695,11 @@ def RefractionAngle(refraction, altitude):
|
||||
# When horizon angle is -1 degrees, the factor is exactly 1.
|
||||
# As altitude approaches -90 (the nadir), the fraction approaches 0 linearly.
|
||||
refr *= (altitude + 90.0) / 89.0
|
||||
else:
|
||||
# No refraction, or the refraction option is invalid.
|
||||
elif refraction == Refraction.Airless:
|
||||
# The caller does not want refraction correction.
|
||||
refr = 0.0
|
||||
else:
|
||||
raise Error('Inalid refraction option')
|
||||
return refr
|
||||
|
||||
def InverseRefractionAngle(refraction, bent_altitude):
|
||||
|
||||
Reference in New Issue
Block a user