''' Module to specify which region (Magnetosphere/Magnetosheath/Solar wind) the spacecraft located.
'''
from irfpy.cy1orb.MoonPos import MoonGse
from irfpy.earth.bowshock import BsModelFairfield as bsmodel
from irfpy.earth.magnetosphere import MsModelShue as msmodel
from irfpy.util import utc
import datetime
#__moonpos_gse = MoonGse()
#__moonpos_gse.setFromDefaultUri()
class __moonpos_gse:
instance = None
@classmethod
def cache(cls):
if cls.instance is None:
cls.instance = MoonGse()
cls.instance.setFromDefaultUri()
return cls.instance
__msmodel=msmodel()
__bsmodel=bsmodel()
[docs]def inMagnetosphere(t):
''' Return True if the Moon is in the magnetosphere at the specified time t.
>>> print(inMagnetosphere(datetime.datetime(2009, 1, 25, 0, 0, 0)))
False
>>> print(inMagnetosphere(datetime.datetime(2009, 1, 10, 0, 0, 0)))
True
'''
x,y,z = __moonpos_gse.cache().getGse(t)
return __msmodel.isInsideKm(x,y,z)
[docs]def inMagnetosheath(t):
''' Return True if the Moon is in the magnetosheath at the specified time t.
>>> print(inMagnetosheath(datetime.datetime(2009, 1, 25, 0, 0, 0)))
False
>>> print(inMagnetosheath(datetime.datetime(2009, 1, 10, 0, 0, 0)))
False
'''
x,y,z = __moonpos_gse.cache().getGse(t)
inms = __msmodel.isInsideKm(x,y,z)
inbs = __bsmodel.isInsideKm(x,y,z)
return not inms and inbs
[docs]def inSolarWind(t):
''' Return True if the Moon is in the solar wind at the specified time t.
>>> print(inSolarWind(datetime.datetime(2009, 1, 25, 0, 0, 0)))
True
>>> print(inSolarWind(datetime.datetime(2009, 1, 10, 0, 0, 0)))
False
'''
x,y,z = __moonpos_gse.cache().getGse(t)
return not __bsmodel.isInsideKm(x,y,z)
#if __name__=='__main__':
# t=datetime.datetime(2009,1,25,15,25)
# while t<datetime.datetime(2009,8,30,15,25):
# print t,
# print inMagnetosphere(t),
# print inMagnetosheath(t),
# print inSolarWind(t),
# print
# t=t+datetime.timedelta(0,3500)