| @@ 266-287 (lines=22) @@ | ||
| 263 | ||
| 264 | return qlat, qlon |
|
| 265 | ||
| 266 | def _qd2apex_nonvectorized(self, qlat, qlon, height): |
|
| 267 | """Converts quasi-dipole to modified apex coordinates. |
|
| 268 | ||
| 269 | Parameters |
|
| 270 | ---------- |
|
| 271 | qlat : float |
|
| 272 | Quasi-dipole latitude |
|
| 273 | qlon : float |
|
| 274 | Quasi-dipole longitude |
|
| 275 | height : float |
|
| 276 | Altitude in km |
|
| 277 | ||
| 278 | Returns |
|
| 279 | ------- |
|
| 280 | alat : float |
|
| 281 | Modified apex latitude |
|
| 282 | alon : float |
|
| 283 | Modified apex longitude |
|
| 284 | ||
| 285 | Raises |
|
| 286 | ------ |
|
| 287 | ApexHeightError |
|
| 288 | if apex height < reference height |
|
| 289 | ||
| 290 | """ |
|
| @@ 220-263 (lines=44) @@ | ||
| 217 | # ------------------------- |
|
| 218 | # Define the hidden methods |
|
| 219 | ||
| 220 | def _apex2qd_nonvectorized(self, alat, alon, height): |
|
| 221 | """Convert from apex to quasi-dipole (not-vectorised) |
|
| 222 | ||
| 223 | Parameters |
|
| 224 | ----------- |
|
| 225 | alat : (float) |
|
| 226 | Apex latitude in degrees |
|
| 227 | alon : (float) |
|
| 228 | Apex longitude in degrees |
|
| 229 | height : (float) |
|
| 230 | Height in km |
|
| 231 | ||
| 232 | Returns |
|
| 233 | --------- |
|
| 234 | qlat : (float) |
|
| 235 | Quasi-dipole latitude in degrees |
|
| 236 | qlon : (float) |
|
| 237 | Quasi-diplole longitude in degrees |
|
| 238 | ||
| 239 | """ |
|
| 240 | # Evaluate the latitude |
|
| 241 | alat = helpers.checklat(alat, name='alat') |
|
| 242 | ||
| 243 | # Convert modified apex to quasi-dipole, longitude is the same |
|
| 244 | qlon = alon |
|
| 245 | ||
| 246 | # Get the apex height |
|
| 247 | h_apex = self.get_apex(alat) |
|
| 248 | ||
| 249 | if h_apex < height: |
|
| 250 | if np.isclose(h_apex, height, rtol=0, atol=1e-5): |
|
| 251 | # Allow for values that are close |
|
| 252 | h_apex = height |
|
| 253 | else: |
|
| 254 | estr = ''.join(['height {:.3g} is > '.format(np.max(height)), |
|
| 255 | 'apex height {:.3g} for alat {:.3g}'.format( |
|
| 256 | h_apex, alat)]) |
|
| 257 | raise ApexHeightError(estr) |
|
| 258 | ||
| 259 | # Convert the latitude |
|
| 260 | salat = np.sign(alat) if alat != 0 else 1 |
|
| 261 | qlat = salat * np.degrees(np.arccos(np.sqrt((self.RE + height) / |
|
| 262 | (self.RE + h_apex)))) |
|
| 263 | ||
| 264 | return qlat, qlon |
|
| 265 | ||
| 266 | def _qd2apex_nonvectorized(self, qlat, qlon, height): |
|