Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2.0 #38

Open
wants to merge 147 commits into
base: main
Choose a base branch
from
Open

V2.0 #38

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
147 commits
Select commit Hold shift + click to select a range
edd6723
migrating to new repo structure
KedoKudo Dec 3, 2024
c5a7443
new static data manager
KedoKudo Dec 3, 2024
3ccd1cd
add unit test and update pytest settings
KedoKudo Dec 4, 2024
1a16aa3
add github action for unit test
KedoKudo Dec 4, 2024
987c743
add skeleton for the sammy backend support
KedoKudo Dec 17, 2024
f097c11
add configuration management for SAMMY execution backends
KedoKudo Dec 20, 2024
b986aaa
add directory preparation and execution logic for LocalSammyRunner
KedoKudo Dec 20, 2024
3717a34
refactor main execution logic in LocalSammyRunner for improved readab…
KedoKudo Dec 20, 2024
b8dfbe3
refactor Docker configuration validation and output collection logic …
KedoKudo Dec 20, 2024
b955a65
add NOVA backend implementation for SAMMY execution with configuratio…
KedoKudo Dec 23, 2024
867c661
add testing input data
KedoKudo Dec 23, 2024
3445307
add pyyaml dependency and configuration for SAMMY runner
KedoKudo Dec 23, 2024
0caa788
add back images
KedoKudo Dec 23, 2024
5b8d5b8
refactor SAMMY backend: update output collection logic and remove asy…
KedoKudo Dec 23, 2024
3a84dad
update poetry lock file
KedoKudo Dec 23, 2024
7e4c5d4
fix issues on runner
KedoKudo Dec 23, 2024
37e50c7
add unit test for interface
KedoKudo Dec 23, 2024
36b77d0
add unit tests for LocalSammyRunner and update coverage configuration
KedoKudo Dec 26, 2024
6efd3b2
fix errors introduced by pre-commit
KedoKudo Dec 26, 2024
d0fb413
fix issues related to mocked sammy binary
KedoKudo Dec 26, 2024
44c0173
add unit test for docker runner
KedoKudo Dec 26, 2024
93f72c1
add unit test for nova runner
KedoKudo Dec 26, 2024
1ad4f9a
add unit test for factory
KedoKudo Dec 27, 2024
3a97728
fix missing mocks for sammy binary
KedoKudo Dec 27, 2024
01492ea
add physical constants and validation tests
KedoKudo Dec 30, 2024
d15009e
add core physical quantity models with validation
KedoKudo Dec 30, 2024
14d2516
update deps lock
KedoKudo Dec 30, 2024
4fbc9b7
add models unit test
KedoKudo Dec 31, 2024
2106807
add neutron transmission calculations with error handling and logging
KedoKudo Dec 31, 2024
fdfdf2f
migrate sammy par file handler
KedoKudo Dec 31, 2024
cfb252a
switch back to original parFile parser
KedoKudo Jan 1, 2025
1dd4264
add legacy folder for og implementation
KedoKudo Jan 1, 2025
3aa1f55
add resonance card
KedoKudo Jan 7, 2025
58514cb
fix import error that leads to incorrect cov report
KedoKudo Jan 7, 2025
572110d
add extern R card parser
KedoKudo Jan 9, 2025
b862f63
add document to docs for original design
KedoKudo Jan 10, 2025
5975f47
fix name typo
KedoKudo Jan 14, 2025
8d73e39
add refactor design document
KedoKudo Jan 14, 2025
cb0cc0f
switch to pep621 format
KedoKudo Jan 16, 2025
3d5c043
add boardening card parser
KedoKudo Jan 16, 2025
8911e3f
add boradening paramter card
KedoKudo Jan 17, 2025
9d23c64
add unused card
KedoKudo Jan 17, 2025
b177aa0
add normalization card
KedoKudo Jan 17, 2025
41b09e6
add radius parser
KedoKudo Jan 22, 2025
be6e341
add unit test for radii
KedoKudo Jan 22, 2025
0ea0069
finished up development for radii card
KedoKudo Jan 22, 2025
081c50d
Merge pull request #23 from lanl/refactor_2nd_attempt
KedoKudo Jan 22, 2025
cfec5a1
add parser for data reduction
KedoKudo Jan 23, 2025
7ba58c3
add unit test for data reduction
KedoKudo Jan 23, 2025
5cbc690
Merge pull request #24 from lanl/sammy_param_datareduction
KedoKudo Jan 23, 2025
b25018c
add draft orres card
KedoKudo Jan 24, 2025
09f6882
update orres and imp partial unit test
KedoKudo Jan 26, 2025
18bbdfd
add unit test for LITHI
KedoKudo Jan 26, 2025
675390e
add unit test for NE110
KedoKudo Jan 27, 2025
251463d
add unit test for ChannelParameters
KedoKudo Jan 27, 2025
4f3743d
add final integrate test for orres card
KedoKudo Jan 27, 2025
229c2cd
expore orrse card at top level
KedoKudo Jan 27, 2025
57f9883
Merge pull request #25 from lanl/sammy_orres
KedoKudo Jan 27, 2025
70a10ff
add isotope and unit test
KedoKudo Jan 28, 2025
42e3706
Merge pull request #26 from lanl/sammy_iso_abund_mass
KedoKudo Jan 29, 2025
e493ea6
add delta and eta
KedoKudo Jan 30, 2025
5de5a55
add finit and gamma card
KedoKudo Jan 30, 2025
306ede1
add Tzero
KedoKudo Jan 30, 2025
a7609dd
add siabn
KedoKudo Jan 30, 2025
ea906b0
add SELFI
KedoKudo Jan 30, 2025
264ad35
add EFFIC
KedoKudo Jan 30, 2025
0e16330
add DELTE
KedoKudo Jan 30, 2025
2ed8a1f
add DrcapParameters
KedoKudo Jan 30, 2025
6dec7b9
add NONUN
KedoKudo Jan 30, 2025
c0333cb
remove special character
KedoKudo Jan 30, 2025
4deb0cd
Merge pull request #27 from lanl/sammy_param_misc
KedoKudo Jan 30, 2025
2c4c38e
add paramagnetic card
KedoKudo Jan 30, 2025
35e6a3f
Merge pull request #28 from lanl/sammy_param_paramag
KedoKudo Jan 30, 2025
6970fc2
enable checks from v2.0
KedoKudo Jan 31, 2025
b5d3fc2
add place holder modules for card not used now
KedoKudo Jan 31, 2025
8fe392e
enable pre-commit
KedoKudo Jan 31, 2025
2bda518
adjust exclude pattern
KedoKudo Jan 31, 2025
ab30e90
Merge pull request #32 from lanl/repo_config_adjust_3rd_attemp
KedoKudo Jan 31, 2025
b2a524b
safe guard not implemented cards
KedoKudo Feb 3, 2025
f09d580
safe guard resolution card with not implemented errors
KedoKudo Feb 3, 2025
b5632ee
safe guard det efficiency card with not implemented error
KedoKudo Feb 3, 2025
f811997
start with Burst param
KedoKudo Feb 7, 2025
9290971
add CHANN param
KedoKudo Feb 7, 2025
ee71936
deal with edge cases
KedoKudo Feb 7, 2025
2ab0757
update top level import
KedoKudo Feb 7, 2025
7f360fa
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 7, 2025
05ba314
Merge pull request #34 from lanl/sammy_param_user
KedoKudo Feb 7, 2025
c8d2177
add placeholder for the last card
KedoKudo Feb 7, 2025
81d09d7
Merge pull request #35 from lanl/sammy_param_last_placeholder
KedoKudo Feb 7, 2025
2da5efa
add to_string method for top level
KedoKudo Feb 10, 2025
3d218d5
add from string and aux func to top param class
KedoKudo Feb 12, 2025
cb7f20a
fix unit basic unit tests
KedoKudo Feb 12, 2025
31a2fdb
fix broadening card str format issue
KedoKudo Feb 12, 2025
df3fcfb
fixing logic errors in parsing cards
KedoKudo Feb 13, 2025
a4ce75b
radius card has serious issue, need special attention, disable for now
KedoKudo Feb 13, 2025
a266b93
Fix radius card bug
KedoKudo Feb 17, 2025
8626668
remove debug print and add usage example notebook
KedoKudo Feb 17, 2025
47b7258
Merge pull request #37 from lanl/sammy_parfile
along4 Feb 18, 2025
f2e4015
adding ex012 example in notebook format.
alexmlongLANL Feb 18, 2025
907d17d
fixed bug with reading in isotope header for card 10 in the parfile
alexmlongLANL Feb 18, 2025
a01df6b
added some print statements for errors from_string that prints the ac…
alexmlongLANL Feb 18, 2025
8fe77d5
cut out print statements I added into wrong error message.
alexmlongLANL Feb 19, 2025
3f3fd8c
added repo map (not complete)
alexmlongLANL Feb 19, 2025
be1d4f8
adding notebooks.
alexmlongLANL Feb 19, 2025
b060098
deleted notebook
alexmlongLANL Feb 19, 2025
2fb392d
made fudge card optional
alexmlongLANL Feb 19, 2025
7cca3dd
updated repo.map
alexmlongLANL Feb 19, 2025
21fc928
got rid off le=1.0 for abundances in Isotope class.
alexmlongLANL Feb 19, 2025
124fb1d
modified isotope.py to not use extended format and git rid of validat…
alexmlongLANL Feb 19, 2025
472889e
added a fudge factor line
alexmlongLANL Feb 19, 2025
1b9d628
modified print_parameters function.
alexmlongLANL Feb 19, 2025
f0c01b1
modified notebook ex012a.ipynb
alexmlongLANL Feb 20, 2025
c67acab
modified notebook
alexmlongLANL Feb 21, 2025
e4fa46c
adding logger for debugging issues
alexmlongLANL Feb 21, 2025
359ab09
adding os and logger imports to parfile.py
alexmlongLANL Feb 21, 2025
d80ef6b
moved _log_and_raise_error() to logger.py
alexmlongLANL Feb 21, 2025
260c4e3
implemented logging in parfile.py for most functions.
alexmlongLANL Feb 21, 2025
dc780be
adding more logging functionality.
alexmlongLANL Feb 21, 2025
b0be537
added class and function finder.
alexmlongLANL Feb 21, 2025
d8f0420
reorged radius.py
alexmlongLANL Feb 21, 2025
32cd3c4
got rid of logger functionality to find class and function being called
alexmlongLANL Feb 21, 2025
3d8d65a
got rid of get_current_class_and_function()
alexmlongLANL Feb 22, 2025
51d2df7
using where_am_i strings for debugging
alexmlongLANL Feb 22, 2025
f505fd6
idk!
alexmlongLANL Feb 22, 2025
eba8fd9
debugging default card reading
alexmlongLANL Feb 22, 2025
e4e7ea4
fixed bug to allow RadiusCard to handle multiple RadiusParameters ent…
alexmlongLANL Feb 22, 2025
7860595
deleted example.
alexmlongLANL Feb 22, 2025
d528bc1
added attribustes in doc string of ResonanceEntry
alexmlongLANL Feb 22, 2025
d128137
finally fixed bugs in radius with printing to file!
alexmlongLANL Feb 22, 2025
e71c678
expanded print function for parameters
alexmlongLANL Feb 22, 2025
f305335
added notes on parameter libraries.
alexmlongLANL Feb 22, 2025
842af1f
updated debug to info for logging
alexmlongLANL Feb 22, 2025
b7b6bf4
added loggign
alexmlongLANL Feb 22, 2025
4294188
got rid of RadiusParametersContainer class.
alexmlongLANL Feb 22, 2025
40068a6
adding more detials to parfile_notes.md
alexmlongLANL Feb 22, 2025
c25dc03
updated notebook for example 12.
alexmlongLANL Feb 22, 2025
75f9c51
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 22, 2025
c4d7cb5
got rid of testing abundance validation, since this is no longer true…
alexmlongLANL Feb 22, 2025
b0d97d8
Fixed bug in IsotopeCard.is_header_line(). Can now identify both "ISO…
alexmlongLANL Feb 22, 2025
2599a4f
Merge branch '39-v20-examples' of github.com:lanl/PLEIADES into 39-v2…
alexmlongLANL Feb 22, 2025
1528139
adjusted functions test_radius.py for new list object for RadiusCard.
alexmlongLANL Feb 22, 2025
9cd9253
adjusted test_full_roundtrip to handle list of radiusParameters
alexmlongLANL Feb 22, 2025
fa9bd68
fixed bug in reading in parFile strings.
alexmlongLANL Feb 22, 2025
aeecdb8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 22, 2025
3b589a6
using unused variables in RadiusCardKeyword class to make overlord "p…
alexmlongLANL Feb 22, 2025
b48eed1
more making overlord happy
alexmlongLANL Feb 22, 2025
607a4b4
Merge pull request #40 from lanl/39-v20-examples
along4 Feb 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/unittest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Run Unittests

on:
pull_request:
branches:
- main
- v2.0
push:
branches:
- main
- v2.0

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
export PATH="$HOME/.local/bin:$PATH"
poetry --version

- name: Install dependencies
run: |
export PATH="$HOME/.local/bin:$PATH"
poetry install

- name: Run tests with pytest
run: |
export PATH="$HOME/.local/bin:$PATH"
poetry run pytest tests
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ repos:
args: [--allow-multiple-documents]
exclude: "conda.recipe/meta.yaml"
- id: end-of-file-fixer
exclude: "nucDataLibs/.*"
exclude: "(tests/data/.*|src/pleiades/data/.*)"
- id: trailing-whitespace
exclude: "nucDataLibs/.*"
exclude: "(tests/data/.*|src/pleiades/data/.*)"
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.3
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
exclude: "nucDataLibs/.*"
exclude: "(tests/data/.*|legacy/.*|src/pleiades/data/.*)"
- id: ruff-format
exclude: "nucDataLibs/.*"
exclude: "(tests/data/.*|legacy/.*|src/pleiades/data/.*)"
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
exclude: "(nucDataLibs/.*|.*\\.ipynb)|poetry.lock"
exclude: "(tests/data/.*|.*\\.ipynb|poetry.lock|src/pleiades/data/.*)"
args: ["--ignore-words-list=DELTE"]
7 changes: 3 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
.. image:: ./docs/images/PLEIADES.jpg
:alt: **PLEIADES:** Python Libraries Extensions for Isotopic Analysis via Detailed Examination of SAMMY.
:align: center

PLEIADES
========
.. image:: https://results.pre-commit.ci/badge/github/lanl/PLEIADES/main.svg
:target: https://results.pre-commit.ci/latest/github/lanl/PLEIADES/main
:alt: pre-commit.ci status

.. image:: https://readthedocs.org/projects/example-sphinx-basic/badge/?version=latest
:target: https://pleiades-sammy.readthedocs.io/en/latest/
Expand Down
190 changes: 190 additions & 0 deletions docs/development/architecture_v1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
# PLEIADES Architecture Documentation

This document is the design document for PLEIADES(v1), followed by suggestions on refactoring and enhancements.

## Overview

PLEIADES is a computational platform designed for neutron resonance analysis, with a focus on SAMMY integration and workflow management. The architecture follows a layered design with clear separation between configuration, execution, and analysis components.

## System Architecture

The system is divided into four main layers:

1. **Core Layer**: Core configuration management and nuclear data access
1. **Processing Layer**: Workflow orchestration and input generation
1. **Execution Layer**: SAMMY execution and parameter management
1. **Analysis Layer**: Results parsing and visualization

```mermaid
graph TD
User[User Script] --> |"Configure"| SammyUtils
User --> |"Visualize"| SammyPlotter

subgraph Core["Core Layer"]
SammyStructures["sammyStructures.py<br/>Configuration Management"]
NucData["nucData.py<br/>Nuclear Data Access"]
end

subgraph Processing["Processing Layer"]
SammyUtils["sammyUtils.py<br/>Orchestration"] --> SammyStructures
SammyUtils --> NucData
SammyInput["sammyInput.py<br/>Input Generation"] --> NucData
SammyParFile["sammyParFile.py<br/>Parameter Management"] --> NucData
end

subgraph Execution["Execution Layer"]
SammyRunner["sammyRunner.py<br/>SAMMY Integration"]
SammyUtils --> SammyRunner
SammyRunner --> SammyInput
SammyRunner --> SammyParFile
end

subgraph Analysis["Analysis Layer"]
SammyOutput["sammyOutput.py<br/>Results Parser"]
SammyPlotter["sammyPlotter.py<br/>Visualization"]
SammyOutput --> SammyPlotter
SammyRunner --> SammyOutput
end
```

## Module Details

| Module | Key Components | Complexity | Summary |
|--------|---------------|------------|----------|
| sammyStructures.py | `SammyFitConfig`, `sammyRunConfig` | High | Core configuration management system handling parameter storage, validation, and directory structures |
| nucData.py | `get_mass_from_ame()`, `extract_isotope_info()`, `get_info()` | Medium | Nuclear data access layer providing isotope information and atomic mass calculations |
| sammyUtils.py | `create_parFile_from_endf()`, `configure_sammy_run()`, `run_sammy()` | High | High-level orchestrator managing workflow and coordinating between modules |
| sammyRunner.py | `run_sammy_fit()`, `check_sammy_environment()` | Medium | SAMMY execution manager handling both local and Docker environments |
| sammyInput.py | `InputFile` class | Medium | SAMMY input file generator with format-specific handlers |
| sammyParFile.py | `ParFile`, `Update` classes | High | Parameter file manager supporting complex operations on SAMMY par files |
| sammyOutput.py | `lptResults` class | Medium | Output parser extracting fit results from SAMMY output files |
| sammyPlotter.py | `process_and_plot_lst_file()` | Low | Visualization tools for SAMMY results |
| simData.py | `create_transmission()`, `Isotope` class | Low | Simulation support for transmission data |

## Example Workflow

The following example demonstrates a typical workflow using PLEIADES for SAMMY analysis:

```python
# 1. Configuration Setup
from pleiades import sammyUtils, sammyPlotter
config = sammyUtils.SammyFitConfig("uranium.ini")

# 2. Generate Parameter Files
sammyUtils.create_parFile_from_endf(config, verbose_level=1)

# 3. Configure SAMMY Run
sammy_run = sammyUtils.configure_sammy_run(config, verbose_level=1)

# 4. Execute SAMMY Fit
sammyUtils.run_sammy(config, verbose_level=1)

# 5. Analyze Results
sammyPlotter.process_and_plot_lst_file(
f"{config.params['directories']['sammy_fit_dir']}/results/SAMMY.LST",
residual=True,
quantity="transmission"
)

# Optional: Iterative Refinement
# Update isotopes/parameters and rerun
config.params["isotopes"]["names"].append("Ta-181")
config.params["isotopes"]["abundances"].append(0.01)
sammy_run = sammyUtils.configure_sammy_run(config, verbose_level=1)
```

Key Workflow Steps:

1. Initialize configuration from `INI` file
2. Generate parameter files from `ENDF` data
3. Configure SAMMY run environment
4. Execute SAMMY fit
5. Analyze and visualize results
6. [Optional] Iterate with parameter refinements

The system supports both simple workflows and complex scenarios involving multiple isotopes and iterative refinement of fits.

## Opportunities for Enhancement

### Core Considerations

1. **SAMMY Integration Requirements**
- The existing codebase effectively handles SAMMY's fixed-width format requirements
- This core functionality must be preserved during any refactoring
- Format definitions and card structures are essential and cannot be simplified

1. **Class Organization**
- The `ParFile` and `InputFile` classes successfully manage complex SAMMY requirements
- Could benefit from internal reorganization while maintaining external interfaces
- Consider using composition for different card types while keeping format compliance

```python
# Current approach works but could be reorganized internally
class ParFile:
def __init__(self):
self._SPIN_GROUP_FORMAT = {...} # Essential format definition
self._CHANNEL_RADII_FORMAT = {...}
```

### Implementation Opportunities

1. **Type System Enhancement**
- Adding type hints could improve code maintainability
- Would help new developers understand data structures better

```python
# Potential enhancement while maintaining functionality
def parse_spin_group(self, data: SpinGroupData) -> SpinGroupCard:
"""Parse spin group data into SAMMY-compliant format"""
```

1. **File Handling Consistency**
- Consider standardizing on `pathlib` for path operations
- Maintain robust file handling while improving consistency

```python
# Standardize on pathlib while keeping functionality
symlink_path = pathlib.Path(fit_dir) / "res_endf8.endf"
```

1. **Input Validation**
- Could consolidate validation while maintaining format requirements
- Early validation would help users identify issues sooner

### Testing and Documentation

1. **Test Coverage**
- Add unit tests to ensure format compliance
- Create test fixtures for common SAMMY input scenarios
- Validate output formats match SAMMY requirements

1. **Documentation Enhancement**
- Expand docstrings for complex format handling
- Add examples of correct SAMMY input generation
- Document format requirements clearly

### Performance Considerations

1. **Resource Management**
- Review file handling patterns
- Consider streaming for large files where possible

```python
# Potential enhancement for large files
def process_large_file(self, filename: Path) -> Iterator[str]:
with filename.open() as f:
for line in f:
yield self.process_line(line)
```

### Future Development Opportunities

1. **Module Organization**
- Consider grouping related SAMMY format handlers
- Maintain format compliance while improving code organization

1. **Error Handling**
- Enhance error messages for format-related issues
- Help users understand SAMMY's requirements better

The original implementation effectively manages SAMMY's complex requirements. These suggestions aim to build upon that foundation while maintaining full compatibility with SAMMY's fixed-width format requirements.
Loading