Skip to main content

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.

Metadata

Release files for nestpy 2.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nestpy 2.1.3
File Size Uploaded
nestpy-2.1.3.tar.gz 1.0 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for nestpy 2.1.3
File
nestpy-2.1.3-cp312-cp312-musllinux_1_2_x86_64.whl CPython 3.12 CPython 3.12 Linux musl 1.2+ x86-64 Details
nestpy-2.1.3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details
nestpy-2.1.3-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
nestpy-2.1.3-cp311-cp311-musllinux_1_2_x86_64.whl CPython 3.11 CPython 3.11 Linux musl 1.2+ x86-64 Details
nestpy-2.1.3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details
nestpy-2.1.3-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details
nestpy-2.1.3-cp310-cp310-musllinux_1_2_x86_64.whl CPython 3.10 CPython 3.10 Linux musl 1.2+ x86-64 Details
nestpy-2.1.3-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details
nestpy-2.1.3-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details
nestpy-2.1.3-cp39-cp39-musllinux_1_2_x86_64.whl CPython 3.9 CPython 3.9 Linux musl 1.2+ x86-64 Details
nestpy-2.1.3-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details
nestpy-2.1.3-cp39-cp39-macosx_11_0_arm64.whl CPython 3.9 CPython 3.9 macOS 11.0+ ARM64 Details

Total release size: 10.4 MB

Release files / nestpy-2.1.3.tar.gz

Download URL nestpy-2.1.3.tar.gz
Size 1.0 MB
Tags Source
SHA-256 checksum
How to use checksums
258155894377e24c02a763e8e58319e01fbd42f12aa7a8c960084848b1a84e84
BLAKE2b-256 checksum
How to use checksums
4cede3b0465c42efee32946d08e632cb2c42693215d8189900c40c3daa4621aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / nestpy-2.1.3-cp312-cp312-musllinux_1_2_x86_64.whl

Download URL nestpy-2.1.3-cp312-cp312-musllinux_1_2_x86_64.whl
Size 1.5 MB
Tags CPython 3.12 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
8947ddf533c3a1c67d626d1c52fbb734756c498a872e05333932762df95facd8
BLAKE2b-256 checksum
How to use checksums
0415f7b3558d467c9ce9d76c3ab4a8b4f2ba843392868570faf2b15fb09cbd53
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / nestpy-2.1.3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL nestpy-2.1.3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 468.4 kB
Tags CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
c569c7685bc4f1bfe42709ca1a5f40429bb83ef2d12a7055f07a085c8c54a398
BLAKE2b-256 checksum
How to use checksums
d389fb0a4c3eee9c18a74009fe1d9fcc317167f0ce3000cad5d2bdabf3b59ad1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / nestpy-2.1.3-cp312-cp312-macosx_11_0_arm64.whl

Download URL nestpy-2.1.3-cp312-cp312-macosx_11_0_arm64.whl
Size 365.0 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
e6c604cef3522294c74ec24b51216e07c64b1e56d11eb5fe464d49dc04e20b44
BLAKE2b-256 checksum
How to use checksums
d70050602d795841a26e31835145de5f05cae98863085b4e65e73e7cdcc41112
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / nestpy-2.1.3-cp311-cp311-musllinux_1_2_x86_64.whl

Download URL nestpy-2.1.3-cp311-cp311-musllinux_1_2_x86_64.whl
Size 1.5 MB
Tags CPython 3.11 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
70ca78b63d2b9b29fb905768ef11175e3bfd8dbbcfa3c0238ce64dc1773b0161
BLAKE2b-256 checksum
How to use checksums
263a27887ff252f8fc2f54f44da4e77e07951e4fe7bddc53e7bdbb71ece21c38
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / nestpy-2.1.3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL nestpy-2.1.3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 468.2 kB
Tags CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
61799047607d6722b933884d871bbbff340aa3b9c7f77ccebe1fa7a8ce7ea765
BLAKE2b-256 checksum
How to use checksums
e262e49ccf8b3e9f0502e4152dbf91b11296199581d7ed02c1c6cfc1baf124f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / nestpy-2.1.3-cp311-cp311-macosx_11_0_arm64.whl

