Beispiel #1
0
def simulate_a_microlensing_model(event,
                                  model='PSPL',
                                  args=(),
                                  parallax=['None', 0.0],
                                  xallarap=['None', 0.0],
                                  orbital_motion=['None', 0.0],
                                  source_spots='None'):
    """ Simulate a a microlensing model.

        :param object event: the microlensing event you look at. More details in event module
        :param str model: the microlensing model you want. Default is 'PSPL'. More details in microlmodels module
        :param array_like parallax : the parallax effect you want to add. Default is no parallax.
                                     More details in microlmodels module
        :param array_like xallarap : the xallarap effect you want to add. Default is no parallax.
                                     More details in microlmodels module
        :param str source_spots : If you want to add source spots. Default is no source_spots.
                                     More details in microlmodels module

        :return: a model object
        :rtype: object
    """

    fake_model = microlmodels.create_model(model, event, args, parallax,
                                           xallarap, orbital_motion,
                                           source_spots)
    fake_model.define_model_parameters()

    return fake_model
Beispiel #2
0
def simulate_a_microlensing_model(event, model='PSPL', parallax=['None', 0.0], xallarap=['None', 0.0],
                                  orbital_motion=['None', 0.0], source_spots='None'):
    """ Simulate a a microlensing model.

        :param object event: the microlensing event you look at. More details in event module
        :param str model: the microlensing model you want. Default is 'PSPL'. More details in microlmodels module
        :param array_like parallax : the parallax effect you want to add. Default is no parallax.
                                     More details in microlmodels module
        :param array_like xallarap : the xallarap effect you want to add. Default is no parallax.
                                     More details in microlmodels module
        :param str source_spots : If you want to add source spots. Default is no source_spots.
                                     More details in microlmodels module

        :return: a model object
        :rtype: object
    """

    fake_model = microlmodels.create_model(model, event, parallax, xallarap,
                                           orbital_motion, source_spots)
    fake_model.define_model_parameters()

    return fake_model
Beispiel #3
0
    def initial_guess(self):
        """Try to estimate the microlensing parameters. Only use for PSPL and FSPL
           models. More details on microlguess module.

           :return guess_parameters: a list containing parameters guess related to the model.
           :rtype: list
        """

        if len(self.model.parameters_guess) == 0:

            # Estimate  the Paczynski parameters

            if self.model.model_type == 'PSPL':
                guess_paczynski_parameters, f_source = microlguess.initial_guess_PSPL(self.event)

            if self.model.model_type == 'FSPL':
                guess_paczynski_parameters, f_source = microlguess.initial_guess_FSPL(self.event)

            if self.model.model_type == 'DSPL':
                guess_paczynski_parameters, f_source = microlguess.initial_guess_DSPL(self.event)

            # Estimate  the telescopes fluxes (flux_source + g_blending) parameters, with a PSPL model

            fake_model = microlmodels.create_model('PSPL', self.event)
            fake_model.define_model_parameters()
            telescopes_fluxes = self.find_fluxes(guess_paczynski_parameters, fake_model)

            # The survey fluxes are already known from microlguess
            telescopes_fluxes[0] = f_source
            telescopes_fluxes[1] = 0.0

            if self.model.parallax_model[0] != 'None':
                guess_paczynski_parameters = guess_paczynski_parameters + [0.0, 0.0]

            if self.model.xallarap_model[0] != 'None':
                guess_paczynski_parameters = guess_paczynski_parameters + [0, 0]

            if self.model.orbital_motion_model[0] != 'None':
                guess_paczynski_parameters = guess_paczynski_parameters + [0, 0]

            if self.model.source_spots_model != 'None':
                guess_paczynski_parameters = guess_paczynski_parameters + [0]



        else:

            guess_paczynski_parameters = list(self.model.parameters_guess)

            telescopes_fluxes = self.find_fluxes(guess_paczynski_parameters, self.model)

        guess_paczynski_parameters += telescopes_fluxes

        guess_parameters_pyLIMA_standards = collections.namedtuple('parameters',
                                                                   self.model.pyLIMA_standards_dictionnary.keys())

        for key_parameter in self.model.pyLIMA_standards_dictionnary.keys():

            try:
                setattr(guess_parameters_pyLIMA_standards, key_parameter,
                        guess_paczynski_parameters[self.model.pyLIMA_standards_dictionnary[key_parameter]])

            except:

                pass

        fancy_parameters_guess = self.model.pyLIMA_standard_parameters_to_fancy_parameters(
            guess_parameters_pyLIMA_standards)

        model_guess_parameters = []
        for key_parameter in self.model.model_dictionnary.keys():
            model_guess_parameters.append(getattr(fancy_parameters_guess, key_parameter))

        print sys._getframe().f_code.co_name, ' : Initial parameters guess SUCCESS'
        return model_guess_parameters
