From 017c8ce30b1d35410cf0cf74a8454417651796c2 Mon Sep 17 00:00:00 2001 From: Sarah Blunt Date: Wed, 24 Jul 2024 09:57:51 -0700 Subject: [PATCH 1/3] modify read_input to read in brightness vals --- orbitize/read_input.py | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/orbitize/read_input.py b/orbitize/read_input.py index f37f5e41..69e2f0fe 100644 --- a/orbitize/read_input.py +++ b/orbitize/read_input.py @@ -103,8 +103,9 @@ def read_file(filename): "quant12_corr", "quant_type", "instrument", + "brightness", ), - dtype=(float, int, float, float, float, float, float, "S5", "S5"), + dtype=(float, int, float, float, float, float, float, "S5", "S5", float), ) # read file @@ -179,6 +180,10 @@ def read_file(filename): have_seppacorr = np.zeros( num_measurements, dtype=bool ) # zeros are False + if "brightness" in input_table.columns: + have_brightness = ~input_table["brightness"].mask + else: + have_brightness = np.zeros(num_measurements, dtype=bool) if "rv" in input_table.columns: have_rv = ~input_table["rv"].mask else: @@ -231,11 +236,14 @@ def read_file(filename): else: have_rv = np.zeros(num_measurements, dtype=bool) # zeros are False - # Rob: not sure if we need this but adding just in case if "instrument" in input_table.columns: have_inst = np.ones(num_measurements, dtype=bool) else: have_inst = np.zeros(num_measurements, dtype=bool) + if "brightness" in input_table.columns: + have_brightness = np.ones(num_measurements, dtype=bool) + else: + have_brightness = np.zeros(num_measurements, dtype=bool) # orbitize! backwards compatability since we added new columns, some old data formats may not have them # fill in with default values @@ -243,6 +251,12 @@ def read_file(filename): if "quant12_corr" not in input_table.keys(): default_corrs = np.nan * np.ones(len(input_table)) input_table.add_column(default_corrs, name="quant12_corr") + if "brightness" not in input_table.keys(): + default_brightness = np.nan * np.ones(len(input_table)) + input_table.add_column(default_brightness, name="brightness") + have_brightness = np.zeros(num_measurements, dtype=bool) + else: + have_brightness = np.ones(num_measurements, dtype=bool) if "instrument" not in input_table.keys(): default_insts = [] for this_quant_type in input_table["quant_type"]: @@ -275,6 +289,10 @@ def read_file(filename): MJD = row["epoch"] - 2400000.5 else: MJD = row["epoch"] + if have_brightness[index]: + brightness = row["brightness"] + else: + brightness = None # check that "object" is an integer (instead of ABC/bcd) if not isinstance(row["object"], (int, np.int32, np.int64)): @@ -294,6 +312,7 @@ def read_file(filename): None, row["quant_type"], row["instrument"], + None, ] ) @@ -322,6 +341,7 @@ def read_file(filename): quant12_corr, row["quant_type"], row["instrument"], + brightness, ] ) else: # catch wrong formats @@ -332,6 +352,7 @@ def read_file(filename): ) else: # When not in orbitize style + if have_ra[index] and have_dec[index]: # check if there's a covariance term if have_radeccorr[index]: @@ -362,6 +383,7 @@ def read_file(filename): quant12_corr, "radec", this_inst, + brightness, ] ) @@ -395,6 +417,7 @@ def read_file(filename): quant12_corr, "seppa", this_inst, + brightness, ] ) @@ -411,6 +434,7 @@ def read_file(filename): None, "rv", row["instrument"], + brightness, ] ) else: @@ -426,6 +450,7 @@ def read_file(filename): None, "rv", "defrv", + brightness, ] ) From 03ea9844904c291d4cda2f05e58dc6d1f2b3109c Mon Sep 17 00:00:00 2001 From: Sarah Blunt Date: Wed, 24 Jul 2024 09:58:45 -0700 Subject: [PATCH 2/3] update todos in test_brightness --- tests/test_brightness.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/test_brightness.py b/tests/test_brightness.py index e3fdfedb..a56daf95 100644 --- a/tests/test_brightness.py +++ b/tests/test_brightness.py @@ -11,8 +11,14 @@ def test_brightness_calculation(): num_secondary_bodies = 1 + + # TODO (sarah): change dataset to one where we can see brightness variations input_file = os.path.join(DATADIR, "GJ504.csv") + # input_file = os.path.join(DATADIR, "new_dataset.csv") data_table = read_input.read_file(input_file) + + times = data_table["epoch"].value + system_mass = 1.47 plx = 24.30 @@ -37,8 +43,18 @@ def test_brightness_calculation(): ] ) + print(test_system.param_idx) + ra, dec, vz, brightness = test_system.compute_all_orbits(params) + # TODO (farrah): make plot of brightness vs time + + +def test_read_input_with_brightness(): + + # TODO (farrah): use code above as inspiration to read in a csv file with a brightness column + if __name__ == "__main__": test_brightness_calculation() + test_read_input_with_brightness() From 64045dd54b3830b11e5e40c8a828f614075291d2 Mon Sep 17 00:00:00 2001 From: Sarah Blunt Date: Wed, 24 Jul 2024 10:09:36 -0700 Subject: [PATCH 3/3] test system for brightness calc: gj 504 -> beta pic --- tests/test_brightness.py | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/tests/test_brightness.py b/tests/test_brightness.py index a56daf95..1a7afd52 100644 --- a/tests/test_brightness.py +++ b/tests/test_brightness.py @@ -12,9 +12,8 @@ def test_brightness_calculation(): num_secondary_bodies = 1 - # TODO (sarah): change dataset to one where we can see brightness variations - input_file = os.path.join(DATADIR, "GJ504.csv") - # input_file = os.path.join(DATADIR, "new_dataset.csv") + # input_file = os.path.join(DATADIR, "GJ504.csv") + input_file = os.path.join(DATADIR, "betaPic.csv") data_table = read_input.read_file(input_file) times = data_table["epoch"].value @@ -24,27 +23,21 @@ def test_brightness_calculation(): test_system = system.System(num_secondary_bodies, data_table, system_mass, plx) + print(test_system.param_idx) + params = np.array( [ - 7.2774010e01, - 4.1116819e-02, - 5.6322372e-01, - 3.5251172e00, - 4.2904768e00, - 9.4234377e-02, - 4.5418411e01, - 1.4317369e-03, - 5.6322372e-01, - 3.1016846e00, - 4.2904768e00, - 3.4033456e-01, - 2.4589758e01, - 1.4849439e00, + 10.0, + 0.1, + np.radians(89), + np.radians(21), + np.radians(31), + 0.0, # note: I didn't convert tau here, just picked random number + 51.5, + 1.75, ] ) - print(test_system.param_idx) - ra, dec, vz, brightness = test_system.compute_all_orbits(params) # TODO (farrah): make plot of brightness vs time @@ -54,6 +47,8 @@ def test_read_input_with_brightness(): # TODO (farrah): use code above as inspiration to read in a csv file with a brightness column + print("hello! :D ") + if __name__ == "__main__": test_brightness_calculation()