Commit 205c9675 authored by Theo Steininger's avatar Theo Steininger

Added pymultinest importer.

Adapted carrier_mapper.py to multinest prior cube.
parent 903a891b
...@@ -6,6 +6,8 @@ from magnetic_fields import * ...@@ -6,6 +6,8 @@ from magnetic_fields import *
from observers import * from observers import *
from priors import * from priors import *
from pymultinest import pymultinest
from pipeline import Pipeline from pipeline import Pipeline
import nifty import nifty
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
import numpy as np import numpy as np
def carrier_mapper(x, a=-np.inf, m=0, b=np.inf): def infinity_mapper(x, a=-np.inf, m=0, b=np.inf):
""" """
Maps x from [-inf, inf] into the interval [a, b], where x=0 -> m Maps x from [-inf, inf] into the interval [a, b], where x=0 -> m
""" """
...@@ -31,3 +31,11 @@ def carrier_mapper(x, a=-np.inf, m=0, b=np.inf): ...@@ -31,3 +31,11 @@ def carrier_mapper(x, a=-np.inf, m=0, b=np.inf):
# strech y to the interval [a,b] # strech y to the interval [a,b]
y = y*(b-a) + a y = y*(b-a) + a
return y return y
def unity_mapper(x, a=0, b=1):
"""
Maps x from [0, 1] into the interval [a, b]
"""
# rescale and shift
return x * (b-a) + a
...@@ -4,7 +4,7 @@ import numpy as np ...@@ -4,7 +4,7 @@ import numpy as np
from keepers import Loggable from keepers import Loggable
from imagine.carrier_mapper import carrier_mapper from imagine.carrier_mapper import unity_mapper
from nifty import FieldArray, RGSpace from nifty import FieldArray, RGSpace
...@@ -96,10 +96,13 @@ class MagneticFieldFactory(Loggable, object): ...@@ -96,10 +96,13 @@ class MagneticFieldFactory(Loggable, object):
for variable_name in variables: for variable_name in variables:
if variable_name in self.variable_to_parameter_mappings: if variable_name in self.variable_to_parameter_mappings:
mapping = self.variable_to_parameter_mappings[variable_name] mapping = self.variable_to_parameter_mappings[variable_name]
mapped_variable = carrier_mapper(variables[variable_name], mapped_variable = unity_mapper(variables[variable_name],
a=mapping[0], a=mapping[0],
m=mapping[1], b=mapping[2])
b=mapping[2]) # mapped_variable = carrier_mapper(variables[variable_name],
# a=mapping[0],
# m=mapping[1],
# b=mapping[2])
else: else:
mapped_variable = np.float(variables[variable_name]) mapped_variable = np.float(variables[variable_name])
parameter_dict[variable_name] = mapped_variable parameter_dict[variable_name] = mapped_variable
......
# -*- coding: utf-8 -*-
from pymultinest import pymultinest
# -*- coding: utf-8 -*-
class _MPI(object):
def __init__(self):
self.COMM_WORLD = _COMM_WORLD()
class _COMM_WORLD(object):
def Get_size(self):
return 1
MPI = _MPI()
# -*- coding: utf-8 -*-
import sys
import mpi4py
import mpi4py_shadow
mpi4py_backup = sys.modules['mpi4py']
sys.modules['mpi4py'] = mpi4py_shadow
import pymultinest
sys.modules['mpi4py'] = mpi4py_backup
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment