@@ 343-383 (lines=41) @@ | ||
340 | # if array is returned, dtype is object, so convert to float |
|
341 | return np.float64(glat), np.float64(glon), np.float64(error) |
|
342 | ||
343 | def _apex2qd_nonvectorized(self, alat, alon, height): |
|
344 | """Convert from apex to quasi-dipole (not-vectorised) |
|
345 | ||
346 | Parameters |
|
347 | ----------- |
|
348 | alat : (float) |
|
349 | Apex latitude in degrees |
|
350 | alon : (float) |
|
351 | Apex longitude in degrees |
|
352 | height : (float) |
|
353 | Height in km |
|
354 | ||
355 | Returns |
|
356 | --------- |
|
357 | qlat : (float) |
|
358 | Quasi-dipole latitude in degrees |
|
359 | qlon : (float) |
|
360 | Quasi-diplole longitude in degrees |
|
361 | """ |
|
362 | ||
363 | alat = helpers.checklat(alat, name='alat') |
|
364 | ||
365 | # convert modified apex to quasi-dipole: |
|
366 | qlon = alon |
|
367 | ||
368 | # apex height |
|
369 | hA = self.get_apex(alat) |
|
370 | ||
371 | if hA < height: |
|
372 | if np.isclose(hA, height, rtol=0, atol=1e-5): |
|
373 | # allow for values that are close |
|
374 | hA = height |
|
375 | else: |
|
376 | estr = 'height {:.3g} is > apex height '.format(np.max(height)) |
|
377 | estr += '{:.3g} for alat {:.3g}'.format(hA, alat) |
|
378 | raise ApexHeightError(estr) |
|
379 | ||
380 | qlat = np.sign(alat) * np.degrees(np.arccos(np.sqrt((self.RE + height) / |
|
381 | (self.RE + hA)))) |
|
382 | ||
383 | return qlat, qlon |
|
384 | ||
385 | def apex2qd(self, alat, alon, height): |
|
386 | """Converts modified apex to quasi-dipole coordinates. |
|
@@ 416-436 (lines=21) @@ | ||
413 | # if array is returned, the dtype is object, so convert to float |
|
414 | return np.float64(qlat), np.float64(qlon) |
|
415 | ||
416 | def _qd2apex_nonvectorized(self, qlat, qlon, height): |
|
417 | ||
418 | qlat = helpers.checklat(qlat, name='qlat') |
|
419 | ||
420 | alon = qlon |
|
421 | hA = self.get_apex(qlat, height) # apex height |
|
422 | ||
423 | if hA < self.refh: |
|
424 | if np.isclose(hA, self.refh, rtol=0, atol=1e-5): |
|
425 | # allow for values that are close |
|
426 | hA = self.refh |
|
427 | else: |
|
428 | estr = 'apex height ({:.3g}) is < reference height '.format(hA) |
|
429 | estr += '({:.3g}) for qlat {:.3g}'.format(self.refh, qlat) |
|
430 | raise ApexHeightError(estr) |
|
431 | ||
432 | alat = np.sign(qlat) * np.degrees(np.arccos(np.sqrt((self.RE + |
|
433 | self.refh) / |
|
434 | (self.RE + hA)))) |
|
435 | ||
436 | return alat, alon |
|
437 | ||
438 | def qd2apex(self, qlat, qlon, height): |
|
439 | """Converts quasi-dipole to modified apex coordinates. |