From 2ca8419ca66d652f88afdad0880b098e7517d622 Mon Sep 17 00:00:00 2001 From: Farrah Molina Date: Fri, 20 Sep 2024 13:12:31 -0500 Subject: [PATCH] cleaned up test brightness --- tests/Visual.py | 50 ++++++++++++++++++++++++++++++++++++++++ tests/test_brightness.py | 11 +++++---- 2 files changed, 56 insertions(+), 5 deletions(-) create mode 100644 tests/Visual.py diff --git a/tests/Visual.py b/tests/Visual.py new file mode 100644 index 00000000..a56db702 --- /dev/null +++ b/tests/Visual.py @@ -0,0 +1,50 @@ +from orbitize import system, read_input, DATADIR +import os +import numpy as np +import matplotlib.pyplot as plt + + +num_secondary_bodies = 1 + +input_file = os.path.join(DATADIR, "GJ504.csv") +data_table = read_input.read_file(input_file) + +system_mass = 1.47 +plx = 24.30 + +test_system = system.System(num_secondary_bodies, data_table, system_mass, plx) + +params_arr = np.array( + [ + 10.0, # sma + 0.9, # ecc + np.radians(30), # inc + np.radians(60), # aop + np.radians(120), # pan + 0.0, # tau + plx, + system_mass, + ] +) +epochs = np.linspace(0, 365 * 30, int(1e3)) +ra, dec, vz, brightness = test_system.compute_all_orbits(params_arr, epochs=epochs) + +fig, ax = plt.subplots(2, 1, figsize=(5, 10)) + +ax[0].scatter( + epochs, + brightness, + color=plt.cm.RdYlBu((epochs - epochs[0]) / (epochs[-1] - epochs[0])), +) + +ax[1].scatter( + ra[:, 1, :], + dec[:, 1, :], + color=plt.cm.RdYlBu((epochs - epochs[0]) / (epochs[-1] - epochs[0])), +) + +ax[1].scatter([0], [0], color="red") + +ax[1].axis("equal") + +plt.savefig("visual4farrah.png") \ No newline at end of file diff --git a/tests/test_brightness.py b/tests/test_brightness.py index 9c5ca348..e7b094ee 100644 --- a/tests/test_brightness.py +++ b/tests/test_brightness.py @@ -29,23 +29,25 @@ def test_brightness_calculation(): params = np.array( [ 10.0, - 0.1, + 0.3, np.radians(89), np.radians(21), np.radians(31), - 0.0, # note: I didn't convert tau here, just picked random number + 0.0, 51.5, 1.75, ] ) ra, dec, vz, brightness = test_system.compute_all_orbits(params) + + # TODO (farrah): make plot of brightness vs time plt.figure() plt.scatter(times, brightness) - plt.xlabel("Time [dy]") - plt.ylabel("Brightness") + plt.xlabel("Time [dy]", fontsize=18) + plt.ylabel("Brightness", fontsize=18) plt.savefig("Test_brightness.png") @@ -62,7 +64,6 @@ def test_read_input_with_brightness(): times = data_table["epoch"].value brightness_values = data_table["brightness"].value - # Do we need the rest of this? since the values for time and brightness are given print("hello! :D ")