Beispiel #1
0
def PosVelToPTW(pos, vel):
    """
	Converts position and velocity vectors to U, V, W vectors.
	The resulting vectors have the following meanings. 
	U vector: V x W 
	V vector: along velocity direction 
	W vector: pos x vel 
	
	:param float[3] pos: The position vector to be converted. (double[3])
	:param float[3] vel: The velocity vector to be converted. (double[3])
	:return:
		- **uVec** (*float[3]*) - The resulting U vector. (double[3])
		- **vVec** (*float[3]*) - The resulting V vector. (double[3])
		- **wVec** (*float[3]*) - The resulting W vector. (double[3])
	"""
    pos = settings.list_to_array(pos)
    vel = settings.list_to_array(vel)
    uVec = settings.double3()
    vVec = settings.double3()
    wVec = settings.double3()
    C_ASTRODLL.PosVelToPTW(pos, vel, uVec, vVec, wVec)
    uVec = settings.array_to_list(uVec)
    vVec = settings.array_to_list(vVec)
    wVec = settings.array_to_list(wVec)
    return (uVec, vVec, wVec)
Beispiel #2
0
def RotJ2KToDate(spectr, nutationTerms, ds50TAI, posDate, velDate):
    """
	Rotates position and velocity vectors from coordinates of date to J2000. 
	
	:param float spectr: Specifies whether to run in SPECTR compatibility mode. A value of 1 means Yes.
	:param float nutationTerms: Nutation terms (4-106, 4:less accurate, 106:most acurate).
	:param float ds50TAI: Time in days since 1950, TAI for which the coordinates of position and velocity vectors are currently expressed.
	:param float[3] posJ2K: The position vector from J2000. (double[3])
	:param float[3] velJ2K: The velocity vector from J2000. (double[3])
	:return:
		- **posDate** (*float[3]*) - The resulting position vector in coordinates of date, ds50TAI. (double[3])
		- **velDate** (*float[3]*) - The resulting velocity vector in coordinates of date, ds50TAI. (double[3])
	"""
    spectr = c.c_int32(spectr)
    nutationTerms = c.c_int32(nutationTerms)
    ds50TAI = c.c_double(ds50TAI)
    posJ2K = settings.list_to_array(posJ2K)
    velJ2K = settings.list_to_array(velJ2K)
    posDate = settings.double3()
    velDate = settings.double3()
    C_ASTRODLL.RotJ2KToDate(spectr, nutationTerms, ds50TAI, posJ2K, velJ2K,
                            posDate, velDate)
    posDate = settings.array_to_list(posDate)
    velDate = settings.array_to_list(velDate)
    return (posDate, velDate)
Beispiel #3
0
def RAEToECI(theta, astroLat, xa_rae):
    """
	Converts full state RAE (range, az, el, and their rates) to full state ECI (position and velocity)

	:param float theta: Theta - local sidereal time(rad).
	:param float astroLat: Astronomical latitude (ded).
	:param float[6] xa_rae: An array contains input data. The data at each index is listed below. (double[6])

		- [0]: Range (km) 
		- [1]: Azimuth (deg) 
		- [2]: Elevation (deg) 
		- [3]: Range Dot (km/s) 
		- [4]: Azimuth Dot (deg/s) 
		- [5]: Elevation Dot (deg/s) 
	
	:return:
		- **senPos** (*float[3]*) - Sensor position in ECI (km). (double[3])
		- **satPos** (*float[3]*) - Satellite position in ECI (km). (double[3])
		- **satVel** (*float[3]*) - Satellite velocity in ECI (km/s). (double[3])
	"""
    theta = c.c_double(theta)
    astroLat = c.c_double(astroLat)
    xa_rae = settings.list_to_array(xa_rae)
    senPos = settings.double3()
    satPos = settings.double3()
    satVel = settings.double3()
    C_ASTRODLL.RAEToECI(theta, astroLat, xa_rae, senPos, satPos, satVel)
    senPos = settings.array_to_list(senPos)
    satPos = settings.array_to_list(satPos)
    satVel = settings.array_to_list(satVel)
    return (senPos, satPos, satVel)
