Commit 7b47efbb authored by Theo Steininger's avatar Theo Steininger

Improved logging

parent b0cc236d
......@@ -14,6 +14,7 @@ from magnetic_field import MagneticField
class MagneticFieldFactory(Loggable, object):
def __init__(self, box_dimensions, resolution):
self.logger.debug("Setting up MagneticFieldFactory.")
self.box_dimensions = box_dimensions
self.resolution = resolution
self._parameter_defaults = self._initial_parameter_defaults
......@@ -124,5 +125,6 @@ class MagneticFieldFactory(Loggable, object):
domain=domain,
parameters=work_parameters,
distribution_strategy='equal')
self.logger.debug("Generated magnetic field with work-parameters %s" %
work_parameters)
return result_magnetic_field
......@@ -144,6 +144,8 @@ class Hammurapy(Observer):
local_length = dummy.distributor.local_length
for local_ensemble_index in xrange(local_length):
self.logger.debug("Processing local_ensemble_index %i." %
local_ensemble_index)
# create a temporary folder
working_directory = self._make_temp_folder()
......@@ -165,130 +167,3 @@ class Hammurapy(Observer):
self._remove_folder(working_directory)
return observable_dict
###########
# def _make_parameter_file(self, working_directory, resolution, dimensions,
# custom_parameters={}):
#
# # setup the default parameters
# parameters_dict = {'B_field_lx': dimensions[0],
# 'B_field_ly': dimensions[1],
# 'B_field_lz': dimensions[2],
# 'B_field_nx': int(resolution[0]),
# 'B_field_ny': int(resolution[1]),
# 'B_field_nz': int(resolution[2]),
# }
#
# {
# 'do_sync_emission': 'T',
# 'do_rm': 'T',
# 'do_dm': 'F',
# 'do_dust': 'F',
# 'do_tau': 'F',
# 'do_ff': 'F'}
#
# if self.parameters_dict['do_sync_emission'] == 'T':
# obs_sync_file_name = os.path.join(working_directory,
# 'IQU_sync.fits')
# parameters_dict['obs_file_name'] = obs_sync_file_name
#
# if self.parameters_dict['do_rm'] == 'T':
# obs_RM_file_name = os.path.join(working_directory, 'rm.fits')
# parameters_dict['obs_RM_file_name'] = obs_RM_file_name
#
# if self.parameters_dict['do_dm'] == 'T':
# obs_DM_file_name = os.path.join(working_directory,
# 'dm.fits')
# parameters_dict['obs_DM_file_name'] = obs_DM_file_name
#
# if self.parameters_dict['do_dust'] == 'T':
# obs_dust_file_name = os.path.join(working_directory,
# 'IQU_dust.fits')
# parameters_dict['obs_dust_file_name'] = obs_dust_file_name
#
# if self.parameters_dict['do_tau'] == 'T':
# obs_tau_file_name = os.path.join(working_directory,
# 'tau.fits')
# parameters_dict['obs_tau_file_name'] = obs_tau_file_name
#
# if self.parameters_dict['do_ff'] == 'T':
# obs_ff_file_name = os.path.join(working_directory,
# 'free.fits')
# parameters_dict['obs_ff_file_name'] = obs_ff_file_name
#
# # ammend the parameters_dict
# parameters_dict.update(self.parameters_dict)
#
# # add custom parameters
# parameters_dict.update(custom_parameters)
#
# parameters_string = ''
# for item in parameters_dict:
# parameters_string += item + '=' + str(parameters_dict[item]) + '\n'
#
# parameters_file_path = os.path.join(working_directory,
# 'parameters.txt')
# with open(parameters_file_path, 'wb') as config_file:
# config_file.write(parameters_string)
#
#
#
#
# def _build_observables(self, temp_folder):
# observables = {}
# if self.parameters_dict['do_sync_emission'] == 'T':
# [sync_I, sync_Q, sync_U] = self._read_fits_file(temp_folder,
# 'IQU_sync.fits')
# logger.debug('Read the sync_map')
# observables['sync_observable'] = {'sync_I': sync_I,
# 'sync_Q': sync_Q,
# 'sync_U': sync_U}
#
# if self.parameters_dict['do_rm'] == 'T':
# [rm_map] = self._read_fits_file(temp_folder, 'rm.fits')
# logger.debug('Read the rm_map')
# observables['rm_observable'] = {'rm_map': rm_map}
#
# if self.parameters_dict['do_dm'] == 'T':
# [dm_map] = self._read_fits_file(temp_folder, 'dm.fits')
# logger.debug('Read the dm_map')
# observables['dm_observable'] = {'dm_map': dm_map}
#
# if self.parameters_dict['do_dust'] == 'T':
# [dust_I, dust_Q, dust_U] = self._read_fits_file(temp_folder,
# 'IQU_dust.fits')
# logger.debug('Read the dust_map')
# observables['dust_observable'] = {'dust_I': dust_I,
# 'dust_Q': dust_Q,
# 'dust_U': dust_U}
#
# if self.parameters_dict['do_tau'] == 'T':
# [tau_map] = self._read_fits_file(temp_folder, 'tau.fits')
# logger.debug('Read the tau_map')
# observables['tau_observable'] = {'tau_map': tau_map}
#
# if self.parameters_dict['do_ff'] == 'T':
# [ff_map] = self._read_fits_file(temp_folder, 'free.fits')
# logger.debug('Read the ff_map')
# observables['ff_observable'] = {'ff_map': ff_map}
#
# return observables
#
#############
#
# if self.do_sync_emission:
# result_observable['sync_emission'] = \
# Field(domain=(ensemble_space, hp128, FieldArray((3,))))
# if self.do_rm:
# result_observable['rm'] = Field(domain=(ensemble_space, hp128))
# if self.do_dm:
# result_observable['dm'] = Field(domain=(ensemble_space, hp128,))
# if self.do_dust:
# result_observable['dust'] = \
# Field(domain=(ensemble_space, hp128, FieldArray((3,))))
# if self.do_tau:
# result_observable['tau'] = Field(domain=(ensemble_space, hp128,))
# if self.do_ff:
# result_observable['ff'] = Field(domain=(ensemble_space, hp128,))
......@@ -141,7 +141,7 @@ class Pipeline(Loggable, object):
"rank==0.")
for i in xrange(1, size):
comm.send(cube_content, dest=i, tag=WORK_TAG)
self.logger.debug("Sent multinest-cube to rank %i" % i)
self.logger.debug("Sent multinest-cube to nodes with rank > 0.")
return self._core_likelihood(cube_content)
......@@ -179,14 +179,15 @@ class Pipeline(Loggable, object):
for like in self.likelihood:
likelihood += like(observables)
self.logger.debug("Evaluated likelihood: %f" % likelihood)
self.logger.info("Evaluated likelihood: %f for %s" %
(likelihood, str(cube)))
return likelihood
def __call__(self, variables):
if rank == 0:
# kickstart pymultinest
self.logger.info("starting pymultinest.")
self.logger.info("Starting pymultinest.")
if not os.path.exists("chains"):
os.mkdir("chains")
pymultinest.run(self._multinest_likelihood,
......
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