Source code for irfpy.vexpvat.domain

""" Domain of the spacecraft

Domains (solar wind, induced magnetosphere, magnetosheath) are handled.
"""
from irfpy.venus import bowshock as _bs
from irfpy.venus import icb as _icb

from irfpy.vexpvat import vexspice as _vs
from irfpy.vexpvat import orbnum as _onr

from irfpy.asperacommon.domain_common import bisect_boundary_crossing as _boundary_crossing


[docs]def inside_bowshock(t, model=None): """ Return if the spacecraft is inside the bow shock. :param t: :keyword model: The model used. As default, use the Martinecz model https://irfpy.irf.se/projects/planets/api/api_irfpy.venus.bowshock.html is used. **Currently, only Martinecz model is implemented** :return: *True* if the VEX is inside the bow shock. It include the magnetosheath, induced magnetosphere, magnetotail, or innosphere >>> import datetime >>> t = datetime.datetime(2009, 1, 15, 7, 0, 30) >>> print(inside_bowshock(t)) True >>> t = datetime.datetime(2009, 1, 15, 7, 0, 25) >>> print(inside_bowshock(t)) False """ if not _vs.isinitialized(): _vs.init() pos = _vs.get_position(t, target='VEX', origin='VENUS') pos /= 6052 # Now in Rv return _bs.inside_martinecz08(pos[0], pos[1], pos[2])
[docs]def inside_icb(t, model=None): """ Return if the spacecraft is inside the bow shock. :param t: :keyword model: The model used. As default, use the Martinecz model https://irfpy.irf.se/projects/planets/api/api_irfpy.venus.bowshock.html is used. **Currently, only Martinecz model is implemented** :return: *True* if the VEX is inside the ICB. It include the induced magnetosphere, magnetotail, or ionosphere. >>> import datetime >>> t = datetime.datetime(2009, 1, 15, 8, 38, 40) >>> print(inside_icb(t)) True >>> t = datetime.datetime(2009, 1, 15, 8, 38, 50) >>> print(inside_icb(t)) False """ if not _vs.isinitialized(): _vs.init() pos = _vs.get_position(t, target='VEX', origin='VENUS') pos /= 6052 # Now in Rv return _icb.inside_martinecz08(pos[0], pos[1], pos[2])
[docs]def inside_eclipse(t): r""" Return if the spacecraft is inside the geometric eclipse. :param t: Time :returns: Boolean value, *True* if the spacecraft is in the eclipse. The definition of the eclipse is just geometric: :math:`R(=\sqrt{x^2+y^2+z^2})\ge 1 [Rv]` and :math:`x<0` and :math:`r(=\sqrt{y^2+z^2})\le 1 [Rv]` where ``R`` is the radius and ``r`` is the distance from x-axis. >>> import datetime >>> t = datetime.datetime(2010, 8, 8, 8) >>> print(inside_eclipse(t)) True >>> t = datetime.datetime(2010, 8, 8, 9) >>> print(inside_eclipse(t)) False """ if not _vs.isinitialized(): _vs.init() pos = _vs.get_position(t, target='VEX', origin='VENUS') x, y, z = pos / 6052 # Now in Rv if x >= 0: return False r3_2 = x ** 2 + y ** 2 + z ** 2 if r3_2 < 1: return False r2_2 = y ** 2 + z ** 2 if r2_2 > 1: return False return True
[docs]def bowshock_crossings(orbit_number, tolerance=0.1): return [inbound_bowshock(orbit_number, tolerance=tolerance), outbound_bowshock(orbit_number, tolerance=tolerance)]
[docs]def icb_crossings(orbit_number, tolerance=0.1): return [inbound_icb(orbit_number, tolerance=tolerance), outbound_icb(orbit_number, tolerance=tolerance)]
[docs]def inbound_bowshock(orbit_number, tolerance=0.1, model=None): """ Bow shock time inbound the specific orbit :param orbit_number: Orbit number :keyword tolerance: Tolerance acceptable :keyword model: The model used. As default, use the Martinecz model https://irfpy.irf.se/projects/planets/api/api_irfpy.venus.bowshock.html is used. **Currently, only Martinecz model is implemented** :return: Time of crossing >>> print('{:%F %T}'.format(inbound_bowshock(1000))) 2009-01-15 07:00:27 """ t0 = _onr.get_start_time(orbit_number) t1 = _onr.get_pericenter(orbit_number) tc = _boundary_crossing(t0, t1, inside_bowshock) return tc
[docs]def outbound_bowshock(orbit_number, tolerance=0.1, model=None): """ Bow shock time outbound the specific orbit :param orbit_number: Orbit number :keyword tolerance: Tolerance acceptable :keyword model: The model used. As default, use the Martinecz model https://irfpy.irf.se/projects/planets/api/api_irfpy.venus.bowshock.html is used. **Currently, only Martinecz model is implemented** :return: Time of crossing >>> print('{:%F %T}'.format(outbound_bowshock(1000))) 2009-01-15 08:48:26 """ t0 = _onr.get_pericenter(orbit_number) t1 = _onr.get_stop_time(orbit_number) tc = _boundary_crossing(t0, t1, inside_bowshock) return tc
[docs]def inbound_icb(orbit_number, tolerance=0.1, model=None): """ ICB time inbound the specific orbit :param orbit_number: Orbit number :keyword tolerance: Tolerance acceptable :keyword model: The model used. As default, use the Martinecz model https://irfpy.irf.se/projects/planets/api/api_irfpy.venus.icb.html is used. **Currently, only Martinecz model is implemented** :return: Time of crossing >>> print('{:%F %T}'.format(inbound_icb(1000))) 2009-01-15 08:01:54 """ t0 = _onr.get_start_time(orbit_number) t1 = _onr.get_pericenter(orbit_number) tc = _boundary_crossing(t0, t1, inside_icb) return tc
[docs]def outbound_icb(orbit_number, tolerance=0.1, model=None): """ ICB time outbound the specific orbit :param orbit_number: Orbit number :keyword tolerance: Tolerance acceptable :keyword model: The model used. As default, use the Martinecz model https://irfpy.irf.se/projects/planets/api/api_irfpy.venus.icb.html is used. **Currently, only Martinecz model is implemented** :return: Time of crossing >>> print('{:%F %T}'.format(outbound_icb(1000))) 2009-01-15 08:38:41 """ t0 = _onr.get_pericenter(orbit_number) t1 = _onr.get_stop_time(orbit_number) tc = _boundary_crossing(t0, t1, inside_icb) return tc