Skip to main content

Python bindings for the NEST noble element simulation

Project description

nestpy

Join the chat at https://gitter.im/NESTCollaboration/nestpy Pytest DOI PyPi version Project Status: Active – The project has reached a stable, usable state and is being actively developed. Python Versions PyPI downloads

Visit the tutorials directory for tutorials on the nestpy calls, maintenance, and benchmark plots.

These are the Python bindings for the NEST library, which provides a direct wrapping of functionality. The library is now pythonic, so be weary of the separate naming conventions for functions/variables from the C++ library.

You do not have to have NEST already installed to use this package.

Installing from PyPI

For 64-bit Linux or Mac systems, instally 'nestpy' should just require running:

pip install nestpy

You can then test that it works by running the example above.

Installing from source

Requirements: You must have CMake>=3.6 and a C++17 compatible compiler (GCC>=4.8) to build.

First, you must check out this repository then simply run the installer:

git clone https://github.com/NESTCollaboration/nestpy
cd nestpy
git submodule update --init --recursive
pip install .

Installing with custom NEST code

Almost all NEST users will want to incorporate some custom code into their workflow, such as custom Detector files or TestSpectra. In order to incorporate that custom code into the nestpy installation, you'll have to copy the files you've edited into the lib/nest/ directory and rerun:

pip install .

In order to create a more efficient workflow, we suggest the user takes the following steps:

  1. Fork the official NEST repository into your own public/private one.
  2. Make whatever changes to your fork and maintain them with commits.
  3. Download or fork nestpy and change the NEST entry in the .gitmodules files to point to your custom fork of NEST.
[submodule "lib/nest"]
	path = lib/nest
	url = https://github.com/NESTCollaboration/nest # change this to any custom fork of NEST if you want to use your own code!
[submodule "lib/gcem"]
	path = lib/gcem
	url = https://github.com/kthohr/gcem.git

Usage

Python bindings to the NEST library:

Simple example covering the basic logic behind NEST

import nestpy

# This is same as C++ NEST with naming
nc = nestpy.NESTcalc(nestpy.detectors.VDetector())

interaction = nestpy.interactions.NR  # NR

E = 10  # keV
print('For an %s keV %s' % (E, interaction))

# Get particle yields
y = nc.GetYields(interaction,
		 E)

print('The photon yield is:', y.PhotonYield)
print('With statistical fluctuations',
      nc.GetQuanta(y).photons)

Examples using a vectorised approach

Get the yields as a function of energy

# Want to use custom yields parameters (e.g. from LZ WS2024)
lz_2024 = nestpy.detectors.LZ_WS2024()
# Get yields as a dataframe 
energy = np.linspace(1, 10, 10000)
nr_yeild = nestpy.helpers.get_yields_df(ne.interactions.NR, energy)
er_devel_yield = ne.helpers.get_yields_df(ne.interactions.beta, energy, nr_parameters = lz_2024.nr_parameters, er_parameters = lz_2024.er_parameters)

Run a vectorised simulation of S1 and S2 parameters

n = int(1e5)

t = nestpy.helpers.run_nest_df(
    # "beta",
    nestpy.interactions.beta,
    lz_2024,
    nestpy.spectra.CH3T(number=n), # Vectorised sampler from energy spectra
    # By default uses random positions in the detector
)

d = nestpy.helpers.run_nest_df(
    nestpy.interactions.NR,
    lz_2024,
    ne.spectra.DD(number=n),
    # nr_yield_params = det.nr_yield_params <- can set custom yield parameters
    # er_yield_params = det.er_yield_params <- can set custom yield parameters
    # width_params = det.width_yield_params <- can set this too
    # s1_mode" = NEST::S1CalculationMode::Hybrid <- Can simulate more detailed calculation or waveforms
    # s2_mode" = NEST::S2CalculationMode::Full <- Can simulate Waveforms with E-trains
)

For more examples on possible calls, please see the tests and tutorials folders.

Support

  • Bugs: Please report bugs to the issue tracker on Github such that we can keep track of them and eventually fix them. Please explain how to reproduce the issue (including code) and which system you are running on.
  • Help: Help can be provided also via the issue tracker by tagging your issue with 'question'
  • Contributing: Please fork this repository then make a pull request. In this pull request, explain the details of your change and include tests.

Technical implementation

This package is a pybind11 wrapper of NEST that uses GitHub Workflows to build binaries using the manylinux Docker image from this page.

  • Help from Henry Schreiner, which included a great binding tutorial
  • Implementation also based on this
  • Implementation of GitHub test and build actions was made possible by Joran Angevaare.

See AUTHORS.md for information on the developers.

Citation

When you use nestpy, please say so in your slides or publications (for publications, see Zenodo link above). You can mention this in addition to how you cite NEST. This is important for us being able to get funding to support this project.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nestpy-2.1.1.tar.gz (1.0 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

nestpy-2.1.1-cp312-cp312-musllinux_1_2_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

nestpy-2.1.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (427.5 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

nestpy-2.1.1-cp312-cp312-macosx_11_0_arm64.whl (341.6 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

nestpy-2.1.1-cp311-cp311-musllinux_1_2_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

nestpy-2.1.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (426.1 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

nestpy-2.1.1-cp311-cp311-macosx_11_0_arm64.whl (339.8 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

nestpy-2.1.1-cp310-cp310-musllinux_1_2_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

nestpy-2.1.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (424.1 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

nestpy-2.1.1-cp310-cp310-macosx_11_0_arm64.whl (338.9 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

nestpy-2.1.1-cp39-cp39-musllinux_1_2_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.9musllinux: musl 1.2+ x86-64

nestpy-2.1.1-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (424.2 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

nestpy-2.1.1-cp39-cp39-macosx_11_0_arm64.whl (338.9 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

Details for the file nestpy-2.1.1.tar.gz.

File metadata

  • Download URL: nestpy-2.1.1.tar.gz
  • Upload date:
  • Size: 1.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for nestpy-2.1.1.tar.gz
Algorithm Hash digest
SHA256 494a3e63c55706807740403a30fa91a944168343e2882f97a0966dedfeacfec6
MD5 3edf557fbb6d91c725b2c99163fb6917
BLAKE2b-256 3ba378da956e5a5985d2006949f624e28d6534e600c405863fdc4ab3c77c3768

See more details on using hashes here.

File details

Details for the file nestpy-2.1.1-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for nestpy-2.1.1-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 1e171424a8a733f470511e5a25bf2c04b261a6b744aca99fa5fd042f00f24c7b
MD5 668e559e11b3b20924075a6e897e90b4
BLAKE2b-256 403ef28addcbd5012986f49e0332825eb1cdcc7387b1d6ea82cc9d80785b50a8

See more details on using hashes here.

File details

Details for the file nestpy-2.1.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for nestpy-2.1.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 be950e0701453b89228f8b7363c525db74eda15a3f97edbdc198254ff1aa8a14
MD5 bd34afff5dfce2d97138983c7a5456a6
BLAKE2b-256 8f89531e5662d7dcf5cb722b6f460d224579a6788461a97868230c1b2592153c

See more details on using hashes here.

File details

Details for the file nestpy-2.1.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for nestpy-2.1.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c58484068b442d63fe48e0cd0019c7175a2f87ac1e307bda6ccbaccd7ebfc96a
MD5 5c966d45d779ae296192f5d391d40b3e
BLAKE2b-256 622e0b5297bf26e047cf3bebed19b5e3114a1bc0c74b581c0bbbe0f1d95279d5

See more details on using hashes here.

File details

Details for the file nestpy-2.1.1-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for nestpy-2.1.1-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 c434e75c9d8a2589b69d2c2c8e204a64bb14f8da559d26feede6db5de2caf902
MD5 8632409ef178ef3046a1f2ddece9898a
BLAKE2b-256 25882aeb989f00574e94e0b6706197db82d1eb88bfda922bb6ad44a93870f0cc

See more details on using hashes here.

File details

Details for the file nestpy-2.1.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for nestpy-2.1.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 05b8fe40e0e0502cb33eb2f42818a3ee93e49b732736c900afa04cc36e96a8fe
MD5 0e2999d5ac525a21a02659250354fdc2
BLAKE2b-256 50588aeba052369cb3bbe606aaefdf94da3d4822af40e5bbcebd06dbf61e5e84

See more details on using hashes here.

File details

Details for the file nestpy-2.1.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for nestpy-2.1.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b547fc72e2ba12b858c6294907650d1355e89a47be1844641d23338a67e9a370
MD5 9867902b818e163e328133d8564e7c73
BLAKE2b-256 8cbaa43970d9ebf21b56ed5a3399354a694415680080cb46a937b15be044a45c

See more details on using hashes here.

File details

Details for the file nestpy-2.1.1-cp310-cp310-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for nestpy-2.1.1-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 1290f1e9220d6727222e3b9cff058bb50e87566884163490925d8fb384ed3307
MD5 9b59848fb1053adabb099975b2fd1621
BLAKE2b-256 7a22c7e5372709ab7f6d041ba6da9d070aed3b3719e883a64905965b9ba964c8

See more details on using hashes here.

File details

Details for the file nestpy-2.1.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for nestpy-2.1.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e95230701783d26d803745519ae4bccbeccf6d8e985a53f735aa9aa407a67248
MD5 25351da62ce8a1bbdef180b05952a5e7
BLAKE2b-256 a88c2946cf12b2577a225361a06683ba15731eea437c968c827347789868f2a8

See more details on using hashes here.

File details

Details for the file nestpy-2.1.1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for nestpy-2.1.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c519fd22f5e688f1719767f8e4bba4ccd3ff397a1be69b54c90d29c0253f7b7f
MD5 02d871ba101eabf039e0ae377c1b9355
BLAKE2b-256 9118ae4353b99d570b34bba37bda128488c7b86ded22a116a38f45c10e1f1e35

See more details on using hashes here.

File details

Details for the file nestpy-2.1.1-cp39-cp39-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for nestpy-2.1.1-cp39-cp39-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 9c39e39e0468676048086fd21e87d545377169efdd27bc83f147e43b3c0b600f
MD5 3fdef3c9c29932e59e6d48884618aba0
BLAKE2b-256 fe14d37930556bb08111633d5df5dfb18beee4d8416c6f8fc99199ff7dd9e897

See more details on using hashes here.

File details

Details for the file nestpy-2.1.1-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for nestpy-2.1.1-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d1660b2a48a280d63f5049157035e3bcddbf1c4fe21b9b177c3749eb41496d7c
MD5 a6c47aa1dd689dde07f70170fbcb9bb8
BLAKE2b-256 4a1f5c7361f1c154544a8c6d0d7ef6abebd0691ceead52c835bb9881df6b1480

See more details on using hashes here.

File details

Details for the file nestpy-2.1.1-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for nestpy-2.1.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d7ae708e9ca1ab9e695951e19844c4eff7a5dfc36d139cef58c461e399948e51
MD5 9848bb9cfb16c5d849835e64c7f85142
BLAKE2b-256 23d8e0e034a6d0a8c9086af5b1ba45104c945b6d708dfa6ed9a14d08944671ce

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page