Ejemplo n.º 1
0
def optimize_source_model(input_path, area_src_disc, output_path):
    """
    Read a source model and generate a new one, converting area sources to
    point sources.
    """
    area_src_disc = float(area_src_disc)
    source.optimize_source_model(input_path, area_src_disc, output_path)
    engine.complain_and_exit(output_path)
Ejemplo n.º 2
0
def optimize_source_model(input_path, area_src_disc, output_path):
    """
    Read a source model and generate a new one, converting area sources to
    point sources.
    """
    area_src_disc = float(area_src_disc)
    source.optimize_source_model(input_path, area_src_disc,
                                 output_path)
    engine.complain_and_exit(output_path)
Ejemplo n.º 3
0
    def test_optimize_source_model(self):
        in_file = helpers.touch(content=self.input_source_model)
        out_file = helpers.touch(content=self.output_source_model)
        area_src_disc = 50.0
        try:
            source_input.optimize_source_model(in_file, area_src_disc,
                                               out_file)
            expected = ElementTree.tostring(
                ElementTree.XML(self.output_source_model))

            actual = ElementTree.tostring(
                ElementTree.XML(open(out_file).read()))
            self.assertEqual(expected, actual)
        finally:
            os.unlink(in_file)
            os.unlink(out_file)
Ejemplo n.º 4
0
    def test_optimize_source_model(self):
        in_file = helpers.touch(content=self.input_source_model)
        out_file = helpers.touch(content=self.output_source_model)
        area_src_disc = 50.0
        try:
            source_input.optimize_source_model(in_file, area_src_disc,
                                               out_file)
            expected = ElementTree.tostring(
                ElementTree.XML(self.output_source_model))

            actual = ElementTree.tostring(
                ElementTree.XML(open(out_file).read()))
            self.assertEqual(expected, actual)
        finally:
            os.unlink(in_file)
            os.unlink(out_file)
Ejemplo n.º 5
0
 def test_optimize_source_model(self):
     in_file = helpers.touch(content=self.input_source_model)
     out_file = helpers.touch(content=self.output_source_model)
     area_src_disc = 50.0
     try:
         source_input.optimize_source_model(in_file, area_src_disc,
                                            out_file)
         expected = etree.tostring(
             etree.parse(StringIO.StringIO(self.output_source_model)),
             pretty_print=True
         )
         actual = etree.tostring(etree.parse(out_file), pretty_print=True)
         self.assertEqual(expected, actual)
     finally:
         os.unlink(in_file)
         os.unlink(out_file)