1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
/* Copyright (c) 2015, 2016 Saurav Sachidanand Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ //! Corrections for atmospheric refraction use angle; use std::f64::consts::PI; /** Computes the refraction term for true altitudes greater than 15 degrees # Returns * `refrac_term`: The refraction term *| in radians*, that needs to be subtracted from the apparent altitude to get the true altitude # Arguments * `apprnt_alt`: Apparent altitude *| in radians* **/ pub fn refrac_frm_apprnt_alt_15(apprnt_alt: f64) -> f64 { angle::deg_frm_dms(0, 0, 58.294).to_radians() * (PI - apprnt_alt).tan() - angle::deg_frm_dms(0, 0, 0.0668).to_radians() * (PI - apprnt_alt).tan().powi(3) } /** Computes the refraction term for apparent altitudes greater than 15 degrees # Returns * `refrac_term`: The refraction term *| in radians*, that needs to be added to the true altitude to get the apparent altitude # Arguments * `true_alt`: True altitude *| in radians* **/ pub fn refrac_frm_true_alt_15(true_alt: f64) -> f64 { angle::deg_frm_dms(0, 0, 58.276).to_radians() * (PI - true_alt).tan() - angle::deg_frm_dms(0, 0, 0.0824).to_radians() * (PI - true_alt).tan().powi(3) } /** Computes the refraction term for true altitude # Returns * `refrac_term`: The refraction term *| in radians*, that needs to be subtracted from the apparent altitude to get the rue altitude The accuracy of `refrac_term` is upto 0.07 arcminutes. # Arguments * `apprnt_alt`: Apparent altitude *| in radians* **/ pub fn refrac_frm_apprnt_alt(apprnt_alt: f64) -> f64 { if apprnt_alt == PI { 0.0 } else { let a = apprnt_alt.to_degrees() + 7.31/(apprnt_alt.to_degrees() + 4.4); let R = 1.0 / a.to_radians().tan(); (R / 60.0).to_radians() } } /** Computes the refraction term for apparent altitude This function is consistent with `refrac_frm_apprnt_alt()` to within 4 arcseconds. # Returns * `refrac_term`: The refraction term *| in radians*, that needs to be added to the true altitude to get the apparent altitude # Arguments * `true_alt`: True altitude *| in radians* **/ pub fn refrac_frm_true_alt(true_alt: f64) -> f64 { if true_alt == PI { 0.0 } else { let a = true_alt.to_degrees() + 10.3/(true_alt.to_degrees() + 5.11); let R = 1.02 / a.to_radians().tan(); (R / 60.0).to_radians() } } /** Computes the refraction term modifier for local pressure # Returns * `refrac_term_modifier`: The value that needs to be multiplied by the refraction term to account for local pressure # Arguments * `pressure`: Local pressure *| in millibars* **/ #[inline(always)] pub fn refrac_by_pressr(pressure: f64) -> f64 { pressure / 1010.0 } /** Computes the refraction term modifier for local temperature # Returns * `refrac_term_modifier`: The value that needs to be multiplied by the refraction term to account for local temperature # Arguments * `temp`: Local temperature *| in kelvins* **/ #[inline(always)] pub fn refrac_by_temp(temp: f64) -> f64 { 283.0 / temp }