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
On Thursday, 7th July from 1 to 3 pm there will be a maintenance with a short downtime of GitLab.
Open sidebar
ift
IMAGINE
Commits
f3c48059
Commit
f3c48059
authored
Nov 06, 2017
by
Theo Steininger
Browse files
Removed 'mean' from carrier_mapper
parent
8d30b8fe
Changes
6
Hide whitespace changes
Inline
Side-by-side
docker/Dockerfile
View file @
f3c48059
...
...
@@ -93,10 +93,11 @@ RUN python setup.py install
WORKDIR
..
#Hammurabi
RUN
git clone https://bitbucket.org/ricphy/hamx
-b
flexible_output
RUN
git clone https://bitbucket.org/ricphy/hamx
-b
maintenance
WORKDIR
hamx
RUN
cp install
/Makefile ./
RUN
make
-f
Makefile
ENV
HAMMURABI=/home/Downloads/hamx/bin/hamx
WORKDIR
..
#IMAGINE
...
...
imagine/carrier_mapper.py
View file @
f3c48059
...
...
@@ -33,12 +33,8 @@ def infinity_mapper(x, a=-np.inf, m=0, b=np.inf):
return
y
def
unity_mapper
(
x
,
a
=
0
,
m
=
0.5
,
b
=
1
):
def
unity_mapper
(
x
,
a
=
0
,
b
=
1
):
"""
Maps x from [0, 1] into the interval [a, b]
"""
# rescale and shift
if
x
<=
0.5
:
return
2
*
x
*
(
m
-
a
)
+
a
else
:
return
(
2
*
x
-
1
)
*
(
b
-
m
)
+
m
return
x
*
(
b
-
a
)
+
a
imagine/magnetic_fields/magnetic_field/magnetic_field_factory.py
View file @
f3c48059
...
...
@@ -69,11 +69,11 @@ class MagneticFieldFactory(Loggable, object):
@
staticmethod
def
_interval
(
mean
,
sigma
,
n
):
return
[
mean
-
n
*
sigma
,
mean
,
mean
+
n
*
sigma
]
return
[
mean
-
n
*
sigma
,
mean
+
n
*
sigma
]
@
staticmethod
def
_positive_interval
(
mean
,
sigma
,
n
):
return
[
max
(
0
,
mean
-
n
*
sigma
),
mean
,
mean
+
n
*
sigma
]
return
[
max
(
0
,
mean
-
n
*
sigma
),
mean
+
n
*
sigma
]
@
property
def
parameter_defaults
(
self
):
...
...
@@ -85,6 +85,15 @@ class MagneticFieldFactory(Loggable, object):
for
k
,
v
in
new_defaults
.
items
()
if
k
in
self
.
_parameter_defaults
)
@
property
def
variable_defaults
(
self
):
variable_defaults
=
{}
for
parameter
in
self
.
parameter_defaults
:
low
,
high
=
self
.
variable_to_parameter_mappings
[
parameter
]
default
=
self
.
parameter_defaults
[
parameter
]
variable_defaults
[
parameter
]
=
(
default
-
low
)
/
(
high
-
low
)
return
variable_defaults
@
property
def
variable_to_parameter_mappings
(
self
):
return
self
.
_variable_to_parameter_mappings
...
...
@@ -94,7 +103,7 @@ class MagneticFieldFactory(Loggable, object):
"""
The parameter-mapping must be a dictionary with
key: parameter-name
value: [min,
mean,
max]
value: [min, max]
"""
for
k
,
v
in
new_mapping
.
items
():
if
k
in
self
.
_variable_to_parameter_mappings
:
...
...
@@ -111,8 +120,7 @@ class MagneticFieldFactory(Loggable, object):
mapping
=
self
.
variable_to_parameter_mappings
[
variable_name
]
mapped_variable
=
unity_mapper
(
variables
[
variable_name
],
a
=
mapping
[
0
],
m
=
mapping
[
1
],
b
=
mapping
[
2
])
b
=
mapping
[
1
])
# mapped_variable = carrier_mapper(variables[variable_name],
# a=mapping[0],
# m=mapping[1],
...
...
imagine/magnetic_fields/wmap3yr_magnetic_field/wmap3yr_magnetic_field_factory.py
View file @
f3c48059
...
...
@@ -31,7 +31,7 @@ class WMAP3yrMagneticFieldFactory(MagneticFieldFactory):
'psi0'
:
self
.
_positive_interval
(
27.0
,
5.0
,
n
),
# psi0 astro-ph/0603450
'psi1'
:
self
.
_positive_interval
(
0.9
,
5.0
,
n
),
# psi1 astro-ph/0603450
'chi0'
:
self
.
_positive_interval
(
25
,
5.0
,
n
),
# xsi0 astro-ph/0603450
'random_rms'
:
self
.
_positive_interval
(
1.0
,
2
.0
,
n
),
'random_rho'
:
self
.
_positive_interval
(
0.5
,
1
/
6.
,
n
)
'random_rms'
:
self
.
_positive_interval
(
1.0
,
1
.0
,
n
),
'random_rho'
:
self
.
_positive_interval
(
0.5
,
0.166
,
n
)
}
return
defaults
imagine/observers/hammurapy/hammurapy.py
View file @
f3c48059
...
...
@@ -98,62 +98,6 @@ class Hammurapy(Observer):
distribution_strategy
=
'equal'
)
return
observable_dict
def
_build_parameter_dict
(
self
,
parameter_dict
,
magnetic_field
,
local_ensemble_index
):
parameter_dict
.
update
(
self
.
magnetic_field_model
.
parameter_dict
)
parameter_dict
.
update
(
{(
'./Interface/fe_grid'
,
'read'
):
'1'
,
(
'./Interface/fe_grid'
,
'filename'
):
os
.
path
.
join
(
self
.
input_directory
,
'fe_grid.bin'
),
})
# access the magnetic-field's random-seed d2o directly, since we
# know that the distribution strategy is the same for the
# randam samples and the magnetic field itself
random_seed
=
magnetic_field
.
random_seed
.
data
[
local_ensemble_index
]
parameter_dict
.
update
(
{(
'./Galaxy/MagneticField/Random'
,
'seed'
):
random_seed
})
for
key
,
value
in
magnetic_field
.
parameters
.
iteritems
():
large_key
=
magnetic_field
.
descriptor_lookup
[
key
]
parameter_dict
[
large_key
]
=
value
grid_space
=
magnetic_field
.
domain
[
1
]
lx
,
ly
,
lz
=
np
.
array
(
grid_space
.
shape
)
*
np
.
array
(
grid_space
.
distances
)
nx
,
ny
,
nz
=
grid_space
.
shape
parameter_dict
.
update
({(
'./Grid/Box/lx'
,
'value'
):
lx
,
(
'./Grid/Box/ly'
,
'value'
):
ly
,
(
'./Grid/Box/lz'
,
'value'
):
lz
,
(
'./Grid/Box/nx'
,
'value'
):
nx
,
(
'./Grid/Box/ny'
,
'value'
):
ny
,
(
'./Grid/Box/nz'
,
'value'
):
nz
})
parameter_dict
.
update
(
{(
'./Grid/Integration/nside'
,
'value'
):
self
.
nside
})
def
_write_parameter_file
(
self
,
working_directory
):
# load the default xml
try
:
default_parameters_xml
=
os
.
path
.
join
(
self
.
input_directory
,
'default_parameters.xml'
)
tree
=
et
.
parse
(
default_parameters_xml
)
except
IOError
:
import
imagine
module_path
=
os
.
path
.
split
(
imagine
.
observers
.
hammurapy
.
__file__
)[
0
]
default_parameters_xml
=
os
.
path
.
join
(
module_path
,
'input/default_parameters.xml'
)
tree
=
et
.
parse
(
default_parameters_xml
)
root
=
tree
.
getroot
()
for
key
,
value
in
parameter_dict
.
iteritems
():
root
.
find
(
key
[
0
]).
set
(
key
[
1
],
str
(
value
))
parameters_file_path
=
os
.
path
.
join
(
working_directory
,
'parameters.xml'
)
tree
.
write
(
parameters_file_path
)
def
_write_parameter_xml
(
self
,
magnetic_field
,
local_ensemble_index
,
working_directory
):
# load the default xml
...
...
@@ -175,6 +119,7 @@ class Hammurapy(Observer):
custom_parameters
=
[
[
'./Grid/Integration/shell/auto/nside_min'
,
'value'
,
self
.
nside
],
[
'./Grid/Integration/nside_sim'
,
'value'
,
self
.
nside
],
[
'./Interface/fe_grid'
,
'read'
,
'1'
],
[
'./Interface/fe_grid'
,
'filename'
,
os
.
path
.
join
(
self
.
input_directory
,
'fe_grid.bin'
)]
...
...
imagine/observers/hammurapy/input/default_parameters.xml
View file @
f3c48059
...
...
@@ -71,7 +71,7 @@
</shell>
<nside_sim
value=
"16"
/>
<!-- output map resolution -->
<!-- maximum radius in earth/Galactic centric frame -->
<ec_r_max
value=
"3
0
.0"
/>
<!-- kpc -->
<ec_r_max
value=
"3.0"
/>
<!-- kpc -->
<gc_r_max
value=
"20.0"
/>
<!-- kpc -->
<!-- maximum height in galactic centric frame -->
<gc_z_max
value=
"10.0"
/>
<!-- kpc -->
...
...
@@ -209,8 +209,7 @@
<!-- verification -->
<Verify>
<n0
value=
"0.01"
/>
<!-- pccm -->
<r0
value=
"20.0"
/>
<!-- kpc -->
<z0
value=
"0.1"
/>
<!-- kpc -->
<r0
value=
"3.0"
/>
<!-- kpc -->
</Verify>
</Regular>
<!-- turbulent free electron -->
...
...
@@ -257,8 +256,7 @@
<!-- verification -->
<Verify>
<alpha
value=
"3.0"
/>
<r0
value=
"20.0"
/>
<!-- kpc -->
<z0
value=
"1.0"
/>
<!-- kpc -->
<r0
value=
"3.0"
/>
<!-- kpc -->
<je
value=
"0.25"
/>
<!-- local CRE flux norm factor @ 10GeV -->
</Verify>
...
...
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