Commit f7b3c2e5 authored by Theo Steininger's avatar Theo Steininger

Added random_seed to MagneticField class.

parent 8575b02a
# -*- coding: utf-8 -*-
import numpy as np
from nifty import RGSpace, Field, FieldArray
from imagine.magnetic_fields.magnetic_field import MagneticField
......
......@@ -7,7 +7,7 @@ from nifty import Field, FieldArray, RGSpace
class MagneticField(Field):
def __init__(self, parameters=[], domain=None, val=None, dtype=None,
distribution_strategy=None, copy=False):
distribution_strategy=None, copy=False, random_seed=None):
super(MagneticField, self).__init__(
domain=domain,
......@@ -25,6 +25,12 @@ class MagneticField(Field):
for p in self.parameter_list:
self._parameters[p] = np.float(parameters[p])
self.random_seed = np.empty(self.shape[0], dtype=np.int)
if random_seed is None:
random_seed = np.random.randint(np.uint32(-1)/3,
size=self.shape[0])
self.random_seed[:] = random_seed
@property
def parameter_list(self):
return []
......
......@@ -42,6 +42,7 @@ class Hammurapy(Observer):
'do_dust': 'F',
'do_tau': 'F',
'do_ff': 'F',
'obs_freq_GHz': '23'
}
@abc.abstractproperty
......@@ -98,6 +99,7 @@ class Hammurapy(Observer):
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
random_seed = magnetic_field.random_seed[local_ensemble_index]
parameter_dict.update({'B_field_lx': lx,
'B_field_ly': ly,
......@@ -107,6 +109,7 @@ class Hammurapy(Observer):
'B_field_nz': nz,
})
parameter_dict.update({'obs_NSIDE': self.nside})
parameter_dict.update({'B_field_seed': random_seed})
def _write_parameter_dict(self, parameter_dict, working_directory):
parameters_string = ''
......
......@@ -12,8 +12,7 @@ class JF12Mixin(object):
'B_field_RMS_uG': '1',
'B_field_interp': 'T',
'use_B_analytic': 'F',
'B_ran_mem_lim': '4',
'obs_freq_GHz': '23'}
'B_ran_mem_lim': '4'}
super(JF12Mixin, self).__init__(hammurabi_executable,
conf_directory,
working_directory_base,
......
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