diff --git a/Code/Mantid/instrument/sans_generator.py b/Code/Mantid/instrument/sans_generator.py index e7c72b440931..2464e97c9719 100644 --- a/Code/Mantid/instrument/sans_generator.py +++ b/Code/Mantid/instrument/sans_generator.py @@ -11,25 +11,25 @@ class Generator(object): pixel_size_x = 5.15/1000.0 ## Pixel size in Y [mm] pixel_size_y = 5.15/1000.0 - + ## Instrument name name = "GPSANS" - + ## Number of pixels n_pixels_x = 192 n_pixels_y = 192 - + def __init__(self, name="GPSANS", pixel_size_x=5.15, pixel_size_y=5.15): self.name = name self.pixel_size_x = float(pixel_size_x)/1000.0 self.pixel_size_y = float(pixel_size_y)/1000.0 - - + + def __call__(self): - + self._create_definition() self._create_parameters() - + def _create_definition(self): output = open("%s_Definition.xml" % self.name.upper(), 'w') input = open(DEFINITION_TEMPLATE, 'r') @@ -38,10 +38,10 @@ def _create_definition(self): l=l.replace("%last_modified%", time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())) l=l.replace("%pixel_positions%", self._get_positions()) l=l.replace("%pixels_ids%", self._get_ids()) - + half_x = self.pixel_size_x/2.0 half_y = self.pixel_size_y/2.0 - + l=l.replace("%pixel_left_front_bottom_x%", "%6.6f" % -half_x) l=l.replace("%pixel_left_front_bottom_y%", "%6.6f" % -half_y) l=l.replace("%pixel_left_front_top_x%", "%6.6f" % -half_x) @@ -54,7 +54,7 @@ def _create_definition(self): input.close() output.close() - + def _get_positions(self): positions = "" for i_x in range(self.n_pixels_x): @@ -62,9 +62,9 @@ def _get_positions(self): x = self.pixel_size_x * (i_x-self.n_pixels_x/2.0+0.5) y = self.pixel_size_y * (i_y-self.n_pixels_y/2.0+0.5) positions += " \n" % (y, x) - + return positions - + def _get_ids(self): ids = "" for i in range(self.n_pixels_y): @@ -72,7 +72,7 @@ def _get_ids(self): end = 1000000 + (self.n_pixels_x-1)*1000 + i ids += " \n" % (start, end) return ids - + def _create_parameters(self): output = open("%s_Parameters.xml" % self.name.upper(), 'w') input = open(PARAMETERS_TEMPLATE, 'r') @@ -87,7 +87,7 @@ def _create_parameters(self): input.close() output.close() - - + + if __name__ == '__main__': g = Generator(*sys.argv[1:])() \ No newline at end of file