Beispiel #4
0
def Sgp4PosVelToKep(yr, day, pos, vel):
    """
	Converts osculating position and velocity vectors to a set of mean Keplerian SGP4 elements.
	
	The new position and velocity vectors are the results of using SGP4 propagator to propagate the computed sgp4MeanKep to the time specified in year and day of epoch time. They should be closely matched with the input osculating position and velocity vectors. 

	The mean Keplerian elements are SGP4's Brouwer mean motion not SGP's Kozai mean motion. 

	:param int yr: 2 or 4 digit year of the epoch time
	:param float day: Day of year of the epoch time.
	:param float[3] pos: Input osculating position vector (km). (double[3])
	:param float[3] vel: Input osculating velocity vector (km/s). (double[3])
	:return:
		- **retcode** (*int*) - 0 if the conversion is successful, non-0 if there is an error.
		- **posNew** (*float[3]*) - Resulting position vector (km) propagated from the sgp4MeanKep. (double[3])
		- **velNew** (*float[3]*) - Resulting velocity vector (km/s) propagated from the sgp4MeanKep. (double[3])
		- **sgp4MeanKep** (*float[6]*) - Resulting set of Sgp4 mean Keplerian elements. (double[6])
	"""
    yr = c.c_int32(yr)
    day = c.c_double(day)
    pos = settings.list_to_array(pos)
    vel = settings.list_to_array(vel)
    posNew = settings.double3()
    velNew = settings.double3()
    sgp4MeanKep = settings.double6()
    retcode = C_SGP4DLL.Sgp4PosVelToKep(yr, day, pos, vel, posNew, velNew,
                                        sgp4MeanKep)
    posNew = settings.array_to_list(posNew)
    velNew = settings.array_to_list(velNew)
    return (retcode, posNew, velNew, sgp4MeanKep)
Beispiel #5
0
def ECIToTopoComps(theta, lat, senPos, satPos, satVel):
    """
	Converts satellite ECI position/velocity vectors and sensor location to topocentric components.
	
	:param float theta: Theta - local sidereal time(rad).
	:param float lat: Station's astronomical latitude (deg). (+N) (-S)
	:param float[3] senPos: Sensor position in ECI (km). (double[3])
	:param float[3] satPos: Satellite position in ECI (km). (double[3])
	:param float[3] satVel: Satellite velocity in ECI (km/s). (double[3])
	:return:
		**xa_topo** (*float[10]*) - An array that stores the resulting topocentric components. (double[10])

			- [0]: Resulting right ascension (RA) (deg) 
			- [1]: Declination (deg) 
			- [2]: Azimuth (deg) 
			- [3]: Elevation (deg) 
			- [4]: Range (km) 
			- [5]: RAdot (first derivative of right ascension) (deg/s) 
			- [6]: DecDot (first derivative of declination) (deg/s) 
			- [7]: AzDot (first derivative of azimuth) (deg/s) 
			- [8]: ElDot (first derivative of elevation) (deg/s) 
			- [9]: RangeDot (first derivative of range) (km/s) 
	"""
    theta = c.c_double(theta)
    lat = c.c_double(lat)
    senPos = settings.list_to_array(senPos)
    satPos = settings.list_to_array(satPos)
    satVel = settings.list_to_array(satVel)
    xa_topo = settings.double10()
    C_ASTRODLL.ECIToTopoComps(theta, lat, senPos, satPos, satVel, xa_topo)
    xa_topo = settings.array_to_list(xa_topo)
    return xa_topo
Beispiel #6
0
def Sgp4PropDs50UtcPos(satKey, ds50UTC):
    """
	Propagates a satellite, represented by the satKey, to the time expressed in days since 1950, UTC. Only the ECI position vector is returned by this function. 
	
	It is the users' responsibility to decide what to do with the returned value. For example, if the users want to check for decay or low altitude, they can put that logic into their own code. 

	This function is similar to Sgp4PropDs50UTC but returns only ECI position vector. This function is designed especially for applications which plot satellite position in 3D. 

	The following cases will result in an error: 

		- Semi major axis A <= 0 or A >1.0D6
		- Eccentricity E >= 1.0 or E < -1.0D-3
		- Mean anomaly MA>=1.0D10
		- Hyperbolic orbit E2>= 1.0
		- satKey doesn't exist in the set of loaded satellites
		- GEO model not set to WGS-72 and/or FK model not set to FK5

	:param settings.stay_int64 satKey: 
	:param float ds50UTC: The unique key of the satellite to propagate.
	:return:
		- **retcode** (*int*) - 0 if the propagation is successful, non-0 if there is an error.
		- **ds50UTC** (*float*) - The time to propagate to, expressed in days since 1950, UTC.
		- **pos** (*float[3]*) - Resulting ECI position vector (km) in True Equator and Mean Equinox of Epoch. (double[3]) 
	"""
    if not isinstance(satKey, settings.stay_int64):
        raise TypeError("satKey is type %s, should be type %s" %
                        (type(satKey), settings.stay_int64))
    ds50UTC = c.c_double(ds50UTC)
    pos = settings.double3()
    retcode = C_SGP4DLL.Sgp4PropDs50UtcPos(satKey, ds50UTC, pos)
    pos = settings.array_to_list(pos)
    return (retcode, pos)
Beispiel #7
0
def KepToPosVel(metricKep):
    """
	Converts a set of osculating Keplerian elements to osculating position and velocity vectors. 
	
	:param float[6] metricKep: The set of Keplerian elements to be converted. (double[6])
	:return:
		- **pos** (*float[3]*) - The resulting position vector. (double[3])
		- **vel** (*float[3]*) - The resulting velocity vector. (double[3])
	"""
    metricKep = settings.list_to_array(metricKep)
    pos = settings.double3()
    vel = settings.double3()
    C_ASTRODLL.KepToPosVel(metricKep, pos, vel)
    pos = settings.array_to_list(pos)
    vel = settings.array_to_list(vel)
    return (pos, vel)
Beispiel #8
0
def EqnxToPosVel(metricEqnx):
    """
	Converts a set of equinoctial elements to position and velocity vectors. 
	
	:param float[6] metricEqnx: The set of equinoctial elements to be converted. (double[6])
	:return:
		- **pos** (*float[3]*) - The resulting position vector. (double[3])
		- **vel** (*float[3]*) - The resulting velocity vector. (double[3])
	"""
    metricEqnx = settings.list_to_array(metricEqnx)
    pos = settings.double3()
    vel = settings.double3()
    C_ASTRODLL.EqnxToPosVel(metricEqnx, pos, vel)
    pos = settings.array_to_list(pos)
    vel = settings.array_to_list(vel)
    return (pos, vel)
Beispiel #9
0
def KepToUVW(metricKep):
    """
	Converts a set of Keplerian elements to Ubar, Vbar, and Wbar vectors. 
	
	:param float[6] metricKep: The set of Keplerian elements to be converted. (double[6])
	:return:
		- **uBar** (*float[3]*) - The resulting ubar vector. (double[3])
		- **vBar** (*float[3]*) - The resulting vbar vector. (double[3])
		- **wBar** (*float[3]*) - The resulting wbar vector. (double[3])
	"""
    metricKep = settings.list_to_array(metricKep)
    uBar = settings.double3()
    vBar = settings.double3()
    wBar = settings.double3()
    C_ASTRODLL.KepToUVW(metricKep, uBar, vBar, wBar)
    uBar = settings.array_to_list(uBar)
    vBar = settings.array_to_list(vBar)
    wBar = settings.array_to_list(wBar)
    return (uBar, vBar, wBar)
Beispiel #10
0
def EFGToECI(thetaG, posEFG, velEFG):
    """
	Converts EFG position and velocity vectors to ECI position and velocity vectors. 
	
	:param float thetaG: Theta - Greenwich mean sidereal time (rad).
	:param float[3] posEFG: The EFG position vector (km) to be converted. (double[3])
	:param float[3] velEFG: The EFG velocity vector (km/s) to be converted. (double[3])
	:return:
		- **posECI** (*float[3]*) - The resulting ECI (TEME of Date) position vector (km). (double[3])
		- **velECI** (*float[3]*) - The resulting ECI (TEME of Date) velocity vector (km/s). (double[3])
	"""
    thetaG = c.c_double(thetaG)
    posEFG = settings.list_to_array(posEFG)
    velEFG = settings.list_to_array(velEFG)
    posECI = settings.double3()
    velECI = settings.double3()
    C_ASTRODLL.EFGToECI(thetaG, posEFG, velEFG, posECI, velECI)
    posECI = settings.array_to_list(posECI)
    velECI = settings.array_to_list(velECI)
    return (posECI, velECI)
