diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..6cad2d9 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,68 @@ +name: Release + +# Controls when the action will run. +on: + # Triggers the workflow on push or pull request events but only for the master branch + push: + tags: + - "*" + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + inputs: + build-items: + description: 'Items to be build' + required: true + default: 'all' + type: choice + options: + - all + - windows + - linux + - mac + +jobs: + build-ubuntu-latest: + runs-on: ubuntu-latest + if: ${{ (github.event_name != 'workflow_dispatch') || (contains(fromJson('["all", "linux"]'), github.event.inputs.build-items)) }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.11' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build + pip install -r requirements.txt + - name: Build PyPI package + run: | + python3 -m build + - name: Upload to PyPI + if: github.event_name != 'workflow_dispatch' + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.PYPI_TOKEN }} + skip-existing: true + - name: Archive distribution + uses: actions/upload-artifact@v4 + with: + name: linux-dist + path: | + dist/*.tar.gz + + release: + if: github.event_name != 'workflow_dispatch' + runs-on: ubuntu-latest + needs: [build-ubuntu-latest] + steps: + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 + with: + name: linux-dist + - uses: ncipollo/release-action@v1 + with: + artifacts: "amor*.tar.gz" + token: ${{ secrets.GITHUB_TOKEN }} + allowUpdates: true diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml new file mode 100644 index 0000000..b833369 --- /dev/null +++ b/.github/workflows/unit_tests.yml @@ -0,0 +1,37 @@ +name: Unit Testing + +on: + push: + branches: + - main + pull_request: + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + build: + + runs-on: ubuntu-22.04 + strategy: + matrix: + python-version: [3.8, 3.9, '3.10', '3.11', '3.12'] + fail-fast: false + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install pytest + pip install -r requirements.txt + + - name: Test with pytest + run: | + cd tests + python -m pytest --pyargs . diff --git a/.gitignore b/.gitignore index 4ad5afb..7f4f5b5 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,6 @@ __pycache__ raw .idea -test_data +test_results build dist diff --git a/README.md b/README.md deleted file mode 100644 index 8fdbf05..0000000 --- a/README.md +++ /dev/null @@ -1,12 +0,0 @@ -Software repository for the neutron reflectometer Amor at the Paul Scherrer Institut, Switzerland - -reduction of the raw files (.hdf) to reflectivity files in one of the representations of the **ORSO reflectivity file format**: - -> `eos.py` -> `neos.py` : version for playing and testing - -visualisation of the content of a raw file (.hdf): - -> `events2histogram.py` - -#TODO: real readme for final system needed. diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..e3696d5 --- /dev/null +++ b/README.rst @@ -0,0 +1,27 @@ +EOS - The AMOR focusing reflectometry data reduction software +------------------------------------------------------------- + +.. image:: https://img.shields.io/pypi/v/amor-eos.svg + :target: https://pypi.python.org/pypi/amor-eos/ + + +Software repository for the neutron reflectometer Amor at the Paul Scherrer Institut, Switzerland + +Reduction of the raw files (.hdf) to reflectivity files in one of the representations of the **ORSO reflectivity file format**: + + eos.py --help + +visualisation of the content of a raw file (.hdf): + + events2histogram.py + +:TODO: real readme for final system needed. + +Installation +------------ +Create a virtual python environment (>3.8) and install the PyPI package: + + pip install amor-eos + +On Windows you can also use the binary eos.exe that you find in the +[GitHub Releases]([https://github.com/jochenstahn/amor/releases/latest) section diff --git a/libeos/__init__.py b/libeos/__init__.py index ed53792..eab079d 100644 --- a/libeos/__init__.py +++ b/libeos/__init__.py @@ -2,5 +2,5 @@ Package to handle data redction at AMOR instrument to be used by eos.py script. """ -__version__ = '2.1.1' -__date__ = '2024-10-22' +__version__ = '2.1.2' +__date__ = '2024-10-30' diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..374b58c --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,6 @@ +[build-system] +requires = [ + "setuptools>=42", + "wheel" +] +build-backend = "setuptools.build_meta" diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..d41e64a --- /dev/null +++ b/setup.cfg @@ -0,0 +1,32 @@ +[bdist_wheel] +universal = 1 + +[metadata] +name = amor_eos +version = attr: libeos.__version__ +author = Jochen Stahn - Paul Scherrer Institut +author_email = jochen.stahn@psi.ch +description = EOS reflectometry reduction for AMOR instrument +long_description = Reduces data obtained by focusing time of flight neutron reflectivity to full reflectivity curve. +license = MIT +classifiers = + Programming Language :: Python :: 3 + License :: OSI Approved :: MIT License + Operating System :: OS Independent + Topic :: Scientific/Engineering + Development Status :: 5 - Production/Stable + +[options] +python_requires = >=3.8 +packages = + libeos +scripts = + eos.py +install_requires = + numpy + h5py + orsopy + numba + +[project.urls] +Homepage = "https://github.com/jochenstahn/amor" diff --git a/test_data/amor2023n000608.hdf b/test_data/amor2023n000608.hdf new file mode 100644 index 0000000..da050fa Binary files /dev/null and b/test_data/amor2023n000608.hdf differ diff --git a/test_data/amor2023n000609.hdf b/test_data/amor2023n000609.hdf new file mode 100644 index 0000000..a3c869c Binary files /dev/null and b/test_data/amor2023n000609.hdf differ diff --git a/test_data/amor2023n000610.hdf b/test_data/amor2023n000610.hdf new file mode 100644 index 0000000..204cda8 Binary files /dev/null and b/test_data/amor2023n000610.hdf differ diff --git a/test_data/amor2023n000611.hdf b/test_data/amor2023n000611.hdf new file mode 100644 index 0000000..077ecdf Binary files /dev/null and b/test_data/amor2023n000611.hdf differ diff --git a/test_data/amor2023n000612.hdf b/test_data/amor2023n000612.hdf new file mode 100644 index 0000000..3ef5b3c Binary files /dev/null and b/test_data/amor2023n000612.hdf differ diff --git a/test_data/amor2023n000613.hdf b/test_data/amor2023n000613.hdf new file mode 100644 index 0000000..8986f99 Binary files /dev/null and b/test_data/amor2023n000613.hdf differ diff --git a/tests/test_full_analysis.py b/tests/test_full_analysis.py index 9eff6d0..a1fc875 100644 --- a/tests/test_full_analysis.py +++ b/tests/test_full_analysis.py @@ -21,15 +21,14 @@ class FullAmorTest(TestCase): self.pr.enable() self.reader_config = options.ReaderConfig( year=2023, - dataPath=os.path.join('..', "test_data"), - raw=(os.path.join('..', "test_data"),) + rawPath=(os.path.join('..', "test_data"),), ) def tearDown(self): self.pr.disable() for fi in ['test.Rqz.ort', '614.norm']: try: - os.unlink(os.path.join(self.reader_config.dataPath, fi)) + os.unlink(os.path.join(self.reader_config.rawPath[0], fi)) except FileNotFoundError: pass @@ -38,6 +37,8 @@ class FullAmorTest(TestCase): experiment_config = options.ExperimentConfig( chopperPhase=-13.5, chopperPhaseOffset=-5, + monitorType=options.Defaults.monitorType, + lowCurrentThreshold=options.Defaults.lowCurrentThreshold, yRange=(11., 41.), lambdaRange=(2., 15.), qzRange=(0.005, 0.30), @@ -60,7 +61,8 @@ class FullAmorTest(TestCase): ) output_config = options.OutputConfig( outputFormats=["Rqz.ort"], - outputName='test' + outputName='test', + outputPath=os.path.join('..', 'test_results'), ) config=options.EOSConfig(self.reader_config, experiment_config, reduction_config, output_config) # run three times to get similar timing to noslicing runs @@ -75,6 +77,8 @@ class FullAmorTest(TestCase): experiment_config = options.ExperimentConfig( chopperPhase=-13.5, chopperPhaseOffset=-5, + monitorType=options.Defaults.monitorType, + lowCurrentThreshold=options.Defaults.lowCurrentThreshold, yRange=(11., 41.), lambdaRange=(2., 15.), qzRange=(0.005, 0.30), @@ -91,12 +95,13 @@ class FullAmorTest(TestCase): thetaRangeR=(-12., 12.), fileIdentifier=["610", "611", "608,612-613", "609"], scale=[1], - normalisationFileIdentifier=["614"], + normalisationFileIdentifier=["608"], autoscale=(True, True) ) output_config = options.OutputConfig( outputFormats=["Rqz.ort"], - outputName='test' + outputName='test', + outputPath=os.path.join('..', 'test_results'), ) config=options.EOSConfig(self.reader_config, experiment_config, reduction_config, output_config) reducer = reduction.AmorReduction(config)