using proton charge as monitor, not tested with norm file

This commit is contained in:
2024-09-05 09:15:13 +02:00
parent be271c0b0a
commit af2cb1037a
2 changed files with 21 additions and 14 deletions

View File

@@ -37,8 +37,7 @@ class AmorData:
kap: float
lambdaMax: float
lambda_e: np.ndarray
monitor1: float
#monitor2: float
monitor: float
mu: float
nu: float
tau: float
@@ -69,14 +68,17 @@ class AmorData:
_detZ_e = []
_lamda_e = []
_wallTime_e = []
_monitor = 0
for file in self.file_list:
self.read_individual_data(file, norm)
_detZ_e = np.append(_detZ_e, self.detZ_e)
_lamda_e = np.append(_lamda_e, self.lamda_e)
_wallTime_e = np.append(_wallTime_e, self.wallTime_e)
_monitor += self.monitor
self.detZ_e = _detZ_e
self.lamda_e = _lamda_e
self.wallTime_e = _wallTime_e
self.monitor = _monitor
#-------------------------------------------------------------------------------------------------
#def path_generator(self, number):
@@ -167,15 +169,13 @@ class AmorData:
self.header.measurement_data_files.append(fileio.File(file=fileName.split('/')[-1], timestamp=self.fileDate))
logging.info(f' mu = {self.mu:6.3f}, nu = {self.nu:6.3f}, kap = {self.kap:6.3f}, kad = {self.kad:6.3f}')
# TODO: should extract monitor from counts or beam current times time
# using proton charge for normalisation
try:
self.monitor1 = self.hdf['/entry1/Amor/detector/proton_monitor/value'][1:].max()
logging.info(f' using proton charge = {int(self.monitor1)} mC as monitor')
self.monitor = self.hdf['/entry1/Amor/detector/proton_monitor/value'][1:].max() / 1e6
logging.info(f' using proton charge = {int(self.monitor)} C as monitor')
except NameError:
self.monitor1 = self.ctime
logging.info(f' using measurement time = {self.monitor1:.1f} s as monitor')
#self.monitor2 = self.monitor1
self.monitor = self.ctime
logging.info(f' using measurement time = {self.monitor:.1f} s as monitor')
self.read_event_stream()
totalNumber = np.shape(self.tof_e)[0]
@@ -281,7 +281,7 @@ class AmorData:
if not self.startTime and not norm:
self.startTime = self.wallTime_e[0]
self.wallTime_e -= self.startTime
logging.debug(f'wall time from {self.wallTime_e[0]} to {self.wallTime_e[-1]}')
logging.debug(f' wall time from {self.wallTime_e[0]} to {self.wallTime_e[-1]}')
def read_event_stream(self):
self.tof_e = np.array(self.hdf['/entry1/Amor/detector/data/event_time_offset'][:])/1.e9

View File

@@ -74,9 +74,13 @@ class AmorReduction:
def read_unsliced(self, i):
lamda_e = self.file_reader.lamda_e
detZ_e = self.file_reader.detZ_e
detZ_e = self.file_reader.detZ_e
qz_lz, qx_lz, ref_lz, err_lz, res_lz, lamda_lz, theta_lz, int_lz, self.mask_lz = self.project_on_lz(
self.file_reader, self.norm_lz, self.normAngle, lamda_e, detZ_e)
monitor = self.file_reader.monitor
if monitor>1 :
ref_lz *= 1/monitor
err_lz *= 1/monitor
try:
ref_lz *= self.reduction_config.scale[i]
err_lz *= self.reduction_config.scale[i]
@@ -318,6 +322,7 @@ class AmorReduction:
self.normFileList = np.load(fh, allow_pickle=True)
self.normAngle = np.load(fh, allow_pickle=True)
self.norm_lz = np.load(fh, allow_pickle=True)
self.normMonitor = np.load(fh, allow_pickle=True)
for i, entry in enumerate(self.normFileList):
self.normFileList[i] = entry.split('/')[-1]
self.header.measurement_additional_files = self.normFileList
@@ -328,8 +333,9 @@ class AmorReduction:
config=self.experiment_config,
short_notation=short_notation, norm=True)
self.normAngle = fromHDF.nu - fromHDF.mu
lamda_e = fromHDF.lamda_e
detZ_e = fromHDF.detZ_e
lamda_e = fromHDF.lamda_e
detZ_e = fromHDF.detZ_e
self.normMonitor = fromHDF.monitor
self.norm_lz, bins_l, bins_z = np.histogram2d(lamda_e, detZ_e, bins = (self.grid.lamda(), self.grid.z()))
self.norm_lz = np.where(self.norm_lz>2, self.norm_lz, np.nan)
# correct for the SM reflectivity
@@ -349,6 +355,7 @@ class AmorReduction:
np.save(fh, np.array(fromHDF.file_list), allow_pickle=False)
np.save(fh, np.array(self.normAngle), allow_pickle=False)
np.save(fh, self.norm_lz, allow_pickle=False)
np.save(fh, self.normMonitor, allow_pickle=False)
self.normFileList = fromHDF.file_list
self.header.reduction.corrections.append('normalisation with \'additional files\'')
@@ -401,8 +408,8 @@ class AmorReduction:
int_lz = np.where(mask_lz, int_lz, np.nan)
thetaF_lz = np.where(mask_lz, alphaF_lz, np.nan)
ref_lz = (int_lz * np.absolute(thetaN_lz)) / (norm_lz * np.absolute(thetaF_lz))
err_lz = ref_lz * np.sqrt( 1/(int_lz+.1) + 1/norm_lz )
ref_lz = (int_lz * np.absolute(thetaN_lz)) / (norm_lz * np.absolute(thetaF_lz)) * self.normMonitor
err_lz = ref_lz * np.sqrt( 1/(int_lz+.1) + 1/norm_lz )
res_lz = np.ones((np.shape(lamda_l[:-1])[0], np.shape(alphaF_z)[0])) * 0.022**2
res_lz = res_lz + (0.008/alphaF_lz)**2