Beispiel #11
0
def Sgp4PropMse(satKey, mse):
    """
	Propagates a satellite, represented by the satKey, to the time expressed in minutes since the satellite's epoch time. The resulting data about the satellite is placed in the various reference parameters. 
	
	It is the users' responsibility to decide what to do with the returned value. For example, if the users want to check for decay or low altitude, they can put that logic into their own code. 
	
	This function can be called in random time requests. 
	
	The following cases will result in an error: 
	
		- Semi major axis A <= 0 or A >1.0D6
		- Eccentricity E >= 1.0 or E < -1.0D-3
		- Mean anomaly MA>=1.0D10
		- Hyperbolic orbit E2>= 1.0
		- satKey doesn't exist in the set of loaded satellites
		- GEO model not set to WGS-72 and/or FK model not set to FK5
	
	:param settings.stay_int64 satKey: The satellite's unique key.
	:param float mse: The time to propagate to, specified in minutes since the satellite's epoch time.
	:return:
		- **retcode** (*int*) - 0 if the propagation is successful, non-0 if there is an error.
		- **ds50UTC** (*float*) - Resulting time in days since 1950, UTC.
		- **pos** (*float[3]*) - Resulting ECI position vector (km) in True Equator and Mean Equinox of Epoch. (double[3])
		- **vel** (*float[3]*) - Resulting ECI velocity vector (km/s) in True Equator and Mean Equinox of Epoch. (double[3])
		- **llh** (*float[3]*) - Resulting geodetic latitude (deg), longitude(deg), and height (km). (double[3])
	"""
    if not isinstance(satKey, settings.stay_int64):
        raise TypeError("satKey is type %s, should be type %s" %
                        (type(satKey), settings.stay_int64))
    mse = c.c_double(mse)
    ds50UTC = c.c_double(0)
    pos = settings.double3()
    vel = settings.double3()
    llh = settings.double3()
    retcode = C_SGP4DLL.Sgp4PropMse(satKey, mse, c.byref(ds50UTC), pos, vel,
                                    llh)
    ds50UTC = ds50UTC.value
    pos = settings.array_to_list(pos)
    vel = settings.array_to_list(vel)
    llh = settings.array_to_list(llh)
    return (retcode, ds50UTC, pos, vel, llh)
Beispiel #12
0
def RADecToLAD(RA, dec):
    """
	Converts right ascension and declination to vector triad LAD in topocentric equatorial coordinate system. 
	
	:param float RA: Right ascension (deg)
	:param float dec: Declination (deg)
	:return:
		- **L** (*float[3]*) - The resulting unit vector from the station to the satellite (referred to the equatorial coordinate system axis). (double[3])
		- **A_Tilde** (*float[3]*) - The resulting unit vector perpendicular to the hour circle passing through the satellite, in the direction of increasing RA. (double[3])
		- **D_Tilde** (*float[3]*) - The resulting unit vector perpendicular to L and is directed toward the north, in the plane of the hour circle. (double[3])
	"""
    RA = c.c_double(RA)
    dec = c.c_double(dec)
    L = settings.double3()
    A_Tilde = settings.double3()
    D_Tilde = settings.double3()
    C_ASTRODLL.RADecToLAD(RA, dec, L, A_Tilde, D_Tilde)
    L = settings.array_to_list(L)
    A_Tilde = settings.array_to_list(A_Tilde)
    D_Tilde = settings.array_to_list(D_Tilde)
    return (L, A_Tilde, D_Tilde)
Beispiel #13
0
def AzElToLAD(az, el):
    """
	Converts azimuth and elevation to vector triad LAD in topocentric horizontal coordinate system. 

	:param float az: Input azimuth (deg).
	:param float el: Input elevation angle (deg).
	:return:
		- **Lh** (*float[3]*) - The resulting unit vector from the station to the satellite (referred to the horizon coordinate system axis). (double[3])
		- **Ah** (*float[3]*) - The resulting unit vector perpendicular to the hour circle passing through the satellite, in the direction of increasing Az. (double[3])
		- **Dh** (*float[3]*) - The resulting unit vector perpendicular to L and is directed toward the zenith, in the plane of the hour circle. (double[3])
"""
    az = c.c_double(az)
    el = c.c_double(el)
    Lh = settings.double3()
    Ah = settings.double3()
    Dh = settings.double3()
    C_ASTRODLL.AzElToLAD(az, el, Lh, Ah, Dh)
    Lh = settings.array_to_list(Lh)
    Ah = settings.array_to_list(Ah)
    Dh = settings.array_to_list(Dh)
    return (Lh, Ah, Dh)
