Skip to content

Commit

Permalink
Re #10137. Fixing python whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
peterfpeterson committed Aug 20, 2014
1 parent c290f1e commit 853c06c
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions Code/Mantid/instrument/sans_generator.py
Expand Up @@ -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')
Expand All @@ -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)
Expand All @@ -54,25 +54,25 @@ def _create_definition(self):

input.close()
output.close()

def _get_positions(self):
positions = ""
for i_x in range(self.n_pixels_x):
for i_y in range(self.n_pixels_y):
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 += " <location y=\"%6.6f\" x=\"%6.6f\" />\n" % (y, x)

return positions

def _get_ids(self):
ids = ""
for i in range(self.n_pixels_y):
start = 1000000 + i
end = 1000000 + (self.n_pixels_x-1)*1000 + i
ids += " <id start=\"%d\" step=\"1000\" end=\"%d\" />\n" % (start, end)
return ids

def _create_parameters(self):
output = open("%s_Parameters.xml" % self.name.upper(), 'w')
input = open(PARAMETERS_TEMPLATE, 'r')
Expand All @@ -87,7 +87,7 @@ def _create_parameters(self):

input.close()
output.close()


if __name__ == '__main__':
g = Generator(*sys.argv[1:])()

0 comments on commit 853c06c

Please sign in to comment.