Source code for irfpy.mars.mpb

''' Magnetic pileup boundary (MPB) model.

Usage:

>>> from irfpy.mars import mpb
>>> mpb_model = mpb.MpbVignes.mpb_xr()

This will return the Vignes's MPB model in X-R coordinates (as [2, 180] shaped matrix).

'''

import numpy as np

[docs]class MpbVignes:
[docs] @classmethod def mpb_xr(self): ''' Return the magnetic pileup boundary position. :returns: The array with shape of (2, 180). Unit is in Rm. >>> print(MpbVignes.mpb_xr()[:, 50]) [1.16947853 0.46878494] ''' L = 0.96 e = 0.90 x0 = 0.78 theta = np.linspace(0, 180 * np.pi / 180., 180) r = L / (1 + e * np.cos(theta)) x = r * np.cos(theta) + x0 y = r * np.sin(theta) return np.array([x, y])
[docs] @classmethod def inside(self, x, y, z): ''' Return if the s/c is in MPB >>> print(MpbVignes.inside(1, 0, 0)) True >>> print(MpbVignes.inside(0, 2, 0)) False ''' L = 0.96 e = 0.90 x0 = 0.78 xx = x - x0 yy = np.sqrt(y ** 2 + z ** 2) theta = np.arctan2(yy, xx) rr2 = xx ** 2 + yy ** 2 rb = L / (1 + e * np.cos(theta)) rb2 = rb ** 2 return rr2 < rb2
import unittest import doctest
[docs]def doctests(): return unittest.TestSuite(( doctest.DocTestSuite(), ))
if __name__ == '__main__': unittest.main(defaultTest='doctests')