Repository navigation
fluo_corr: normalize with the group's pre_edge ranges - #637
Merged
Merged
Conversation
fluo_corr looked for the group's normalization in pre_edge_details.call_args, which pre_edge never sets, so it always used its own defaults (norm1=100, nnorm=1) and re-found E0 on the corrected spectrum. On a short XANES scan norm1=100 is past the last point, and norm_corr is not comparable with norm. Use the ranges pre_edge stored in pre_edge_details, and the group's e0.
Member
|
@jhuang165 Thanks -- you are absolutely right that We should probably also force the call to |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fluo_corr()means to normalize with the optionspre_edge()used for the group, but it reads them fromgroup.pre_edge_details.call_args, whichpre_edge()never sets (the arguments go togroup.callargs.pre_edgethroughMake_CallArgs). So it always falls back to its own defaults:norm1=100,nnorm=1,pre2=-30, with E0 found again on each spectrum. Larix's Fluo Corr panel callsfluo_corr()without range keywords, so it goes through this path too.That matters in two places:
mu * alpha / (alpha + 1 - norm)), so a different normalization gives a differentmu_corr.norm_corrisn't normalized likenorm, so the two can't be compared directly. On a short XANES scannorm1=100can be past the last point. On a Fe K-edge fluorescence scan ending 98.5 eV above E0, withpre_edge()defaults, the corrected peak came out 1.171. Correcting with the group's own ranges gives 1.167, and that's also what you get by runningpre_edge()onmu_corrwith those ranges.This PR takes
pre1,pre2,norm1,norm2andnnormfromgroup.pre_edge_details, plusgroup.e0. Those are the valuespre_edge()actually used, including the ones it chose itself. Keywords passed tofluo_corr()still override them, and a group that was never normalized behaves as before.I first tried
group.callargs.pre_edge. That only records what the caller passed, mostlyNone, sopreedge()re-derived E0 and the ranges from the corrected spectrum, andnorm_corrstill differed fromnorm's normalization (1.172 in the example above).tests/test_xafs_fluo.pychecks thatfluo_corr()on a normalized group matches passing the group's ranges explicitly, after default and after custompre_edge()options, usingexamples/xafsdata/fe2o3_rt1.xmu. Both cases fail on master and pass with the change.I found this while fixing
larch_fluo_corrin xraylarch-mcp (Joint-Photon-Sciences-Institute/xraylarch-mcp#5), which now passes the ranges explicitly as a workaround.