Beispiel #14
0
def LLHToEFGPos(metricLLH):
    """
	Converts geodetic latitude, longitude, and height to an EFG position vector.
	
	:param float[3] metricLLH: An Array containing the geodetic north latitude (degree), east longitude (degree), and height (km) to be converted. (double[3])
	:return:
		**posEFG** (*float[3]*) - The resulting EFG position vector (km). (double[3])
	"""
    metricLLH = settings.list_to_array(metricLLH)
    posEFG = settings.double3()
    C_ASTRODLL.LLHToEFGPos(metricLLH, posEFG)
    posEFG = settings.array_to_list(posEFG)
    return posEFG
Beispiel #15
0
def KepToEqnx(metricKep):
    """
	Converts a set of Keplerian elements to a set of equinoctial elements. 
	
	:param float[6] metricKep: The set of Keplerian elements to be converted. (double[6])
	:return:
		**metricEqnx** (*float[6]*) - The resulting set of equinoctial elements. (double[6])
	"""
    metricKep = settings.list_to_array(metricKep)
    metricEqnx = settings.double6()
    C_ASTRODLL.KepToEqnx(metricKep, metricEqnx)
    metricEqnx = settings.array_to_list(metricEqnx)
    return metricEqnx
Beispiel #16
0
def KepOscToMean(metricOscKep):
    """
	Converts a set of osculating Keplerian elements to a set of mean Keplerian elements using method 9 algorithm. 
	
	:param float[6] metricOscKep: The set of osculating Keplerian elements to be converted. (double[6])
	:return:
		**metricMeanKep** (*float[6]*) - The resulting set of mean Keplerian elements. (double[6])
	"""
    metricOscKep = settings.list_to_array(metricOscKep)
    metricMeanKep = settings.double6()
    C_ASTRODLL.KepOscToMean(metricOscKep, metricMeanKep)
    metricMeanKep = settings.array_to_list(metricMeanKep)
    return metricMeanKep
Beispiel #17
0
def EFGToECR(polarX, polarY, posEFG, velEFG):
    """
	Converts EFG position and velocity vectors to ECR position and velocity vectors.

	:param float polarX: Polar motion X (arc-sec).
	:param float polarY: Polar motion Y (arc-sec).
	:param float[3] posEFG: The EFG position vector (km) to be converted. (double[3])
	:param float[3] velEFG: The EFG velocity vector (km/s) to be converted. (double[3])
	:return:
		- **posECR** (*float[3]*) - The resulting ECR position vector (km). (double[3])
		- **velECR** (*float[3]*) - The resulting ECR velocity vector (km/s). (double[3])
	"""
    polarX = c.c_double(polarX)
    polarY = c.c_double(polarY)
    posEFG = settings.list_to_array(posEFG)
    velEFG = settings.list_to_array(velEFG)
    posECR = settings.double3()
    velECR = settings.double3()
    C_ASTRODLL.EFGToECR(polarX, polarY, posEFG, velEFG, posECR, velECR)
    posECR = settings.array_to_list(posECR)
    velECR = settings.array_to_list(velECR)
    return (posECR, velECR)
Beispiel #18
0
def EFGPosToLLH(posEFG):
    """
	Converts an EFG position vector to geodetic latitude, longitude, and height. 
	
	:param float[3] posEFG: The EFG position vector (km) to be converted. (double[3])
	:return:
		**metricLLH** (*float[3]*) - The resulting geodetic north latitude (degree), east longitude (degree), and height (km). (double[3])
	"""
    posEFG = settings.list_to_array(posEFG)
    metricLLH = settings.double3()
    C_ASTRODLL.EFGPosToLLH(posEFG, metricLLH)
    metricLLH = settings.array_to_list(metricLLH)
    return metricLLH
