Closed jokasimr closed 4 weeks ago
Here's a description of the basic idea of the procedure. There are two different ways to implement the reference correction, I'm not sure which one is the best to use. Possibly the best is just to use what Jochen is using now, and I think he's using the option that is not implemented in the PR. So this might be something we want to change.
Model the intensity obtained from the sample measurement as $$I^{sample}(z, \lambda)= I^{reference}(z, \lambda) R(Q(z, \lambda))$$ where $I^{reference}$ is the intensity obtained when $R(Q)=1$, $z$ is here not the coordinate in the global coordinate system, but instead the logical $z$-coordinate of the detector.
Two options for how to compute $R(Q)$
Update: Comparison between method 1 and method 2 mentioned above.
The results seem quite similar, so probably okay to leave it as is right now.
da = pl.compute(FootprintCorrectedData[Sample])\
.group('z_index').bin(wavelength=pl.compute(WBins))
n = pl.compute(NormalizationFactor)
R = da / sc.values(n)
q = n.coords['Q']
def compute_ioq(R, q, relaxation):
vR = R.copy(deep=True)
vR.data = sc.variances(vR.data)
A = sc.ones(dims=('z_index',), shape=(14*32,)) * (pl.compute(WBins)[1:] - pl.compute(WBins)[:-1])
# Add small relaxation factor to variances, increases noise in regions with few counts, but makes the inverse of the variances more well behaved
vR = A / (vR.hist() + sc.scalar(relaxation))
vR.coords['Q'] = q
return (R * vR).bins.concat().hist(Q=pl.compute(QBins)) / vR.flatten(to='Q').hist(Q=pl.compute(QBins))
f = sc.plot({
'method1(0.001)': compute_ioq(R, q, 0.001),
'method1(0.01)': compute_ioq(R, q, 0.01),
'method1(0.1)': compute_ioq(R, q, 0.1),
'method1(0.5)': compute_ioq(R, q, 0.5),
'method2': pl.compute(NormalizedIofQ).hist(),
}, norm='log')
f
The results seem quite similar, so probably okay to leave it as is right now.
There appear to be significant differences for some Q. Is it the scientist's judgement that this is irrelevant?
Is it the scientist's judgement that this is irrelevant?
No it is not.
Comparison between Jochens workflow and essreflectometry for all data files:
~The shift in $Q$ is likely due to a tof correction that is missing in essreflectometry.~ Probably done, might be another smaller correction left. Other differences might be due to differences in masking. Other differences might be due to bugs.
There are some things that I'm aware needs improvement, mainly, docstrings and tests.
@SimonHeybrock I think we would like you to check that all your comments have been addressed, but it is not required for you to go through everything again.
I added some 'reasonable' x positions for now. We are ignoring x in the coordinate transform, so I think we are good now :+1:
I added some 'reasonable' x positions for now. We are ignoring x in the coordinate transform, so I think we are good now 👍
Not sure what you mean by we're ignoring the x coord. It's used in the lambda computation.
Adding some reasonable dummy values is fine for me. I'll add an issue for figuring out the real values.
Not sure what you mean by we're ignoring the x coord. It's used in the lambda computation.
Ah it's ignored in the theta
computation, but not in the wavelength computation.
Fixes #38 Fixes #41
~This should not be merged in its current state.~ ~The workflow does not give the same result as the program Jochen has.~ ~Some parts of the notebook should be removed and placed elsewhere in the project, such as the geometry definition.~
Edit:
The workflow still does not match the PSI software results exactly, but at this point it is close enough, and we will fix the rest in a follow-up