DataMedSci / pymchelper

Python toolkit for SHIELD-HIT12A and FLUKA
http://datamedsci.github.io/pymchelper/
15 stars 7 forks source link

646 reading output of topas simulation #650

Closed Bogdan2423 closed 1 year ago

reviewpad[bot] commented 1 year ago

AI-Generated Summary: This pull request consists of two patches.

In the first patch, a new simulator type option for runner is added, and test runner for topas is implemented. This involves changes in pymchelper/executor/options.py, pymchelper/utils/runmc.py, and tests/test_runner.py. The TopasEnvironment class is added, and the SimulationSettings class is modified to support the new simulator type.

In the second patch, the Runner class is changed to accept the settings as an input in the constructor, and the interface for the main class is updated accordingly. This patch also improves test_runner by adding test cases for the SHIELD-HIT12A and TOPAS simulators. Changes are found in examples/scripting_sh12a_run.py, pymchelper/executor/runner.py, pymchelper/utils/runmc.py, and tests/test_runner.py.

reviewpad[bot] commented 1 year ago

Thank you @Bogdan2423 for this first contribution!

Bogdan2423 commented 1 year ago

For now I added "simulator type" option to simulation settings - I think it would be hard to do it another way. I also changed Runner class to get settings in constructor instead in run() method, as simulator type is required anyway for reading output. At the moment the runner can run topas mock, as it just calls the script in provided directory, but it can't read its output.

reviewpad[bot] commented 1 year ago

AI-Generated Summary: This pull request includes changes to support multiple simulator types like SHIELD-HIT12A, TOPAS, and FLUKA, along with adding a command line argument to specify the simulator type. The diff shows modifications in scripting_sh12a_run.py, options.py, runner.py, and runmc.py to accommodate the new feature, as well as updates to the related test file test_runner.py to perform tests on mock simulators.

reviewpad[bot] commented 1 year ago

AI-Generated Summary: This pull request introduces support for multiple Monte Carlo simulators in addition to SHIELD-HIT12A. It modifies the SimulationSettings class to accept a new simulator_type parameter, which can be either 'shieldhit', 'topas', or 'fluka'. The Runner class now takes into account the simulator_type when creating settings objects and running simulations.

Changes are made to the executor options, and a new simulator environment class, TopasEnvironment, is added. Furthermore, the runner's execution logic is updated, and more tests are added to cover these new features.

reviewpad[bot] commented 1 year ago

AI-Generated Summary: This pull request introduces changes to accommodate multiple types of MC simulators (SHIELD-HIT12A, TOPAS, and FLUKA). It updates the SimulationSettings class and the Runner class to handle simulator_type as a parameter. Also, it includes a new file simulator_type.py that contains an IntEnum class for simulator types. Additionally, the test suite has been updated to test runner functionality with mock simulators.

reviewpad[bot] commented 1 year ago

AI-Generated Summary: This pull request introduces support for different types of MC simulators and simplifies the Runner class usage. The changes include:

  1. Adding a new SimulatorType enum with three options: shieldhit, topas, and fluka.

  2. Modifying the SimulationSettings class to include a simulator_type parameter.

  3. Refactoring the Runner class to take settings as an argument in the constructor, and simplifying the run() method by removing the settings argument.

  4. Updating input_output.py to handle SimulatorType when reading output files.

  5. Adding tests for shieldhit and topas simulators in test_runner.py.

The changes should improve the support for different MC simulators and simplify the usage of the Runner class.

reviewpad[bot] commented 1 year ago

AI-Generated Summary: This pull request introduces support for running multiple simulators (SHIELD-HIT12A, TOPAS, FLUKA) in code reviews. The changes include:

reviewpad[bot] commented 1 year ago

AI-Generated Summary: This pull request introduces support for TOPAS MC simulator alongside the existing SHIELD-HIT12A and FLUKA simulators. Changes include:

These updates allow users to run simulations with the TOPAS MC simulator, in addition to the existing supported simulators. The input and output handling for TOPAS has been integrated into the existing structure for ease of use and maintainability.

reviewpad[bot] commented 1 year ago

AI-Generated Summary: This pull request updates the code to handle different types of MC simulators such as SHIELD-HIT12A, TOPAS, and FLUKA. It introduces a new enum SimulatorType for specifying the simulator type and modifies the SimulationSettings class to allow setting the simulator type. Moreover, it updates the Runner class to use the selected simulator type and make appropriate adjustments in RNG seeds, working directories, and estimator lists. It also adds a test case for TOPAS simulation alongside the existing test case for SHIELD-HIT12A simulation. Finally, it includes minor changes related to the choice of simulator type in the command-line arguments and output file handling.

reviewpad[bot] commented 1 year ago

AI-Generated Summary: This pull request includes changes to support the TOPAS MC simulator, as well as refactoring and improvements to the code. Key changes include:

These changes enable better support for multiple MC simulators, making the code more adaptable to future changes and additions.

reviewpad[bot] commented 1 year ago

AI-Generated Summary: This pull request introduces support for the TOPAS MC simulator. It modifies the SimulationSettings class to accommodate the new simulator type and updates the Runner class to handle both SHIELD-HIT12A and TOPAS. The diff also adds a new SimulatorType enum to represent the types of simulators. Furthermore, it includes new functions to manage Topas estimators and additional tests for the SHIELD-HIT12A and TOPAS simulators.

reviewpad[bot] commented 1 year ago

AI-Generated Summary: This pull request introduces significant improvements to the repository, particularly in handling different types of MC simulators, such as shieldhit, topas, and fluka. Key updates include the addition of the SimulatorType enumeration class, improved support for Topas file reading in the input_output.py file, and the implementation of separate code paths for different simulator types in the Runner class. Furthermore, several new files were added to support tests related to Topas, such as test files, output files, and simulation settings configuration files. Modifications were also made to the existing test files, such as incorporating the SimulationSettings object, using pytest fixtures for temporary directories, and skipping tests on MacOSX and Windows platforms. Lastly, minor changes were made to the .gitignore file.

reviewpad[bot] commented 1 year ago

AI-Generated Summary: This pull request includes several enhancements, focusing on adding support for the TOPAS simulator alongside the existing SHIELD-HIT12A and FLUKA simulators. Key changes involve the addition of new test files, the implementation of a TopasReaderFactory class, a new SimulatorType enumeration, a new command-line argument to specify the simulator type, and updates to the Runner class to handle various simulators. The test suite has undergone improvements to better handle different file types and to become more modular and organized. Lastly, the newly added pymchelper/readers/topas.py module enables the reading and processing of Topas output files in the CSV format.

reviewpad[bot] commented 1 year ago

AI-Generated Summary: This pull request introduces support for the TOPAS MC simulator in pymchelper by adding new classes, modifying existing classes, and updating tests. Major changes include the addition of SimulatorType and TopasReaderFactory, as well as updating the executor, runner, and tests to accommodate the new TOPAS functionality. Several new test and configuration files related to TOPAS have also been added. Overall, these changes improve support for different simulator types and provide better handling for various MC environments.

reviewpad[bot] commented 1 year ago

AI-Generated Summary: This pull request introduces support for TOPAS simulations, adds new test cases and simulation configurations, and refactors existing code. Key changes include the addition of a new TopasReader, support for reading and processing TOPAS output files, updates to the Runner class for handling TOPAS simulations, and improvements to the input_output.py file. New test cases include scenarios for binning by energy, cylindrical coordinates, and differential axis. The .gitignore file has been updated to ignore specific files, and the options.py file has been modified to support providing the simulator type as an argument. This pull request also includes new test data files with fluence values for different energy bins and surface tracks on a cylindrical surface. Overall, these changes enhance the functionality of the code by adding support for Topas readers, incorporating additional utility functions, and providing more test cases and simulation configurations.

reviewpad[bot] commented 1 year ago

AI-Generated Summary: This pull request introduces several code updates and new features related to improved support for various simulator types such as SHIELD-HIT12A, TOPAS, and FLUKA. Key changes include adding a new command-line argument for specifying the simulator type, updating the SimulationSettings object to include the simulator_type argument, and modifying the Runner object and its methods to expect and handle different simulator types. New test files, updated test functions, and test scenarios have been added, along with new data files, such as energy-bin fluence results, CSV files from TOPAS simulations, geometry setup files, and more. Overall, the changes enhance the code's flexibility, improve organization, and provide better support for different Monte Carlo simulations.

grzanka commented 1 year ago

@Bogdan2423 I've just merged https://github.com/DataMedSci/pymchelper/pull/658 which introduced a lot of conflicts

reviewpad[bot] commented 1 year ago

AI-Generated Summary: This pull request introduces various changes to improve the project's testing capabilities, support for the Topas simulator, and code documentation. Key changes include:

  1. Updates to tests/test_runner.py, adding new tests and modifying existing ones.
  2. Addition of new test files, such as FoilToCylinder.txt, test_read_topas_files.py, MyScorer.csv, minimal.txt, and other test-related data files.
  3. Enhancements in the input_output.py file to support the Topas reader.
  4. Modifications in the run_sh12a function and the Runner class to handle different simulator types and settings.
  5. Introduction of the SimulatorType enumeration and related changes in the pymchelper/executor/options.py and other files, as well as new command-line options for specifying the type of simulator.
  6. Addition of the pymchelper/readers/topas.py file, which introduces a reader for Topas output files, and a factory class for creating TopasReader instances.
  7. Assorted changes in the .gitignore file and adjustments to correct typos in code documentation and various file updates.

Overall, these changes enhance the flexibility, usability, and testing capabilities of the project, particularly in terms of Topas simulator support.

reviewpad[bot] commented 1 year ago

AI-Generated Summary: This pull request introduces several changes to improve the handling of different simulator types (SHIELD-HIT12A, TOPAS, and FLUKA) in the code. Key additions include a new SimulatorType enumeration, the TopasReaderFactory and TopasReader classes for handling Topas output files, and updates to the Runner, SimulationSettings, and input_output classes to accommodate the new simulator types. Furthermore, modifications have been made to the run_sh12a function in the scripting_sh12a_run.py file and the pymchelper/utils/runmc.py file, streamlining the creation of Runner objects. The test suite has also been expanded to include new test cases for the Topas reader and functionality.

Several new files have been added to the repository, such as test files for Topas output file reading, additional configuration files for particle simulations, and output files containing simulation results. Overall, these changes enhance the flexibility, functionality, and code organization, allowing for better support of multiple simulation types.

reviewpad[bot] commented 1 year ago

AI-Generated Summary: This pull request introduces support for Topas simulations by adding a TopasReader class, updates the .gitignore file, adds multiple test files, and modifies existing files to improve compatibility with different simulation types. Notably, a new SimulatorType enumeration is added, representing different types of Monte Carlo simulators: SHIELD-HIT12A, TOPAS, and FLUKA. The Runner class is refactored to handle various simulation types, the command-line parser is updated to include a --simulator option, and the SimulationSettings class is updated to include a simulator_type attribute. This also results in the addition of several new test cases to ensure the correct functionality of the new implementation.

reviewpad[bot] commented 1 year ago

AI-Generated Summary: This pull request includes updates to support particle simulation software and introduces support for the TOPAS simulator. Multiple new test files and result files have been added, along with updates to existing code and tests. The changes mainly involve adding support for reading and extracting data from Topas output files, improving the handling of various simulation types (SHIELDHIT, FLUKA, and TOPAS) in the Runner class, and updating the command-line parser to include a new option for specifying the type of simulator. The new test cases cover reading minimal output files, files with cylindrical coordinates, and files with binning by energy. The added result files include simulation data and settings for a variety of geometries, scoring configurations, and output types.

reviewpad[bot] commented 1 year ago

AI-Generated Summary: This pull request includes various updates, improvements, and additions to support Topas simulations and related functionality. Major changes include:

  1. Addition of new test and configuration files for simulations, particle filters, and geometry settings.
  2. Updates to the executor and reader modules, including the support of Topas Environment and TopasReader.
  3. New test suites for reading Topas output files and checking properties of Estimators and differential axes.
  4. Expanded test coverage and handling for Topas simulations and enhancements to Runner and SimulationSettings classes.
  5. Improved logging and code generalization for different simulation types.
  6. Introduction of the SimulatorType enumerated class with three types of MC simulators: SHIELD-HIT12A, TOPAS, and FLUKA.
  7. Modifications to input and output handling, including updates to the get_topas_estimators() method and frompattern() method descriptions.

These updates improve the configurability, test coverage, and flexibility of handling for Topas simulations while introducing new functionalities and better options for users running the simulations.

reviewpad[bot] commented 1 year ago

AI-Generated Summary: This pull request includes various updates and additions to support Topas, a Monte Carlo simulation program, alongside existing supported simulators like SHIELD-HIT12A and FLUKA. It involves:

  1. Introduction of new test configuration files (e.g., minimal.txt, FoilToCylinder.txt) and result files in various folders (e.g., tests/res/topas/).
  2. Modification of existing files like runner.py, runmc.py, and input_output.py to enhance compatibility with different types of simulators and support optional specification of the simulator type.
  3. Creation of new files like topas.py, simulator_type.py, and test_read_topas_files.py for handling Topas input and output along with corresponding test cases.
  4. Updates to pymchelper/import_settings.py to include TopasEnvironment and refactoring of the existing structure for better path handling.
  5. Improvements in test coverage by adding tests for the TOPAS simulator and making necessary API adjustments in existing tests.

Overall, these changes allow the program to integrate Topas alongside SHIELD-HIT12A and FLUKA, providing users with enhanced flexibility in their choice of simulators.

reviewpad[bot] commented 1 year ago

AI-Generated Summary: This pull request introduces various updates and new features to support the TOPAS Monte Carlo simulation engine alongside the existing Fluka and SHIELD-HIT12A engines. Significant changes include the addition of new test files with different configurations for TOPAS simulations, the introduction of new classes and methods to read Topas output files, and updates to existing code to handle TOPAS input files and output data more effectively.

Notable changes include:

  1. New test files with configurations for TOPAS simulations, such as minimal settings, cylindrical and spherical scorings, and different binning options.
  2. Introduction of the TopasReaderFactory and TopasReader classes for reading Topas output files and extracting relevant information.
  3. Updates to Runner class, input_output.py, and executor/options.py to handle TOPAS files and data more effectively.
  4. Enhancements to existing test functions and addition of new test cases to ensure correct functionality with the Topas simulator integration.

Overall, this pull request expands the functionality of the pymchelper library to support the TOPAS Monte Carlo simulation engine, making it more versatile and useful for users working with different simulation platforms.

Bogdan2423 commented 1 year ago

I made the "simulator type" argument in SimulationSettings optional and brought back guessing in case it is not provided. I also added more tests for reader and fixed reading output files for some cases - now the topas reader should work in all cases I can think of.

reviewpad[bot] commented 1 year ago

AI-Generated Summary: This pull request introduces support for the TOPAS Monte Carlo simulation engine along with the existing SHIELD-HIT12A and Fluka simulators. Changes include adding a new command-line argument for specifying the simulator type, refactoring the Runner class, updating the SimulationSettings class, and modifying various test files. New test files have been added to account for TOPAS-related simulations and output files. A TopasReader class has been added to handle reading Topas output files, and updates have been made to the pymchelper.input_output module to support this functionality. Overall, the pull request improves the usability and maintainability of the code by allowing users to specify the simulator type and facilitating handling and processing of multiple simulators' output files.

reviewpad[bot] commented 1 year ago

AI-Generated Summary: This pull request introduces several changes in different areas of the codebase.

Firstly, it adds several test cases and related files to validate the correct reading of Topas output files covering different scenarios. A new python test file test_read_topas_files.py and multiple new test data files, including csv and txt, are included for this purpose.

There are significant changes in tests/test_runner.py, including refactoring and addition of new tests. The creation of a new python module topas.py in pymchelper/readers directory further aids in reading Topas output files.

Enhancements in pymchelper/simulator_type.py now allow support for three types of simulators: SHIELD-HIT12A, TOPAS, and FLUKA. This development closely coordinates with changes observed in the run_sh12a function of the scripting_sh12a_run.py file and pymchelper/executor/options.py to handle these different simulator types.

Modifications can also be seen in pymchelper/input_output.py and pymchelper/executor/runner.py to accommodate different simulator types and improve file reader function versatility.

There are minor changes to .gitignore to exclude a test-related file and updates to the tests/conftest.py to provide a new main_dir pytest fixture. The pull request also updates pymchelper/utils/runmc.py for greater flexibility while specifying simulator types.

Altogether, this pull request presents substantial enhancements and additions to test cases, handling different simulator types, and reading Topas output files, bolstering the codebase's flexibility and robustness.

reviewpad[bot] commented 1 year ago

AI-Generated Summary: This pull request introduces a number of new enhancements and refactoring to support the reading and handling of Topas high energy physics simulation output files. Key changes include:

New files have been added including various test files (sphere.txt, minimal.txt, FoilToCylinder.txt, etc.), python scripts for additional functionality (pymchelper/readers/topas.py, pymchelper/simulator_type.py, etc.), and output files (MyScorer.csv, fluence_bp_protons_xy.csv, etc.).

It's recommended to verify the values provided in the new files to ensure correct configuration of the particle physics tests and to test the integration of the new code modules within the larger codebase.

reviewpad[bot] commented 1 year ago

AI-Generated Summary: This pull request includes significant updates to the codebase, primarily aiming towards enhancing support for different simulator types (Topas, Shieldhit, and Fluka).

Enhancements to the code structure include:

A new enumeration class SimulatorType was introduced to label different simulator types used across the project. Modifications were made to the SimulationSettings to handle settings for different simulator types.

Multiple new tests have been added to validate the functionality of reading Topas output files, including different scenarios such as reading cylindrical coordinates, optional differential axis, spherical coordinates and binning by time, and Topas output file without any bins.

Also includes updates in .gitignore file and adjustments in existing code to align with the updates.

Furthermore, multiple new files were introduced including configuration files, CSV files containing simulation data and testing data.

reviewpad[bot] commented 1 year ago

AI-Generated Summary: This pull request introduces comprehensive support for the Topas simulation tool in the PyMCHelper package, including reading and parsing Topas output files, setting up parameters, and handling various simulation environments and scenarios.

Notably, a new topas.py file has been added to implement classes and functions for reading and processing Topas output. A new SimulatorType enumeration was introduced to handle various types of Monte Carlo simulators.

Several existing files have been modified to accommodate the changes. The runmc.py file now allows the simulator type to be specified via command-line argument, with a corresponding attribute added to the SimulationSettings class. Argument-parsing changes have been made to support different simulator types. The executor.options.py file has been updated to improve management of the simulation environment and robustly handle cases where the Monte Carlo engine type can't be determined.

The Runner class in executor/runner.py has been updated to improve handling of different simulators and various RNG seeds generation and working directories creation based on the simulator type. The input_output.py file has been updated to support 'Topas' readers.

Several new files and directories have been added to the tests and resources directories for different simulator output standards and scenarios, including minimal output, various geometric and temporal binning, and particle-specific output. Most notably are minimal.txt files, which seem to be configuration files for particle simulations in each case like foil-to-cylinder and foil-to-sphere scenarios or cases when no bins are employed.

Unit tests were also added to validate these Topas-related functionalities. This includes multiple assertions to check various parameters and data values from the specified Topas output files are being correctly read and processed.

Finally, minor updates and adjustments were made to related files like tests/test_runner.py, and .gitignore, and also docstring comments were updated in several places.

reviewpad[bot] commented 1 year ago

AI-Generated Summary: This pull request includes various modifications to the codebase to accommodate new features, improve existing functionality, and fix minor issues.

Significant additions have been made to unit tests in test_runner.py, which includes importing new modules, adding new test functions, and making changes to existing ones. New binary files, text files and CSV files have been added across different directories, including topas.tar, 'fluence_bp_protons_xy.csv', ‘minimal.txt’, and 'sphere.txt', many of which contain test-related data and scripts.

In terms of changes to the existing code, the pymchelper/executor/runner.py file has been refactored with more imports, alterations to the Runner class methods, RNG seeding logic improvements, and modifications to output file processing. The .gitignore file has been updated to ignore specific test-related files. There are also adjustments made to the value of "NumberOfHistoriesInRun" in tests/res/mocks/topas_minimal/minimal.txt.

Files such as test_read_topas_files.py, input_output.py, and options.py have been extended to improve support for Topas files. A significant addition includes a new Python file, pymchelper/simulator_type.py, that introduces enumeration for different types of Monte Carlo simulators.

Additions and alterations to pymchelper/readers/topas.py, conftest.py, options.py, and scripting_sh12a_run.py appear to be geared towards enhancing functionality of Topas file processing, test fixtures, simulation engine selection, and the simulator running functionality, respectively.

In summary, these changes enhance the Python scripts' capability to handle and work with TOPAS simulation data files and other Monte Carlo simulators, improve their maintainability by introducing explicit type annotations, and increase test coverage.

reviewpad[bot] commented 1 year ago

AI-Generated Summary: This pull request introduces a broad range of changes encompassing additions of new files and modifications in existing ones. The new files include binary, text, and CSV output data files, in addition to Python scripts to manage and process simulation data. Changes to existing files primarily involve modifications in Python scripts for supporting the features introduced in this request.

The newly added files suggest expansion of test cases to cover particle path simulations under multiple scenarios, including spherical and cylindrical ones, as well as scoring within these paths. Configurations for such test scenarios are observed in the added text files. The CSV files provide simulation results, presumably for comparison and assertions in testing.

On the Python side, changes revolve around supporting output from the Topas simulation software. The newly added topas.py script allows reading and processing Topas output files. Changes in the existing input_output.py file likewise introduce support for Topas and brings in new utility functions. The Options.py and runner.py files now accommodate different types of simulators. Other modified Python scripts essentially conform to these changes and extend the testing suite to validate the added functionalities.

Collaboratively, these changes seem to introduce support for another simulation software (Topas), expand the testing suite for this new addition, and restructure some code constructs to facilitate those changes. Please review the added Python scripts and modifications, paying close attention to the simulations' behaviors and the subsequent validation measures in the testing scripts.

reviewpad[bot] commented 1 year ago

AI-Generated Summary: This pull request includes various changes revolving around enhancements, bug fixes, and the addition of new functionalities. Here's a brief summary of the changes:

  1. Data and testing: Several .csv and .txt files were added in the tests directory, which seem to contain scoring results, configurations and simulation settings for different test scenarios involving TOPAS simulations. They mainly cover various binning conditions, geometries, sources, and scoring methodologies.

  2. Code Modifications: Changes were introduced in the files runmc.py, options.py, runner.py, pymchelper/readers/topas.py, input_output.py and executor/options.py to include enhancements and bug fixes. These changes covered improving the handling of different simulation types, better file detection and reading capabilities, accomodating the new simulator argument, handling the reading of Topas related data, and modifying the Runner object's initialization and usage to adapt to the new changes.

  3. New Python modules: A new python module topas.py was added providing the capability of managing and manipulating '.csv' outputs, with functionalities including creating instances of TopasReader.

  4. Testing: Addition of new tests for the runner and to test out different file reading scenarios involving TOPAS were added. Alterations have been made to correctly initialize the Runner object and call its "run" function in line with the newly introduced modifications.

  5. Cleaning and Documentation: Files like minimal_modified.txt are now being ignored by Git. Typos in comments within various files have been corrected to improve code readability and understanding.

  6. Binary File: A TOPAS binary file has been added, offering potential upgrade in the already available functionalities.

The reviewers are advised to verify the new functionalities and addition of test scenarios and also ensure the bug fixes and modifications align with the existing requirements. It is also necessary to validate the changes involving the 'Runner' class, checking whether the new initialization process and function calls are functioning as expected.

reviewpad[bot] commented 1 year ago

AI-Generated Summary: This pull request is making significant changes across multiple files to introduce robust support for the TOPAS (Tool for Particle Simulation) environment into the pymchelper python package along with improving the overall usability of the software. These changes can be primarily grouped into:

  1. New File Additions: Multiple files containing physics simulation configuration, test results and relevant resources for TOPAS have been added in the tests/res/topas/ and tests/res/mocks/topas_minimal/ directories.
  2. Test Suite Expansion: There is a considerable expansion in the test suite, most notably, the new file test_read_topas_files.py has been added to specifically test the reading of TOPAS output files. Other test files like conftest.py and test_runner.py have been updated.
  3. Refactor and Introductions in pymchelper module: Notable refactoring has been done in pymchelper/executor/runner.py and pymchelper/input_output.py to add support for TOPAS output files. New files like pymchelper/readers/topas.py and pymchelper/simulator_type.py have been introduced to streamline this integration.
  4. Increased Flexibility: The changes also make the program more flexible in terms of allowing users to specify the type of simulator they want to run.

Also, some non-TOPAS specific updates include the correction of typographical errors, updates to .gitignore and changes to how settings is handled in Runner.

Please note, this summary assumes some knowledge of these topics: pytest fixtures, the TOPAS environment, physics simulation, Monte Carlo (MC) simulators, the pymchelper python package.