コード例 #1
0
def test_simulate_lightcurve_flux():
    event = mock.MagicMock()
    telescope = mock.MagicMock()
    telescope.name = 'NDG'
    telescope.lightcurve_flux = np.array([[0, 51, 69], [2, 42, 28.65]])
    event.telescopes = []
    event.telescopes.append(telescope)

    model = microlsimulator.simulate_a_microlensing_model(event)
    parameters = microlsimulator.simulate_microlensing_model_parameters(model)

    fake_flux_parameters = microlsimulator.simulate_fluxes_parameters(
        event.telescopes)

    pyLIMA_parameters = model.compute_pyLIMA_parameters(parameters +
                                                        fake_flux_parameters)

    microlsimulator.simulate_lightcurve_flux(model, pyLIMA_parameters, 'No')

    assert np.all(telescope.lightcurve_flux[:, 1] != [51, 42])
    assert np.all(telescope.lightcurve_flux[:, 2] != [69, 28.65])

    microlsimulator.simulate_lightcurve_flux(model, pyLIMA_parameters, 'Yes')

    assert np.all(telescope.lightcurve_flux[:, 1] != [51, 42])
    assert np.all(telescope.lightcurve_flux[:, 2] != [69, 28.65])
コード例 #2
0
def test_simulate_fluxes_parameters():
    telescope = mock.MagicMock()
    telescopes = [telescope]

    fake_flux_parameters = microlsimulator.simulate_fluxes_parameters(telescopes)

    assert len(fake_flux_parameters) == 2

    assert fake_flux_parameters[0] > 10 ** ((27.4 - 22) / 2.5)
    assert fake_flux_parameters[0] < 10 ** ((27.4 - 14) / 2.5)

    assert fake_flux_parameters[1] < 1
    assert fake_flux_parameters[1] > 0
コード例 #3
0
def test_simulate_fluxes_parameters():
    telescope = mock.MagicMock()
    telescopes = [telescope]

    fake_flux_parameters = microlsimulator.simulate_fluxes_parameters(telescopes)

    assert len(fake_flux_parameters) == 2

    assert fake_flux_parameters[0] > 10 ** ((27.4 - 22) / 2.5)
    assert fake_flux_parameters[0] < 10 ** ((27.4 - 14) / 2.5)

    assert fake_flux_parameters[1] < 1
    assert fake_flux_parameters[1] > 0
コード例 #4
0
def test_simulate_lightcurve_flux():
    event = mock.MagicMock()
    telescope = mock.MagicMock()
    telescope.name = 'NDG'
    telescope.lightcurve_flux = np.array([[0, 51, 69], [2, 42, 28.65]])
    event.telescopes = []
    event.telescopes.append(telescope)

    model = microlsimulator.simulate_a_microlensing_model(event)
    parameters = microlsimulator.simulate_microlensing_model_parameters(model)

    fake_flux_parameters = microlsimulator.simulate_fluxes_parameters(event.telescopes)

    pyLIMA_parameters = model.compute_pyLIMA_parameters(parameters + fake_flux_parameters)

    microlsimulator.simulate_lightcurve_flux(model, pyLIMA_parameters, 'No')

    assert np.all(telescope.lightcurve_flux[:, 1] != [51, 42])
    assert np.all(telescope.lightcurve_flux[:, 2] != [69, 28.65])

    microlsimulator.simulate_lightcurve_flux(model, pyLIMA_parameters, 'Yes')

    assert np.all(telescope.lightcurve_flux[:, 1] != [51, 42])
    assert np.all(telescope.lightcurve_flux[:, 2] != [69, 28.65])
コード例 #5
0
    xallarap=['None', 0.0],
    orbital_motion=['None', 0.0],
    source_spots='None')

# Find some model parameters. If you want specific parameters, you need to respet pyLIMA convention when you create your
# parameters. For the DSPL example, my_own_parameters = [to, uo, delta_to, delta_uo, tE].
my_own_parameters = microlsimulator.simulate_microlensing_model_parameters(
    my_own_model)

# Which source magnitude? Which blending?
# Same here, you can create your own flux parameters with the convention
# [ [magnitude_source_i, blending ratio_i]] for i in telescopes. In our case it looks :
# [ [magnitude_source_survey, blending ratio_survey], [ magnitude_source_SAAO_I, blending ratio_SAAO_I],
# [magnitude_source_SAAO_V, blending ratio_SAAO_V]], i.e [[18.5,0.3],[19.5,1.2],[20.2,1.6]] (example).

my_own_flux_parameters = microlsimulator.simulate_fluxes_parameters(
    my_own_creation.telescopes)
my_own_parameters += my_own_flux_parameters

#Now we need to transform these parameters into a parameter class object (this is a "technical" part but the interested reader can found the function here  [pyLIMA #documentation](file/../../doc/build/html/pyLIMA.microlmodels.html))

# Transform into pyLIMA standards
pyLIMA_parameters = my_own_model.compute_pyLIMA_parameters(my_own_parameters)

#Ok now we have the model we want to simulate, we then need to updates our telescopes observations!

# update the telescopes lightcurve in your event :
microlsimulator.simulate_lightcurve_flux(my_own_model,
                                         pyLIMA_parameters,
                                         red_noise_apply='Yes')

#### Plot it!