def setUp(self): self._solarsystem = Solar_system() #self._planet_1 = None route_1_x = [1000, 0, 0] route_1_v = [0, -1000, 0] route_1 = Route(route_1_x, route_1_v) name_1 = "Aalto-3" mass_1 = 10 state_1 = State.ALIVE self._satellite_1 = Satellite(name_1, route_1, mass_1, state_1) route_1_x = [152100000000, 0, 0] route_1_v = [0, 29780, 0] route_1 = Route(route_1_x, route_1_v) name_1 = "Earth" mass_1 = 5.97237*10**24 diameter = 2*6371000 self._planet_1 = Planet(name_1, route_1, mass_1, diameter) self.pos_test_string = "x:220my:100kmz:20m" self.test_read = Read_planets() test_file = open("test_read.txt") self._solarsystem.read_planets(test_file) test_file.close()
def add_satellite(self, body_name, vi, s_name, r, m, target, d=0): """ Adds a satellite to the system a distance from the surface of a specific body body_name: name of body the satellite starts at vi: velocity of satellite s_name: name of satellite r: radius of satellite m: mass of satellite target: name of body satellite is aiming for d: extra added distance from body, use when adding more than one satellite to body """ #Loops over bodies selecting the specified starting body for body in self.bodies: if body.name == body_name: #Creates a new satellite with the given parameters s = Satellite(s_name, 'green', m, r, body.d - 2 * body.radius - d, vi, target) #Calculates initial acceleration of satellite s.get_init_accn(self.bodies) #Adds satellite to system bodies and a circle to the patches for animation self.bodies.append(s) self.patches.append( plt.Circle(s.r / const.PixelToKM / const.DistScaleFactor, radius=s.radius / const.PixelToKM * const.SatelliteScaleFactor, color=s.c, animated=True)) #Increment satellite couint and then break self.satellite_count += 1 break
def setUp(self): t_init = 0 # 1/24/60 t_end = t_init + 1 / 24 / 60 # 365*5 my_dt = 1 / 24 / 60 / 10 # [days] spline_degree = 3 gaia = Satellite(ti=t_init, tf=t_end, dt=my_dt, k=spline_degree) self.gaia = gaia my_times = np.linspace(t_init, t_end, num=100, endpoint=False) real_sources = [] calc_sources = [] for t in my_times: alpha, delta = af.generate_observation_wrt_attitude( gaia.func_attitude(t)) real_src_tmp = Source(str(t), np.degrees(alpha), np.degrees(delta), 0, 0, 0, 0) calc_src_tmp = Calc_source('calc_' + str(t), [t], real_src_tmp.get_parameters()[0:5], real_src_tmp.get_parameters()[5]) real_sources.append(real_src_tmp) calc_sources.append(calc_src_tmp) # test if source and calc source are equal (as they should be) np.testing.assert_array_almost_equal( np.array(real_sources[0].get_parameters()[0:5]), calc_sources[0].s_params) # create Solver self.Solver = Agis( gaia, calc_sources, real_sources, attitude_splines=[gaia.s_w, gaia.s_x, gaia.s_y, gaia.s_z], spline_degree=spline_degree, attitude_regularisation_factor=1e-3)
def test_sees(self): sat1 = Satellite('SAT1', 0, 0, 1 + earth.radius * sqrt(2)) sat2 = Satellite('SAT2', 0, pi, 1 + earth.radius * sqrt(2)) sat3 = Satellite('SAT2', 0, pi/2, 1 + earth.radius * sqrt(2)) self.assertFalse(sat1.sees(sat2)) self.assertTrue(sat1.sees(sat3)) self.assertTrue(sat2.sees(sat3))
class VirtWho(object): def __init__(self, logger, options): """ VirtWho class provides bridge between virtualization supervisor and Subscription Manager. logger - logger instance options - options for virt-who, parsed from command line arguments """ self.logger = logger self.options = options self.virt = None self.subscriptionManager = None self.unableToRecoverStr = "Unable to recover" if not options.oneshot: self.unableToRecoverStr += ", retry in %d seconds." % RetryInterval # True if reload is queued self.doReload = False def initVirt(self): """ Connect to the virtualization supervisor (libvirt or VDSM) """ if self.options.virtType == "vdsm": self.virt = VDSM(self.logger) elif self.options.virtType == "libvirt": self.virt = Virt(self.logger, registerEvents=self.options.background) # We can listen for libvirt events self.tryRegisterEventCallback() elif self.options.virtType == "rhevm": self.virt = RHEVM(self.logger, self.options.server, self.options.username, self.options.password) elif self.options.virtType == "hyperv": self.virt = HyperV(self.logger, self.options.server, self.options.username, self.options.password) else: # ESX self.virt = VSphere(self.logger, self.options.server, self.options.username, self.options.password) def initSM(self): """ Connect to the subscription manager (candlepin). """ try: if self.options.smType == "sam": self.subscriptionManager = SubscriptionManager(self.logger) self.subscriptionManager.connect() elif self.options.smType == "satellite": self.subscriptionManager = Satellite(self.logger) self.subscriptionManager.connect(self.options.sat_server, self.options.sat_username, self.options.sat_password) except NoOptionError, e: self.logger.exception("Error in reading configuration file (/etc/rhsm/rhsm.conf):") raise except SubscriptionManagerError, e: self.logger.exception("Unable to obtain status from server, UEPConnection is likely not usable:") raise
def test_solar_torque_value(self): state = np.array([1., 0., 0., 0., 0.1, -0.02, -0.2]) mySat = Satellite(state, 128.05) v_sv_i = np.array([1.0, 0.0, 0.0]) #sun vector in eci frame mySat.setSun_i(v_sv_i) result = dist.solar_torque(mySat) print result self.assertTrue( np.allclose(result, [0.00000000e+00, -3.66624000e-11, 3.17376000e-10]))
def apply(self, satellite: Satellite) -> ManeuverCost: orbit = satellite.orbit cur_theta = satellite.true_anomaly() new_theta = cur_theta + self.delta_theta # Find the difference in s and wait by that much cur_s = satellite.true_to_universal_anomaly(cur_theta) new_s = satellite.true_to_universal_anomaly(new_theta) delta_s = new_s - cur_s satellite.wait_s(delta_s) return ManeuverCost(delta_t=satellite.delta_s_to_t(delta_s))
def apply(self, satellite: Satellite) -> ManeuverCost: # We want to rotate around the radial vector. Use Rodrigues. axis = satellite.pos.norm() vel = satellite.vel cos = math.cos(self.angle) sin = math.sin(self.angle) new_vel = vel * cos + axis.cross(vel) * sin + axis * axis.dot(vel) * ( 1 - cos) delta_v = new_vel - vel satellite.boost(delta_v) return ManeuverCost(delta_v=delta_v.length())
def initSM(self): """ Connect to the subscription manager (candlepin). """ try: if self.options.smType == "sam": self.subscriptionManager = SubscriptionManager(self.logger) self.subscriptionManager.connect() elif self.options.smType == "satellite": self.subscriptionManager = Satellite(self.logger) self.subscriptionManager.connect(self.options.sat_server, self.options.sat_username, self.options.sat_password) except NoOptionError, e: self.logger.exception("Error in reading configuration file (/etc/rhsm/rhsm.conf):") raise
def collectData(): printDBG(1, "Collecting data from Satellite") s = Satellite(credentials['hostname']) s.setUsername(credentials['username']) s.setPassword(credentials['password']) h = s.listHosts() for host in h: printDBG(2, "Examining host " + host['name']) host['errata_reboot_suggested'] = False errata = s.getHostErrata(str(host['id'])) if len(errata) == 0: pass else: printDBG(3, "Host has applicable errata.") listOfHosts[host['name']] = host listOfHosts[host['name']]['errata'] = {} for erratum in errata: if erratum['reboot_suggested']: printDBG( 3, "Host will require reboot after errata application") host['errata_reboot_suggested'] = host[ 'errata_reboot_suggested'] or erratum['reboot_suggested'] erratumID = erratum['errata_id'] if erratumID in listOfErrata: pass else: listOfErrata[erratumID] = erratum listOfHosts[host['name']]['errata'][erratumID] = erratum
def collectData(): printDBG(1, "Collecting data from Satellite") s = Satellite(credentials['hostname']) s.setUsername(credentials['username']) s.setPassword(credentials['password']) h = s.listHosts() for host in h: hostItem = {} hostItem['name'] = host['name'] hostItem['subs'] = [] subItems = s.getHostSubscriptions(str(host['id'])) if (type(None) == type(subItems)): continue for item in subItems: si = {} if ('name' not in item): continue if (item['name'] in ['EPEL', 'FPLInternal']): continue si['accountNum'] = item['account_number'] si['contractNum'] = item['contract_number'] si['endDate'] = item['end_date'] si['name'] = item['name'] hostItem['subs'].append(si) listOfHosts.append(hostItem)
def test_solar_torque_type(self): sat = Satellite(np.array([1., 0., 0., 0., 0., 0., 0.]), 13.) sat.setPos(np.array([7070e3, 0., 0.])) v_sv_i = np.array([1.0, 0.0, 0.0]) sat.setSun_i(v_sv_i) sat.setLight(0) result = dist.vTSdB(sat) self.assertEqual(type(result), np.ndarray)
def run(): """ Create the objects source for Sirio, Vega and Proxima as well as the corresponding scanners and the satellite object of Gaia. Then scan the sources from Gaia and print the time. :return: gaia, sirio, scanSirio, vega, scanVega, proxima, scanProxima """ start_time = time.time() sirio = Source("sirio", 101.28, -16.7161, 379.21, -546.05, -1223.14, -7.6) vega = Source("vega", 279.2333, 38.78, 128.91, 201.03, 286.23, -13.9) proxima = Source("proxima", 217.42, -62, 768.7, 3775.40, 769.33, 21.7) scanSirio = Scanner(np.radians(20), np.radians(2)) scanVega = Scanner(np.radians(20), np.radians(2)) scanProxima = Scanner(np.radians(20), np.radians(2)) gaia = Satellite() print(time.time() - start_time) scanSirio.start(gaia, sirio) scanVega.start(gaia, vega) scanProxima.start(gaia, proxima) print(time.time() - start_time) seconds = time.time() - start_time print('Total seconds:', seconds) return gaia, sirio, scanSirio, vega, scanVega, proxima, scanProxima
def apply(self, satellite: Satellite) -> ManeuverCost: cur_theta = satellite.true_anomaly() if satellite.orbit.is_open and cur_theta >= 0: raise ValueError("Periapsis is in the past on an open orbit") delta_theta = 2 * math.pi - cur_theta return WaitAngle(delta_theta).apply(satellite)
def test_aero_value(self): qBI = np.array([-np.sqrt(0.5),0.,0.,np.sqrt(0.5)]) wBIb = np.array([0.1,0.23,0.]) v_pos_i = np.array([0.,0.,7e6]) v_vel_i = np.array([0,2e3,6e3]) qBO = fs.qBI2qBO(qBI,v_pos_i,v_vel_i) wBOB = fs.wBIb2wBOb(wBIb,qBO,v_w_IO_o) sat = Satellite(np.hstack((qBO,wBOB)),13.) sat.setQ_BI(qBI) sat.setPos(np.array([0.,0.,7e6])) sat.setVel(np.array([0,2e3,6e3])) dist.aeroTorqueb(sat) result = sat.getaeroDisturbance_b() self.assertTrue(np.allclose(result, [2.99654080e-10,-2.57065600e-11,-7.71196800e-11]))
def populate_satellites_array(): """Populates the satellites array from TLEs""" total_tles = 0 tles = storage.get_tles_from_cache() metadata = storage.get_metadata() last_updated.append(metadata.get('last_updated')) if len(last_updated) > 1: del last_updated[0] if not tles: print('Fetching from spacetrack') cron_refresh_spacetrack_cache() tles = storage.get_tles_from_cache() for tle in tles: total_tles += 1 s = Satellite(tle) if s.is_valid(): satellites.append(s) print('Loaded {} of {} satellites'.format(len(satellites), total_tles))
def test_aero_type(self): qBI = np.array([-np.sqrt(0.5),0.,0.,np.sqrt(0.5)]) wBIb = np.array([0.1,0.23,0.]) v_pos_i = np.array([0.,0.,7e6]) v_vel_i = np.array([0,2e3,6e3]) qBO = fs.qBI2qBO(qBI,v_pos_i,v_vel_i) wBOB = fs.wBIb2wBOb(wBIb,qBO,v_w_IO_o) sat = Satellite(np.hstack((qBO,wBOB)),13.) sat.setQ_BI(qBI) sat.setPos(np.array([0.,0.,7e6])) sat.setVel(np.array([0,2e3,6e3])) dist.aeroTorqueb(sat) result = sat.getaeroDisturbance_b() self.assertEqual(type(result),np.ndarray)
def test_inertia_eigenvec(self,value): qBI = np.array([0.,0.,0.,1.]) wBIb = np.array([0.1,-0.02,-0.2]) v_pos_i = value v_vel_i = np.array([5.60,-5.0,0.0]) qBO = fs.qBI2qBO(qBI,v_pos_i,v_vel_i) wBOB = fs.wBIb2wBOb(wBIb,qBO,v_w_IO_o) sat = Satellite(np.hstack((qBO,wBOB)),13.) sat.setQ_BI(qBI) sat.setPos(value) sat.setVel(v_vel_i) dist.ggTorqueb(sat) result = sat.getggDisturbance_b() self.assertTrue(np.allclose(result,[0.,0.,0.]))
def test_solar_torque_value(self): qBI = np.array([0.,0.,0.,1.]) wBIb = np.array([0.1,-0.02,-0.2]) v_pos_i = np.array([7070e3,0.,0.]) v_vel_i = np.array([0,2e3,6e3]) qBO = fs.qBI2qBO(qBI,v_pos_i,v_vel_i) wBOB = fs.wBIb2wBOb(wBIb,qBO,v_w_IO_o) sat = Satellite(np.hstack((qBO,wBOB)),13.) sat.setQ_BI(qBI) v_sv_i=np.array([1.0,0.0,0.0]) #sun vector in eci frame sat.setSun_i(v_sv_i) sat.setLight(1) dist.solarTorqueb(sat) result = sat.getsolarDisturbance_b() self.assertTrue(np.allclose(result,[ 0.00000000e+00,-3.66624000e-11,3.17376000e-10]))
def predict(self): sat = str(self.tbChooseSatellite.currentText()) tle = self.tles[sat] with open("temp_tle.txt", "w") as f: f.write(tle + "\n") location = str(self.tbLocation.itemData( self.tbLocation.currentIndex())) satellite = Satellite(sat, tle, location) self.prediction = Prediction(satellite) self.prediction.show()
def test_inertia_eigenvec(self, value): state = np.array([1., 0., 0., 0., 0.1, -0.02, -0.2]) mySat = Satellite(state, 128.05) mySat.setPos(value) mySat.setVel(np.array([5.60, -5.0, 0.0])) result = dist.gg_torque(mySat) self.assertTrue(np.allclose(result, [0., 0., 0.]))
def test_aero(self): sat = Satellite( np.array([np.sqrt(0.5), -np.sqrt(0.5), 0., 0., 0.1, 0.23, 0.]), 13.) sat.setPos(np.array([0., 0., 7e6])) sat.setVel(np.array([0, 2e3, 6e3])) result = dist.aero_torque(sat) print result
def test_gg_data_type(self): qBI = np.array([0.,0.,0.,1.]) wBIb = np.array([0.,0.,0.]) v_pos_i = np.array([7070e3,0.,0.]) v_vel_i = np.array([2.0e3,2.8,-73.2]) qBO = fs.qBI2qBO(qBI,v_pos_i,v_vel_i) wBOB = fs.wBIb2wBOb(wBIb,qBO,v_w_IO_o) sat = Satellite(np.hstack((qBO,wBOB)),13.) sat.setPos(np.array([7070e3,0.,0.])) sat.setQ_BI(qBI) dist.ggTorqueb(sat) result = sat.getggDisturbance_b() self.assertEqual(type(result),np.ndarray)
def apply(self, satellite: Satellite) -> ManeuverCost: cur_theta = satellite.true_anomaly() # TODO: should i also block nearly-parabolic? if satellite.orbit.is_open: raise ValueError("No apoapsis on an open orbit") if cur_theta <= math.pi: # next apoapsis is coming up soon delta_theta = math.pi - cur_theta else: # we just passed it, pass through the periapsis first delta_theta = 3 * math.pi - cur_theta return WaitAngle(delta_theta).apply(satellite)
def get_more_satellite_data(): response = open('TLE.txt', 'r').readlines() splits = response satellites = [] size = 5 for i in range(0, 6000, 2): print(i) satellite = Satellite(id=splits[i].replace(' ', '').split(' ')[2], line1=splits[i].replace('\n', ''), line2=splits[i + 1].replace('\n', ''), size=size) satellites.append(satellite) print('Retrieved [{}] satellites from Celestrak'.format( len(satellites))) return satellites
def test_aero_type(self): sat = Satellite( np.array([np.sqrt(0.5), -np.sqrt(0.5), 0., 0., 0.1, 0.23, 0.]), 13.) sat.setPos(np.array([0., 0., 7e6])) sat.setVel(np.array([0, 2e3, 6e3])) result = dist.aero_torque(sat) self.assertEqual(type(result), np.ndarray)
def _setBlockSize(self, block_size): self.block_size = block_size doppler = int(np.ceil(self.doppler * float(self.block_size) / self.fs)) self.dopplers = range(-doppler, doppler + 1) self.peak_matrix = np.zeros([33, doppler * 2 + 1]) self.phase_matrix = np.zeros([33, doppler * 2 + 1]) # Instantiate satellites if not already instantiated. if len(self.satellites) == 0: for i in range(1, 33): sat = Satellite(i, self.fs, self.block_size) self.satellites.append(sat) # Set the block size for satellites for s in self.satellites: s.setBlockSize(self.block_size)
def test_aero_value(self): sat = Satellite( np.array([np.sqrt(0.5), -np.sqrt(0.5), 0., 0., 0.1, 0.23, 0.]), 13.) sat.setPos(np.array([0., 0., 7e6])) sat.setVel(np.array([0, 2e3, 6e3])) result = dist.aero_torque(sat) print result self.assertTrue( np.allclose(result, [2.99654080e-10, -2.57065600e-11, -7.71196800e-11]))
def test(): MHz = 1e6 fs = 4 * MHz block_size = 1 * int(fs / 1000) # 1 millisecond blocks sat7 = Satellite(7, fs, block_size) # Create a shifted transmit test signal tx_sig = np.roll(sat7.code_sig, 962) # Add noise to give -15dB SNR snr_db = -15 w = 2 * np.pi * 3500 / fs # 3.5kHz doppler shift theta = w * np.arange(len(tx_sig)) rx_sig = tx_sig * np.exp(-1j * theta) + np.random.randn( len(tx_sig)) * 10**(-snr_db / 20) ca = CASearch(fs) ca.processBlock(rx_sig)
def get_satellite_data(): response = open('active.txt', 'r').readlines() splits = response satellites = [] size = 5 for i in range(0, len(splits) - 1, 3): satellite = Satellite(id=splits[i].replace(' ', '').replace('\n', ''), line1=splits[i + 1].replace('\n', ''), line2=splits[i + 2].replace('\n', ''), size=size) satellites.append(satellite) satellites.sort(key=lambda x: x.get_semi_major_axis()) satellites = satellites[:1250 if len(satellites ) >= 1250 else len(satellites)] print('Retrieved [{}] satellites from Celestrak'.format( len(satellites))) return satellites
def collectData(): printDBG(1, "Collecting data from Satellite") s = Satellite(credentials['hostname']) s.setUsername(credentials['username']) s.setPassword(credentials['password']) hcs = s.listHostCollections() for hc in hcs: printDBG(2, "Examining host collection " + hc['name']) hcInfo = s.getHostCollection(hc['id']) hcInfo['errata'] = {} hcInfo['errataRebootSuggested'] = False for hcID in hcInfo['host_ids']: printDBG(3, "Examining collection member host") errata = s.getHostErrata(str(hcID)) for erratum in errata: hcInfo['errataRebootSuggested'] = hcInfo[ 'errataRebootSuggested'] or erratum['reboot_suggested'] erratumID = erratum['errata_id'] if erratumID not in listOfErrata.keys(): listOfErrata[erratumID] = erratum if erratumID not in hcInfo['errata'].keys(): hcInfo['errata'][erratumID] = erratum if hcInfo['name'] not in listOfHostCollections.keys(): listOfHostCollections[hcInfo['name']] = hcInfo
def main(): server = Satellite() server.bind_server("0.0.0.0", 27016) server.run_server()
with open(previous_measurements,'rb') as file: prev_db = pickle.load(file) else: using_previous = False # ------------------- Initial setup -------------------- # GLD_root = 'alex/array/home/Vaisala/feed_data/GLD' # NLDN_root = 'alex/array/home/Vaisala/feed_data/NLDN' GLD_root = 'GLD' sat_TLE = ["1 40378U 15003C 15293.75287141 .00010129 00000-0 48835-3 0 9990", "2 40378 99.1043 350.5299 0153633 201.4233 158.0516 15.09095095 39471"] # Satellite object: sat = Satellite(sat_TLE[0], sat_TLE[1],'Firebird 4') # Measurement object: f = measurement_model(database = db_name, GLD_root=GLD_root, multiple_bands = True) # Start time: # start_time = "2015-11-01T00:45:00" tStep = datetime.timedelta(seconds=30) # Step size thru model cur_time = start_time mid_time = start_time + datetime.timedelta(days=15) # Midpoint of greediness-increasing curve max_greed = 0.95 # Maximum greed asypmtote #cur_time = datetime.datetime.strptime(start_time, "%Y-%m-%dT%H:%M:%S") # Stop time: #stop_time = datetime.datetime(2015,11,1,2,45,00)
coordinates.lat(), energy, time_sampling_vector + f[3]) for energy in bands]) * self.m.get_longitude_scaling(f[0], f[1], coordinates.lon(), I0=f[2]) * self.RES_DT )) # # return flux if __name__== "__main__": # -------------- Here's how to create a satellite and take some flux measurements: ------------- #GLD_root = 'alex/array/home/Vaisala/feed_data/GLD' #NLDN_root = 'alex/array/home/Vaisala/feed_data/NLDN' GLD_root = 'GLD' sat_TLE = ["1 40378U 15003C 15293.75287141 .00010129 00000-0 48835-3 0 9990", "2 40378 99.1043 350.5299 0153633 201.4233 158.0516 15.09095095 39471"] # Satellite object: sat = Satellite(sat_TLE[0], sat_TLE[1],'Firebird 4') # Measurement object: f = measurement_model(database = "database_dicts.pkl", GLD_root = GLD_root, multiple_bands = True) # ---- Do The Thing: inTime = "2015-11-01T00:45:00" plottime = datetime.datetime.strptime(inTime, "%Y-%m-%dT%H:%M:%S") sat.compute(plottime) sat.coords.transform_to('geomagnetic') # bands is a list of energy bands to sample at (depending on database, 1 thru 8) print "From banded measurement (all on):" print f.get_measurement(plottime, sat.coords, mode='banded',bands=f.m.E_bands) print "From single measurement:"