Ejemplo n.º 1
0
def EarthObstructionAngles(earthLimb, satECI, senECI):
    """
	Computes Earth/Sensor/Earth Limb and Earth/Sensor/Satellite angles.
	
	:param float earthLimb: Earth limb distance (km).
	:param float[3] satECI: Satellite position in ECI (km). (double[3])
	:param float[3] senECI: Sensor position in ECI (km). (double[3])
	:return:
		- **earthSenLimb** (*float*) - The resulting earth/sensor/limb angle (deg).
		- **earthSenSat** (*float*) - The resulting earth/sensor/sat angle (deg).
		- **satEarthSen** (*float*) - The resulting sat/earth/sensor angle (deg).
	"""
    earthLimb = c.c_double(earthLimb)
    satECI_compatible = settings.double3()
    senECI_compatible = settings.double3()
    earthSenLimb = c.c_double()
    earthSenSat = c.c_double()
    satEarthSen = c.c_double()
    satECI_compatible = settings.feed_list_into_array(satECI,
                                                      satECI_compatible)
    senECI_compatible = settings.feed_list_into_array(senECI,
                                                      senECI_compatible)
    C_ASTRODLL.EarthObstructionAngles(earthLimb, satECI_compatible,
                                      senECI_compatible, c.byref(earthSenLimb),
                                      c.byref(earthSenSat),
                                      c.byref(satEarthSen))
    #pdb.set_trace()
    earthSenLimb = earthSenLimb.value
    earthSenSat = earthSenSat.value
    satEarthSen = satEarthSen.value
    return (earthSenLimb, earthSenSat, satEarthSen)
Ejemplo n.º 2
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)
Ejemplo n.º 3
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)
Ejemplo n.º 4
0
def CovMtxUVWToPTW(pos, vel, uvwCovMtx):
    """
	Converts covariance matrix UVW to PTW

	:param float[3] pos: the input position vector (km) (double[3])
	:param float[3] vel: the input velocity vector (km/s) (double[3])
	:param float[6][6] uvwCovMtx: the UVW covariance matrix to be converted. (double[6,6])
	:return:
		**ptwCovMtx** (*float[6][6]*) - The resulting PTW covariance matrix (double[6,6])
	"""
    # initialize ctypes
    # initialize ctypes
    pos_compatible = settings.double3()
    vel_compatible = settings.double3()
    ptwCovMtx_compatible = settings.double6x6()
    uvwCovMtx_compatible = settings.double6x6()
    # copy list data into ctypes
    pos_compatible = settings.feed_list_into_array(pos, pos_compatible)
    vel_compatible = settings.feed_list_into_array(vel, vel_compatible)
    uvwCovMtx_compatible = settings.feed_2d_list_into_array(
        uvwCovMtx, ptwCovMtx_compatible)
    # call DLL, will fill ptwCovMtx_compatible
    C_ASTRODLL.CovMtxPTWToUVW(pos_compatible, vel_compatible,
                              uvwCovMtx_compatible, ptwCovMtx_compatible)
    # convert to python datatype and return
    ptwCovMtx = settings.array2d_to_list(uvwCovMtx_compatible)
    return ptwCovMtx
Ejemplo n.º 5
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)
Ejemplo n.º 6
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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 9
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)
Ejemplo n.º 10
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)
Ejemplo n.º 11
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)
Ejemplo n.º 12
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)
Ejemplo n.º 13
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)
Ejemplo n.º 14
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)
Ejemplo n.º 15
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)
Ejemplo n.º 16
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
Ejemplo n.º 17
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
Ejemplo n.º 18
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)
Ejemplo n.º 19
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
Ejemplo n.º 20
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