Download URL nestpy-2.1.3-cp311-cp311-macosx_11_0_arm64.whl
Size 363.4 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
48878b763a6f1aafdd2c61e63f40747e898eedf09e51c0094646ba56d1f31cca
BLAKE2b-256 checksum
How to use checksums
0eb19f3a0c7f05c4061334c6ceae2c8adcb152a4a2b020c1a5bc1d15648b49b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / nestpy-2.1.3-cp310-cp310-musllinux_1_2_x86_64.whl

Download URL nestpy-2.1.3-cp310-cp310-musllinux_1_2_x86_64.whl
Size 1.5 MB
Tags CPython 3.10 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
5837b9801414f1e3609a6791bf9a692071be43ef56ef2766171b5cdb2085f9f8
BLAKE2b-256 checksum
How to use checksums
21423c4b66056084be229c6480232eecf6248fa75cbccb3e268177224497d2da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / nestpy-2.1.3-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL nestpy-2.1.3-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 467.3 kB
Tags CPython 3.10 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
7781270c79f53b3eeba02e75e81463876a7afad948cebf0896c9c127a5026e34
BLAKE2b-256 checksum
How to use checksums
bba03fa8c375a53a64db7904aa9437e6e079706d9fa56964b38ba54ee61845ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / nestpy-2.1.3-cp310-cp310-macosx_11_0_arm64.whl

Download URL nestpy-2.1.3-cp310-cp310-macosx_11_0_arm64.whl
Size 362.3 kB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
a0d2972c9ee377866fbd501e248d1d24f4338ac6be25263c426ee838e72e6059
BLAKE2b-256 checksum
How to use checksums
dc6360d5da70fc819c784a67788ed2d0f76a1b4e3e9a2fee785ee78011128d6a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / nestpy-2.1.3-cp39-cp39-musllinux_1_2_x86_64.whl

Download URL nestpy-2.1.3-cp39-cp39-musllinux_1_2_x86_64.whl
Size 1.5 MB
Tags CPython 3.9 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
a0e541965d613b5dfdddefc67e46e2ef7151319ab761f42bc9667cfe1e0d3ef8
BLAKE2b-256 checksum
How to use checksums
d13282176bece8a33e28ed33b5581986566f812cde36f3474023ffd2c5beb3e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / nestpy-2.1.3-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL nestpy-2.1.3-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 467.6 kB
Tags CPython 3.9 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
20dcd9332d110b7fe41954b4ebe8c0ad3bab039f242e0fd1663a6d7ac53e4f89
BLAKE2b-256 checksum
How to use checksums
5915fd08f49eeb7fe42b0e8ab047e2b2c07c214b7585a0ae97bfdddb674bbdcf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / nestpy-2.1.3-cp39-cp39-macosx_11_0_arm64.whl

Download URL nestpy-2.1.3-cp39-cp39-macosx_11_0_arm64.whl
Size 362.4 kB
Tags CPython 3.9 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
dc0c41fac1f7b1675ee118d801c4e360e8cf5caf0fd52a3eed1ba945cb4d09d6
BLAKE2b-256 checksum
How to use checksums
162f84269bc62dc2e5929a2ec127256505ebf073850978e4de3b7a8b01a99edc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

2.1.3 This release

13 release files

2.1.0

13 release files

2.0.6

9 release files

2.0.5

4 release files

2.0.4

4 release files

2.0.3

8 release files

2.0.2

10 release files

1.5.4

17 release files

1.5.2

1 release file

1.5.1

1 release file

1.5.0

8 release files

1.4.11

8 release files

1.4.4

13 release files

1.4.3

6 release files

1.4.2

6 release files

1.4.1

6 release files

1.4.0

6 release files

1.3.3

7 release files

1.2.1

14 release files

1.1.1

18 release files

1.1.0

18 release files

1.0.3

18 release files

1.0.2

18 release files

1.0.1

18 release files

1.0.0

17 release files

0.2.5

11 release files

0.1.0

6 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page