Skip to content

Commit

Permalink
Merge pull request #6 from nicolasaunai/toto
Browse files Browse the repository at this point in the history
simplify MSH
  • Loading branch information
nicolasaunai authored Nov 4, 2020
2 parents 90ecad2 + 885a00d commit 4344e79
Showing 1 changed file with 33 additions and 14 deletions.
47 changes: 33 additions & 14 deletions space/models/planetary.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,14 +318,6 @@ def quad(i, s):
"bs_jerab": bs_Jerab2005}


class Magnetosheath:
def __init__(self, **kwargs):
self.magnetopause = _models[kwargs.get("magnetopause", "shue")]
self.bow_shock = _models[kwargs.get("bow_shock", "jerab")]

def boundaries(self, theta, phi, **kwargs):
return self.magnetopause(theta, phi, **kwargs), self.bow_shock(theta, phi, **kwargs)


def _interest_points(model, **kwargs):
dup = kwargs.copy()
Expand All @@ -346,16 +338,46 @@ def _parabolic_approx(theta, phi, x, xf, **kwargs):
return coords.BaseChoice(kwargs.get("base", "cartesian"), r, theta, phi)


class ParabolicMagnetosheath:

def check_parabconfoc(func):
def wrapper(self, theta, phi, **kwargs):
kwargs["parabolic"] = kwargs.get("parabolic", False)
kwargs["confocal"] = kwargs.get("confocal", False)
if kwargs["parabolic"] is False and kwargs["confocal"] is True:
raise ValueError("cannot be confocal if not parabolic")
return func(self, theta, phi, **kwargs)
return wrapper


class Magnetosheath:
def __init__(self, **kwargs):
self._magnetopause = _models[kwargs.get("magnetopause", "shue")]
self._bow_shock = _models[kwargs.get("bow_shock", "jerab")]


@check_parabconfoc
def magnetopause(self, theta, phi, **kwargs):
return self._parabolize(theta, phi, **kwargs)[0]
if kwargs["parabolic"]:
return self._parabolize(theta, phi, **kwargs)[0]
else:
return self._magnetopause(theta, phi, **kwargs)


@check_parabconfoc
def bow_shock(self, theta, phi, **kwargs):
return self._parabolize(theta, phi, **kwargs)[1]
if kwargs["parabolic"]:
return self._parabolize(theta, phi, **kwargs)[1]
else:
return self._magnetopause(theta, phi, **kwargs)

@check_parabconfoc
def boundaries(self, theta, phi, **kwargs):
if kwargs["parabolic"]:
return self._parabolize(theta, phi, **kwargs)
else:
return self._magnetopause(theta, phi, **kwargs),\
self._bow_shock(theta, phi, **kwargs)


def _parabolize(self, theta, phi, **kwargs):
xmp, y, xfmp = _interest_points(self._magnetopause, **kwargs)
Expand All @@ -366,6 +388,3 @@ def _parabolize(self, theta, phi, **kwargs):
mp_coords = _parabolic_approx(theta, phi, xmp, xfmp, **kwargs)
bs_coords = _parabolic_approx(theta, phi, xbs, xfbs, **kwargs)
return mp_coords, bs_coords

def boundaries(self, theta, phi, **kwargs):
return self._parabolize(theta, phi, **kwargs)

0 comments on commit 4344e79

Please sign in to comment.