Exemplo n.º 1
0
    def params(self):
        """Get params from param file."""
        if simulators.paths["parameters"].startswith("."):
            param_file = os.path.join(self.base, "../",
                                      simulators.paths["parameters"],
                                      "{}_params.dat".format(self.name))
        else:
            param_file = os.path.join(simulators.paths["parameters"],
                                      "{}_params.dat".format(self.name))
        params = parse_paramfile(param_file, path=None)
        print(params)
        print("self mode", self.mode)
        if self.mode == "bhm":
            host_params = target_params(params, mode=self.mode)
            closest_host_model = closest_model_params(
                *host_params)  # unpack temp, logg, fe_h with *
        else:
            host_params, comp_params = target_params(params, mode=self.mode)
            closest_host_model = closest_model_params(
                *host_params)  # unpack temp, logg, fe_h with *
            closest_comp_model = closest_model_params(*comp_params)
            params.update({
                "teff_2": closest_comp_model[0],
                "logg_2": closest_comp_model[1],
                "feh_2": closest_comp_model[2]
            })

        params.update({
            "teff_1": closest_host_model[0],
            "logg_1": closest_host_model[1],
            "feh_1": closest_host_model[2]
        })
        return params
Exemplo n.º 2
0
def test_target_parameters_from_dict(params, mode, expected):
    result = target_params(params, mode=mode)
    if isinstance(result, tuple):
        assert np.all(result[0] == expected[0])
        assert np.all(result[1] == expected[1])
        assert mode == "iam"
    else:
        assert mode == "bhm"
        assert np.all(result == expected[0])
Exemplo n.º 3
0
def test_target_parameters_invalid_mode(params_1, mode):
    with pytest.raises(ValueError):
        target_params(params_1, mode=mode)
Exemplo n.º 4
0
def test_target_parameters_with_comp_vals_in_file(params_2):
    host, comp = target_params(params_2, mode="iam")
    assert np.all(host == [5340, 4.65, -0.22])
    assert np.all(comp == [1733, 5.3, -0.4])
Exemplo n.º 5
0
def test_target_parameters_comp_not_in_file(params_1):
    host, comp = target_params(params_1, mode="iam")
    assert np.all(host == [5340, 4.65, -0.22])
    assert np.all(comp == [1733, 4.65, -0.22])