コード例 #1
0
 def Start(self, settingsToApply, run=True):
     Log("M1M3: Start(%s, %s)" % (run, settingsToApply))
     data = m1m3_command_StartC()
     data.Start = run
     data.SettingsToApply = settingsToApply
     cmdId = self.sal.issueCommand_Start(data)
     self.sal.waitForCompletion_Start(cmdId, 10)
コード例 #2
0
 def RaiseM1M3(self, bypassReferencePosition, run=True):
     Log("M1M3: RaiseM1M3(%s, %s)" % (run, bypassReferencePosition))
     data = m1m3_command_RaiseM1M3C()
     data.RaiseM1M3 = run
     data.BypassReferencePosition = bypassReferencePosition
     cmdId = self.sal.issueCommand_RaiseM1M3(data)
     self.sal.waitForCompletion_RaiseM1M3(cmdId, 10)
コード例 #3
0
 def __init__(self):
     Log("M1M3: Initializing SAL")
     self.sal = SAL_m1m3()
     self.sal.setDebugLevel(0)
     self.sal.salCommand("m1m3_command_Start")
     self.sal.salCommand("m1m3_command_Enable")
     self.sal.salCommand("m1m3_command_EnterEngineering")
     self.sal.salCommand("m1m3_command_RaiseM1M3")
     self.sal.salCommand("m1m3_command_AbortRaiseM1M3")
     self.sal.salCommand("m1m3_command_LowerM1M3")
     self.sal.salCommand("m1m3_command_ExitEngineering")
     self.sal.salCommand("m1m3_command_Disable")
     self.sal.salCommand("m1m3_command_Standby")
     self.sal.salCommand("m1m3_command_Shutdown")
     self.sal.salEvent("m1m3_logevent_DetailedState")
コード例 #4
0
 def __new__(cls, *arg, **karg):
     '''
     This method automatically initialize the attributes of an Engine instance.
     '''
     result = object.__new__(cls)
     result.din = karg.get('din', '.')
     result.dout = karg.get('dout', '.')
     result.log = Log(dir=karg.get('dlog', '.'))
     for dir in [result.din, result.dout, result.log.dir]:
         if cls.MKDIR and not os.path.exists(dir): os.makedirs(dir)
     result.name = karg.get('name', '')
     result.parameters = Parameters(karg.get('parameters', ()))
     result.map = karg.get('map', None)
     result.clock = Timers()
     result.preloads = []
     result.apps = {}
     result.records = {}
     return result
コード例 #5
0
 def Standby(self, run=True):
     Log("M1M3: Standby(%s)" % (run))
     data = m1m3_command_StandbyC()
     data.Standby = run
     cmdId = self.sal.issueCommand_Standby(data)
     self.sal.waitForCompletion_Standby(cmdId, 10)
コード例 #6
0
 def Disable(self, run=True):
     Log("M1M3: Disable(%s)" % (run))
     data = m1m3_command_DisableC()
     data.Disable = run
     cmdId = self.sal.issueCommand_Disable(data)
     self.sal.waitForCompletion_Disable(cmdId, 10)
コード例 #7
0
 def ExitEngineering(self, run=True):
     Log("M1M3: ExitEngineering(%s)" % (run))
     data = m1m3_command_ExitEngineeringC()
     data.ExitEngineering = run
     cmdId = self.sal.issueCommand_ExitEngineering(data)
     self.sal.waitForCompletion_ExitEngineering(cmdId, 10)
コード例 #8
0
 def LowerM1M3(self, run=True):
     Log("M1M3: LowerM1M3(%s)" % (run))
     data = m1m3_command_LowerM1M3C()
     data.LowerM1M3 = run
     cmdId = self.sal.issueCommand_LowerM1M3(data)
     self.sal.waitForCompletion_LowerM1M3(cmdId, 10)
コード例 #9
0
 def AbortRaiseM1M3(self, run=True):
     Log("M1M3: AbortRaiseM1M3(%s)" % (run))
     data = m1m3_command_AbortRaiseM1M3C()
     data.AbortRaiseM1M3 = run
     cmdId = self.sal.issueCommand_AbortRaiseM1M3(data)
     self.sal.waitForCompletion_AbortRaiseM1M3(cmdId, 10)
コード例 #10
0
# import python modules needed
import pandas as pd
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import statsmodels.api as sm
import itertools
import warnings
#from fbprophet import Prophet

# import project's classes and scripts
from Utilities import Log

# Configure logger
log = Log.setup_logger("data_mining")

# Configure pyplot
plt.style.use('fivethirtyeight')
warnings.filterwarnings("ignore")

# Configure matplotlib
matplotlib.rcParams['axes.labelsize'] = 14
matplotlib.rcParams['xtick.labelsize'] = 12
matplotlib.rcParams['ytick.labelsize'] = 12
matplotlib.rcParams['text.color'] = 'k'

