Skip to content

Commit

Permalink
Merge pull request #272 from sblunt/deprecation
Browse files Browse the repository at this point in the history
Remove deprecated functions
  • Loading branch information
sblunt committed Sep 4, 2021
2 parents f8df80e + 64c34e0 commit 6783c42
Show file tree
Hide file tree
Showing 14 changed files with 89 additions and 956 deletions.
32 changes: 16 additions & 16 deletions docs/faq/Orientation_Of_Orbit.ipynb

Large diffs are not rendered by default.

864 changes: 48 additions & 816 deletions docs/tutorials/show-me-the-orbit.ipynb

Large diffs are not rendered by default.

14 changes: 0 additions & 14 deletions orbitize/basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1110,20 +1110,6 @@ def verify_params(self):
if (max_index - best_epoch_loc < 2):
raise Exception("For now, the epoch with the lowest sepparation error should not be one of the last two entries for body{}".format(body_num))

# Other conversions
def tau_to_t0(tau, ref_epoch, period, after_date=None):
"""
DEPRECATING!! Replaced by tau_to_tp
"""
warnings.warn('DEPRECATION: tau_to_t0 is being deprecated in the next orbitize! release. Please use tau_to_tp instead!', FutureWarning)
return tau_to_tp(tau, ref_epoch, period, after_date=after_date)

def t0_to_tau(tp, ref_epoch, period):
"""
DEPRECATING!! Replaced by tp_to_tau
"""
warnings.warn('DEPRECATION: t0_to_tau is being deprecated in the next orbitize! release. Please use t0_to_tau instead!', FutureWarning)
return tp_to_tau(tp, ref_epoch, period)

