Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

CALINS

CALculations and Investigations on Nuclear data uncertainties and Sensitivities

Python Version License: BSD-3-Clause

A Python package for computing nuclear data uncertainty propagation, sensitivity analyses, and data assimilation using the Generalized Linear Least Squares Method (GLLSM).

📚 Read the Documentation | 🚀 Quick Start Guide | 💡 Usage Examples

Developed by: French Authority for Nuclear Safety and Radiation Protection (ASNR)


Table of Contents


About

CALINS is a specialized Python package designed for nuclear safety and criticality calculations. It enables:

  • Uncertainty propagation from nuclear data to integral responses
  • Sensitivity analysis of nuclear systems to cross-section variations
  • Data assimilation using the Generalized Linear Least Squares Method (GLLSM)
  • Bias estimation for calculated responses based on experimental benchmarks

The package is particularly useful for criticality safety analyses where understanding uncertainties and biases in calculated keff values is essential.

Features

  • ✅ Uncertainty Calculation: Propagate nuclear data uncertainties using the sandwich formula
  • ✅ Sensitivity Analysis: Process and visualize sensitivity profiles from SDF files
  • ✅ Similarity Indices: Calculate E, Ck, G, and SSR indices between cases
  • ✅ GLLSM Assimilation: Assimilate experimental benchmark data to reduce uncertainties
  • ✅ Multiple Covariance Formats: Support for SCALE (COVERX binary/text), COMAC, GENDF, and Excel (xlsx) formats, with auto-detection
  • ✅ Interactive Visualizations: Generate HTML reports with Plotly graphs
  • ✅ Chi-squared Filtering: Automatic filtering of inconsistent benchmark cases

Installation

Prerequisites

  • Python: Version 3.9 or higher
  • Operating System: Windows, macOS, or Linux
  • Dependencies: Listed in requirements.txt (automatically installed)
    • numpy ≥ 1.24.2
    • pandas ≥ 2.0.0
    • plotly ≥ 5.14.0
    • matplotlib ≥ 3.8.3
    • tabulate ≥ 0.9.0
    • scipy ≥ 1.13.0

Installing CALINS

Method 1: From GitHub (Latest Version)

  1. Clone or download the repository:

    git clone https://github.com/ASNR-fr/CALINS.git
    cd CALINS
    
  2. Install the package:

    pip install .
    

Method 2: From ZIP Archive

If you have downloaded a compressed archive:

pip install calins-archive.zip

Method 3: Development Installation

For development or contributing, install in editable mode with the development tools (pytest, ruff, black, pre-commit):

pip install -e .[dev]

Optional extras: xlsx (Excel import/export of covariances), export (static image export with kaleido), docs (MkDocs documentation).

Verification

Verify that CALINS is installed correctly:

import calins as cl
print(cl.__version__)  # version derived from the git tags (e.g. 1.0.0b0)

You can also check for auto-completion in your Python IDE/environment to confirm the installation.

Usage Examples

This section provides practical examples for common CALINS operations. For comprehensive examples, refer to the USER_EXAMPLES.ipynb notebook.

Creating a Case Object

A Case object represents an application case or benchmark with sensitivity data:

import calins as cl

# Path to your sensitivity file (.sdf format)
sensi_file_path = 'path/to/sensitivity.sdf'

# Create Case object
# occurrences_rule: how to handle multiple occurrences of same iso-reac pair
#   Options: "first", "last", "sum" (default)
my_case = cl.Case(sdf_path=sensi_file_path, occurrences_rule="sum")

# Generate HTML interactive visualization of sensitivities
my_case.export_to_html(
    output_html_path='case_sensitivities.html',
    plotting_unit='pcm'  # Options: 'pcm' or 'relative'
)
# Generate publication-level static plots
my_case.plot_integrals(output_path='./case_integrals.png')
my_case.plot_profiles(iso_reac_list=[('U-235', 1), ('U-235', 18), ('U-238', 101)], dashed_traces= [True, False, True], traces_colors=['black', 'red', 'green'],  output_path='./case_U5.png')

