Skip to content

Commit

Permalink
Merge branch 'add-brigtness-calc-to-comp-all-orbits' of https://githu…
Browse files Browse the repository at this point in the history
…b.com/sblunt/orbitize into add-brigtness-calc-to-comp-all-orbits
  • Loading branch information
sblunt committed Sep 20, 2024
2 parents 30248b6 + 17574f8 commit d9ef026
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 15 deletions.
10 changes: 10 additions & 0 deletions orbitize/example_data/reflected_light_example.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
epoch,object,raoff,decoff,raoff_err,decoff_err,brightness
57298,1,253.72,92.35,2.98,2.85,0.5
57606,1,236.63,127.94,9.77,9.18,0.5
57645,1,234.52,123.39,1.79,1.03,0.5
57946,1,210.76,152.09,1.94,1.88,0.5
58276,1,167.49,180.87,1.61,16.97,0.5
58287,1,177.67,174.6,1.67,1.67,0.5
58365,1,165.7,185.33,3.28,3.66,0.5
58368,1,170.38,185.94,2.52,2.74,0.5
58414,1,161.64,176.21,13.6,14.31,
2 changes: 1 addition & 1 deletion orbitize/read_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def read_file(filename):
if have_brightness[index]:
brightness = row["brightness"]
else:
brightness = None
brightness = np.nan

# check that "object" is an integer (instead of ABC/bcd)
if not isinstance(row["object"], (int, np.int32, np.int64)):
Expand Down
50 changes: 50 additions & 0 deletions tests/Visual.py
Original file line number Diff line number Diff line change
@@ -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")
25 changes: 11 additions & 14 deletions tests/test_brightness.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,42 +31,41 @@ 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")


def test_read_input_with_brightness():

# TODO (farrah): use code above as inspiration to read in a csv file with a brightness column
num_secondary_bodies = 1

# input_file = os.path.join(DATADIR, "GJ504.csv")
input_file = os.path.join(DATADIR, "betaPic.csv")
input_file = os.path.join(DATADIR, "reflected_light_example.csv")

data_table = read_input.read_file(input_file)

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(data_table)

print("hello! :D ")
# TODO (Farrah): add a test that asserts the brightness column of the data table is
# what you expect (hint: check in the reflected_light_example.csv to see what
# the brightness values should be


def test_compute_posteriors():
Expand Down Expand Up @@ -115,7 +114,5 @@ def test_compute_posteriors():

if __name__ == "__main__":
# test_brightness_calculation()
# test_read_input_with_brightness()
test_compute_posteriors()

# Test commit
test_read_input_with_brightness()
# test_compute_posteriors()

0 comments on commit d9ef026

Please sign in to comment.