Beispiel #4
0
    def initial_guess(self):
        """Try to estimate the microlensing parameters. Only use for PSPL and FSPL
           models. More details on microlguess module.

           :return guess_parameters: a list containing parameters guess related to the model.
           :rtype: list
        """

        if len(self.model.parameters_guess) == 0:

            # Estimate  the Paczynski parameters

            if self.model.model_type == 'PSPL':
                guess_paczynski_parameters, f_source = microlguess.initial_guess_PSPL(
                    self.event)

            if self.model.model_type == 'FSPL':
                guess_paczynski_parameters, f_source = microlguess.initial_guess_FSPL(
                    self.event)

            if self.model.model_type == 'DSPL':
                guess_paczynski_parameters, f_source = microlguess.initial_guess_DSPL(
                    self.event)

            # Estimate  the telescopes fluxes (flux_source + g_blending) parameters, with a PSPL model

            fake_model = microlmodels.create_model('PSPL', self.event)
            fake_model.define_model_parameters()
            telescopes_fluxes = self.find_fluxes(guess_paczynski_parameters,
                                                 fake_model)

            # The survey fluxes are already known from microlguess
            telescopes_fluxes[0] = f_source
            telescopes_fluxes[1] = 0.0

            if self.model.parallax_model[0] != 'None':
                guess_paczynski_parameters = guess_paczynski_parameters + [
                    0.0, 0.0
                ]

            if self.model.xallarap_model[0] != 'None':
                guess_paczynski_parameters = guess_paczynski_parameters + [
                    0, 0
                ]

            if self.model.orbital_motion_model[0] != 'None':
                guess_paczynski_parameters = guess_paczynski_parameters + [
                    0, 0
                ]

            if self.model.source_spots_model != 'None':
                guess_paczynski_parameters = guess_paczynski_parameters + [0]

        else:

            guess_paczynski_parameters = list(self.model.parameters_guess)

            telescopes_fluxes = self.find_fluxes(guess_paczynski_parameters,
                                                 self.model)

        guess_paczynski_parameters += telescopes_fluxes

        guess_parameters_pyLIMA_standards = collections.namedtuple(
            'parameters', self.model.pyLIMA_standards_dictionnary.keys())

        for key_parameter in self.model.pyLIMA_standards_dictionnary.keys():

            try:
                setattr(
                    guess_parameters_pyLIMA_standards, key_parameter,
                    guess_paczynski_parameters[
                        self.model.pyLIMA_standards_dictionnary[key_parameter]]
                )

            except:

                pass

        fancy_parameters_guess = self.model.pyLIMA_standard_parameters_to_fancy_parameters(
            guess_parameters_pyLIMA_standards)

        model_guess_parameters = []
        for key_parameter in self.model.model_dictionnary.keys():
            model_guess_parameters.append(
                getattr(fancy_parameters_guess, key_parameter))

        print sys._getframe(
        ).f_code.co_name, ' : Initial parameters guess SUCCESS'
        return model_guess_parameters