reflectometry / refl1d

1-D reflectometry fitting
https://refl1d.readthedocs.io/
Other
17 stars 23 forks source link

can't load single cross section as PolarizedNeutronProbe? #141

Open bmaranville opened 2 years ago

bmaranville commented 2 years ago

Purnima reports that loading a file with a single cross-section results in a Probe, not a PolarizedNeutronProbe. This should not be the case when loading a file with polarization defined.

pkienzle commented 2 years ago

Yeah, it is right there in load4: if len(entries) == 1: ....

It is a feature that you can fit ++ and -- as independent non-polarized curves. So either load4 returns an unpolarized probe and the user needs to wrap it as a polarized neutron probe or load4 returns a polarized probe and the user needs to pull out the individual cross sections as unpolarized.

I think returning polarized is the better choice, so we need to change the condition to:

    CROSS_SECTIONS = {'++', '-+', '+-', '--'}
    polarization = strip_quotes(entry[0].get("polarization", ""))
    if len(entries) == 1 and polarization not in CROSS_SECTIONS:
        ...

Meanwhile, use:

    xs = load4(...)
    probe = PolarizedNeutronProbe([None, ..., xs, ...], Aguide=Aguide, H=H)