Beispiel #1
0
def main():
    config = Configuration()
    handle = dataHandler()
    alerts = Alerts()

    for k, v in config.modclass.items():
        parseStrats = StrategyParse(config.Strats[k], v)
        parseStrats.sock.start()
Beispiel #2
0
    def makeModDialog(self, varnames):
        datahandlers = []
        for name in varnames:
            dh = dataHandler(self.data, str(name))
            datahandlers.append(dh)

        moddialog = modifyDialog(datahandlers, self)
        moddialog.setWindowTitle("Modify netCDF data")
        moddialog.show()
Beispiel #3
0
    def __init__(self, Strategy, metadata):
        super().__init__()
        self.handle = dataHandler()
        self.alerts = Alerts()
        self.sock = Socks(self.SpotClient)
        self.Strategy = Strategy

        self.data = self.handle.prefetchForStrategies(metadata)
        self.ws = self.handle.WebSocketForStrategies(metadata, self.sock,
                                                     self.callback)
Beispiel #4
0
    def makeDialog(self, varnames):
        datahandlers = []
        for name in varnames:
            dh = dataHandler(self.data, str(name))
            datahandlers.append(dh)
        pdialog = plotDialog(datahandlers)
        pdialog.setWindowTitle("Matplotlib Plot")
        pdialog.show()

        cdialog = configDialog(pdialog)
        cdialog.setWindowTitle("Configure")
        cdialog.show()
Beispiel #5
0
    def makeHumCreatorDialog(self, varnames):
        datahandlers = []

        # read in temperature and specific humidity from forcing file
        temperature = self.data.variables["t"][0, :]
        spechum = self.data.variables["q"][0, :]

        varnames = list(set().union(varnames, ["q", "t"]))
        print varnames
        nlvl = 0
        for name in varnames:
            dh = dataHandler(self.data, str(name))
            datahandlers.append(dh)
            nlvl = dh.nlvl

        if "vct_a" in self.data.variables.keys() and "vct_b" in self.data.variables.keys():
            print "vct_a", self.data.variables["vct_a"][:].shape
            hyam = self.data.variables["vct_a"][:]
            hybm = self.data.variables["vct_b"][:]
            print "vct_a taken from file:"
            print hyam
            print "vct_b taken from file:"
            print hybm
        if nlvl == 31:
            hyam = hyam31
            hybm = hybm31
        elif nlvl == 47:
            hyam = hyam47
            hybm = hybm47
        else:
            print "cannot handle those modellevels:", self.data.nlev
            return

        if "aps" in self.data.variables.keys():
            aps = self.data.variables["aps"][0]
            print "aps taken from file: aps = %s" % (aps)
        else:
            aps = 100000

        mlev = hyam + hybm * aps
        # interpolate interface pressure to midlvl pressures to much T and q
        # this can be done more carefully, but it doesn't really matter for the
        # application, so it may be improved some time later.
        if len(mlev) % 2 == 0:
            i = np.arange(len(mlev) - 1)
            mlev = (mlev[i] + mlev[i + 1]) / 2.0
        humConverter = HumidityConverter(mlev, temperature, spechum)

        moddialog = modifyDialog(datahandlers, self, humConverter)
        moddialog.setWindowTitle("Modify netCDF data")
        moddialog.show()
        print "finished showing moddialog"
import numpy as np
import matplotlib.pyplot as plt
from tqdm import tqdm
from datahandler import dataHandler
from datetime import datetime

handler = dataHandler()
handler.read_data("capture51.labeled")
handler.filter_background_data()
netflows = np.array(handler.get_filtered_data())
infected = np.array(handler.get_ip_data("147.32.84.165"))

times = [
    datetime.strptime(infected[i][0], "%Y-%m-%d %H:%M:%S.%f")
    for i in range(len(infected))
]
protocols = [infected[i][2] for i in range(len(infected))]
bytes = [int(infected[i][8]) for i in range(len(infected))]

infected_by_byte_date = []
infected_filtered_by_byte = []
for i in range(len(bytes)):
    if bytes[i] <= 1066:
        infected_by_byte_date.append(times[i])
        infected_filtered_by_byte.append(bytes[i])

print("Show usage of protocols")
plt.plot(times, protocols, color="red")
plt.show()

print("Show the amount of bytes used")