GitLab will be upgraded on June 23rd evening. During the upgrade the service will be unavailable, sorry for the inconvenience.

Commit 1d8f20eb authored by bliss administrator's avatar bliss administrator

Detector access only via the tomo object. The tomo detector can change on the fly.

parent 7598292f
......@@ -16,7 +16,6 @@ class ImageCorrection():
self.__flat_image = None
self.__tomo = None
self.__detector = None
@property
def name(self):
......@@ -33,10 +32,8 @@ class ImageCorrection():
return self.__config
def set_tomo(self, tomo):
self.__tomo = tomo
self.__detector = self.__tomo.tomo_ccd.detector
def take_dark(self):
......@@ -46,8 +43,8 @@ class ImageCorrection():
self.__dark_image = None
exposure_time = self.__tomo.parameters.exposure_time
file_format = self.__detector.saving.file_format
self.__detector.saving.file_format = "EDF"
file_format = self.__tomo.tomo_ccd.detector.saving.file_format
self.__tomo.tomo_ccd.detector.saving.file_format = "EDF"
try:
self.dark_off()
......@@ -56,15 +53,15 @@ class ImageCorrection():
dark_n = 1
dark_scan = self.__tomo.dark_scan(dark_n, exposure_time, save=True)
self.__dark_image = self.__detector.proxy.saving_directory + "/" + self.__detector.proxy.saving_prefix + \
"{:>04}".format(self.__detector.proxy.last_image_saved) + self.__detector.proxy.saving_suffix
self.__dark_image = self.__tomo.tomo_ccd.detector.proxy.saving_directory + "/" + self.__tomo.tomo_ccd.detector.proxy.saving_prefix + \
"{:>04}".format(self.__tomo.tomo_ccd.detector.proxy.last_image_saved) + self.__tomo.tomo_ccd.detector.proxy.saving_suffix
except:
self.__detector.saving.file_format = file_format
self.__tomo.tomo_ccd.detector.saving.file_format = file_format
raise
self.__detector.saving.file_format = file_format
self.__tomo.tomo_ccd.detector.saving.file_format = file_format
self.__detector.processing.background = self.__dark_image
self.__tomo.tomo_ccd.detector.processing.background = self.__dark_image
print(f"Background image = {self.__dark_image}")
def take_flat(self):
......@@ -74,8 +71,8 @@ class ImageCorrection():
self.__flat_image = None
exposure_time = self.__tomo.parameters.exposure_time
file_format = self.__detector.saving.file_format
self.__detector.saving.file_format = "EDF"
file_format = self.__tomo.tomo_ccd.detector.saving.file_format
self.__tomo.tomo_ccd.detector.saving.file_format = "EDF"
try:
self.flat_off()
......@@ -84,54 +81,43 @@ class ImageCorrection():
ref_n = 1
ref_scan =self.__tomo.ref_scan(ref_n, exposure_time, save=True)
self.__flat_image = self.__detector.proxy.saving_directory + "/" + self.__detector.proxy.saving_prefix + \
"{:>04}".format(self.__detector.proxy.last_image_saved) + self.__detector.proxy.saving_suffix
self.__flat_image = self.__tomo.tomo_ccd.detector.proxy.saving_directory + "/" + self.__tomo.tomo_ccd.detector.proxy.saving_prefix + \
"{:>04}".format(self.__tomo.tomo_ccd.detector.proxy.last_image_saved) + self.__tomo.tomo_ccd.detector.proxy.saving_suffix
except:
self.__detector.saving.file_format = file_format
self.__tomo.tomo_ccd.detector.saving.file_format = file_format
raise
self.__detector.saving.file_format = file_format
self.__tomo.tomo_ccd.detector.saving.file_format = file_format
self.__detector.processing.flatfield = self.__flat_image
self.__tomo.tomo_ccd.detector.processing.flatfield = self.__flat_image
print(f"Flatfield image = {self.__flat_image}")
#def on(self):
#if self.__detector.processing.background == None or self.__detector.processing.flatfield == None:
#raise RuntimeError("Cannot switch on! Missing image for dark or flat!")
#self.__detector.processing.use_background_substraction = "enable_file"
#self.__detector.processing.use_flatfield = True
#def off(self):
#self.__detector.processing.use_background_substraction = "disable"
#self.__detector.processing.use_flatfield = False
def dark_on(self):
if self.__detector.processing.background == None:
if self.__tomo.tomo_ccd.detector.processing.background == None:
raise RuntimeError("Cannot switch on! Missing image for dark")
self.__detector.processing.use_background_substraction = "enable_file"
self.__tomo.tomo_ccd.detector.processing.use_background_substraction = "enable_file"
def dark_off(self):
self.__detector.processing.use_background_substraction = "disable"
self.__tomo.tomo_ccd.detector.processing.use_background_substraction = "disable"
# be sure that it is applied
ct(self.__tomo.parameters.exposure_time)
def flat_on(self, normalize=True):
if self.__detector.processing.flatfield == None:
if self.__tomo.tomo_ccd.detector.processing.flatfield == None:
raise RuntimeError("Cannot switch on! Missing image for flat")
# set normaization
ff_proxy = self.__detector._get_proxy("flatfield")
ff_proxy = self.__tomo.tomo_ccd.detector._get_proxy("flatfield")
ff_proxy.normalize = normalize
# start
self.__detector.processing.use_flatfield = True
self.__tomo.tomo_ccd.detector.processing.use_flatfield = True
def flat_off(self):
self.__detector.processing.use_flatfield = False
self.__tomo.tomo_ccd.detector.processing.use_flatfield = False
# be sure that it is applied
ct(self.__tomo.parameters.exposure_time)
......@@ -146,12 +132,12 @@ class ImageCorrection():
return info_str
info_str = (f"tomo : {self.__tomo.name}\n")
info_str += (f"detector : {self.__tomo.tomo_ccd.detector.name}\n")
info_str += (f"dark_image : {self.__detector.processing.background}\n")
info_str += (f"flat_image : {self.__detector.processing.flatfield}\n")
info_str += (f"dark_image : {self.__tomo.tomo_ccd.detector.processing.background}\n")
info_str += (f"flat_image : {self.__tomo.tomo_ccd.detector.processing.flatfield}\n")
if self.__detector.processing.use_background_substraction == 'disable':
if self.__tomo.tomo_ccd.detector.processing.use_background_substraction == 'disable':
background = 'OFF'
if self.__detector.processing.use_flatfield == False:
if self.__tomo.tomo_ccd.detector.processing.use_flatfield == False:
flatfield = 'OFF'
info_str += (f"use_background_substraction : {background}\n")
info_str += (f"use_flatfield : {flatfield }\n")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment