def test_instantiation_from_config(name, parameters): cp = WorkflowConfigParser() cp.add_section('test') ifo_name = 'ifo' cp.set('test', '{}_model'.format(ifo_name), name) for key in parameters: cp.set('test', '{}_{}'.format(ifo_name, key), parameters[key]) from_config = calibration.Recalibrate.from_config(cp, ifo_name, 'test') assert all([from_config.name == name, from_config.ifo_name == ifo_name])
def test_instantiation_from_config(self): parameters = dict(minimum_frequency='10', maximum_frequency='1024', n_points='5') cp = WorkflowConfigParser() cp.add_section('test') ifo_name = 'ifo' cp.set('test', '{}_model'.format(ifo_name), 'cubic_spline') for key in parameters: cp.set('test', '{}_{}'.format(ifo_name, key), parameters[key]) from_config = strain.read_model_from_config(cp, ifo_name, 'test') self.assertTrue(all([from_config.name == 'cubic_spline', from_config.ifo_name == ifo_name]))
def test_instantiation_from_config(self): parameters = dict(minimum_frequency='10', maximum_frequency='1024', n_points='5') cp = WorkflowConfigParser() cp.add_section('test') ifo_name = 'ifo' cp.set('test', '{}_model'.format(ifo_name), 'cubic_spline') for key in parameters: cp.set('test', '{}_{}'.format(ifo_name, key), parameters[key]) from_config = strain.read_model_from_config(cp, ifo_name, 'test') self.assertTrue( all([ from_config.name == 'cubic_spline', from_config.ifo_name == ifo_name ]))
def __init__(self, args, name): """ Create a pycbc workflow Parameters ---------- args : argparse.ArgumentParser The command line options to initialize a CBC workflow. """ super(Workflow, self).__init__(name) # Parse ini file self.cp = WorkflowConfigParser.from_args(args) # Dump the parsed config file ini_file = os.path.abspath(self.name + '_parsed.ini') if not os.path.isfile(ini_file): fp = open(ini_file, 'w') self.cp.write(fp) fp.close() else: logging.warn("Cowardly refusing to overwrite %s." %(ini_file)) # Set global values start_time = int(self.cp.get("workflow", "start-time")) end_time = int(self.cp.get("workflow", "end-time")) self.analysis_time = segments.segment([start_time, end_time]) # Set the ifos to analyse ifos = [] for ifo in self.cp.options('workflow-ifos'): ifos.append(ifo.upper()) self.ifos = ifos self.ifos.sort(key=str.lower) self.ifo_string = ''.join(self.ifos) # Set up input and output file lists for workflow self._inputs = FileList([]) self._outputs = FileList([])