rs-station / reciprocalspaceship

Tools for exploring reciprocal space
https://rs-station.github.io/reciprocalspaceship/
MIT License
28 stars 12 forks source link

Converting Structure Factors to Intensities #148

Closed kmdalton closed 2 years ago

kmdalton commented 2 years ago

We have made it easy to convert intensities to structure factors using our French-Wilson implementation. However, sometimes I find myself wanting to go the other direction. This is especially useful in comparing careless output to other methods.

I propose we provide a method for doing this conversion which takes into account uncertainties. By this I mean,

1) From the definition of variance, I = SigF*SigF + F*F 2) From uncertainty propation, SigI = abs(2*F*SigF)

Note that 2 is only approximate, we could do better if we knew the distribution of F. For starters, we could just add this as a function in the algorithms submodule.

JBGreisman commented 2 years ago

I think this is a reasonable request. I agree it should go in rs.algorithms, and I think it will be important to explicitly specify the assumptions that go into this.

Personally, I don't have a use-case for this, but it seems like a reasonable place to include these equations if they are useful to careless

dennisbrookner commented 2 years ago

Does it seem prudent to give these columns a name that explicitly describes what has been done? Just so as to a) not overwrite existing columns and b) avoid confusion/misinterpretation. Call it like, I_backcalc or I_fromF or something snappier and equally informative.

JBGreisman commented 2 years ago

to avoid that issue, I think we could use an API that returns a new DataSet object (similar to what we do for rs.algorithms.scale_merged_intensities().

dennisbrookner commented 2 years ago

@kmdalton Could you point me towards a suitable dataset for testing that contains F/SigF columns, or even better, contains F/SigF and also I/SigI two which they could be compared?

dennisbrookner commented 2 years ago

You could send it to me offline, or put I suppose just put it in the tests/data directory on the intensities-clean branch

kmdalton commented 2 years ago

i believe this file in tests/data/algorithms fits the bill. As per tests/algorithms/conftest.py, it should be available to tests in the tests/algorithms namespace under the fixture: ref_hewl.

Let me know if that works for you.

dennisbrookner commented 2 years ago

Ah amazing, thanks!