def propergate_orbit(predictor, time, lines_per_second, rows): ''' orbit = propergate_orbit(predictor, time, lines_per_second, rows) Calculate the satellite prediction for each row of an image, where `rows` is the number of rows to calculate, `time` is the calculation start time and `predictor` is a orbit_predictor source. ''' orbit = [] for i in range(0, rows): orbit.append( coordinate_systems.ecef_to_llh(predictor.get_only_position(time))) time += dt.timedelta(seconds=1 / lines_per_second) return orbit
def get_position_detail(self, start_date, n_steps, time_step): """ Get satellite subpoints and details """ latitude = np.empty(n_steps) longitude = np.empty(n_steps) altitude = np.empty(n_steps) datetime = [None] * n_steps dt = start_date for i in range(n_steps): recef = self.get_only_position(dt) lat, lon, h = ecef_to_llh(recef) latitude[i] = lat longitude[i] = lon altitude[i] = h datetime[i] = dt dt += time_step return LLH(datetime, latitude, longitude, altitude)
def distCalculation(): act = False flag = [0]*14 dists_v = [0]*14 i = 0 with open('TLE.txt') as TLE: predictor = get_predictor_from_tle_lines(TLE) result = predictor.get_position(datetime.now()) pos_ecef = result[1] #Rads lat, lon, h = ecef_to_llh(pos_ecef) #Degrees lat = lat*pi/180 lon = lon*pi/180 userLat = -22.412 userLong = -45.46 d = (sqrt(pow((userLat - lat)*60*1852, 2) + pow(userLong - lon*60*1852, 2))/1000); if(d > 20112): d = 40024 - d real_dist = sqrt(pow(d,2)+pow(h,2)) if(real_dist < 14000): flag[i] = 1 dists_v[i++] = real_dist act = True if(act): message = "Working....." password = "******" msgFrom = "*****@*****.**" msgTo = "*****@*****.**" server = smtplib.SMTP('smtp.gmail.com: 587') server.starttls() server.login(msgFrom, password) server.sendmail(msgFrom, msgTo, message) server.quit()
def isnorthbound(sat_pass): aos = coordinate_systems.ecef_to_llh(predictor.get_only_position(sat_pass.aos)) los = coordinate_systems.ecef_to_llh(predictor.get_only_position(sat_pass.los)) return aos[1] < los[1]
def position_llh(self): """Latitude (deg), longitude (deg), altitude (km).""" return coordinate_systems.ecef_to_llh(self.position_ecef)
azimuth_actuator.home(switch, home_angle) lcd.clear() predictor, tracking = get_satellite(current_index, station_names, satlist) # Main loop time = datetime.datetime.utcnow() dt = datetime.timedelta(minutes=1) next_update = time + datetime.timedelta(days=1) try: while True: time = datetime.datetime.utcnow() # The positions are returned in Earth-centric, Earth fixed coords. I need to convert those. ecef_location = locations.Location('station', *ecef_to_llh(predictor.get_only_position(time))) ### Convert ECEF to alt, az ### az, elev = me.get_azimuth_elev_deg(ecef_location) lcd.set_cursor(0,1) lcd.message("{:<8.2f}{:>8.2f}".format(az, elev)) # Move the actuators to the right angles elevation_actuator.angle = elev azimuth_actuator.to_angle(az, block=True) stop = time + datetime.timedelta(seconds=DELAY) while datetime.datetime.utcnow() < stop: sleep(0.1)
def position_llh(self): return coordinate_systems.ecef_to_llh(self.position_ecef)
def sat_locations(database, mylat, mylon, time=None, lat_bins=8, lon_bins=8, alt_edges=[9e99, 30000, 20000, 10000, 5000, 2000, 1000, 0], quiet=True): '''For the satellite IDs in passing_sats.txt, check their current location. Then, fill in a grid of how many satellites are in each cell of a grid. Inputs: ------- database, MemoryTLESource The orbit_predictor TLE database, populated with satellites time, datetime.datetime, optional The time to calculate the grid for. If None, use datetime.datetime.utcnow(). Requires UTC lat_bins, int, optional The number of latitude bins. Used to construct a numpy linspace for the bin edges. lon_bins, int, optional The same, for longitude alt_edges, iterable of floats, optional A list of the altitude bins. Output: ------- grid, 3D numpy array A grid populated with the number of satellites per cell, at the current time. ''' if time is None: time = datetime.utcnow() # What are my bin edges? altrange = abs(OVERHEAD_LIMIT) lat_edges = np.linspace(-altrange, +altrange, lat_bins) lon_edges = np.linspace(-altrange, +altrange, lon_bins) # Init an empty grid. grid = np.zeros((len(alt_edges), lat_bins, lon_bins), dtype=int) # I might be interested in which satellite is currently overhead overhead_now = [] with open('passing_sats.txt', 'r') as f: for line in f: if not quiet: print( "\n\n-------------------------------------------------------------------------------------\n\n" ) ID = line.strip() # create this satellite's predictor predictor = predictors.TLEPredictor(ID, database) # The positions are returned in Earth-centric, Earth fixed coords. I need to convert those. ecef_location = predictor.get_only_position(time) ### Convert ECEF to LLA ### lat, lon, alt = coordinate_systems.ecef_to_llh(ecef_location) if not quiet: print("satellite ID: {}".format(ID)) print( "ECEF coords (x, y, z): {}, {}, {}".format(*ecef_location)) print("LLS coords (lat, lon, alt): {}, {}, {}".format( lat, lon, alt)) # transform lat, lon, to relative to me dlat = lat - mylat dlon = lon - mylon if not quiet: print("Relative to me, the satellite is at {}, {}, {}".format( dlat, dlon, alt)) if dlat < np.min(lat_edges) or dlat > np.max(lat_edges): if not quiet: print("Satellite is not in the visible range") continue if dlon < np.min(lon_edges) or dlon > np.max(lon_edges): if not quiet: print("Satellite is not in the visible range") continue if alt < np.min(alt_edges) or alt > np.max(alt_edges): if not quiet: print("Satellite is not in the visible range") continue # What indexes is this satellite in? index_alt = np.digitize(alt, alt_edges) index_lat = np.digitize(dlat, lat_edges) index_lon = np.digitize(dlon, lon_edges) # If they fall outside the range, I don't care about the object if not quiet: print( "This satellite is in index (lat, lon, alt): ({}, {}, {})". format(index_lat, index_lon, index_alt)) # Save this satellite grid[index_alt, index_lat, index_lon] += 1 overhead_now.append((ID, alt)) return grid, overhead_now