def pass_data(file_num, alg_choice = None):
    """ This function takes the data obtained from the selected menu choices above, and passes them to their respective algorithms.
    
    *** Should be phased out after implementing GUI. ***

    Args:
        file_num (String): The option chosen for number of files selected, either 1, multiple or a test sinusoid is selected. 
        alg_choice (String, optional): Used in the case of creating a test sinusoid. Algorithm is chosen prior to . Defaults to None.
    """    
    if file_num == "1":
        time, detrended_flux, background = data_process.get_data()
        # Change values in columns to float values for later processing.
        time = [float(data) for data in time]
        detrended_flux = [float(data) for data in detrended_flux]
        noise = [float(data) for data in background]
        
        while(True):
            alg_choice = input("Select analysis method: \n1 - Time Series \n2 - Lomb-Scargle \n3 - Autocorrelation \n4 - Morlet Wavelet \n5 - GPS\n6 - All\n0 - Exit Program\n")

            alg.selection(time, detrended_flux, alg_choice)
    else:
        time, detrended_flux, background = data_process.get_data()
        # Change values in columns to float values for later processing.
        time = [float(data) for data in time]
        detrended_flux = [float(data) for data in detrended_flux]
        noise = [float(data) for data in background]

        alg.selection(time, detrended_flux, alg_choice)
Beispiel #2
0
                                    c=C,
                                    graphType=gt,
                                    display=False,
                                    imgHeight=10,
                                    imgWidth=10)

        trainImgs.append(img)

        # train output values
        # source: https://github.com/ztgu/sorting_algorithms_py
        (compsB, movesB) = ALGO.bubble(arrayCopy1d(ys))
        (compsH, movesH) = ALGO.heap(arrayCopy1d(ys))
        (compsI, movesI) = ALGO.insertion(arrayCopy1d(ys))
        (compsM, movesM) = ALGO.merge(arrayCopy1d(ys))
        (compsQ, movesQ) = ALGO.quick(arrayCopy1d(ys))
        (compsS, movesS) = ALGO.selection(arrayCopy1d(ys))

        # train output - comparison
        trainOutputs_0.append([compsB, compsH, compsI, compsM, compsQ, compsS])

        # train output - move
        trainOutputs_1.append([movesB, movesH, movesI, movesM, movesQ, movesS])

        # train output - total cost
        trainOutputs_2.append([
            compsB + movesB, compsH + movesH, compsI + movesI, compsM + movesM,
            compsQ + movesQ, compsS + movesS
        ])

    # 학습 데이터의 평균 및 표준편차 구하기
    # 테스트 시에도 학습 데이터 기준으로 평균 및 표준편차 적용
menu = True
while(menu):
        menu_selec = input("Select file option: \n1 - Single file \n2 - Multiple Files \n0 - Exit Program\n\n")

        if(menu_selec == "1"):
            file_path = input("Choose file for period analysis: ")
            File_Management.read_input_file(file_path)
            pass_data(menu_selec)
            menu = False

        elif(menu_selec == "2"):
           files = File_Management.open_dir()
           alg_choice = input("Select analysis method: \n1 - Time Series \n2 - Lomb-Scargle \n3 - Autocorrelation \n4 - Wavelets \n5 - All\n0 - Exit Program\n")
           for path in files:
               File_Management.read_input_file(path)
               pass_data(menu_selec, alg_choice)
           
        elif(menu_selec == "3"):
            data_process.create_sin()
            alg_choice = input("Select analysis method: \n1 - Time Series \n2 - Lomb-Scargle \n3 - Autocorrelation \n4 - Wavelets \n5 - All\n0 - Exit Program\n")
            time, detrended_flux, background = data_process.get_data()

            alg.selection(time, detrended_flux, alg_choice)
            
        elif(menu_selec == "0"):
            sys.exit()
        else:
            print("This is not a valid selection.")

Beispiel #4
0
def data_op(file_num=None, alg_choice=None):
    """ This function takes in a file/s and an algorithm, and passes the given file data to the chosen algorithm.
    Note: each of these parameters are optional in the event that the user does not select a choice from either of their
    respective ComboBoxes, however if either is left as None this function will exit itself.
    Args:
        file_num (String): the amount of files chosen by the user. Either single or multiple files, or a test sinusoid.
        alg_choice (String): the user's chosen algorithm.
    """

    # Maps the algorithm choices to numbers for compatibility with algorithms.py
    alg_dict = {
        'Time Series': '1',
        'Lomb-Scargle': '2',
        'Autocorrelation': '3',
        'Wavelets': '4',
        'GPS': '5',
        'All': '6'
    }

    # Prevents program from crashing in the event that the user doesn't select properly.
    if file_num is None or file_num == "Select" or alg_choice is None or alg_choice == "Select":
        tk.messagebox.showinfo(
            "Error", "Please select both a file/folder and an algorithm")

    elif file_num == "Single File":

        # Prevents program from crashing in the event that the user closes the file selection window.
        if not files:
            tk.messagebox.showinfo("Error", "Error: No Files Selected")
            return

        # Also prevents program from crashing in the event that the user closes the file selection window.
        elif files[0] == "" or files[0] is None:
            tk.messagebox.showinfo("Error", "Error: No Files Selected")
            return

        else:
            print(files[0])
            File_Management.read_input_file(files[0])

        time, detrended_flux, background = data_process.get_data()
        time = [float(data) for data in time]
        detrended_flux = [float(data) for data in detrended_flux]
        noise = [float(data) for data in background]

        alg_choice = alg_dict[alg_choice]

        alg.selection(time, detrended_flux, alg_choice)

    elif file_num == "Multiple Files":

        # Iterates through the files in the selected folder and passes each one through the chosen algorithm.
        # One potential issue with this is if the user intends to pass files through different algorithms.
        for path in files:
            # Prevents program from crashing in the event that the user chooses a folder containing bad file types.
            if not (path.endswith('.csv') or path.endswith('.fits')):
                continue

            File_Management.read_input_file(path)

            time, detrended_flux, background = data_process.get_data()
            time = [float(data) for data in time]
            detrended_flux = [float(data) for data in detrended_flux]
            noise = [float(data) for data in background]

            alg_new = alg_dict[alg_choice]
            alg.selection(time, detrended_flux, alg_new)

    # This option is not currently functional when used in sequence with a .csv file.
    elif file_num == "Test Sinusoid":
        data_process.create_sin()
        time, detrended_flux, background = data_process.get_data()
        time = [float(data) for data in time]
        detrended_flux = [float(data) for data in detrended_flux]
        noise = [float(data) for data in background]

        alg_choice = alg_dict[alg_choice]
        alg.selection(time, detrended_flux, alg_choice)