resins

Python library for resolution functions of inelastic neutron scattering instruments

https://github.com/pace-neutrons/resins

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.8%) to scientific vocabulary

Keywords

neutron neutron-scattering physics python resolution spectroscopy
Last synced: 6 months ago · JSON representation ·

Repository

Python library for resolution functions of inelastic neutron scattering instruments

Basic Info
  • Host: GitHub
  • Owner: pace-neutrons
  • License: gpl-3.0
  • Language: Python
  • Default Branch: main
  • Homepage:
  • Size: 2.37 MB
Statistics
  • Stars: 4
  • Watchers: 3
  • Forks: 0
  • Open Issues: 21
  • Releases: 0
Topics
neutron neutron-scattering physics python resolution spectroscopy
Created over 1 year ago · Last pushed 9 months ago
Metadata Files
Readme License Citation

README.md

Resolution Functions

Python library for working with resolution functions of inelastic neutron scattering (INS) instruments. This package exists to centralise all things related to resolution of INS instruments and make it easier to work with. It pools related code from existing projects, namely AbINS and PyChop, as well as implementing code published in literature. The main purposes are:

  1. Provide one, central place implementing various models for INS instruments (resolution functions)
  2. Provide a simple way to obtain the broadening at a given frequency, for a given instrument and settings
  3. Provide a way to apply broadening to a spectrum

Quick Start

The package can be installed with pip (see Installation). To start, import the main Instrument class and get the instrument object of your choice:

```

from resolutionfunctions import Instrument maps = Instrument.fromdefault('MAPS', 'MAPS') print(maps) Instrument(name=MAPS, version=MAPS) ```

To get the resolution function, call the get_resolution_function method (providing all your choices for the required settings and configurations), which returns a callable that can be called to broaden the data.

```

The available models for a given instrument can be queried:

maps.availablemodels ['PyChopfit']

There are multiple ways of querying the model-specific parameters, but the most comprehensive is

maps.getmodelsignature('PyChopfit') <Signature (modelname: Optional[str] = 'PyChopfitv1', *, chopperpackage: Literal['A', 'B', 'S'] = 'A', einit: Annotated[ForwardRef('Optional[float]'), 'restriction=[0, 2000]'] = 500, chopperfrequency: Annotated[ForwardRef('Optional[int]'), 'restriction=[50, 601, 50]'] = 400, fittingorder: 'int' = 4, ) -> resolutionfunctions.models.pychop.PyChopModelFermi>

Now we can get the resolution function

pychop = maps.getresolutionfunction('PyChopfit', chopperpackage='B', einit=500, chopperfrequency=300) print(pychop) PyChopModelFermi(citation=['']) ```

Calling the model (like a function) broadens the data at the provided combinations of energy transfer and momentum ([w, Q]), using a mesh and the corresponding data:

```

import numpy as np energytransfer = np.array([100, 200, 300])[:, np.newaxis] data = np.array([0.6, 1.5, 0.9]) mesh = np.linspace(0, 500, 1000) pychop(energytransfer, data, mesh) array([3.43947518e-028, ... 5.99877942e-002, ... 7.31766110e-249]) ```

However, the model also provides methods that go lower;

  • get_kernel computes the broadening kernel at each w, Q
  • get_peak computes the broadening peak at each w, Q
  • get_characteristics returns only the characteristic parameters of the kernel at each w, Q

```

peaks = pychop.getpeak(energytransfer, mesh) meshcenteredon0 = np.linspace(-100, 100, 1000) kernels = pychop.getkernel(energytransfer, meshcenteredon0) pychop.getcharacteristics(energytransfer) {'sigma': array([9.15987016, 7.38868127, 5.93104319])} ```

Installation

This package can be installed using pip, though it is not yet on PyPI, so it has to be installed directly from GitHub:

pip install git+https://github.com/pace-neutrons/resolution_functions.git

or from a local copy:

git clone https://github.com/pace-neutrons/resolution_functions.git pip install resolution_functions

Owner

  • Name: pace-neutrons
  • Login: pace-neutrons
  • Kind: organization

Citation (CITATION.cff)

cff-version: 1.2.0
message: "If you use this software, please cite it as below."
abstract: "ResINS is a Python package for resolution functions of inelastic neutron scattering instruments"
authors:
  - family-names: Turanyi
    given-names: Rastislav
    email: rastislav.turanyi@stfc.ac.uk
  - family-names: "Jackson"
    given-names: "Adam J."
    orcid: https://orcid.org/0000-0001-5272-6530
  - family-names: "Wilkins"
    given-names: "Jacob S."
    orcid: https://orcid.org/0009-0004-9147-3475
title: "ResINS"
repository-code: https://github.com/pace-neutrons/resins
license: GPL-3.0
version: 0.0.1
keywords:
  - "Python"
  - "physics"
  - "inelastic neutron scattering"
  - "instrument resolution"

GitHub Events

Total
  • Issues event: 9
  • Watch event: 2
  • Delete event: 4
  • Issue comment event: 28
  • Push event: 43
  • Pull request review comment event: 27
  • Pull request review event: 34
  • Pull request event: 15
  • Fork event: 1
  • Create event: 5
Last Year
  • Issues event: 9
  • Watch event: 2
  • Delete event: 4
  • Issue comment event: 28
  • Push event: 43
  • Pull request review comment event: 27
  • Pull request review event: 34
  • Pull request event: 15
  • Fork event: 1
  • Create event: 5

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 8
  • Total pull requests: 11
  • Average time to close issues: about 2 months
  • Average time to close pull requests: 2 months
  • Total issue authors: 2
  • Total pull request authors: 3
  • Average comments per issue: 1.13
  • Average comments per pull request: 2.73
  • Merged pull requests: 8
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 8
  • Pull requests: 11
  • Average time to close issues: about 2 months
  • Average time to close pull requests: 2 months
  • Issue authors: 2
  • Pull request authors: 3
  • Average comments per issue: 1.13
  • Average comments per pull request: 2.73
  • Merged pull requests: 8
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • RastislavTuranyi (7)
  • ajjackson (1)
Pull Request Authors
  • RastislavTuranyi (7)
  • ajjackson (1)
  • oerc0122 (1)
Top Labels
Issue Labels
enhancement (4) documentation (2) bug (1) testing (1)
Pull Request Labels
enhancement (5) documentation (1) help wanted (1) bug (1) testing (1)

Dependencies

pyproject.toml pypi
  • PyYAML >= 6.0.2
  • numpy >= 1.26.4
  • scipy >= 1.13.1
.github/workflows/run_tests.yml actions
  • actions/checkout v3 composite
  • conda-incubator/setup-miniconda v3.0.4 composite