Beispiel #19
0
def ClassToEqnx(metricClass):
    """
	Converts a set of classical elements to a set of equinoctial elements. 

	:param float[6] metricClass: The set of classical elements to be converted. (double[6])
	:return: 
		**metricEqnx** (*float[6]*) - The resulting set of equinoctial elements. (double[6])
	"""
    metricClass_compatible = settings.double6()
    metricEqnx_compatible = settings.double6()
    metricClass_compatible = feed_list_into_array(metricClass)
    C_ASTRODLL.ClassToEqnx(metricClass_compatible, metricEqnx_compatible)
    metricEqnx = settings.array_to_list(metricEqnx_compatible)
    return (metricEqnx)
Beispiel #20
0
def CompSunMoonPos(ds50ET):
    """
	Computes the Sun and Moon position at the specified time. 
	
	:param float ds50ET: The number of days since 1950, ET for which to compute the sun and moon position.
	:return:
		- **uvecSun** (*float[3]*) - The resulting sun position unit vector. (double[3])
		- **sunVecMag** (*float*) - The resulting magnitude of the sun position vector (km).
		- **uvecMoon** (*float[3]*) - The resulting moon position unit vector. (double[3])
		- **moonVecMag** (*float*) - The resulting magnitude of the moon position vector (km).
	"""
    ds50ET = c.c_double(ds50ET)
    uvecSun = settings.double3()
    sunVecMag = c.c_double()
    uvecMoon = settings.double3()
    moonVecMag = c.c_double()
    C_ASTRODLL.CompSunMoonPos(ds50ET, uvecSun, c.byref(sunVecMag), uvecMoon,
                              c.byref(moonVecMag))
    uvecSun = settings.array_to_list(uvecSun)
    sunVecMag = sunVecMag.value
    uvecMoon = settings.array_to_list(uvecMoon)
    moonVecMag = moonVecMag.value
    return (uvecSun, sunVecMag, uvecMoon, moonVecMag)
Beispiel #21
0
def EqnxToKep(metricEqnx):
    """
	Converts a set of equinoctial elements to a set of classical elements
	
	TODO: Determine and document vector sequence
	
	:param float[6] metricEqnx: The set of equinoctial elements to be converted. (double[6])
	:return:
		**metricClass** (*float[6]*) - The resulting set of classical elements. (double[6])
	"""
    metricEqnx = settings.list_to_array(metricEqnx)
    metricKep = settings.double6()
    C_ASTRODLL.EqnxToKep(metricEqnx, metricKep)
    metricKep = settings.array_to_list(metricKep)
    return metricKep
Beispiel #22
0
def XYZToLLH(thetaG, metricPos):
    """
	Converts an ECI position vector XYZ to geodetic latitude, longitude, and height. 
	
	:param float thetaG: ThetaG - Greenwich mean sidereal time (rad).
	:param float[3] metricPos: The ECI (TEME of Date) position vector (km) to be converted. (double[3])
	:return:
		**metricLLH** (*float[3]*) - The resulting geodetic north latitude (degree), east longitude(degree), and height (km). (double[3])
	"""
    thetaG = c.c_double(thetaG)
    metricPos = settings.list_to_array(metricPos)
    metricLLH = settings.double3()
    C_ASTRODLL.XYZToLLH(thetaG, metricPos, metricLLH)
    metricLLH = settings.array_to_list(metricLLH)
    return metricLLH
Beispiel #23
0
def PosVelToKep(pos, vel):
    """
	Converts osculating position and velocity vectors to a set of osculating Keplerian elements. 
	
	:param float[3] pos: The position vector to be converted. (double[3])
	:param float[3] vel: The velocity vector to be converted. (double[3])
	:return:
		**metricKep** (*float[6]*) - The resulting set of Keplerian elements. (double[6])
	"""
    pos = settings.list_to_array(pos)
    vel = settings.list_to_array(vel)
    metricKep = settings.double6()
    C_ASTRODLL.PosVelToKep(pos, vel, metricKep)
    metricKep = settings.array_to_list(metricKep)
    return metricKep
Beispiel #24
0
def PosVelToEqnx(pos, vel):
    """
	Converts position and velocity vectors to a set of equinoctial elements. 
	
	:param float[3] pos: The position vector to be converted. (double[3])
	:param float[3] vel: The velocity vector to be converted. (double[3])
	:return:
		 **metricEqnx** (*float[6]*) - The resulting set of equinoctial elements. (double[6])
	"""
    pos = settings.list_to_array(pos)
    vel = settings.list_to_array(vel)
    metricEqnx = settings.double6()
    C_ASTRODLL.PosVelToEqnx(pos, vel, metricEqnx)
    metricEqnx = settings.array_to_list(metricEqnx)
    return metricEqnx