class DataMining:


# TODO: make more methods from the execute_process() method
コード例 #11
0
 def __del__(self):
     Log("M1M3: Shutting down SAL")
     time.sleep(1)
     self.sal.salShutdown()
コード例 #12
0
# Author: Ioannis Matzakos | Date: 01/05/2020

# import python modules needed

# import project's classes and scripts
from Utilities import Log

# Configure logger
log = Log.setup_logger("feature_engineering")


class FeatureEngineering:

    def calculate_cases(self, time_series, column_name):
        """Calculates the daily new cases, new deaths and new recovered cases
        :param time_series: pandas dataframe
        :param column_name: string
        :return: list
        """
        # Initialize the list for the new calculated feature
        new_cases_list = list()
        log.debug(f"new_cases_list list size before {len(new_cases_list)}")

        # create a list of the data source (a data frame column)
        sum_cases_list = time_series[str(column_name)].tolist()
        log.info(f"Source list size: {len(sum_cases_list)}")

        # Create features
        new_cases_list.append(0)
        i = 0
        for i in range(len(sum_cases_list)-1):
コード例 #13
0
# import python modules needed
import pandas as pd
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import statsmodels.api as sm
import itertools
import warnings
from pylab import rcParams

# import project's classes and scripts
from Utilities import Log

# Configure logger
log = Log.setup_logger("data_visualization")

# Configure pyplot
plt.style.use('fivethirtyeight')
warnings.filterwarnings("ignore")

# Configure matplotlib
matplotlib.rcParams['axes.labelsize'] = 14
matplotlib.rcParams['xtick.labelsize'] = 12
matplotlib.rcParams['ytick.labelsize'] = 12
matplotlib.rcParams['text.color'] = 'k'


class DataVisualization:
    def plot_data_structure(self, dataframe):
        dataframe.plot(figsize=(15, 6))
コード例 #14
0
ファイル: Main.py プロジェクト: johnmatzakos/predict-covid-19
# Author: Ioannis Matzakos | Date: 01/05/2020

# import python modules needed
import time

# import project's classes and scripts
from Utilities import Log
from Utilities import Constants
from PreliminaryAnalysis import PreliminaryAnalysis
from DataPreprocessing import DataPreprocessing
from FeatureEngineering import FeatureEngineering
from DataVisualization import DataVisualization
from DataMining import DataMining

# Configure logger
log = Log.setup_logger("main")

log.info(Constants.INITIAL_MSG)

# Start calculating execution time
start_time = time.time()

log.info(Constants.START_MSG)

# Data Preprocessing Phase
log.info(Constants.DATA_PREPROCESSING_MSG)
dp = DataPreprocessing()
time_series = dp.preprocessing()

# Feature Engineering Phase
log.info(Constants.FEATURE_ENGINEERING_MSG)
コード例 #15
0
 def Shutdown(self, run=True):
     Log("M1M3: Shutdown(%s)" % (run))
     data = m1m3_command_ShutdownC()
     data.Shutdown = run
     cmdId = self.sal.issueCommand_Shutdown(data)
     self.sal.waitForCompletion_Shutdown(cmdId, 10)
コード例 #16
0
# Author: Ioannis Matzakos | Date: 18/05/2020

import pandas as pd
from statsmodels.tsa.stattools import adfuller, kpss
from Utilities import Log

# Configure logger
log = Log.setup_logger("preliminary_analysis")


class PreliminaryAnalysis:
    def is_stationary(self, time_series, column_name):
        """
        Checks if a time series is stationary or not.
        :param time_series: pandas dataframe with datetime index
        :param column_name: string
        :return: true or false
        """
        is_stationary = False
        significance_level = 0.05

        log.info("Augmented Dickey Fuller Test (ADH Test)")

        # ADF Test
        result = adfuller(time_series[str(column_name)], autolag='AIC')
        log.info(f'ADF Statistic: {result[0]}')
        p_value = result[1]
        log.info(f'p-value: {p_value}')

        # Print Critical Values
        for key, value in result[4].items():
コード例 #17
0
# Author: Ioannis Matzakos | Date: 01/05/2020

import pandas as pd
from statsmodels.tsa.stattools import adfuller, kpss
from Utilities import Log

# Configure logger
log = Log.setup_logger("data_preprocessing")


class DataPreprocessing:
    def __init__(self):
        self.file = ""

    def set_file(self, file):
        self.file = file

    def get_file(self):
        return self.file

    def set_dataframe_name(self, df, name):
        """
        Sets the name of a pandas dataframe
        :param df: pandas dataframe
        :param name: string
        :return: pandas dataframe
        """
        log.info(f"Setting name: {name} for data frame")
        df.name = name
        return df