Example #1
0
    def compute_the_microlensing_model(self, telescope, pyLIMA_parameters):
        """ Compute the microlens model according the injected parameters. This is modified by child submodel sublclass,
        if not the default microlensing model is returned.

        :param object telescope: a telescope object. More details in telescope module.
        :param object pyLIMA_parameters: a namedtuple which contain the parameters
        :returns: the microlensing model
        :rtype: array_like
        """
        lightcurve = telescope.lightcurve_flux
        time = lightcurve[:, 0] - 2456425

        amplification, u = self.model_magnification(telescope, pyLIMA_parameters)

        period = getattr(pyLIMA_parameters, 'period')

        pulsations = 0.0

        # factor = 0.0
        # pulsations = getattr(pyLIMA_parameters, 'AO'+'_' + telescope.filter)
        for i in xrange(self.number_of_harmonics):
            # mplitude = getattr(pyLIMA_parameters, 'A_' + str(i))
            # factor = getattr(pyLIMA_parameters, 'q_' + telescope.filter)
            # factor2 = getattr(pyLIMA_parameters, 'phi_' + telescope.filter)
            amplitude = getattr(pyLIMA_parameters, 'A' + str(i + 1) + '_' + telescope.filter)
            # phase = getattr(pyLIMA_parameters, 'phi_' + str(i) + '1')
            phase = getattr(pyLIMA_parameters, 'phi' + str(i + 1) + '_' + telescope.filter)

            # if telescope.filter != 'I':
            # amplitude *= getattr(pyLIMA_parameters, 'A'+str(i+1)+'_'+'I')
            # phase *= getattr(pyLIMA_parameters, 'phia'+str(i+1)+'_' +'I')
            # phase += getattr(pyLIMA_parameters, 'phib' + str(i + 1) + '_' + telescope.filter)
            # import pdb;
            # pdb.set_trace()
            # phase *=(1+factor2)
            pulsations += amplitude * np.cos(2 * np.pi * (i + 1) / period * time + phase)

        # import pdb;
        # pdb.set_trace()

        pulsations = 10 ** (-pulsations / 2.5)
        f_source, f_blending = self.derive_telescope_flux(telescope, pyLIMA_parameters, amplification, pulsations)

        # microlensing_model = f_source * pulsations * amplification + f_blending
        microlensing_model = f_source * amplification * pulsations + f_blending
        # Prior here.
        # print telescope.name,f_source,f_blending
        priors = microlpriors.microlensing_flux_priors(len(microlensing_model), f_source, f_blending / f_source)
        return microlensing_model, priors, f_source, f_blending
Example #2
0
    def _default_microlensing_model(self, telescope, pyLIMA_parameters, amplification):
        """ Compute the default microlens model according the injected parameters:

        flux(t) = f_source*magnification(t)+f_blending

        :param object telescope: a telescope object. More details in telescope module.
        :param object pyLIMA_parameters: a namedtuple which contain the parameters
        :param array_like amplification: the magnification associated to the model
        :returns: the microlensing model, the microlensing priors
        :rtype: array_like, float
        """

        f_source, g_blending = self.derive_telescope_flux(telescope, pyLIMA_parameters, amplification)

        microlensing_model = f_source * (amplification + g_blending)

        # Prior here
        priors = microlpriors.microlensing_flux_priors(len(microlensing_model), f_source, g_blending)
        # print 'the microl model', python_time.time() - start_time

        return microlensing_model, priors, f_source, g_blending