Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ift
IMAGINE
Commits
205c9675
Commit
205c9675
authored
Feb 21, 2017
by
Theo Steininger
Browse files
Added pymultinest importer.
Adapted carrier_mapper.py to multinest prior cube.
parent
903a891b
Changes
6
Hide whitespace changes
Inline
Side-by-side
imagine/__init__.py
View file @
205c9675
...
...
@@ -6,6 +6,8 @@ from magnetic_fields import *
from
observers
import
*
from
priors
import
*
from
pymultinest
import
pymultinest
from
pipeline
import
Pipeline
import
nifty
...
...
imagine/carrier_mapper.py
View file @
205c9675
...
...
@@ -3,7 +3,7 @@
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
"""
...
...
@@ -31,3 +31,11 @@ def carrier_mapper(x, a=-np.inf, m=0, b=np.inf):
# strech y to the interval [a,b]
y
=
y
*
(
b
-
a
)
+
a
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
imagine/magnetic_fields/magnetic_field/magnetic_field_factory.py
View file @
205c9675
...
...
@@ -4,7 +4,7 @@ import numpy as np
from
keepers
import
Loggable
from
imagine.carrier_mapper
import
carrier
_mapper
from
imagine.carrier_mapper
import
unity
_mapper
from
nifty
import
FieldArray
,
RGSpace
...
...
@@ -96,10 +96,13 @@ class MagneticFieldFactory(Loggable, object):
for
variable_name
in
variables
:
if
variable_name
in
self
.
variable_to_parameter_mappings
:
mapping
=
self
.
variable_to_parameter_mappings
[
variable_name
]
mapped_variable
=
carrier_mapper
(
variables
[
variable_name
],
a
=
mapping
[
0
],
m
=
mapping
[
1
],
b
=
mapping
[
2
])
mapped_variable
=
unity_mapper
(
variables
[
variable_name
],
a
=
mapping
[
0
],
b
=
mapping
[
2
])
# mapped_variable = carrier_mapper(variables[variable_name],
# a=mapping[0],
# m=mapping[1],
# b=mapping[2])
else
:
mapped_variable
=
np
.
float
(
variables
[
variable_name
])
parameter_dict
[
variable_name
]
=
mapped_variable
...
...
imagine/pymultinest/__init__.py
0 → 100644
View file @
205c9675
# -*- coding: utf-8 -*-
from
pymultinest
import
pymultinest
imagine/pymultinest/mpi4py_shadow.py
0 → 100644
View file @
205c9675
# -*- 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
()
imagine/pymultinest/pymultinest.py
0 → 100644
View file @
205c9675
# -*- 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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment