pleiades.sammy.io.inp_manager module
Module for managing SAMMY input (.inp) files.
This module provides the InpManager class to generate and write SAMMY input files based on FitOptions configurations. It supports different modes (ENDF, fitting, custom) through the refactored FitOptions class and its factory methods.
- class pleiades.sammy.io.inp_manager.InpDatasetMetadata(*, element: str | None = None, mass_number: int | None = None, atomic_mass_amu: float | None = None, min_energy_eV: float | None = None, max_energy_eV: float | None = None, temperature_K: float | None = None, density_g_cm3: float | None = None, thickness_mm: float | None = None, vary_normalization: bool | None = None, vary_background: bool | None = None, vary_tzero: bool | None = None, vary_thickness: bool | None = None)[source]
Bases:
BaseModelOptional typed dataset metadata used to seed INP generation.
These values are dataset-level hints and should only be used when the corresponding value is not already provided in
FitConfig.- model_config = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class pleiades.sammy.io.inp_manager.InpManager(options: FitOptions = None, title: str = None, isotope_info: Dict | None = None, physical_constants: Dict | None = None, reaction_type: str = None, fit_config: FitConfig = None)[source]
Bases:
objectManages creation and writing of SAMMY input (.inp) files.
This class takes a FitOptions object and generates a SAMMY input file with the appropriate commands based on the selected options.
- options
Configuration options for SAMMY
- Type:
- isotope_info
Dictionary with isotope information
- Type:
Dict, optional
- physical_constants
Dictionary with physical constants
- Type:
Dict, optional
- __init__(options: FitOptions = None, title: str = None, isotope_info: Dict | None = None, physical_constants: Dict | None = None, reaction_type: str = None, fit_config: FitConfig = None)[source]
Initialize with optional FitOptions and section information.
- Parameters:
options – FitOptions instance containing SAMMY configuration
title – Title/description for the inp file
isotope_info – Isotope information (name, mass, energy range)
physical_constants – Physical constants (temperature, flight path, etc.)
reaction_type – Reaction type (transmission, capture, etc.)
- set_options(options: FitOptions) None[source]
Set FitOptions after initialization.
- Parameters:
options – FitOptions instance to use
- generate_commands() List[str][source]
Generate SAMMY input commands from options.
- Returns:
List of SAMMY alphanumeric commands
- Return type:
List[str]
- generate_title_section() str[source]
Generate the title section of the inp file.
- Returns:
Title line (defaults to “SAMMY analysis” if not provided)
- Return type:
- generate_isotope_section() str[source]
Generate the isotope information section of the inp file using Card Set 2 format.
- Returns:
Properly formatted Card Set 2 element information line
- Return type:
- generate_physical_constants_section(dataset_metadata: InpDatasetMetadata | None = None) str[source]
Generate Card Set 5 physical constants from FitConfig.
- Parameters:
dataset_metadata – Optional typed metadata used only as a fallback source for temperature when FitConfig does not define one.
- Returns:
Physical constants line
- Return type:
- generate_card_7_section(dataset_metadata: InpDatasetMetadata | None = None) str[source]
Generate Card Set 7 (CRFN, THICK) from FitConfig.
- Parameters:
dataset_metadata – Optional typed metadata used to derive THICK when broadening.thick is not already defined in FitConfig.
- Returns:
Card Set 7 line or empty string if unavailable
- Return type:
- generate_reaction_type_section() str[source]
Generate the reaction type section of the inp file.
- Returns:
Reaction type (defaults to “transmission” if not provided)
- Return type:
- generate_card_set_2_element_info(dataset_metadata: InpDatasetMetadata | None = None) str[source]
Generate Card Set 2 (element information) according to SAMMY documentation.
This generates the second line with element name, atomic weight, and energy range according to SAMMY Card Set 2 specification.
- Parameters:
dataset_metadata – Optional typed metadata used to override selected Card 2 values after reading defaults from FitConfig.
- Returns:
Properly formatted Card Set 2 element information line
- Return type:
- generate_broadening_parameters_section(dataset_metadata: InpDatasetMetadata | None = None) str[source]
Generate broadening parameters section from FitConfig.
- Parameters:
dataset_metadata – Optional typed metadata used to fill temperature and derive THICK when these are not defined in FitConfig.
- Returns:
Broadening parameters section with required blank line before it
- Return type:
- generate_misc_parameters_section(flight_path_m: float = 25.0, dataset_metadata: InpDatasetMetadata | None = None) str[source]
Generate miscellaneous parameters (TZERO) section.
- Parameters:
flight_path_m – Flight path length in meters (default 25.0 for VENUS)
dataset_metadata – Optional metadata; if vary_tzero is False, uses identity values (t0=0, L0=1) with flags set to NO.
- Returns:
Miscellaneous parameters section
- Return type:
- generate_normalization_parameters_section(dataset_metadata: InpDatasetMetadata | None = None) str[source]
Generate normalization parameters section.
- Parameters:
dataset_metadata – Optional metadata; if vary_normalization is False, fixes normalization at 1.0. If vary_background is False, sets all backgrounds to 0.0 with NO flags.
- Returns:
Normalization parameters section with required blank line before it
- Return type:
- generate_resolution_function_section(resolution_file: str = 'venus_resolution.dat') str[source]
Generate user-defined resolution function section.
- Parameters:
resolution_file – Name of resolution function file, or None to disable
- Returns:
Resolution function section or empty string if disabled
- Return type:
- generate_multi_isotope_inp_content(dataset_metadata: InpDatasetMetadata | None = None, resolution_file_path: Path = None) str[source]
Generate complete multi-isotope INP content with parameter sections.
- Parameters:
dataset_metadata – Optional typed metadata with dataset-level hints
resolution_file_path – Optional absolute path to resolution function file
- Returns:
Complete multi-isotope INP file content
- Return type:
- generate_inp_content() str[source]
Generate full content for SAMMY input file.
- Returns:
Complete content for SAMMY input file
- Return type:
- write_inp_file(file_path: Path) Path[source]
Write a SAMMY input file to disk.
- Parameters:
file_path – Path where the input file should be written
- Returns:
Path to the created file
- Return type:
Path
- Raises:
IOError – If file cannot be written
- read_inp_file(file_path: Path, fit_config: FitConfig = None) FitConfig[source]
Read a SAMMY input file and populate a FitConfig instance.
- Parameters:
file_path – Path to the input file
fit_config – Optional FitConfig to populate
- Returns:
Populated FitConfig instance
- Return type:
- classmethod from_fit_config(fit_config: FitConfig, isotope_info: Dict | None = None, physical_constants: Dict | None = None, reaction_type: str | None = None, options: FitOptions | None = None, title: str | None = None) InpManager[source]
Create an InpManager instance backed by a FitConfig.
- Parameters:
fit_config – FitConfig object to read defaults from
isotope_info – Optional dict to override Card Set 2 element info
physical_constants – Optional dict to override Card Set 5 constants
reaction_type – Optional reaction type override
options – Optional FitOptions override
title – Optional title override
- classmethod parse_inp_file(file_path: Path, fit_config: FitConfig = None) FitConfig[source]
Parse an input file into a FitConfig instance.
- Parameters:
file_path – Path to the input file
fit_config – Optional FitConfig to populate
- Returns:
Populated FitConfig
- Return type:
- classmethod create_endf_inp(output_path: Path, title: str = None) Path[source]
Create input file for ENDF mode.
- Parameters:
output_path – Path to write the input file
title – Optional title for the inp file
- Returns:
Path to the created file
- Return type:
Path
- classmethod create_fitting_inp(output_path: Path, title: str = None) Path[source]
Create input file for fitting mode.
- Parameters:
output_path – Path to write the input file
title – Optional title for the inp file
- Returns:
Path to the created file
- Return type:
Path
- classmethod create_multi_isotope_inp(output_path: Path, fit_config: FitConfig, title: str = None, dataset_metadata: InpDatasetMetadata | None = None, resolution_file_path: Path = None, fit_options: FitOptions | None = None) Path[source]
Create input file for multi-isotope JSON mode fitting.
This method generates a complete INP file for multi-isotope fitting that includes both static alphanumeric commands and calculated parameter sections.
- Parameters:
output_path – Path to write the input file
fit_config – Typed fit configuration used as the source of INP values
title – Optional title for the inp file
dataset_metadata – Optional dataset metadata for material/energy overrides
resolution_file_path – Optional absolute path to resolution function file
fit_options – Optional FitOptions to override the default multi-isotope config. When
None, usesFitOptions.from_multi_isotope_config(). Pass a custom instance to change SAMMY behaviour (e.g. forward-model mode withDO NOT SOLVE BAYES EQUATIONS).
- Returns:
Path to the created file
- Return type:
Path