Skip to content

Commit

Permalink
Merge pull request #98 from sblunt/OFTI_speedups
Browse files Browse the repository at this point in the history
Fixing issue #83
  • Loading branch information
Sarah Blunt committed Mar 19, 2019
2 parents ff23515 + 6a95d45 commit a972b34
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
19 changes: 13 additions & 6 deletions orbitize/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,25 @@ def __init__(self, system, like='chi2_lnlike', custom_lnlike=None):

super(OFTI, self).__init__(system, like=like, custom_lnlike=custom_lnlike)

# compute priors and columns containing ra/dec and sep/pa
self.priors = self.system.sys_priors
self.tbl = self.system.data_table
self.radec_idx = self.system.radec[1]
self.seppa_idx = self.system.seppa[1]

# store input table and table with values used by OFTI
self.input_table = self.system.data_table
self.data_table = self.system.data_table.copy()

# these are of type astropy.table.column
self.sep_observed = self.tbl[:]['quant1']
self.pa_observed = self.tbl[:]['quant2']
self.sep_err = self.tbl[:]['quant1_err']
self.pa_err = self.tbl[:]['quant2_err']
self.sep_observed = self.data_table[:]['quant1'].copy()
self.pa_observed = self.data_table[:]['quant2'].copy()
self.sep_err = self.data_table[:]['quant1_err'].copy()
self.pa_err = self.data_table[:]['quant2_err'].copy()

# convert RA/Dec rows to sep/PA
if len(self.radec_idx) > 0:
print('Converting ra/dec data points in data_table to sep/pa. Original data are stored in input_table.')

for i in self.radec_idx:
self.sep_observed[i], self.pa_observed[i] = radec2seppa(
self.sep_observed[i], self.pa_observed[i]
Expand All @@ -120,7 +127,7 @@ def __init__(self, system, like='chi2_lnlike', custom_lnlike=None):
self.sep_err[i], self.pa_err[i]
)

self.epochs = np.array(self.tbl['epoch'])
self.epochs = np.array(self.data_table['epoch'])

# choose scale-and-rotate epoch
self.epoch_idx = np.argmin(self.sep_err) # epoch with smallest error
Expand Down
2 changes: 1 addition & 1 deletion tests/test_OFTI.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_scale_and_rotate():
sep_sar, pa_sar = np.median(sep[s.epoch_idx]), np.median(pa[s.epoch_idx])

# test to make sure sep and pa scaled to scale-and-rotate epoch
sar_epoch = s.tbl[s.epoch_idx]
sar_epoch = s.data_table[s.epoch_idx]
assert sep_sar == pytest.approx(sar_epoch['quant1'], abs=sar_epoch['quant1_err'])
assert pa_sar == pytest.approx(sar_epoch['quant2'], abs=sar_epoch['quant2_err'])

Expand Down

0 comments on commit a972b34

Please sign in to comment.