def generate_sat_obj_list(): """ Generates list of satellite objects based on orbital elements :return: List of satellites """ global sat_objs sat_objs = [None] * NUM_SHELLS for shell_cntr in range(0, NUM_SHELLS): sat_objs[shell_cntr] = [None] * (NUM_ORBS[shell_cntr] * NUM_SATS_PER_ORB[shell_cntr]) counter = 0 for orb in range(0, NUM_ORBS[shell_cntr]): raan = orb * 360 / NUM_ORBS[shell_cntr] orbit_wise_shift = 0 if orb % 2 == 1: if PHASE_DIFF == 'Y': orbit_wise_shift = 360 / (NUM_SATS_PER_ORB[shell_cntr] * 2) for n_sat in range(0, NUM_SATS_PER_ORB[shell_cntr]): mean_anomaly = orbit_wise_shift + ( n_sat * 360 / NUM_SATS_PER_ORB[shell_cntr]) sat = ephem.EarthSatellite() sat._epoch = EPOCH sat._inc = ephem.degrees(INCLINATION_DEGREE[shell_cntr]) sat._e = ECCENTRICITY sat._raan = ephem.degrees(raan) sat._ap = ARG_OF_PERIGEE sat._M = ephem.degrees(mean_anomaly) sat._n = MEAN_MOTION_REV_PER_DAY[shell_cntr] sat_objs[shell_cntr][counter] = sat counter += 1 return sat_objs
def generate_sat_obj_list(num_orbit, num_sats_per_orbit, epoch, phase_diff, inclination, eccentricity, arg_perigee, mean_motion, altitude): """ Generates list of satellite objects based on orbital elements :param num_orbit: Number of orbits :param num_sats_per_orbit: Number of satellites per orbit :param epoch: Epoch (start time) :param phase_diff: Phase difference between adjacent orbits :param inclination: Angle of inclination :param eccentricity: Eccentricity of orbits :param arg_perigee: Argument of perigee of orbits :param mean_motion: Mean motion in revolutions per day :param altitude: Altitude in metres :return: List of satellite objects """ sat_objs = [None] * (num_orbit * num_sats_per_orbit) counter = 0 for orb in range(0, num_orbit): raan = orb * 360 / num_orbit orbit_wise_shift = 0 if orb % 2 == 1: if phase_diff: orbit_wise_shift = 360 / (num_sats_per_orbit * 2) for n_sat in range(0, num_sats_per_orbit): mean_anomaly = orbit_wise_shift + (n_sat * 360 / num_sats_per_orbit) sat = ephem.EarthSatellite() sat._epoch = epoch sat._inc = ephem.degrees(inclination) sat._e = eccentricity sat._raan = ephem.degrees(raan) sat._ap = arg_perigee sat._M = ephem.degrees(mean_anomaly) sat._n = mean_motion sat_objs[counter] = { "sat_obj": sat, "alt_km": altitude / 1000, "orb_id": orb, "orb_sat_id": n_sat } counter += 1 return sat_objs
def constellationFromSaVi(): DELETE_FROM_BEGINING = 3 DELETE_FROM_END = 2 constellation = list() with open(TCL_FILE_NAME, 'r') as tclfile: #we read from the TCL file and obtain a list containing SATELLITES_PER_ORBIT*NUMBER_OF_ORBITS #Attention : these elements are each one list(string) of size 1 spaceX_SaVi = list(csv.reader(tclfile, delimiter='\n')) #we delete the lines that do not give any infomation for the satellites for i in range(0, DELETE_FROM_BEGINING): spaceX_SaVi.pop(0) for i in range(0, DELETE_FROM_END): spaceX_SaVi.pop(len(spaceX_SaVi) - 1) if len(spaceX_SaVi) != SATELLITES_PER_ORBIT * NUMBER_OF_ORBITS: raise Exception('The total number of satellites is not correct') for i in range(0, NUMBER_OF_ORBITS): orbit_i = list() for j in range(0, SATELLITES_PER_ORBIT): SaVi_line = spaceX_SaVi.pop(0)[0].split() for i in range(0, 2): SaVi_line.pop(0) to_add_sat = ephem.EarthSatellite() to_add_sat._epoch = EPOCH #ok to_add_sat._n = geom.semi_major_to_mean_motion( float(SaVi_line[0])) #ok to_add_sat._e = float(SaVi_line[1]) + ECCENTRICITY_ADJUSTMENT #ok to_add_sat._inc = float(SaVi_line[2]) #ok to_add_sat._raan = float(SaVi_line[3]) #ok to_add_sat._ap = float(SaVi_line[4]) #ok to_add_sat._M = geom.time_to_periapsis_to_mean_anomaly( float(SaVi_line[5]), to_add_sat._n) #ok to_add_sat._drag = 0.0 orbit_i.append(to_add_sat) constellation.append(orbit_i) return constellation
# # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. import ephem import math import sys # Generate a satellite from orbital elements # Check parent script 02_get_sat_positions_at_time.sh for the arguments supplied sat1 = ephem.EarthSatellite() sat1._epoch = sys.argv[1] + ' ' + sys.argv[2] sat1._inc = ephem.degrees(float(sys.argv[9])) sat1._e = float(sys.argv[10]) sat1._raan = ephem.degrees(float(sys.argv[5])) sat1._ap = float(sys.argv[11]) sat1._M = ephem.degrees(float(sys.argv[6])) sat1._n = float(sys.argv[12]) sat1.compute(sys.argv[3] + ' ' + sys.argv[4]) counter = sys.argv[7] num_orbit = sys.argv[8] num_sat_in_orbit = sys.argv[13] # Print the satellite position in terms of coordinates and elevation print('%d %d %d %s %s %s' % (int(counter), int(num_orbit), int(num_sat_in_orbit), math.degrees(sat1.sublat), math.degrees(sat1.sublong), sat1.elevation))
def earthsat_builder(df, ob_lat, ob_lon, ob_alt, ddate, cn): """ :param df: :param ob_lat: :param ob_lon: :param ob_alt: :param ddate: :param cn: :return: DataFrame Observer: Obs - Computes the position of the Body. - Uses the date of the observer. - Uses the epoch of the observer. lon,lat : Latitude and longitude (String) elevation : (Int) ddate : (String) (date format : '1984/5/30 16:22:56' ) earthSat : (ephem.Body) """ g = 6.67408e-11 m_earth = 5.97219e24 column_to_add = ["el", "az", "rx_lon", "rx_lat", "rx_alt", "cn0", "ddate"] for col in range(len(column_to_add)): df[column_to_add[col]] = np.nan res=pd.DataFrame() for rx_lat, rx_lon, rx_alt, rx_date, signal_cn in zip(ob_lat, ob_lon, ob_alt, ddate, cn): act_df = df ob_lon = np.deg2rad(rx_lon) ob_lat = np.deg2rad(rx_lat) obs = ephem.Observer() obs.lat = np.deg2rad(ob_lat) obs.long = np.deg2rad(ob_lon) obs.elevation = rx_alt for index, row in act_df.iterrows(): esat = ephem.EarthSatellite() esat._e = act_df.at[index, 'Eccentricity'] esat._M = np.rad2deg(act_df.at[index, 'Mean Anom(rad)']) esat._ap = np.rad2deg(act_df.at[index, 'Argument of Perigee(rad)']) esat._raan = np.rad2deg(act_df.at[index, 'Right Ascen at Week(rad)']) esat._n = np.sqrt(g * m_earth / (act_df.at[index, 'SQRT(A) (m 1/2)'] ** 2) ** 3) * (86400 / (2 * np.pi)) esat._epoch = ephem.Date(rx_date) esat._inc = np.rad2deg(act_df.at[index, 'Orbital Inclination(rad)']) obs.date = ephem.Date(rx_date.strftime('%Y/%-m/%-d %H:%M:%S')) esat.compute(obs) values = [np.rad2deg(esat.alt), np.rad2deg(esat.az), rx_lon, rx_lat, rx_alt, signal_cn, rx_date] for i in range(len(values)): act_df.set_value(index, column_to_add[i], values[i]) res=pd.concat([res, act_df]) res=res.reset_index(drop=True) return df_filter_info(res)