irfpy.cy1orb.pvat2¶
Spacecraft position and attitude
The module irfpy.cy1orb.pvat2 provides functionality of
- Spacecraft position
Position in LSE frame
Position in ME frame
Spacecraft attitude - Convert between LSE frame and spacecraft (SC) frame
For frame conversions, please refer also to How to convert between frames.
Setup
See Position of Chandrayaan-1 for the setup.
Warning
The returned values are in irfpy.util.vector3d, which should be
modified in some ways.
Getting position
To get the position of spacecraft, one can use either of the function.
irfpy.cy1orb.pvat2.getlsepos(): To get LSE position.irfpy.cy1orb.pvat2.getmepos(): To get ME position.
>>> import datetime
>>> from irfpy.cy1orb import pvat2 as pvat
>>> t = datetime.datetime(2009, 5, 10, 3, 10)
>>> pos_lse = pvat.getlsepos(t, asarray=True)
>>> print(pos_lse)
[1396.34 1005.16 633.71]
>>> pos_me_lonlatalt = pvat.getmepos(t)
>>> print(pos_me_lonlatalt) # The returned value is longitude, latitude and altitude
(28.6, 21.2, 96.1)
>>> pos_me_xyz = pvat.getmepos(t, asarray=True)
>>> print(pos_me_xyz)
[1501.32901199 818.5511499 663.25562399]
Conversion between LSE and SC
The spacecraft frame and LSE frame conversion can be doen using
- lse2sc(), from LSE to SC
- sc2lse(), from SC to LSE
The example below will give the representation of the spacecraft x-axis in the LSE frame.
>>> vec = sc2lse(datetime.datetime(2009,1,25,14,0,0), [1, 0, 0])
>>> print(vec)
[-0.8204 0.5718 -0.0042]
The next example will give the representations of LSE x-axis in the SC frame. Since LSE a-axis is toward the Sun, the returned vector is the Sun direction in the SC frame.
>>> vec = lse2sc(datetime.datetime(2009,1,25,14,0,0), [1, 0, 0])
>>> print(vec)
[-0.8204 0.0147 0.57163338]
To convert the LSE frame to ME (lunar fixed) frame, see the module irfpy.cy1orb.lseme.
- irfpy.cy1orb.pvat2.clear_cache()[source]¶
Clear the cache.
Usually user do not need to use this function.
- irfpy.cy1orb.pvat2.getlsepos(t, asarray=False)[source]¶
Get LSE orbit at the time of t.
The LSE postiion of Chandrayaan-1. The unit is km.
The returned position of the spacecraft is at the sampling time (1 sec resolution) closest to the specified time.
- Parameters
t – Time of the data to inquire
asarray – If True, numpy array is returned. Otherwise,
Vector3dis used.
- Returns
The position of spacecraft.
- Return type
Vector3d(default) ornp.narray(as_array=True)
- irfpy.cy1orb.pvat2.getmepos(t, as_vector=None, asarray=False, asvector=False)[source]¶
Get s/c position in ME frame as an array of [lon,lat,height].
lon and lat is in degrees, height is in km above the surface.
>>> me=getmepos(datetime.datetime(2009,4,18,1,30,0))
- Param
Time to inquire
- Parameters
as_vector – Deprecated. Same effect as
asarrayasarray – Return as numpy array, in km.
asvector – Return as
Vector3dclass object.
- Returns
The position of the spacecraft. Default is (longitude, latitude, and height). Angles in degrees, and height in km. If asarray is True, the returned is
[x, y, z]in the ME frame in km. If asvector is True, the returns isVector3d(x, y, z).
- irfpy.cy1orb.pvat2.getlsevec(t, vec_in_sc)[source]¶
Convert the SC -> LSE.
Get LSE-frame vector correspoinding to the SC-frame vector at the time of t. The returned variable is vector3d.Vector3d instance.
>>> vec = getlsevec(datetime.datetime(2009,1,25,14,0,0), ... vector3d.Vector3d(1, 0, 0)) >>> print(vec.x, vec.y, vec.z) -0.8204 0.5718 -0.0042
- irfpy.cy1orb.pvat2.sc2lse(t, arr_sc)[source]¶
Convert SC -> LSE
Get LSE-frame arrray correspoinding to the given SC-frame array at the time of t.
- Parameters
t – Time
arr_sc – (…, 3) shaped array in SC frame
- Returns
(…, 3) shaped array in LSE frame
>>> vec = sc2lse(datetime.datetime(2009,1,25,14,0,0), ... [1, 0, 0]) >>> print(vec) [-0.8204 0.5718 -0.0042]
>>> arr_sc = [[1, 0, 0], [0, 1, 0]] >>> arr_lse = sc2lse(datetime.datetime(2009,1,25,14,0,0), arr_sc) >>> print(arr_lse) [[-0.8204 0.5718 -0.0042] [ 0.0147 0.0284 0.9995]]
- irfpy.cy1orb.pvat2.getscvec(t, vec_in_lse)[source]¶
Convert LSE -> SC.
Inverse function of
getlsevec().Conversion from LSE vector to SC vector at the time of t. The returned is vector3d.Vector3d instance.
>>> vec = getscvec(datetime.datetime(2009, 1, 25, 14, 0, 0), ... vector3d.Vector3d(1, 0, 0)) >>> print('{:.4f} {:.4f} {:.4f}'.format(vec.x, vec.y, vec.z)) -0.8204 0.0147 0.5716
- irfpy.cy1orb.pvat2.lse2sc(t, arr_lse)[source]¶
Convert LSE -> SC.
Inverse function of
sc2lse().Conversion from LSE vector to SC vector at the time of t.
- Parameters
t – Time
arr_sc – (…, 3) shaped array in SC frame
- Returns
(…, 3) shaped array in LSE frame
>>> vec_sc = lse2sc(datetime.datetime(2009, 1, 25, 14, 0, 0), [1, 0, 0]) >>> print('{v[0]:.4f} {v[1]:.4f} {v[2]:.4f}'.format(v=vec_sc)) -0.8204 0.0147 0.5716
- irfpy.cy1orb.pvat2.getdatarange()[source]¶
Return the data range.
- Returns
The range of the data that can be accessed.
- Return type
util:irfpy.util.timeinterval.timeintervalinstance.
>>> trange = getdatarange() >>> print(datetime.datetime(2009, 3, 1, 0) in trange) True >>> print(datetime.datetime(2008, 12, 8, 0) in trange) False >>> print(datetime.datetime(2009, 9, 1, 0) in trange) False