Add theta filter for issues with parts of incoming divergence
This commit is contained in:
@@ -91,10 +91,12 @@ class ArgParsable:
|
||||
if get_origin(typ) is list:
|
||||
args['nargs'] = '+'
|
||||
typ = get_args(typ)[0]
|
||||
if get_origin(typ) is tuple:
|
||||
# tuple of items are put together during evaluation
|
||||
typ = get_args(typ)[0]
|
||||
elif get_origin(typ) is tuple:
|
||||
args['nargs'] = len(get_args(typ))
|
||||
typ = get_args(typ)[0]
|
||||
|
||||
if issubclass(typ, StrEnum):
|
||||
args['choices'] = [ci.value for ci in typ]
|
||||
if field.default is not MISSING:
|
||||
@@ -149,7 +151,12 @@ class ArgParsable:
|
||||
if get_origin(field.type) is Union and type(None) in get_args(field.type):
|
||||
# optional argument
|
||||
typ = get_args(field.type)[0]
|
||||
|
||||
if get_origin(typ) is list:
|
||||
item_typ = get_args(typ)[0]
|
||||
if get_origin(item_typ) is tuple:
|
||||
# tuple of items are put together during evaluation
|
||||
tuple_length = len(get_args(item_typ))
|
||||
value = [tuple(value[i*tuple_length+j] for j in range(tuple_length)) for i in range(len(value)//tuple_length)]
|
||||
if isinstance(typ, type) and issubclass(typ, StrEnum):
|
||||
# convert str to enum
|
||||
try:
|
||||
@@ -359,6 +366,14 @@ class ReflectivityReductionConfig(ArgParsable):
|
||||
'help': 'theta region of interest w.r.t. beam center',
|
||||
},
|
||||
)
|
||||
thetaFilters: List[Tuple[float, float]] = field(
|
||||
default_factory=lambda: [],
|
||||
metadata={
|
||||
'short': 'TF',
|
||||
'group': 'region of interest',
|
||||
'help': 'add one or more theta ranges that will be filtered in reduction',
|
||||
},
|
||||
)
|
||||
normalisationMethod: NormalisationMethod = field(
|
||||
default=NormalisationMethod.over_illuminated,
|
||||
metadata={
|
||||
@@ -701,6 +716,15 @@ class E2HReductionConfig(ArgParsable):
|
||||
},
|
||||
)
|
||||
|
||||
thetaFilters: List[Tuple[float, float]] = field(
|
||||
default_factory=lambda: [],
|
||||
metadata={
|
||||
'short': 'TF',
|
||||
'group': 'region of interest',
|
||||
'help': 'add one or more theta ranges that will be filtered in reduction',
|
||||
},
|
||||
)
|
||||
|
||||
fontsize: float = field(
|
||||
default=8.,
|
||||
metadata={
|
||||
|
||||
@@ -154,6 +154,8 @@ class E2HReduction:
|
||||
self.projection.correct_gravity(last_file_header.geometry.detectorDistance)
|
||||
self.projection.apply_lamda_mask(self.config.experiment.lambdaRange)
|
||||
self.projection.apply_theta_mask(thetaRange)
|
||||
for thi in self.config.reduction.thetaFilters:
|
||||
self.projection.apply_theta_filter((thi[0]+tthh, thi[1]+tthh))
|
||||
self.projection.apply_norm_mask(self.norm)
|
||||
|
||||
if self.config.reduction.plot==E2HPlotSelection.Q:
|
||||
@@ -163,6 +165,8 @@ class E2HReduction:
|
||||
plz.calculate_q()
|
||||
plz.apply_lamda_mask(self.config.experiment.lambdaRange)
|
||||
plz.apply_theta_mask(thetaRange)
|
||||
for thi in self.config.reduction.thetaFilters:
|
||||
self.projection.apply_theta_filter((thi[0]+tthh, thi[1]+tthh))
|
||||
plz.apply_norm_mask(self.norm)
|
||||
self.projection = ReflectivityProjector(plz, self.norm)
|
||||
|
||||
@@ -191,6 +195,8 @@ class E2HReduction:
|
||||
plz.calculate_q()
|
||||
plz.apply_lamda_mask(self.config.experiment.lambdaRange)
|
||||
plz.apply_theta_mask(thetaRange)
|
||||
for thi in self.config.reduction.thetaFilters:
|
||||
plz.apply_theta_filter((thi[0]+tthh, thi[1]+tthh))
|
||||
plz.apply_norm_mask(self.norm)
|
||||
pr = ReflectivityProjector(plz, self.norm)
|
||||
pyz = YZProjection()
|
||||
|
||||
@@ -373,8 +373,8 @@ class ReflectivityReduction:
|
||||
proj = LZProjection.from_dataset(dataset, self.grid,
|
||||
has_offspecular=(self.config.experiment.incidentAngle!=IncidentAngle.alphaF))
|
||||
|
||||
t0 = dataset.geometry.nu-dataset.geometry.mu
|
||||
if not self.config.reduction.is_default('thetaRangeR'):
|
||||
t0 = dataset.geometry.nu - dataset.geometry.mu
|
||||
# adjust range based on detector center
|
||||
thetaRange = [ti+t0 for ti in self.config.reduction.thetaRangeR]
|
||||
proj.apply_theta_mask(thetaRange)
|
||||
@@ -384,6 +384,9 @@ class ReflectivityReduction:
|
||||
thetaRange = [dataset.geometry.nu - dataset.geometry.mu - dataset.geometry.div/2,
|
||||
dataset.geometry.nu - dataset.geometry.mu + dataset.geometry.div/2]
|
||||
proj.apply_theta_mask(thetaRange)
|
||||
for thi in self.config.reduction.thetaFilters:
|
||||
# apply theta filters relative to angle on detector (issues with parts of the incoming divergence)
|
||||
proj.apply_theta_filter((thi[0]+t0, thi[1]+t0))
|
||||
|
||||
proj.apply_lamda_mask(self.config.experiment.lambdaRange)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user