reflectometry/refl1d

can't load single cross section as PolarizedNeutronProbe?

Opened this issue · 1 comments

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.

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)