Ejemplo n.º 1
0
def run_plot(s1, s2, t, ft, set_vec):  # dt, code, tails, save, plot, load, num
    """runs plots"""
    while set_vec[4] == 'y':
        print(
            ' #     Mass(kg)    k(N/m)    length(m)\n---   --------   ------   ---------'
        )
        print(f'{s1}\n{s2}\n\n {t}\n\nRunning... (Close Figures to Continue)')
        plot_ani(s1, s2, t, set_vec[3], set_vec[6], set_vec[2])
        plot(s1, s2, t, set_vec[3], set_vec[6])
        fourier_plot(ft, set_vec[3], set_vec[6], t)
        set_vec[4] = 'n'
        s.clear()
        set_vec = re_run(set_vec)
    s.clear()
Ejemplo n.º 2
0
def exit_choice(*args):
    if not len(args) == 0:
        stay = input(f"""\n
        {red} 1 {normal}: {blue} Main menu {normal}\n
        {red} 2 {normal}: {blue} Do it again {normal}\n
        {red} x {normal}: {blue} exit {normal}\n
        >>>  """)
    else:
        stay = input(f"""\n
                {red} 1 {normal}: {blue} Main menu {normal}\n
                {red} x {normal}: {blue} exit {normal}\n
        >>>  """)
    if stay == "1":
        main_menu()
    elif stay == "2":
        for func in args:
            func()
            Red()
            exit_choice(func)
    elif stay == "x" or "X":
        clear()
Ejemplo n.º 3
0
def main_menu():
    global message
    Red()

    choice = input(f"""{green}
            Welcome to Redpaper. This is a sudo-GUI used to
            control the underlying Redpaper program.
            Select an option:\n{normal}
           {red} 1 {normal}: {blue} Download wallpapers {normal} \n
           {red} 2 {normal}: {blue} Change wallpaper{normal}\n
           {red} 3 {normal}: {blue} Settings{normal}\n
           {red} 4 {normal}: {blue} Help {normal}\n
           {red} x {normal}: {blue} exit {normal}\n
            >>>  """)
    if choice == "1":
        message = ""
        Red()
        fetch.wall_dl()
        exit_choice(fetch.wall_dl)
    if choice == "2":
        message = f"{green} Changed wallpaper {normal}\n"
        Red()
        wall_set.set_wallpaper()
        exit_choice(wall_set.set_wallpaper)
    elif choice == "3":
        message = ""
        main_settings()
        main_menu()
    elif choice == "4" or choice == "R":
        # TODO: create a help page
        message = "HELP\n"
        Red()
        print(f"""
              {green}This section is still under develpment{normal}""")
        exit_choice()
    elif choice == "x" or choice == "X":
        clear()
    else:
        # message = f"\n{red_error} Choice not understood, try again.{normal}"
        main_menu()
Ejemplo n.º 4
0
def re_run(set_vec):
    """asks if the simulation should be rerun"""
    print('Rerun last simulation? (y/n) ', end='')
    a = input()
    if a == 'y':
        set_vec[3], set_vec[4] = 'n', 'y'
        s.clear()
        return set_vec
    elif a == 'n':
        s.clear()
        return set_vec
    else:
        s.clear()
        print('Invalid Entry!\n')
        return re_run(set_vec)
Ejemplo n.º 5
0
def run_prog(set_vec):
    """runs simulation"""
    set_vec = [set_vec[0], set_vec[1], set_vec[2], 'y', 'y',
               'n']  # dt, code, tails, save, plot, load, num
    print("Press ENTER to continue or type 'q' to quit:  ", end='')
    a = input()
    if a == '':
        s.clear()
        select_scenario(set_vec)
    elif a == 'q':
        s.clear()
        quit()
    else:
        s.clear()
        print('Invalid Entry!\n')
        run_prog(set_vec)
Ejemplo n.º 6
0
def clear_failed():  settings.clear('download_failed')

def append(**kwargs):
Ejemplo n.º 7
0
def clear_current(): settings.clear('download_current')
def clear_failed():  settings.clear('download_failed')
Ejemplo n.º 8
0
def clear_history(): settings.clear('download_history')
def clear_current(): settings.clear('download_current')
Ejemplo n.º 9
0
def clear():      settings.clear('searches')
def includes(q):  return q in collection()
Ejemplo n.º 10
0
def clear():
    settings.clear('searches')
Ejemplo n.º 11
0
def Red():
    global message
    red_banner = f"{red}{banner}{normal}"
    clear()
    print(red_banner)
    print(message)
Ejemplo n.º 12
0
def clear():
    settings.clear('favorites2')
Ejemplo n.º 13
0
def clear():
    settings.clear("favorites2")
Ejemplo n.º 14
0
    # generate data
    if set_vec[5] == 'n':
        # time input
        sec = s.simulation_time()
        # create objects/data
        s1, s2, t = spring.Spring(inc1), spring.Spring(inc2), spring.Time(
            sec, set_vec[0])
        # gets and appends num
        set_vec.append(data.get_num())
        # runs calc
        s1, s2, ft, dat_arr = calc.run_calc(s1, s2, t)
        # saves data
        data.save_data(set_vec[6], dat_arr)
    else:
        sst, ft = dat_arr[0], dat_arr[1]
        s1, s2, t = sst[0], sst[1], sst[2]
        set_vec.append('null')

    # plot data
    p.run_plot(s1, s2, t, ft, set_vec)
    if set_vec[5] == 'n':
        print(f'Data saved in:  trials/trial_{set_vec[6]}\n')
    run_prog(set_vec)


if __name__ == '__main__':
    s.clear()
    print('Welcome to Spring Mass Simulator!\n')
    default_data()
Ejemplo n.º 15
0
def load_data(num):
    """loads data from npy file"""
    settings.clear()
    dat_arr = load(f'trials/trial_{num}/{num}_data.npy', allow_pickle=True)
    return dat_arr