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))
Esempio n. 2
0
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
Esempio n. 3
0
 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
Esempio n. 4
0
                    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:"
Esempio n. 5
0
def main():
	server = Satellite()
	server.bind_server("0.0.0.0", 27016)
	server.run_server()
Esempio n. 6
0
        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)