Beispiel #25
0
def LLHToXYZ(thetaG, metricLLH):
    """
	Converts geodetic latitude, longitude, and height to an ECI position vector XYZ. 
	
	:param float thetaG: Theta - Greenwich mean sidereal time (rad).
	:param float[3] metric LLH: An array containing geodetic north latitude (degree), east longitude (degree), and height (km) to be converted. (double[3])
	:return:
		**metricXYZ** (*float[3]*) - The resulting ECI (TEME of Date) position vector (km). (double[3])
	"""
    thetaG = c.c_double(thetaG)
    metricLLH = settings.list_to_array(metricLLH)
    metricXYZ = settings.double3()
    C_ASTRODLL.LLHToXYZ(thetaG, metricLLH, metricXYZ)
    metricXYZ = settings.array_to_list(metricXYZ)
    return metricXYZ
Beispiel #26
0
def AstroConvFrTo(xf_Conv, frArr):
    """
	This function is intended for future use. No information is currently available.

	Because the purpose of frArr and toArr is unclear, each array is automatically set to the maximum length permitted in the C_ASTRODLL spec.

	:param int xf_Conv: The purpose of this parameter is not yet known

	:param float[<=128] frArr: The purpose of this parameter is not yet known

	:return: 
		**toArr** (*float[128]*) - The output array of data
	"""
    xf_Conv = c.c_int(xf_Conv)
    frArr_compatible = settings.double128()
    toArr_compatible = settings.double128()
    frArr_compatible = settings.feed_list_into_array(frArr, frArr_compatible)
    C_ASTRODLL.AstroConvFrTo(xf_Conv, frArr_compatible, toArr_compatible)
    toArr = settings.array_to_list(toArr_compatible)
    return toArr
Beispiel #27
0
def TimeConvFrTo(funcIdx, frArr):
    """
	This function is intended for future use. No information is currently available. 
	Developer note: because the interface has documented types, we "did our best"
	The documentation incorrectly identifies the frArr data type to be a double instead of a double[]. No big deal.
	It is unclear what the maximum array length is permitted to be. 
	It is not memory safe to use this function until we constrain the index lengths.

	:param int funcIdx: ?
	:param float[] frArr: ?
	:return:
		**toArr** (*float[]*) - ?
	"""
    funcIdx = c.c_int(funcIdx)
    frArr_compatible = unknown_type()
    toArr_compatible = unknown_type()
    frArr_compatible = settings.feed_list_into_array(frArr, frArr_compatible)
    C_TIMEDLL.TimeConvFrTo(funcIdx, frArr_compatible, toArr_compatible)
    toArr = settings.array_to_list(toArr_compatible)
    return toArr
Beispiel #28
0
def Sgp4PropAll(satKey, timeType, timeIn):
    """
	Propagates a satellite, represented by the satKey, to the time expressed in either minutes since epoch or days since 1950, UTC. All propagation data is returned by this function. 

	TODO: Create a table identifying each element of ``xa_Sgp4Out``. This value was undocumented and the data must be recovered and crosschecked manually.

	:param settings.stay_int64 satKey: The unique key of the satellite to propagate.
	:param int timeType: The propagation time type: 0 = minutes since epoch, 1 = days since 1950, UTC
	:param float timeIn: The time to propagate to, expressed in either minutes since epoch or days since 1950, UTC.
	:return:
		- **retcode** (*int*) - 0 if the propagation is successful, non-0 if there is an error.
		- **xa_Sgp4Out** (*float[64]*) - The array that stores all Sgp4 propagation data, see XA_SGP4OUT_? for array arrangement (double[64]) 
	"""
    if not isinstance(satKey, settings.stay_int64):
        raise TypeError("satKey is type %s, should be type %s" %
                        (type(satKey), settings.stay_int64))
    timeType = c.c_int32(timeType)
    timeIn = c.c_double(timeIn)
    xa_Sgp4Out = settings.double64()
    retcode = C_SGP4DLL.Sgp4PropAll(satKey, timeType, timeIn, xa_Sgp4Out)
    xa_Sgp4Out = settings.array_to_list(xa_Sgp4Out)
    return (retcode, xa_Sgp4Out)
