scipp / essreflectometry

Reflectometry data reduction for the European Spallation Source
https://scipp.github.io/essreflectometry/
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Reimplement ORSO filewriter #27

Closed jl-wynen closed 5 months ago

jl-wynen commented 5 months ago

~Fixes #6~ Most of #6 except tracking corrections.

This is still missing saving the actual data, tracking 'corrections', and filling in the remaining 'instrument' data. But it implements the basic mechanism and this part is ready for review.

For reference, adding it to the default pipeline like this:

from essreflectometry import orso as ess_orso
from essreflectometry.amor import orso as amor_orso
from essreflectometry.amor import providers, default_parameters
from essreflectometry.orso import providers as orso_providers
from essreflectometry.types import *
from orsopy import fileio

providers = (
    *providers,
    *amor_orso.providers,
    *orso_providers,
)

params = {
    **default_parameters,
    Filename[Sample]: "sample.nxs",
    Filename[Reference]: "reference.nxs",
    ess_orso.OrsoCreator: ess_orso.OrsoCreator(
        fileio.base.Person(
            name='Jan-Lukas',
            affiliation='ESS',
        )
    ),
}
pipeline = sciline.Pipeline(providers, params=params)

print(pipeline.compute((ess_orso.OrsoDataSource, ess_orso.OrsoReduction)))

results in

DataSource(
           owner=Person(name='J. Stahn', affiliation=None, contact='jochen.stahn@psi.ch'),
           experiment=Experiment(title='commissioning', instrument='AMOR', start_date=datetime.datetime(2020, 11, 25, 16, 3, 10), probe='neutron', facility='SINQ'),
           sample=Sample(name=None),
           measurement=Measurement(
                                   instrument_settings=None,
                                   data_files=[File(file='sample.nxs')],
                                   additional_files=[File(file='reference.nxs', comment='supermirror')],
                                   ),
           )
Reduction(
          software=Software(name='ess.reflectometry', version='23.11.1.dev18+gd1cfaa6.d20240124', platform='Linux'),
          timestamp=datetime.datetime(2024, 2, 2, 14, 58, 14, 919380, tzinfo=datetime.timezone.utc),
          creator=Person(name='Jan-Lukas', affiliation='ESS'),
          corrections=[],
          )

With this graph: Screenshot_20240202_155917

jl-wynen commented 5 months ago

ORSO also allows specifying the machine that the software runs on and the old code used this: https://github.com/scipp/ess/blob/5372ef6e91f2ee8bf4903c3db081b949e76952fd/src/ess/amor/orso.py#L47 I omitted this here because storing a user computer's name doesn't help much and seems like exposing private information. What do you think @jokasimr ?

jokasimr commented 5 months ago

ORSO also allows specifying the machine that the software runs on and the old code used this: https://github.com/scipp/ess/blob/5372ef6e91f2ee8bf4903c3db081b949e76952fd/src/ess/amor/orso.py#L47 I omitted this here because storing a user computer's name doesn't help much and seems like exposing private information. What do you think @jokasimr ?

Yes I noticed that as well. It seems unnecessary.

jl-wynen commented 5 months ago

It is now complete except for listing corrections.

We still need to figure out how do do that. The approach with tags that I outlined in the issue #6 will stop working when https://github.com/scipp/sciline/pull/116 is merged.

jl-wynen commented 5 months ago

I forgot to add tests. Did that now