Commit bc43115f authored by Ellert van der Velden's avatar Ellert van der Velden
Browse files

Created the remaining 5 observable mixins classes

parent 513e9f8c
# -*- coding: utf-8 -*-
import os
from nifty import Field, HPSpace
class DMMixin(object):
def _initialize_observable_dict(self, observable_dict, magnetic_field):
ensemble_space = magnetic_field.domain[0]
hpSpace = HPSpace(nside=self.nside)
observable_dict['dm'] = Field(domain=(ensemble_space, hpSpace),
distribution_strategy='equal')
super(DMMixin, self)._initialize_observable_dict(observable_dict,
magnetic_field)
def _build_parameter_dict(self, parameter_dict, magnetic_field,
working_directory, local_ensemble_index):
obs_DM_file_name = os.path.join(working_directory, 'dm.fits')
parameter_dict['do_dm'] = 'T'
parameter_dict['obs_DM_file_name'] = obs_DM_file_name
super(DMMixin, self)._build_parameter_dict(parameter_dict,
magnetic_field,
working_directory,
local_ensemble_index)
def _fill_observable_dict(self, observable_dict, working_directory,
local_ensemble_index):
self.logger.debug('Reading DM-map.')
[dm_map] = self._read_fits_file(path=working_directory,
name='dm.fits',
nside=self.nside)
dm_field = observable_dict['dm']
dm_field.val.data[local_ensemble_index] = dm_map
super(DMMixin, self)._fill_observable_dict(observable_dict,
working_directory,
local_ensemble_index)
# -*- coding: utf-8 -*-
import os
from nifty import Field, HPSpace, FieldArray
class DustMixin(object):
def _initialize_observable_dict(self, observable_dict, magnetic_field):
ensemble_space = magnetic_field.domain[0]
hpSpace = HPSpace(nside=self.nside)
fieldArray = FieldArray((3,))
observable_dict['dust'] = Field(domain=(ensemble_space, hpSpace,
fieldArray),
distribution_strategy='equal')
super(DustMixin, self)._initialize_observable_dict(observable_dict,
magnetic_field)
def _build_parameter_dict(self, parameter_dict, magnetic_field,
working_directory, local_ensemble_index):
obs_dust_file_name = os.path.join(working_directory, 'IQU_dust.fits')
parameter_dict['do_dust'] = 'T'
parameter_dict['obs_dust_file_name'] = obs_dust_file_name
super(DustMixin, self)._build_parameter_dict(parameter_dict,
magnetic_field,
working_directory,
local_ensemble_index)
def _fill_observable_dict(self, observable_dict, working_directory,
local_ensemble_index):
self.logger.debug('Reading Dust-map.')
[dust_I, dust_Q, dust_U] = self._read_fits_file(path=working_directory,
name='IQU_dust.fits',
nside=self.nside)
dust_field = observable_dict['dust']
dust_field.val.data[local_ensemble_index, :, 0] = dust_I
dust_field.val.data[local_ensemble_index, :, 1] = dust_Q
dust_field.val.data[local_ensemble_index, :, 2] = dust_U
super(DustMixin, self)._fill_observable_dict(observable_dict,
working_directory,
local_ensemble_index)
# -*- coding: utf-8 -*-
import os
from nifty import Field, HPSpace
class FFMixin(object):
def _initialize_observable_dict(self, observable_dict, magnetic_field):
ensemble_space = magnetic_field.domain[0]
hpSpace = HPSpace(nside=self.nside)
observable_dict['ff'] = Field(domain=(ensemble_space, hpSpace),
distribution_strategy='equal')
super(FFMixin, self)._initialize_observable_dict(observable_dict,
magnetic_field)
def _build_parameter_dict(self, parameter_dict, magnetic_field,
working_directory, local_ensemble_index):
obs_ff_file_name = os.path.join(working_directory, 'free.fits')
parameter_dict['do_ff'] = 'T'
parameter_dict['obs_ff_file_name'] = obs_ff_file_name
super(FFMixin, self)._build_parameter_dict(parameter_dict,
magnetic_field,
working_directory,
local_ensemble_index)
def _fill_observable_dict(self, observable_dict, working_directory,
local_ensemble_index):
self.logger.debug('Reading FF-map.')
[ff_map] = self._read_fits_file(path=working_directory,
name='free.fits',
nside=self.nside)
ff_field = observable_dict['ff']
ff_field.val.data[local_ensemble_index] = ff_map
super(FFMixin, self)._fill_observable_dict(observable_dict,
working_directory,
local_ensemble_index)
# -*- coding: utf-8 -*-
import os
from nifty import Field, HPSpace, FieldArray
class SyncMixin(object):
def _initialize_observable_dict(self, observable_dict, magnetic_field):
ensemble_space = magnetic_field.domain[0]
hpSpace = HPSpace(nside=self.nside)
fieldArray = FieldArray((3,))
observable_dict['sync'] = Field(domain=(ensemble_space, hpSpace,
fieldArray),
distribution_strategy='equal')
super(SyncMixin, self)._initialize_observable_dict(observable_dict,
magnetic_field)
def _build_parameter_dict(self, parameter_dict, magnetic_field,
working_directory, local_ensemble_index):
obs_sync_file_name = os.path.join(working_directory, 'IQU_sync.fits')
parameter_dict['do_sync_emission'] = 'T'
parameter_dict['obs_file_name'] = obs_sync_file_name
super(SyncMixin, self)._build_parameter_dict(parameter_dict,
magnetic_field,
working_directory,
local_ensemble_index)
def _fill_observable_dict(self, observable_dict, working_directory,
local_ensemble_index):
self.logger.debug('Reading Sync-map.')
[sync_I, sync_Q, sync_U] = self._read_fits_file(path=working_directory,
name='IQU_sync.fits',
nside=self.nside)
sync_field = observable_dict['sync']
sync_field.val.data[local_ensemble_index, :, 0] = sync_I
sync_field.val.data[local_ensemble_index, :, 1] = sync_Q
sync_field.val.data[local_ensemble_index, :, 2] = sync_U
super(SyncMixin, self)._fill_observable_dict(observable_dict,
working_directory,
local_ensemble_index)
# -*- coding: utf-8 -*-
import os
from nifty import Field, HPSpace
class TauMixin(object):
def _initialize_observable_dict(self, observable_dict, magnetic_field):
ensemble_space = magnetic_field.domain[0]
hpSpace = HPSpace(nside=self.nside)
observable_dict['tau'] = Field(domain=(ensemble_space, hpSpace),
distribution_strategy='equal')
super(TauMixin, self)._initialize_observable_dict(observable_dict,
magnetic_field)
def _build_parameter_dict(self, parameter_dict, magnetic_field,
working_directory, local_ensemble_index):
obs_tau_file_name = os.path.join(working_directory, 'tau.fits')
parameter_dict['do_tau'] = 'T'
parameter_dict['obs_tau_file_name'] = obs_tau_file_name
super(TauMixin, self)._build_parameter_dict(parameter_dict,
magnetic_field,
working_directory,
local_ensemble_index)
def _fill_observable_dict(self, observable_dict, working_directory,
local_ensemble_index):
self.logger.debug('Reading Tau-map.')
[tau_map] = self._read_fits_file(path=working_directory,
name='tau.fits',
nside=self.nside)
tau_field = observable_dict['tau']
tau_field.val.data[local_ensemble_index] = tau_map
super(TauMixin, self)._fill_observable_dict(observable_dict,
working_directory,
local_ensemble_index)
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