SandiaSpecUtils 0.0.10__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,93 @@
1
+ cmake_minimum_required(VERSION 3.15...3.26)
2
+
3
+ project(SpecUtils_py LANGUAGES CXX)
4
+
5
+ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
6
+
7
+ set( SpecUtils_ENABLE_D3_CHART ON CACHE BOOL "" )
8
+ set( SpecUtils_D3_SUPPORT_FILE_STATIC ON CACHE BOOL "" )
9
+ set( SpecUtils_PYTHON_BINDINGS ON CACHE BOOL "Build the python bindings" )
10
+ set( SpecUtils_ENABLE_EQUALITY_CHECKS OFF CACHE BOOL "" )
11
+ set( PERFORM_DEVELOPER_CHECKS OFF CACHE BOOL "" )
12
+ set( SpecUtils_SHARED_LIB OFF CACHE BOOL "" ) #we'll statically link SpecUtils into the lib we create here
13
+ set( SpecUtils_FLT_PARSE_METHOD "strtod" CACHE STRING "Float parsing method" )
14
+
15
+ # Enable URI spectra for macOS and Linux (since we are already linking to zlib), but not Windows
16
+ if(WIN32)
17
+ set( SpecUtils_ENABLE_URI_SPECTRA OFF CACHE BOOL "" )
18
+ else()
19
+ set( SpecUtils_ENABLE_URI_SPECTRA ON CACHE BOOL "" )
20
+ endif()
21
+
22
+ add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/../.. ${CMAKE_CURRENT_BINARY_DIR}/LibSpecUtils )
23
+
24
+ if (NOT SKBUILD)
25
+ message(FATAL_ERROR "\
26
+ This CMake file is must be executed using 'scikit-build'.
27
+ If you are a user trying to install this package, please use the command
28
+ below, which will install all necessary build dependencies, compile
29
+ the package in an isolated environment, and then install it.
30
+ =====================================================================
31
+ $ pip install .
32
+ =====================================================================
33
+ If you are a software developer, and this is your own package, then
34
+ it is usually much more efficient to install the build dependencies
35
+ in your environment once and use the following command that avoids
36
+ a costly creation of a new virtual environment at every compilation:
37
+ =====================================================================
38
+ $ pip install nanobind scikit-build-core
39
+ $ pip install --no-build-isolation -ve .
40
+ =====================================================================
41
+ You may optionally add -Ceditable.rebuild=true to auto-rebuild when
42
+ the package is imported. Otherwise, you need to re-run the above
43
+ after editing C++ files.")
44
+ endif()
45
+
46
+ # Try to import all Python components potentially needed by nanobind
47
+ find_package(Python 3.8
48
+ REQUIRED COMPONENTS Interpreter Development.Module
49
+ OPTIONAL_COMPONENTS Development.SABIModule)
50
+
51
+ # Import nanobind through CMake's find_package mechanism
52
+ find_package(nanobind CONFIG REQUIRED)
53
+
54
+ # We are now ready to compile the actual extension module
55
+ nanobind_add_module(
56
+ # Name of the extension
57
+ PySpecUtils
58
+
59
+ # Target the stable ABI for Python 3.12+, which reduces
60
+ # the number of binary wheels that must be built. This
61
+ # does nothing on older Python versions
62
+ STABLE_ABI
63
+
64
+ # Build libnanobind statically and merge it into the
65
+ # extension (which itself remains a shared library)
66
+ #
67
+ # If your project builds multiple extensions, you can
68
+ # replace this flag by NB_SHARED to conserve space by
69
+ # reusing a shared libnanobind across libraries
70
+ NB_STATIC
71
+
72
+ #Perform link time optimization.
73
+ #LTO
74
+
75
+
76
+ # Source code goes here
77
+ SpecFile_py.cpp
78
+ )
79
+
80
+ set_target_properties( PySpecUtils PROPERTIES OUTPUT_NAME "SpecUtils" )
81
+ target_link_libraries( PySpecUtils PUBLIC SpecUtils )
82
+
83
+ # Install directive for scikit-build-core
84
+ install(TARGETS PySpecUtils LIBRARY DESTINATION SpecUtils)
85
+ install(FILES __init__.py DESTINATION SpecUtils)
86
+
87
+ nanobind_add_stub(
88
+ SpecUtils_stub
89
+ MODULE SpecUtils
90
+ OUTPUT SpecUtils.pyi
91
+ PYTHON_PATH $<TARGET_FILE_DIR:PySpecUtils>
92
+ DEPENDS PySpecUtils
93
+ )
@@ -0,0 +1,98 @@
1
+ Metadata-Version: 2.1
2
+ Name: SandiaSpecUtils
3
+ Version: 0.0.10
4
+ Summary: Python bindings for SpecUtils using nanobind and scikit-build
5
+ Author-Email: Will Johnson <wcjohns@sandia.gov>
6
+ Classifier: License :: OSI Approved :: GNU Lesser General Public License v2 (LGPLv2)
7
+ Project-URL: Homepage, https://github.com/sandialabs/SpecUtils
8
+ Requires-Python: >=3.9
9
+ Description-Content-Type: text/markdown
10
+
11
+ # Gamma Spectrum file utilities
12
+
13
+ [SpecUtils](https://github.com/sandialabs/SpecUtils) is a library for reading, manipulating, and exporting spectrum files produced by RadioIsotope Identification Devices (RIIDs), Radiation Portal Monitors (RPMs), radiation search systems, Personal Radiation Detectors (PRDs), and many laboratory detection systems.
14
+ It opens [N42](https://www.nist.gov/programs-projects/ansiieee-n4242-standard) (2006 and 2012 formats), [SPE](https://inis.iaea.org/collection/NCLCollectionStore/_Public/32/042/32042415.pdf), [SPC](https://web.archive.org/web/20160418031030/www.ortec-online.com/download/ortec-software-file-structure-manual.pdf), CSV, TXT, [PCF](https://www.osti.gov/biblio/1378172-pcf-file-format), [DAT](https://www.aseg.org.au/sites/default/files/gr-135.pdf), and many more files; altogether much more than a 100 file format variants. This library lets you either programmatically access and/or modify the parsed information, or you can save it to any of 13 different formats, or create spectrum files from scratch.
15
+
16
+
17
+ This package is a Python wrapper around the C++ [SpecUtils](https://github.com/sandialabs/SpecUtils) library, with the bindings created using [nanobind](https://github.com/wjakob/nanobind). [SpecUtils](https://github.com/sandialabs/SpecUtils) is primarily developed as part of [InterSpec](https://github.com/sandialabs/InterSpec/), but is also used by [Cambio](https://github.com/sandialabs/Cambio/), and a number of other projects.
18
+
19
+ An example use is:
20
+ ```python
21
+ import SpecUtils
22
+
23
+ # Create a SpecFile object
24
+ spec = SpecUtils.SpecFile()
25
+
26
+ # Load a spectrum file
27
+ spec.loadFile("spectrum_file.n42", SpecUtils.ParserType.Auto)
28
+
29
+ # Get list of all individual records in the spectrum file
30
+ meass = spec.measurements()
31
+ print( "There are", len(meass), "spectrum records." )
32
+
33
+ # Get first measurement
34
+ meas = meass[0]
35
+
36
+ # Get gamma counts, and the lower energy of each channel
37
+ counts = meas.gammaCounts()
38
+ energies = meas.channelEnergies()
39
+
40
+ # Get neutron counts
41
+ neutrons = meas.neutronCountsSum()
42
+
43
+ # Get start time
44
+ startime = meas.startTime()
45
+
46
+ # Print out CSV information of energies and counts
47
+ print( "StartTime: ", startime )
48
+ print( "Neutron counts: ", neutrons, "\n" )
49
+ print( "Energy (keV), Counts" )
50
+ for i in range(len(counts)):
51
+ print( f"{energies[i]},{counts[i]}" )
52
+ ```
53
+
54
+ For further examples, see the [examples](https://github.com/sandialabs/SpecUtils/tree/master/bindings/python/examples) directory.
55
+ To run the examples, run the following commands:
56
+ ```
57
+ python test_python.py
58
+ python make_file_example.py
59
+ python make_html_plot.py /some/path/to/a/file.n42
60
+ ```
61
+
62
+
63
+ ## Installation
64
+ You can install the package using pip like this:
65
+ ```
66
+ mkdir my_venv
67
+ python -m venv my_venv
68
+
69
+ source my_venv/bin/activate
70
+ pip install SandiaSpecUtils
71
+
72
+ python
73
+ >>> import SpecUtils
74
+ >>> spec = SpecUtils.SpecFile()
75
+ >>> ...
76
+ ```
77
+
78
+
79
+ Or instead, you can compile from source yourself, with something like:
80
+ ```
81
+ git clone https://github.com/sandialabs/SpecUtils.git SpecUtils
82
+
83
+ # Optionsally make/use a virtual environment
84
+ mkdir my_venv
85
+ python3 -m venv my_venv
86
+ source my_venv/bin/activate # Windows PowerShell: .\my_venv\Scripts\Activate.ps1
87
+
88
+ # Compile and install the bindings
89
+ pip install --use-feature=in-tree-build SpecUtils/bindings/python
90
+
91
+ # Use the package
92
+ python
93
+ >>> import SpecUtils
94
+ ```
95
+
96
+
97
+ ## Support
98
+ Please create an issue on the [SpecUtils GitHub repository](https://github.com/sandialabs/SpecUtils/issues), or email InterSpec@sandia.gov if you have any questions or problems.
@@ -0,0 +1,88 @@
1
+ # Gamma Spectrum file utilities
2
+
3
+ [SpecUtils](https://github.com/sandialabs/SpecUtils) is a library for reading, manipulating, and exporting spectrum files produced by RadioIsotope Identification Devices (RIIDs), Radiation Portal Monitors (RPMs), radiation search systems, Personal Radiation Detectors (PRDs), and many laboratory detection systems.
4
+ It opens [N42](https://www.nist.gov/programs-projects/ansiieee-n4242-standard) (2006 and 2012 formats), [SPE](https://inis.iaea.org/collection/NCLCollectionStore/_Public/32/042/32042415.pdf), [SPC](https://web.archive.org/web/20160418031030/www.ortec-online.com/download/ortec-software-file-structure-manual.pdf), CSV, TXT, [PCF](https://www.osti.gov/biblio/1378172-pcf-file-format), [DAT](https://www.aseg.org.au/sites/default/files/gr-135.pdf), and many more files; altogether much more than a 100 file format variants. This library lets you either programmatically access and/or modify the parsed information, or you can save it to any of 13 different formats, or create spectrum files from scratch.
5
+
6
+
7
+ This package is a Python wrapper around the C++ [SpecUtils](https://github.com/sandialabs/SpecUtils) library, with the bindings created using [nanobind](https://github.com/wjakob/nanobind). [SpecUtils](https://github.com/sandialabs/SpecUtils) is primarily developed as part of [InterSpec](https://github.com/sandialabs/InterSpec/), but is also used by [Cambio](https://github.com/sandialabs/Cambio/), and a number of other projects.
8
+
9
+ An example use is:
10
+ ```python
11
+ import SpecUtils
12
+
13
+ # Create a SpecFile object
14
+ spec = SpecUtils.SpecFile()
15
+
16
+ # Load a spectrum file
17
+ spec.loadFile("spectrum_file.n42", SpecUtils.ParserType.Auto)
18
+
19
+ # Get list of all individual records in the spectrum file
20
+ meass = spec.measurements()
21
+ print( "There are", len(meass), "spectrum records." )
22
+
23
+ # Get first measurement
24
+ meas = meass[0]
25
+
26
+ # Get gamma counts, and the lower energy of each channel
27
+ counts = meas.gammaCounts()
28
+ energies = meas.channelEnergies()
29
+
30
+ # Get neutron counts
31
+ neutrons = meas.neutronCountsSum()
32
+
33
+ # Get start time
34
+ startime = meas.startTime()
35
+
36
+ # Print out CSV information of energies and counts
37
+ print( "StartTime: ", startime )
38
+ print( "Neutron counts: ", neutrons, "\n" )
39
+ print( "Energy (keV), Counts" )
40
+ for i in range(len(counts)):
41
+ print( f"{energies[i]},{counts[i]}" )
42
+ ```
43
+
44
+ For further examples, see the [examples](https://github.com/sandialabs/SpecUtils/tree/master/bindings/python/examples) directory.
45
+ To run the examples, run the following commands:
46
+ ```
47
+ python test_python.py
48
+ python make_file_example.py
49
+ python make_html_plot.py /some/path/to/a/file.n42
50
+ ```
51
+
52
+
53
+ ## Installation
54
+ You can install the package using pip like this:
55
+ ```
56
+ mkdir my_venv
57
+ python -m venv my_venv
58
+
59
+ source my_venv/bin/activate
60
+ pip install SandiaSpecUtils
61
+
62
+ python
63
+ >>> import SpecUtils
64
+ >>> spec = SpecUtils.SpecFile()
65
+ >>> ...
66
+ ```
67
+
68
+
69
+ Or instead, you can compile from source yourself, with something like:
70
+ ```
71
+ git clone https://github.com/sandialabs/SpecUtils.git SpecUtils
72
+
73
+ # Optionsally make/use a virtual environment
74
+ mkdir my_venv
75
+ python3 -m venv my_venv
76
+ source my_venv/bin/activate # Windows PowerShell: .\my_venv\Scripts\Activate.ps1
77
+
78
+ # Compile and install the bindings
79
+ pip install --use-feature=in-tree-build SpecUtils/bindings/python
80
+
81
+ # Use the package
82
+ python
83
+ >>> import SpecUtils
84
+ ```
85
+
86
+
87
+ ## Support
88
+ Please create an issue on the [SpecUtils GitHub repository](https://github.com/sandialabs/SpecUtils/issues), or email InterSpec@sandia.gov if you have any questions or problems.