# Access case attributes
print(f"Case name: {my_case.casename}")
print(f"Energy groups: {my_case.group_nb}")
print(f"Calculated k_eff: {my_case.resp_calc} ± {my_case.sigma_resp_calc}")
if my_case.resp_expe:
    print(f"Experimental k_eff: {my_case.resp_expe} ± {my_case.sigma_resp_expe}")

Creating a Nuclear Data Covariance Object

import calins as cl

# Load covariance data using NDCovariances object
scale_file_path = 'path/to/scale_44g'
cov_data = cl.NDCovariances(input_path=scale_file_path, format='coverx')
# Alternative formats: 'coverx_text', 'comac', 'gendf', 'xlsx', or 'auto' for auto-detection

# Access NDCovariances attributes
print(f"Reaction uncertainties available: {cov_data.reac_list}")

# Generate publication-level static plots
cov_data.plot_specific(iso_reac_horizontal=('U-235', 18), iso_reac_vertical=('U-235', 18), output_path='scale_44g_U5_18.png')

Calculating Uncertainty

Calculate nuclear data uncertainty using the sandwich formula:

import calins as cl

# Load covariance data using NDCovariances object (recommended)
scale_file_path = 'path/to/scale_44g'
cov_data = cl.NDCovariances(input_path=scale_file_path, format='coverx')
# Alternative formats: 'coverx_text', 'comac', 'gendf', 'xlsx', or 'auto' for auto-detection

# Load sensitivity data
sensi_file_path = 'path/to/sensitivity.sdf'

# Calculate a priori uncertainty
uncertainty = cl.calcul_uncertainty(
    appl_case=sensi_file_path,  # Can also be a Case object
    cov_data=cov_data,
    reac_list=[2, 4, 16, 18, 102, 103, 452, 1018],
    output_html_path='uncertainty_report.html'
)

print(f"A priori uncertainty: {uncertainty.value} pcm")
print(f"Calculated k_eff: {uncertainty.resp_calc}")

# Export decomposition to Excel
uncertainty.decomposition.to_excel('uncertainty_decomposition.xlsx')

# Optional: Export and re-import covariance data via Excel
# cov_data.write_xlsx('covariance_data.xlsx')
# cov_data_reloaded = cl.NDCovariances(input_path='covariance_data.xlsx', format='xlsx')

Computing Similarity Indices

Evaluate similarity between different cases:

import calins as cl

# Load two cases to compare
case1 = cl.Case('path/to/case1.sdf')
case2 = cl.Case('path/to/case2.sdf')

# Load covariance data using NDCovariances object (recommended)
cov_data = cl.NDCovariances(input_path='path/to/covariance', format='auto')

# Calculate E similarity index (0 to 1)
E_index = cl.calcul_E(case1, case2, reac_list=[2, 4, 16, 18, 102, 103, 452, 1018])
print(f"E similarity index: {E_index}")

# Calculate C_k index (weighted by covariances)
Ck_index = cl.calcul_Ck(case1, case2, cov_data, reac_list=[2, 4, 16, 18, 102, 103, 452, 1018])
print(f"C_k similarity index: {Ck_index}")

# Calculate SSR index (Shared Sensitivity Ratio)
SSR_index = cl.calcul_SSR(appl_case=case1, bench_case=case2, reference=case1, reac_list=[2, 4, 16, 18, 102, 103, 452, 1018])
print(f"SSR index: {SSR_index}")

Performing Data Assimilation

Assimilate experimental benchmark data using GLLSM:

import calins as cl

# Define application case
appl_case = cl.Case('path/to/appl_case.sdf')

# Define benchmark cases
benchmarks = [
    cl.Case('path/to/benchmark1.sdf'),
    cl.Case('path/to/benchmark2.sdf'),
    cl.Case('path/to/benchmark3.sdf')
]

# Load covariance data using NDCovariances object (recommended)
cov_data = cl.NDCovariances(input_path='path/to/covariance', format='auto')

# Perform assimilation
assimilation = cl.Assimilation(
    appl_case=appl_case,
    benchmarks_list=benchmarks,
    cov_data=cov_data,
    targetted_chi2=1.5,  # Optional: chi-squared filtering threshold
    Ck_threshold=0.7,    # Optional: C_k similarity threshold
    reac_list=[2, 4, 16, 18, 102, 103, 452, 1018],
    output_html_path='assimilation_results.html'
)

# Access results
print(f"Prior uncertainty: {assimilation.prior_uncertainty.value} pcm")
print(f"Posterior uncertainty: {assimilation.post_uncertainty.value} pcm")
print(f"Bias: {assimilation.bias.value} pcm")
print(f"Chi-squared: {assimilation.prior_chi2} → {assimilation.post_chi2}")

# Export only the interactive sensitivity report of the application case
assimilation.export_appl_case_sensi_to_html(
  output_html_path='application_case_sensitivities.html'
)

Sensitivity Analysis and Case Screening

CALINS provides advanced capabilities for sensitivity analysis and case screening, allowing users to identify the most sensitive cases and analyze sensitivity patterns across multiple benchmarks.

These functions are particularly useful for:

  • Benchmark selection: Identifying the most sensitives cases, targetting specific nuclear data
  • Pattern identification: Spotting systematic sensitivity trends across benchmark suites and uderstanding which energy ranges drive uncertainties
  • Isotope comparison: Comparing sensitivity patterns between different isotopes
  • Benchmark characterization: Understanding the physical characteristics of different experiments
  • Cross-section priority: Determining which nuclear data require the most attention

Finding Sensitive Cases

Use find_sensitive_cases() to identify cases with significant sensitivities to specific isotope-reaction pairs:

import calins as cl
import pickle

# Path to a pickle containing a dictionary of Case objects
pickle_db = "/PATH/TO/DATABASE/cases.pickle" 

with open(pickle_db, "rb") as pickle_file:
    dict_pickle = pickle.load(pickle_file)

# Selecting cases to consider for analysis - here all MIX-COMP-THERM except series 006
filtered_cases = cl.filter_cases(dict_pickle, to_keep=["MIX-COMP-THERM"], to_exclude=["MIX-COMP-THERM-006"]) 

# Searching for cases sensitive to the fission cross-sections of U-235 and Pu-239 in the thermal domain,
# based on integral sensitivities, not normalized in lethargy.
# Only bins with a sensitivity ≥ 2e-3, representing more than 10% of the integral sensitivity, are considered sensitive.
sensitive_cases = cl.find_sensitive_cases(
    dict_pickle,
    filtered_cases,
    isotopes=[92235, 94239],
    reactions=[18, 18],
    energy_regions=["thermal", "thermal"],
    sensitivity_threshold=2e-3,
    fraction_threshold = 0.10,
    integrate_data=True,
    normalize_lethargy = False,
)

# Displaying in the terminal the 50 most sensitive cases according to the previous search criteria
cl.display_most_sensitive_cases(dict_sensitive = sensitive_cases, max_number_of_cases_displayed=50)

Creating Sensitivity Heatmaps

Use plot_sensitivity_heatmap() to create visual heatmaps showing how many cases show the same sensitivity patterns across multiple energy regions:

import calins as cl
import pickle

# Path to a pickle containing a dictionary of Case objects
pickle_path = "/PATH/TO/DATABASE/database_dict.pickle"

with open(pickle_path, "rb") as pickle_file:
    dict_pickle = pickle.load(pickle_file)

# Selecting cases to consider for analysis - here all LEU-COMP-THERM except series 001
list_cases = cl.filter_cases(dict_pickle, to_keep=[], to_exclude=[]) 

# Creating a heatmap of cases sensitive to cross-sections of SCATTER (0), TOTAL (1), ELASTIC (2), N,GAMMA (102)
# Only bins with a sensitivity ≥ 2e-3 and representing more than 10% of the integral sensitivity will be considered sensitive.
cl.plot_sensitivity_heatmap(
    dict_data=dict_pickle,
    cases=list_cases,
    isotopes=[17035, 17037],
    reactions=[0, 1, 2, 102],
    sensitivity_threshold=2e-3,
    fraction_threshold = 0.10,
    user_energy_bins=None,
    title="Cases pickle db sensitivity heatmap for chlorine isotopes",
    namefig=None,
    save_logfile=True,
)

Points of Attention

⚠️ Important Considerations (read this section along with the Theory chapter and examples in USER_EXAMPLES.ipynb)

Special Isotope Handling

  • Bounded isotopes: Some isotopes in sensitivity files are not present in variance-covariance matrices. TSURFER (SCALE) uses data from the closest isotope, and CALINS detects these cases when the hundreds digit of the ID is ≥ 3:

    • be-9 bounded (ID=4309 or 4509) → associated with covariances of be-9 (ID=4009)
    • h-1 bounded (ID=1901 or 1801) → associated with covariances of h-1 (ID=1001)
  • Natural isotopes: Isotopes with 'natural' evaluated forms:

    • c-12 bounded (ID=6312) → associated with covariances of c-0 (ID=6000)

Reaction ID Considerations

  • CAPTURE vs N,GAMMA: Some covariance matrices have data for CAPTURE reaction (ID=101), others for N,GAMMA reaction (ID=102), which are very close. Be careful when associating these reactions.

  • MCNP negative IDs: SDF files from MCNP calculations can contain reactions with negative IDs:

    • CALINS associates reaction -2 to reaction 101 if the mcnp=True flag is enabled when creating the Case object
    • Other negative reactions trigger a warning

Sensitivity Profile Occurrences

When an SDF file has multiple sensitivity profiles for the same isotope-reaction pair (same IDs), TSURFER (SCALE) parses profiles differently. CALINS provides three rules:

  • occurrences_rule='first': Use the first occurrence as the sensitivity profile
  • occurrences_rule='sum' (default): Sum all occurrences for the profile
  • occurrences_rule='last': Use the last occurrence

Migration from CALINS < 1.0

  • The package follows a src/ layout and is split into sub-packages (calins.io, calins.core, calins.analysis, calins.assimilation, calins.plotting, calins.reporting). The public API is unchanged (import calins as cl); the former modules calins.src.* still work but emit a DeprecationWarning.
  • Options are set through cl.config (verbose, offline_export, log_dir, max_log_files).
  • The covariance DataFrame column STD is renamed COV, and the energy bins are no longer stored in a pseudo-row (0, 0, 0, 0) (use NDCovariances.e_bins). Excel files written by older versions are still readable.
  • The covariance matrix built by make_cov_matrix is a sparse scipy.sparse.csr_matrix.
  • The detailed results of the similarity indices (return_iso_reac_list, return_partial, return_decomposition) and the USL_* attributes are dict subclasses (SimilarityResult, USLResult) also readable by attribute.
  • Assimilation(..., auto_run=False) defers the computation to Assimilation.run().

Theory & Developer Manual

For complete theoretical background and developer documentation, see the online documentation:

  • Theory — Sensitivity vectors, covariance matrices, sandwich formula, GLLSM assimilation, similarity indices
  • Developer Manual — Code architecture, data structures, classes, and internal functions

Contributing

Contributions to CALINS are welcome! If you would like to contribute:

  1. Fork the repository on GitHub
  2. Create a new branch for your feature or bug fix
  3. Make your changes with clear, descriptive commit messages
  4. Add tests if applicable
  5. Ensure all tests pass by running pytest (and pre-commit run --all-files for formatting/linting)
  6. Submit a pull request with a clear description of your changes

For major changes, please open an issue first to discuss what you would like to change.

Development Setup

For development, install in editable mode:

git clone https://github.com/ASNR-fr/CALINS.git
cd CALINS
pip install -e .[dev]
pre-commit install  # ruff + black at each commit

The package version is computed from the git tags by setuptools-scm (e.g. tag v1.0.0b0); there is no version file to update by hand.

Troubleshooting

Common Issues

Import Errors

Problem: ModuleNotFoundError: No module named 'calins'

Solution: Ensure CALINS is properly installed:

pip install .
# Or for development:
pip install -e .

Missing Dependencies

Problem: Import errors for numpy, pandas, plotly, etc.

Solution: Install all dependencies:

pip install -r requirements.txt

Sensitivity File Parsing Issues

Problem: Error when loading SDF files

Solutions:

  • Ensure the file path is correct and the file exists
  • Check that the SDF file format is compatible (SCALE/TSUNAMI format)
  • Try using mcnp=True flag for MCNP-generated files with negative reaction IDs
  • Verify the occurrences_rule parameter if you have duplicate iso-reac pairs

Covariance Matrix Issues

Problem: Missing covariance data for specific isotopes

Solution: CALINS automatically handles some cases:

  • Bounded isotopes (e.g., h-poly) use data from base isotopes
  • Natural isotopes (e.g., c-0) are matched to specific isotopes when available
  • Check the warnings in logs for missing data

Matrix Inversion Errors

Problem: Cholesky decomposition fails during assimilation

Solutions:

  • Reduce the number of benchmark cases
  • Check for highly correlated benchmarks
  • Verify that experimental uncertainties are realistic
  • Consider using chi-squared or Ck filtering

Getting Help

If you encounter issues not covered here:

  • Check the logs in ~/.CALINS/ (or cl.config.log_dir) for detailed error messages
  • Review the USER_EXAMPLES.ipynb notebook for working examples
  • Open an issue on GitHub with:
    • Description of the problem
    • Minimal code to reproduce the issue
    • Error messages and logs
    • CALINS version (cl.__version__) and Python version

Citation

If you use CALINS in your research or work, please cite it appropriately:

@article{petillon,
  TITLE = {CALINS: A New ASNR Software for Sensitivity and Uncertainty Analysis in Nuclear Criticality Safety Evaluations},
  AUTHOR = {Petillon, Barth{\'e}l{\'e}mi and Peron, Arthur and Vuiart, Romain and Jaiswal, Vaibhav and Brovchenko, Mariya},
  JOURNAL = {Nuclear Science and Engineering},
  YEAR = {2026},
  PUBLISHER = {Taylor \& Francis},
}

References

Key Publications

License

This project is licensed under the BSD-3-Clause License - see the LICENSE file for details.


Developed and maintained by: French Authority for Nuclear Safety and Radiation Protection (ASNR)

Contact: For questions and support, please use the GitHub issue tracker.

Metadata

Release files for calins 1.0.0b2

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

Source distribution (sdist)

Source distribution for calins 1.0.0b2
File Size Uploaded Provenance Actions
calins-1.0.0b2.tar.gz 3.7 MB With provenance Details for calins-1.0.0b2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for calins 1.0.0b2
File Interpreter ABI Platform Actions
calins-1.0.0b2-py3-none-any.whl Python 3 none any Details for calins-1.0.0b2-py3-none-any.whl

Total release size: 3.9 MB

Release files / calins-1.0.0b2.tar.gz

Download URL calins-1.0.0b2.tar.gz
Size 3.7 MB
Tags Source
SHA-256 checksum
How to use checksums
472b5ec79f03fe186a0f6a056343c258fe66444760d39a870d3d8fcb5a445878
BLAKE2b-256 checksum
How to use checksums
12b373c53381b22efa3d41a885be42c114c26c78168b25fee2fdcf5e70241598
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Release files / calins-1.0.0b2-py3-none-any.whl

Download URL calins-1.0.0b2-py3-none-any.whl
Size 153.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fbbaa67acb33c2669797cf1749781b9bd962d4011e9b747fc2164c606e0f030c
BLAKE2b-256 checksum
How to use checksums
cf463122f93a4597083abe9bc09de239b6e0445c184e5d0ae6be591a3eceec57
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Security for calins 1.0.0b2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for calins-1.0.0b2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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