Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 31 additions & 25 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,10 @@ def const(yz):

def test():
dipole_field_test()
#TODO: Either add more tests or get rid of this function


def compare():
def compare(logger):

def cross_equator(s, yz):
return yz[1]
Expand Down Expand Up @@ -127,7 +128,7 @@ def cross_equator(s, yz):
logger.info(f'RK45 stop const = {const(stop_yz45):.8f}')


def generate():
def generate(logger):

s_eval = np.linspace(0, 2, 5)
n_lines = 5
Expand All @@ -145,31 +146,36 @@ def generate():
return lines


logger = logger_init()
def main():
logger = logger_init()

if compare_methods == True:
compare()
if compare_methods == True:
compare(logger)

if test == True:
dipole_field_test()
if test == True:
dipole_field_test()

if generate_lines == True:
lines = generate(logger)

if generate_lines == True:
lines = generate()

# Option 1 for saving data: NumPy's save function
fname = 'data/lines.npy'
logger.info(f'Writing {fname}')
np.save(fname, lines)
logger.info(f'Wrote {fname}')

# Option 2 for saving data: CSV
# If there is any reason that we would want to inspect the numbers, save each
# field line in a separate CSV file.
for i in range(lines.shape[2]):
fname = f'data/line_{i}.csv'
np.savetxt(fname, lines[:,:,i], delimiter=',')
# Option 1 for saving data: NumPy's save function
fname = 'data/lines.npy'
logger.info(f'Writing {fname}')
np.save(fname, lines)
logger.info(f'Wrote {fname}')

# For discussion:
# 1. What are the pros and cons of each option?
# 2. What about pkl file, HDF5, or CDF?
# Option 2 for saving data: CSV
# If there is any reason that we would want to inspect the numbers, save each
# field line in a separate CSV file.
for i in range(lines.shape[2]):
fname = f'data/line_{i}.csv'
np.savetxt(fname, lines[:,:,i], delimiter=',')
logger.info(f'Wrote {fname}')

# For discussion:
# 1. What are the pros and cons of each option?
# 2. What about pkl file, HDF5, or CDF?

if __name__ == "__main__":
main()