Skip to content

Commit

Permalink
TOML configfile & unit tests. Remove old XML code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Areustle committed Dec 20, 2023
1 parent 22e3c4e commit 3385264
Show file tree
Hide file tree
Showing 35 changed files with 1,277 additions and 1,426 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This is the official release of the *nuspacesim* simulator tool!

This package simulates upward-going extensive air showers caused by neutrino
interactions with the atmosphere. It calculates the tau neutrino acceptance for the
Optical Cherenkov technique. The simulation is parameterized by an input XML
Optical Cherenkov technique. The simulation is parameterized by an input TOML
configuration file, with settings for detector characteristics and global parameters.
The package also provides a python3 API for programatic access.

Expand All @@ -31,18 +31,18 @@ Tau propagation is interpolated using included data tables from [nupyprop](https

![NuSpaceSim Usage](https://raw.githubusercontent.com/NuSpaceSim/nuSpaceSim/main/docs/_static/run.svg)

### Create an XML configuration script
### Create an TOML configuration script

The command line simulator uses an XML file to store configuration parameters. To
The command line simulator uses an TOML file to store configuration parameters. To
generate a default configuration file run the following, with your choice of file name.

`nuspacesim create-config my_config_file.xml`
`nuspacesim create-config my_config_file.toml`

### Run simulator

Simulate neutrino interactions and save the results to a named fits file.

`nuspacesim run my_config_file.xml -o my_nss_sim.fits`
`nuspacesim run my_config_file.toml -o my_nss_sim.fits`

# Documentation

Expand Down
1 change: 0 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@
"click",
"dask",
"h5py",
"lxml",
"matplotlib",
"mpl_toolkits",
"numpy",
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This is the public release of the nuspacesim simulator tool!

This package simulates upward-going electromagnetic air showers caused by neutrino
interactions with the atmosphere. It calculates the tau neutrino acceptance for the
Optical Cherenkov technique. The simulation is parameterized by an input XML
Optical Cherenkov technique. The simulation is parameterized by an input TOML
configuration file, with settings for detector characteristics and global parameters.
The package also provides a python3 API for programatic access.

Expand Down
8 changes: 4 additions & 4 deletions docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ Read the nuspacesim help docstring
python3 -m nuspacesim --help

----------------------------------
Create the XML configuration file
Create the TOML configuration file
----------------------------------

Create a configuration file with the ``create-config`` command. This is editable by the
user for defining different simulation parameters. ::

nuspacesim create-config --numtrajs 1e6 --monospectrum 10.25 my_config_file.xml
nuspacesim create-config --numtrajs 1e6 --monospectrum 10.25 my_config_file.toml

-----------------
Run the simulator
Expand All @@ -42,11 +42,11 @@ Run the simulator
Simulate neutrino interactions, and extensive air showers, then save the results to a
FITS file. ::

nuspacesim run my_config_file.xml -output my_nss_sim.fits
nuspacesim run my_config_file.toml -output my_nss_sim.fits

Optionally, override the configuration file on the command line. ::

nuspacesim run my_config_file.xml 1e5 --powerspectrum 2 6 12 -o my_nss_sim.fits
nuspacesim run my_config_file.toml 1e5 --powerspectrum 2 6 12 -o my_nss_sim.fits


.. raw:: html
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorial/command_line.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ in application or module mode.
nuspacesim --help


Create an XML configuration file.
Create an TOML configuration file.

::

nuspacesim create-config --help
nuspacesim create-config my_config_file.xml
nuspacesim create-config my_config_file.TOML


Run a simulation.
Expand Down
8 changes: 4 additions & 4 deletions docs/tutorial/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ Configuration File
.. toctree::
:hidden:

Simulation configuration is governed by an XML file. The File structure is
Simulation configuration is governed by a TOML file. The File structure is
separated into 2 primary sections, the DetectorCharacteristics and the
SimulationParameters. Both XML sections map 1-to-1 to the nuspacesim.config
SimulationParameters. Both TOML sections map 1-to-1 to the nuspacesim.config
dataclass objects of the same names.



DetectorCharacteristics
Detector
***********************

This is a dataclass holding the Detector Characteristics for a given simulation.
Expand All @@ -34,7 +34,7 @@ The member attributes are as follows:
* **det_gain**: Antenna gain in dB: Default = 1.8


SimulationParameters
Simulation
********************

This is a dataclass holding the Detector Characteristics for a given simulation.
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial/simulation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ variables determined by the physics modules.
Configuration File
******************

Simulation configuration is governed by an XML file.
Simulation configuration is governed by a TOML file.

Results File
************
Expand Down
1 change: 0 additions & 1 deletion recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ requirements:
- importlib_metadata # [py<38]
- importlib_resources # [py<39]
- h5py
- lxml
- matplotlib
- numpy >=1.20
- rich
Expand Down
45 changes: 45 additions & 0 deletions sample_input_file.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
title = "NuSpaceSim"

[detector]
name = "Default Name"

[detector.initial_position]
altitude = "525.0 km"
latitude = "0.0 deg"
longitude = "0.0 deg"

[detector.optical]
telescope_effective_area = "2.5 m2"
quantum_efficiency = 0.2
photo_electron_threshold = 10

[detector.radio]
low_frequency = "30.0 MHz"
high_frequency = "300.0 MHz"
snr_threshold = 5.0
nantennas = 10
gain = "1.8 dB"

[simulation]
mode = "Diffuse"
thrown_events = 10000
max_cherenkov_angle = "3.0000000000000004 deg"
max_azimuth_angle = "360.0 deg"
angle_from_limb = "7.0 deg"
cherenkov_light_engine = "Default"

[simulation.ionosphere]
total_electron_content = 10.0
total_electron_error = 0.1

[simulation.tau_shower]
id = "nupyprop"
etau_frac = 0.5
table_version = "3"

[simulation.spectrum]
id = "monospectrum"
log_nu_energy = 8.0

[simulation.cloud_model]
id = "no_cloud"
39 changes: 0 additions & 39 deletions sample_input_file.xml

This file was deleted.

5 changes: 3 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,16 @@ install_requires =
dask
dask[distributed]
h5py
lxml
matplotlib
numpy>=1.21
pydantic
rich
scipy
cached-property;python_version<"3.8"
tomli-w
configparser;python_version<"3.8"
importlib-metadata;python_version<"3.8"
importlib-resources;python_version<"3.9"
tomli;python_version<"3.11"
python_requires = >=3.8
ext_package = nuspacesim
package_dir =
Expand Down
10 changes: 4 additions & 6 deletions src/nuspacesim/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
nuspacesim.NssConfig
nuspacesim.DetectorCharacteristics
nuspacesim.SimulationParameters
nuspacesim.xml_config
nuspacesim.config
*****************
Simulate Function
Expand Down Expand Up @@ -131,18 +131,17 @@
"""

from . import constants, data, utils, xml_config
from . import constants, data, utils
from ._version import version, version_tuple
from .compute import compute
from .config import DetectorCharacteristics, NssConfig, SimulationParameters
from .config import NssConfig, config_from_toml
from .simulation import eas_optical, geometry, taus

__all__ = [
# Core
"constants",
"NssConfig",
"DetectorCharacteristics",
"SimulationParameters",
"config_from_toml",
"compute",
# modules
"geometry",
Expand All @@ -151,7 +150,6 @@
# other
"data",
"utils",
"xml_config",
# version
"version",
"version_tuple",
Expand Down
4 changes: 2 additions & 2 deletions src/nuspacesim/apps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
"""

__all__ = ["cli"]
__all__ = ["cli", "run", "create_config", "show_plot", "utils"]

from . import cli
from . import cli, create_config, run, show_plot, utils
3 changes: 3 additions & 0 deletions src/nuspacesim/apps/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .cli import cli

cli()
Loading

0 comments on commit 3385264

Please sign in to comment.