diff options
author | hanemile <emile.hansmaennel@gmail.com> | 2018-03-19 20:47:13 +0100 |
---|---|---|
committer | hanemile <emile.hansmaennel@gmail.com> | 2018-03-19 20:47:13 +0100 |
commit | d0f19b8bc7ab11449cea028106504cacecd94f66 (patch) | |
tree | 8ce0c9298694554a46545731c949fb18332669cb /src/python/lookup.py | |
parent | 996e5529f566d7c64763c47348fc68fae51ef6a4 (diff) |
cleaned up
Diffstat (limited to 'src/python/lookup.py')
-rwxr-xr-x | src/python/lookup.py | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/src/python/lookup.py b/src/python/lookup.py index 52e1966..4c81295 100755 --- a/src/python/lookup.py +++ b/src/python/lookup.py @@ -7,6 +7,21 @@ import matplotlib.pyplot as plt import time import os import sys +import argparse + +parser = argparse.ArgumentParser( + description="Lookuptable generator", + usage='./%(prog)s <radius> <path> [-h]', +) +parser.add_argument("radius", help="Number of Values to be calculated") +parser.add_argument("path", help="Path to the location where the lookuptable should be saved", type=str) +args = parser.parse_args() + +# define the radius until where the values should be generated +radius = int(float(args.radius)) + +# Define the path to where the data should be stored +path = 'data/' + str(args.path) + '.big.csv' # Defining some variables sigma = 200 @@ -33,33 +48,22 @@ def phi(x): b = np.log(1. + (x / R_s) ) return a * b -# Defining a list to store the rho-values for plotting -list_rho = [] - -# Define the path to where the data should be stored -path = 'data/' + str(sys.argv[2]) + '.csv' - # get the start time start = time.time() -# define the number of stars using system arguments -stars = int(float(sys.argv[1])) - # open the file where the information should be written to with open(path, "a") as data: # for every star - for i in range(0, stars): + for i in range(0, radius): # calculate the rho value rho_i = rho(i/10) - # append the rho value to list_rho for plotting - # list_rho.append(rho_i) - # print the distance to the center of the universe and the rho value to # the user - print(str(i) + ", " + str(rho_i)) + if ((i % 1000) == 0): + print(str(i) + ", " + str(rho_i)) # write the data into the file data.write(str(i) + ", " + str(rho_i) + "\n") @@ -74,13 +78,7 @@ runtime = end - start print("\n Runtime: ", end="") print(str(runtime) + " seconds") -print(" Stars: " + str(stars)) +print(" Radius: " + str(radius)) print(" Rho-values per second: ", end="") -print(str(stars / runtime)) - -# plt.plot(list_rho) -# plt.xscale('log') -# plt.yscale('log') -# plt.grid() -# plt.show() +print(str(radius / runtime)) |