forked from M-Labs/artiq
1
0
Fork 0

remote_exec_processing: style

This commit is contained in:
Robert Jördens 2016-04-14 19:06:01 +08:00
parent 4a297f0c42
commit b36eded2e1
1 changed files with 4 additions and 2 deletions

View File

@ -13,13 +13,14 @@ def compute_gaussian(r, img_w, img_h,
gaussian_cx, gaussian_cy): gaussian_cx, gaussian_cy):
for y in range(img_h): for y in range(img_h):
for x in range(img_w): for x in range(img_w):
ds = ((gaussian_cx-x)/gaussian_w)**2 ds = ((gaussian_cx-x)/gaussian_w)**2
ds += ((gaussian_cy-y)/gaussian_h)**2 ds += ((gaussian_cy-y)/gaussian_h)**2
r[x, y] = np.exp(-ds/2) r[x, y] = np.exp(-ds/2)
def fit(data, get_dataset): def fit(data, get_dataset):
img_w, img_h = data.shape img_w, img_h = data.shape
def err(parameters): def err(parameters):
r = np.empty((img_w, img_h)) r = np.empty((img_w, img_h))
compute_gaussian(r, img_w, img_h, *parameters) compute_gaussian(r, img_w, img_h, *parameters)
@ -38,6 +39,7 @@ def fit(data, get_dataset):
def get_and_fit(): def get_and_fit():
if "dataset_db" in globals(): if "dataset_db" in globals():
logger.info("using dataset DB for Gaussian fit guess") logger.info("using dataset DB for Gaussian fit guess")
def get_dataset(name, default): def get_dataset(name, default):
try: try:
return dataset_db.get(name) return dataset_db.get(name)
@ -45,7 +47,7 @@ def get_and_fit():
return default return default
else: else:
logger.info("using defaults for Gaussian fit guess") logger.info("using defaults for Gaussian fit guess")
def get_dataset(name, default): def get_dataset(name, default):
return default return default
get_dataset = lambda name, default: default
return fit(controller_driver.get_picture(), get_dataset) return fit(controller_driver.get_picture(), get_dataset)