Skip to content

Commit

Permalink
test_FitData.py: Added a crude test that ephemerides file is used in …
Browse files Browse the repository at this point in the history
…calculating derivatives.
  • Loading branch information
jenniferyee committed Apr 27, 2023
1 parent e9964fe commit fda28dc
Showing 1 changed file with 31 additions and 5 deletions.
36 changes: 31 additions & 5 deletions source/MulensModel/tests/test_FitData.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,7 @@ def test_fit_fluxes():
assert(chi2_1 != my_fit.chi2)


def test_satellite_and_annual_parallax_calculation():
"""
test that data magnifications are correctly retrieved for Spitzer data.
"""

def create_0939_parallax_model():
# Create Model
model_parameters = {
't_0': 2456836.22, 'u_0': 0.922, 't_E': 22.87,
Expand All @@ -322,6 +318,14 @@ def test_satellite_and_annual_parallax_calculation():
model_with_par = mm.Model(model_parameters, coords=coords)
model_with_par.parallax(satellite=True, earth_orbital=True,
topocentric=False)
return model_with_par


def test_satellite_and_annual_parallax_calculation():
"""
test that data magnifications are correctly retrieved for Spitzer data.
"""
model_with_par = create_0939_parallax_model()

# Load Spitzer data and answers
data_Spitzer = mm.MulensData(
Expand All @@ -334,6 +338,28 @@ def test_satellite_and_annual_parallax_calculation():
np.testing.assert_almost_equal(ratio, [1.]*len(ratio), decimal=4)


def test_get_d_u_d_params():
"""
Test that calculating derivatives with an ephemeris file is different from
without an ephemeris file.
"""
parameters = ['pi_E_N', 'pi_E_E']
model_with_par = create_0939_parallax_model()

data_ephm = mm.MulensData(
file_name=SAMPLE_FILE_03, ephemerides_file=SAMPLE_FILE_03_EPH)
fit_ephm = mm.FitData(dataset=data_ephm, model=model_with_par)
derivs_ephm = fit_ephm._get_d_u_d_params(parameters)

data_no_ephm = mm.MulensData(file_name=SAMPLE_FILE_03)
fit_no_ephm = mm.FitData(dataset=data_no_ephm, model=model_with_par)
derivs_no_ephm = fit_no_ephm._get_d_u_d_params(parameters)

for param in parameters:
assert (np.abs(
(derivs_ephm[param] / derivs_no_ephm[param] - 1.)) > 0.001).all()


def test_bad_data():
"""
test how chi2 and chi2_per_point are affected if some datapoints are set
Expand Down

1 comment on commit fda28dc

@rpoleski
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new test should be corrected - see issue #85

Please sign in to comment.