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 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 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 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_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 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_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_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 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 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 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_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 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 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.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 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 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.setPos(value) sat.setVel(v_vel_i) dist.ggTorqueb(sat) result = sat.getggDisturbance_b() self.assertTrue(np.allclose(result, [0., 0., 0.]))
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_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 _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_solar_torque_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([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([7070e3,0.,0.])) v_sv_i=np.array([1.0,0.0,0.0]) sat.setSun_i(v_sv_i) sat.setLight(1) dist.solarTorqueb(sat) result = sat.getsolarDisturbance_b() self.assertEqual(type(result),np.ndarray)
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 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 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 setUp(self): num_observations = 1 t_init = 0 t_end = 10 my_dt = 1 / 24 sat = Satellite(t_init, t_end, my_dt) t_list = np.linspace(t_init, t_end, num_observations) source = Source('test', 0, 1, 2, 3, 4, 5) source.reset() s = np.zeros(5) s[0] = source.alpha / 2 s[1] = source.delta / 2 s[2] = source.parallax / 2 s[3] = source.mu_alpha_dx s[4] = source.mu_delta calc_source = Calc_source('calc_test', t_list, s, source.mu_radial) self.solver = Agis(sat, [calc_source], [source])
def collectData(): printDBG(1, "Collecting data from Satellite") s = Satellite(credentials['hostname']) s.setUsername(credentials['username']) s.setPassword(credentials['password']) printDBG(2, "Getting initial (baseline) content view version errata") cvve1 = s.getCVVerErrata(args.initial) baselineErrata = cvve1['total'] printDBG(2, "Getting target content view version errata") cvve2 = s.getCVVerErrata(args.final) targetErrata = cvve2['total'] list1 = [] for cve in cvve1['results']: list1.append(cve['id']) for cve in cvve2['results']: if cve['id'] not in list1: finalList.append(cve) if not len(finalList) == targetErrata - baselineErrata: printDBG( 1, "Errata mis-count - length not equal to difference in sizes!") printDBG(2, "Data gathered, differential list processed")
def universe(): earth = Body(name="Earth", mass=5.972e24, dimensions=696340, position=(0, 0, 0), rotation_vel=7.292e-5, body_type='planet', body_color=vector(1, 1, 1), texture=textures.earth) sat_1 = Satellite(name="Sat1", mass=4474, dimensions=[10000, 10000, 10000], orbital_info={ "semimajor_axis": 696340 + 1000, "eccentricity": 0.0, "inclination": np.radians(0), "right_ascension": np.radians(0), "argument_perigee": np.radians(0) }, body_type="satellite", body_color=color.red) print(sat_1.position) i = 0 while i < 100: # rate(400) r = sat_1.body.pos F = -G * earth.mass * sat_1.mass * r.hat / (mag2(r)) a = F / sat_1.mass sat_1.body.v = sat_1.body.v + a * dt sat_1.body.pos = sat_1.body.pos + sat_1.body.v * dt # F = ast.law_of_gravitation(G, earth.mass, sat_1.mass, ast.get_distance(earth.position, sat_1.position), # sat_1.body.pos.hat) / grid_scale # a = F / sat_1.mass print("Force: {}, Acceleration: {}".format(F, a)) # sat_1.update_body(a, dt) # print(F) earth.update_body(None, dt) i += 1
def collectData(): printDBG(1, "Collecting data from Satellite") s = Satellite(credentials['hostname']) s.setUsername(credentials['username']) s.setPassword(credentials['password']) printDBG(2, "Getting all content view versions") cvvs = s.getCVVersions() for ver in cvvs['results']: name = ver['name'] cVVObjects[name] = {} object = cVVObjects[name] object['id'] = ver['id'] object['cvID'] = ver['content_view_id'] object['secErrata'] = ver['errata_counts']['security'] object['bugErrata'] = ver['errata_counts']['bugfix'] object['enhErrata'] = ver['errata_counts']['enhancement'] if type(object['secErrata']) == type(None): object['secErrata'] = 0 if type(object['bugErrata']) == type(None): object['bugErrata'] = 0 if type(object['enhErrata']) == type(None): object['enhErrata'] = 0 object['created'] = ver['created_at'] object['errata'] = {} printDBG(3, 'Getting errata for CV Ver ' + name) errata = s.getCVVerErrata(object['id']) for erratum in errata['results']: eo = {} eo['id'] = erratum['id'] eo['name'] = erratum['name'] eo['type'] = erratum['type'] eo['issued'] = erratum['issued'] eo['cves'] = [] for cve in erratum['cves']: eo['cves'].append(cve['cve_id']) object['errata'][erratum['errata_id']] = eo for revName in cVVObjects.keys().sort(reverse=True): print revName
def collectData(): printDBG(1, "Collecting data from Satellite") s = Satellite(credentials['hostname']) s.setUsername(credentials['username']) s.setPassword(credentials['password']) h=s.listHosts() for name in h: hostDetail = s.getHost(name['id']) pprint.pprint(hostDetail) sys.exit(0) if hostDetail['ip'] == None: continue if not hostObjects.has_key(hostDetail['name']): hostObjects[hostDetail['name']] = {} hostName = hostDetail['name'] printDBG(2, "Processing host %s" % (hostName,)) hostObjects[hostName]['ip'] = hostDetail['ip'] if hostDetail.has_key('content_facet_attributes'): hostObjects[hostName]['lifecycleEnvironment'] = hostDetail['content_facet_attributes']['lifecycle_environment_name'] hostObjects[hostName]['contentView'] = hostDetail['content_facet_attributes']['content_view_name'] hostObjects[hostName]['secErrata'] = str(hostDetail['content_facet_attributes']['errata_counts']['security']) hostObjects[hostName]['bugErrata'] = str(hostDetail['content_facet_attributes']['errata_counts']['bugfix']) hostObjects[hostName]['enhErrata'] = str(hostDetail['content_facet_attributes']['errata_counts']['enhancement']) hostObjects[hostName]['pkgUpdates'] = str(hostDetail['content_facet_attributes']['upgradable_package_count']) hostObjects[hostName]['lastCheckin'] = str(hostDetail['content_facet_attributes']['lastCheckin']) else: hostObjects[hostName]['lifecycleEnvironment'] = 'NO DATA' hostObjects[hostName]['contentView'] = 'NO DATA' hostObjects[hostName]['secErrata'] = 'NO DATA' hostObjects[hostName]['bugErrata'] = 'NO DATA' hostObjects[hostName]['enhErrata'] = 'NO DATA' hostObjects[hostName]['pkgUpdates'] = 'NO DATA' hostObjects[hostName]['katelloAgent'] = 'NO DATA' if hostDetail.has_key('subscription_status_label'): hostObjects[hostName]['subStatus'] = hostDetail['subscription_status_label'] else: hostObjects[hostName]['subStatus'] = 'NO DATA'