def tau_to_tp(tau, ref_epoch, period, after_date=None):
"""
Expand Down
12 changes: 2 additions & 10 deletions orbitize/kepler.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def tau_to_manom(date, sma, mtot, tau, tau_ref_epoch):
return mean_anom


def calc_orbit(epochs, sma, ecc, inc, aop, pan, tau, plx, mtot, mass_for_Kamp=None, tau_ref_epoch=58849, tolerance=1e-9, max_iter=100, tau_warning=True):
def calc_orbit(epochs, sma, ecc, inc, aop, pan, tau, plx, mtot, mass_for_Kamp=None, tau_ref_epoch=58849, tolerance=1e-9, max_iter=100):
"""
Returns the separation and radial velocity of the body given array of
orbital parameters (size n_orbs) at given epochs (array of size n_dates)
Expand All @@ -68,9 +68,6 @@ def calc_orbit(epochs, sma, ecc, inc, aop, pan, tau, plx, mtot, mass_for_Kamp=No
tau_ref_epoch (float, optional): reference date that tau is defined with respect to (i.e., tau=0)
tolerance (float, optional): absolute tolerance of iterative computation. Defaults to 1e-9.
max_iter (int, optional): maximum number of iterations before switching. Defaults to 100.
tau_warning (bool, optional, depricating): temporary argument to warn users about tau_ref_epoch default value change.
Users that are calling this function themsleves should receive a warning since default is True.
To be removed when tau_ref_epoch change is fully propogated to users. Users can turn it off to stop getting the warning.
Return:
3-tuple:
Expand All @@ -85,11 +82,6 @@ def calc_orbit(epochs, sma, ecc, inc, aop, pan, tau, plx, mtot, mass_for_Kamp=No
Written: Jason Wang, Henry Ngo, 2018
"""
if tau_warning:
warnings.warn("tau_ref_epoch default for kepler.calc_orbit is 58849 now instead of 0 MJD. "
"Please check that this does not break your code. You can turn off this warning by setting "
"tau_warning=False when you call kepler.calc_orbit.")

n_orbs = np.size(sma) # num sets of input orbital parameters
n_dates = np.size(epochs) # number of dates to compute offsets and vz

Expand Down Expand Up @@ -245,7 +237,7 @@ def _newton_solver(manom, ecc, tolerance=1e-9, max_iter=100, eanom0=None):

if niter >= max_iter:
print(manom[ind], eanom[ind], diff[ind], ecc[ind], '> {} iter.'.format(max_iter))
eanom[ind] = _mikkola_solver_wrapper(manom[ind], ecc[ind], use_c) # Send remaining orbits to the analytical version, this has not happened yet...
eanom[ind] = _mikkola_solver_wrapper(manom[ind], ecc[ind], cext) # Send remaining orbits to the analytical version, this has not happened yet...

return eanom

Expand Down
25 changes: 0 additions & 25 deletions orbitize/read_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Module to read user input from files and create standardized input for orbitize
"""

import deprecation
import numpy as np
import orbitize
from astropy.table import Table
Expand Down Expand Up @@ -314,19 +313,6 @@ def read_file(filename):
return output_table


@deprecation.deprecated(deprecated_in="1.0.2", removed_in="2.0",
current_version=orbitize.__version__,
details="Use read_file() instead. v1.0.2 replaces read_formatted_file and read_orbitize_input with read_file(). For now, this will be a wrapper for read_file and will be removed in the v2.0 release.")
def read_formatted_file(filename):
"""
Version 1.0.2 replaces this function with `read_file`.
Currently exists as a wrapper for `read_file` and will be removed in v2.0
Written: Henry Ngo, 2018
"""

return read_file(filename)


def write_orbitize_input(table, output_filename, file_type='csv'):
""" Writes orbitize-readable input as an ASCII file
Expand All @@ -353,14 +339,3 @@ def write_orbitize_input(table, output_filename, file_type='csv'):
write(table, output=output_filename, format=file_type)


@deprecation.deprecated(deprecated_in="1.0.2", removed_in="2.0",
current_version=orbitize.__version__,
details="Use read_file() instead. v1.0.2 replaces read_orbitize_input and read_formatted_file with read_file(). For now, this will be a wrapper for read_file and will be removed in the v2.0 release.")
def read_orbitize_input(filename):
"""
Version 1.0.2 replaces this function with `read_file`.
Currently exists as a wrapper for `read_file` and will be removed in v2.0
Written: Henry Ngo, 2018
"""
return read_file(filename)
6 changes: 3 additions & 3 deletions orbitize/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ def plot_orbits(self, object_to_plot=1, start_mjd=51544.,
# Calculate ra/dec offsets for all epochs of this orbit
raoff0, deoff0, _ = kepler.calc_orbit(
epochs[i, :], sma[i], ecc[i], inc[i], aop[i], pan[i],
tau[i], plx[i], mtot[i], tau_ref_epoch=self.tau_ref_epoch, tau_warning=False
tau[i], plx[i], mtot[i], tau_ref_epoch=self.tau_ref_epoch
)

raoff[i, :] = raoff0
Expand Down Expand Up @@ -739,15 +739,15 @@ def plot_orbits(self, object_to_plot=1, start_mjd=51544.,
raoff0, deoff0, _ = kepler.calc_orbit(
epochs_seppa[i, :], sma[i], ecc[i], inc[i], aop[i], pan[i],
tau[i], plx[i], mtot[i], tau_ref_epoch=self.tau_ref_epoch,
mass_for_Kamp=m0[i], tau_warning=False
mass_for_Kamp=m0[i]
)

raoff[i, :] = raoff0
deoff[i, :] = deoff0
else:
raoff0, deoff0, _ = kepler.calc_orbit(
epochs_seppa[i, :], sma[i], ecc[i], inc[i], aop[i], pan[i],
tau[i], plx[i], mtot[i], tau_ref_epoch=self.tau_ref_epoch, tau_warning=False
tau[i], plx[i], mtot[i], tau_ref_epoch=self.tau_ref_epoch
)

raoff[i, :] = raoff0
Expand Down
2 changes: 1 addition & 1 deletion orbitize/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def prepare_samples(self, num_samples):
# compute sep/PA of generated orbits
ra, dec, _ = orbitize.kepler.calc_orbit(
self.epochs[min_epoch], sma, ecc, inc, argp, lan, tau, plx, mtot,
tau_ref_epoch=0, mass_for_Kamp=m1, tau_warning=False
tau_ref_epoch=0, mass_for_Kamp=m1
)
sep, pa = orbitize.system.radec2seppa(ra, dec) # sep[mas], PA[deg]

Expand Down
3 changes: 1 addition & 2 deletions orbitize/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,7 @@ def compute_all_orbits(self, params_arr, epochs=None, comp_rebound=False):
# solve Kepler's equation
raoff, decoff, vz_i = kepler.calc_orbit(
epochs, sma, ecc, inc, argp, lan, tau, plx, mtot,
mass_for_Kamp=m0, tau_ref_epoch=self.tau_ref_epoch,
tau_warning=False
mass_for_Kamp=m0, tau_ref_epoch=self.tau_ref_epoch
)

# raoff, decoff, vz are scalers if the length of epochs is 1
Expand Down
9 changes: 3 additions & 6 deletions tests/test_OFTI.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ def test_scale_and_rotate():
sma, ecc, inc, argp, lan, tau, plx, mtot = [samp for samp in samples]

ra, dec, vc = orbitize.kepler.calc_orbit(
s.epochs, sma, ecc, inc, argp, lan, tau, plx, mtot, tau_ref_epoch=0,
tau_warning=False
s.epochs, sma, ecc, inc, argp, lan, tau, plx, mtot, tau_ref_epoch=0
)
sep, pa = orbitize.system.radec2seppa(ra, dec)
sep_sar, pa_sar = np.median(sep[s.epoch_idx]), np.median(pa[s.epoch_idx])
Expand All @@ -58,8 +57,7 @@ def test_scale_and_rotate():
mtot = samples[:, 7]

ra, dec, vc = orbitize.kepler.calc_orbit(
s.epochs, sma, ecc, inc, argp, lan, tau, plx, mtot, tau_ref_epoch=0,
tau_warning=False
s.epochs, sma, ecc, inc, argp, lan, tau, plx, mtot, tau_ref_epoch=0
)
assert np.max(lan) > np.pi
sep, pa = orbitize.system.radec2seppa(ra, dec)
Expand All @@ -81,8 +79,7 @@ def test_scale_and_rotate():
assert np.max(argp) > np.pi and np.max(argp) < 2 * np.pi

ra, dec, vc = orbitize.kepler.calc_orbit(
s.epochs, sma, ecc, inc, argp, lan, tau, plx, mtot, tau_ref_epoch=0,
tau_warning=False
s.epochs, sma, ecc, inc, argp, lan, tau, plx, mtot, tau_ref_epoch=0
)
sep, pa = orbitize.system.radec2seppa(ra, dec)
sep_sar, pa_sar = np.median(sep[s.epoch_idx]), np.median(pa[s.epoch_idx])
Expand Down
2 changes: 1 addition & 1 deletion tests/test_abs_astrometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_1planet():

ra_model, dec_model, _ = kepler.calc_orbit(
epochs, sma, ecc, inc, aop, pan, tau, plx, mtot,
tau_ref_epoch=tau_ref_epoch, tau_warning=False
tau_ref_epoch=tau_ref_epoch
)

# generate some fake measurements to feed into system.py to test bookkeeping
Expand Down
15 changes: 6 additions & 9 deletions tests/test_kepler_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def test_orbit_e03():
raoffs, deoffs, vzs = kepler.calc_orbit(
epochs, orbital_params[0], orbital_params[1], orbital_params[2],
orbital_params[3], orbital_params[4], orbital_params[5],
orbital_params[6], orbital_params[7], tau_ref_epoch=0, tau_warning=False
orbital_params[6], orbital_params[7], tau_ref_epoch=0
)

true_raoff = [152.86786, 180.39408] #mas
Expand Down Expand Up @@ -89,8 +89,7 @@ def test_orbit_e03_array():
mtot = np.array([1.5,1.5,1.5])
epochs = np.array([1000, 1101.4])
raoffs, deoffs, vzs = kepler.calc_orbit(
epochs, sma, ecc, inc, argp, lan, tau, plx, mtot, tau_ref_epoch=0,
tau_warning=False
epochs, sma, ecc, inc, argp, lan, tau, plx, mtot, tau_ref_epoch=0
)

true_raoff = np.array([[ 152.86786, 152.86786, 152.86786],
Expand Down Expand Up @@ -119,8 +118,7 @@ def test_orbit_e99():
raoffs, deoffs, vzs = kepler.calc_orbit(
epochs, orbital_params[0], orbital_params[1], orbital_params[2],
orbital_params[3], orbital_params[4], orbital_params[5],
orbital_params[6], orbital_params[7], tau_ref_epoch=0,
tau_warning=False
orbital_params[6], orbital_params[7], tau_ref_epoch=0
)

true_raoff = [-589.45575, -571.48432]
Expand Down Expand Up @@ -148,7 +146,7 @@ def test_orbit_with_mass():
epochs, orbital_params[0], orbital_params[1], orbital_params[2],
orbital_params[3], orbital_params[4], orbital_params[5],
orbital_params[6], orbital_params[7], mass_for_Kamp=orbital_params[7]/2,
tau_ref_epoch=0, tau_warning=False
tau_ref_epoch=0
)

true_raoff = [-589.45575, -571.48432]
Expand Down Expand Up @@ -179,7 +177,7 @@ def test_orbit_with_mass_array():
mass = mtot/2
raoffs, deoffs, vzs = kepler.calc_orbit(
epochs, sma, ecc, inc, argp, lan, tau, plx, mtot, mass_for_Kamp=mass,
tau_ref_epoch=0, tau_warning=False
tau_ref_epoch=0
)


Expand Down Expand Up @@ -212,8 +210,7 @@ def test_orbit_scalar():
mtot = 1.5
epochs = 1000
raoffs, deoffs, vzs = kepler.calc_orbit(
epochs, sma, ecc, inc, argp, lan, tau, plx, mtot, tau_ref_epoch=0,
tau_warning=False
epochs, sma, ecc, inc, argp, lan, tau, plx, mtot, tau_ref_epoch=0
)

true_raoff = 152.86786
Expand Down
8 changes: 3 additions & 5 deletions tests/test_multiplanet.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_compute_model():

ra_model, dec_model, vz_model = kepler.calc_orbit(
epochs, b_params[0], b_params[1], b_params[2], b_params[3], b_params[4],
b_params[5], plx, mtot, tau_ref_epoch=tau_ref_epoch, tau_warning=False
b_params[5], plx, mtot, tau_ref_epoch=tau_ref_epoch
)

# generate some fake measurements just to feed into system.py to test bookkeeping
Expand Down Expand Up @@ -105,15 +105,13 @@ def test_fit_selfconsist():
# comptue Keplerian orbit of b
ra_model_b, dec_model_b, vz_model = kepler.calc_orbit(
epochs, b_params[0], b_params[1], b_params[2], b_params[3], b_params[4],
b_params[5], plx, mtot_b, mass_for_Kamp=m0, tau_ref_epoch=tau_ref_epoch,
tau_warning=False
b_params[5], plx, mtot_b, mass_for_Kamp=m0, tau_ref_epoch=tau_ref_epoch
)

# comptue Keplerian orbit of c
ra_model_c, dec_model_c, vz_model_c = kepler.calc_orbit(
epochs, c_params[0], c_params[1], c_params[2], c_params[3], c_params[4],
c_params[5], plx, mtot_c, tau_ref_epoch=tau_ref_epoch,
tau_warning=False
c_params[5], plx, mtot_c, tau_ref_epoch=tau_ref_epoch
)

# perturb b due to c
Expand Down
9 changes: 4 additions & 5 deletions tests/test_multiplanet_rebound.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_1planet():

ra_model, dec_model, vz_model = kepler.calc_orbit(
epochs, sma, ecc, inc, aop, pan, tau, plx, mtot,
tau_ref_epoch=tau_ref_epoch, tau_warning=False
tau_ref_epoch=tau_ref_epoch
)

# generate some fake measurements just to feed into system.py to test bookkeeping
Expand Down Expand Up @@ -130,7 +130,7 @@ def test_2planet_massive():
# just want to generate some measurements of plaent b to test compute model
b_ra_model, b_dec_model, b_vz_model = kepler.calc_orbit(
epochs, params[0], params[1], params[2], params[3], params[4], params[5],
params[-2], params[-1], tau_ref_epoch=tau_ref_epoch, tau_warning=False
params[-2], params[-1], tau_ref_epoch=tau_ref_epoch
)

# generate some fake measurements of planet b, just to feed into system.py to test bookkeeping
Expand Down Expand Up @@ -284,8 +284,7 @@ def test_2planet_massive_reverse_order():
# just want to generate some measurements of plaent b to test compute model
b_ra_model, b_dec_model, b_vz_model = kepler.calc_orbit(
epochs, params[6+0], params[6+1], params[6+2], params[6+3], params[6+4],
params[6+5], params[-2], params[-1], tau_ref_epoch=tau_ref_epoch,
tau_warning=False
params[6+5], params[-2], params[-1], tau_ref_epoch=tau_ref_epoch
)

# generate some fake measurements of planet b, just to feed into system.py to test bookkeeping
Expand Down Expand Up @@ -373,7 +372,7 @@ def test_2planet_nomass():
# just want to generate some measurements of plaent b to test compute model
b_ra_model, b_dec_model, b_vz_model = kepler.calc_orbit(
epochs, params[0], params[1], params[2], params[3], params[4], params[5],
params[-2], params[-1], tau_ref_epoch=tau_ref_epoch, tau_warning=False
params[-2], params[-1], tau_ref_epoch=tau_ref_epoch
)

# generate some fake measurements of planet b, just to feed into system.py to test bookkeeping
Expand Down
44 changes: 1 addition & 43 deletions tests/test_read_input.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import pytest
import deprecation
import numpy as np
import os
import orbitize
from orbitize.read_input import read_file, write_orbitize_input, read_formatted_file, read_orbitize_input
from orbitize.read_input import read_file, write_orbitize_input


def _compare_table(input_table):
Expand Down Expand Up @@ -70,21 +69,6 @@ def test_read_file():
read_file(input_file_radec)


@deprecation.fail_if_not_removed
def test_read_formatted_file():
"""
Tests the read_formatted_file function using the test_val.csv file and test_val_radec.csv
This test exists with the fail_if_not_removed decorator as a reminder to remove in v2.0
"""
# Check that main test input is read in with correct values
input_file = os.path.join(orbitize.DATADIR, 'test_val.csv')
_compare_table(read_formatted_file(input_file))
# Check that an input value with all valid entries and only ra/dec columns can be read
input_file_radec = os.path.join(orbitize.DATADIR, 'test_val_radec.csv')
read_file(input_file_radec)


def test_write_orbitize_input():
"""
Test the write_orbitize_input and the read_file functions
Expand All @@ -107,30 +91,6 @@ def test_write_orbitize_input():
os.remove(output_file)


@deprecation.fail_if_not_removed
def test_write_orbitize_input_2():
"""
Test the write_orbitize_input and the read_orbitize_input functions
This test exists with the fail_if_not_removed decorator as a reminder to remove in v2.0
"""
input_file = os.path.join(orbitize.DATADIR, 'test_val.csv')
test_table = read_file(input_file)
output_file = os.path.join(orbitize.DATADIR, 'temp_test_orbitize_input.csv')
# If temp output file already exists, delete it
if os.path.isfile(output_file):
os.remove(output_file)
try: # Catch these tests so that we remove temporary file
# Test that we were able to write the table
write_orbitize_input(test_table, output_file)
assert os.path.isfile(output_file)
# Test that we can read the table and check if it's correct
test_table_2 = read_orbitize_input(output_file)
_compare_table(test_table_2)
finally:
# Remove temporary file
os.remove(output_file)

def test_cov_input():
"""
Test including radec and seppa covariances/correlations.
Expand Down Expand Up @@ -173,8 +133,6 @@ def test_read_old_orbitize_format():

if __name__ == "__main__":
test_read_file()
test_read_formatted_file()
test_write_orbitize_input()
test_write_orbitize_input_2()
test_cov_input()
test_read_old_orbitize_format()

0 comments on commit 6783c42

Please sign in to comment.