Beispiel #29
0
def Sgp4GetPropOut(satKey, xf_Sgp4Out):
    """
	Retrieves propagator's precomputed results. This function can be used to obtain results from a propagation which are not made available through calls to the propagation functions themselves. 
	
	This function should be called immediately after a successful call to Sgp4PropMse() or Sgp4PropDs50UTC() to retrieve the desired values. 

	It is the caller's responsibility to ensure that the array passed in the destArray parameter is large enough to hold the requested values. The required size can be found by looking at the destArray size column of the table below describing valid index values. 

	The destArray Arrangement column lists the order of the elements in the array. It is not necessarily the subscript of the element in the array since this is language-dependent. For example, in C/C++ the first element in every array is the zero-subscripted element. In other programming languages, the subscript of the first element is 1. 

	Note: This function is not thread safe, please use Sgp4PropAll() instead 

	The table below shows the values for the xf_Sgp4Out parameter:
	
	+-------+-------------------------------+----------------+-------------------------------------------------------------------+
	| Index | Index Interpretation          | destArray size | destArray Arrangement                                             |
	+-------+-------------------------------+----------------+-------------------------------------------------------------------+
	| 1     | Revolution number             | 1              | 1. Revolution number (based on the Osculating Keplerian Elements) |
	+-------+-------------------------------+----------------+-------------------------------------------------------------------+
	| 2     | Nodal Apogee Perigee          | 3              |                                                                   |
	|       |                               |                | 1. nodal period (minutes)                                         |
	|       |                               |                | 2. apogee (km)                                                    |
	|       |                               |                | 3. perigee (km)                                                   |
	+-------+-------------------------------+----------------+-------------------------------------------------------------------+
	| 3     | Mean Keplerian Elements       | 6              | 1. semi-major axis (km)                                           |
	|       |                               |                | 2. eccentricity (unitless)                                        |
	|       |                               |                | 3. inclination (degree)                                           |
	|       |                               |                | 4. mean anomaly (degree)                                          |
	|       |                               |                | 5. right ascension of the ascending node (degree)                 |
	|       |                               |                | 6. argument of perigee (degree)                                   |
	+-------+-------------------------------+----------------+-------------------------------------------------------------------+
	| 4     | Osculating Keplerian Elements | 6              | Same as Mean Keplerian Elements                                   |
	+-------+-------------------------------+----------------+-------------------------------------------------------------------+

	:param settings.stay_int64 satKey: The unique key of the satellite for which to retrieve results.
	:param xf_SgpOut: Specifies which propagator outputs to retrieve. See table above.
	:return:
		- **retcode** (*int*) - 0 if the requested information is retrieved successfully, non-0 if there is an error.
		- **destArr** (*float[?]*) - A list of 1 to 6 elements pulled from the propogator. See table above.
	"""

    # test satKey
    if not isinstance(satKey, settings.stay_int64):
        raise TypeError("satKey is type %s, should be type %s" %
                        (type(satKey), settings.stay_int64))

    # test xf_Sgp4Out
    if not (xf_Sgp4Out in [1, 2, 3, 4]):
        raise Exception(
            "xf_Sgp4Out is %i, should be 1, 2, 3, or 4. See table in docs." %
            (xf_Sgp4Out))

    # determine length of destArr by means of xf_Sgp4Out and initialize a double array of that length
    xf_Sgp4Out_type_dict = {
        1: settings.double1,
        2: settings.double3,
        3: settings.double6,
        4: settings.double6
    }
    destArr = xf_Sgp4Out_type_dict[xf_Sgp4Out]()

    # set the argtype for Sgp4GetPropOut
    C_SGP4DLL.Sgp4GetPropOut.argtypes = [
        settings.stay_int64, c.c_int, xf_Sgp4Out_type_dict[xf_Sgp4Out]
    ]

    # call Sgp4GetPropOut
    retcode = C_SGP4DLL.Sgp4GetPropOut(satKey, xf_Sgp4Out, destArr)

    # convert destArr to a list
    destArr = settings.array_to_list(destArr)

    # return values
    return (retcode, destArr)