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

Simulate prod test #875

Merged
merged 23 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
9546d09
add integration test checks for simulate_prod (failure expected)
VictorBarbosaMartins Apr 17, 2024
045f628
remove test flag as we actually need to test it!
VictorBarbosaMartins Apr 17, 2024
89ee698
include test for sim_showers_for_trigger_rates_run.yml
VictorBarbosaMartins Apr 17, 2024
3b4e56c
change to prod6 and name
VictorBarbosaMartins Apr 19, 2024
330e5f1
Merge branch 'main' into simulate_prod_test
GernotMaier Apr 21, 2024
0326de4
Merge branch 'main' into simulate_prod_test
GernotMaier Apr 23, 2024
260727d
minor improvements to production.py
GernotMaier Apr 23, 2024
54a5716
typo
GernotMaier Apr 23, 2024
fb49c56
fix production array
GernotMaier Apr 23, 2024
19a3123
add correct files to integration test of pack for grid
VictorBarbosaMartins Apr 24, 2024
fecf060
add correct files to integration test of pack for grid
VictorBarbosaMartins Apr 24, 2024
2ac2570
ups
VictorBarbosaMartins Apr 24, 2024
6342edc
Merge branch 'main' into simulate_prod_test
VictorBarbosaMartins Apr 26, 2024
283eefb
fix typo
GernotMaier Apr 26, 2024
b782d8a
include test for South - trigger rate production
VictorBarbosaMartins Apr 29, 2024
f787401
name of test
VictorBarbosaMartins Apr 29, 2024
dddd5fe
names
VictorBarbosaMartins Apr 29, 2024
5f4ffc0
Merge branch 'main' into simulate_prod_test
VictorBarbosaMartins Apr 29, 2024
7595b4d
Merge branch 'main' into simulate_prod_test
VictorBarbosaMartins Apr 29, 2024
3693248
Merge branch 'main' into simulate_prod_test
VictorBarbosaMartins Apr 29, 2024
b8abe67
fix test
VictorBarbosaMartins Apr 30, 2024
351c323
fix test, include south
VictorBarbosaMartins Apr 30, 2024
5283ae2
Merge branch 'main' into simulate_prod_test
VictorBarbosaMartins Apr 30, 2024
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
23 changes: 10 additions & 13 deletions simtools/applications/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

Command line arguments
----------------------
productionconfig (str, required)
simulation_configuration (str, required)
Path to the simulation configuration file.
primary (str)
Name of the primary to be selected from the configuration file. In case it \
Expand All @@ -34,7 +34,7 @@
simulate (perform simulations),
file_list (print list of output files)
inspect (plot sim_telarray histograms for quick inspection)
resources (print quicklook into used computational resources)
resources (print quick look into used computational resources)
array_only (activation mode)
Simulates only array detector (no showers).
showers_only (activation mode)
Expand Down Expand Up @@ -66,7 +66,7 @@

.. code-block:: console

simtools-production --task simulate --productionconfig prod_config_test.yml \
simtools-production --task simulate --simulation_configuration prod_config_test.yml \
--test --showers_only --submit_command local

The output is saved in simtools-output/test-production.
Expand All @@ -83,8 +83,6 @@
from copy import copy
from pathlib import Path

from astropy.io.misc import yaml

import simtools.utils.general as gen
from simtools.configuration import configurator
from simtools.simulator import Simulator
Expand All @@ -108,7 +106,7 @@ def _parse(description=None):

config = configurator.Configurator(description=description)
config.parser.add_argument(
"--productionconfig",
"--simulation_configuration",
help="Simulation configuration file",
type=str,
required=True,
Expand Down Expand Up @@ -193,8 +191,7 @@ def _process_simulation_config_file(config_file, primary_config, logger):
"""

try:
with open(config_file, encoding="utf-8") as file:
config_data = yaml.load(file)
config_data = gen.collect_data_from_file_or_dict(file_name=config_file, in_dict=None)
except FileNotFoundError:
logger.error(f"Error loading simulation configuration file from {config_file}")
raise
Expand All @@ -213,24 +210,24 @@ def _process_simulation_config_file(config_file, primary_config, logger):
config_showers[primary] = copy(this_default.pop("showers", {}))
config_arrays[primary] = copy(this_default.pop("array", {}))

# Grabbing common entries for showers and array
# common entries for showers and array
for key, value in primary_data.items():
if key in ["showers", "array"]:
continue
config_showers[primary][key] = value
config_arrays[primary][key] = value

# Grabbing showers entries
# shower entries
for key, value in primary_data.get("showers", {}).items():
config_showers[primary][key] = value
config_showers[primary]["primary"] = primary

# Grabbing array entries
# array entries
for key, value in primary_data.get("array", {}).items():
config_arrays[primary][key] = value
config_arrays[primary]["primary"] = primary

# Filling in the remaining default keys
# remaining default keys
for key, value in this_default.items():
config_showers[primary][key] = value
config_arrays[primary][key] = value
Expand All @@ -244,7 +241,7 @@ def main():
logger.setLevel(gen.get_log_level_from_user(args_dict["log_level"]))

label, shower_configs, array_configs = _process_simulation_config_file(
args_dict["productionconfig"], args_dict["primary"], logger
args_dict["simulation_configuration"], args_dict["primary"], logger
)
if args_dict["label"] is None:
args_dict["label"] = label
Expand Down
2 changes: 1 addition & 1 deletion simtools/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ def _get_runs_and_files_to_submit(self, input_file_list=None):
Returns
-------
runs_and_files: dict
dictionary with runnumber as key and (if available) simulation
dictionary with run number as key and (if available) simulation
file name as value

"""
Expand Down
2 changes: 1 addition & 1 deletion tests/integration_tests/config/production_array_only.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ CTA_SIMPIPE:
APPLICATION: simtools-production
TEST_NAME: array_only
CONFIGURATION:
PRODUCTIONCONFIG: ./tests/resources/prod_config_test.yml
SIMULATION_CONFIG: ./tests/resources/prod_config_test.yml
TASK: simulate
ARRAY_ONLY: true
SUBMIT_COMMAND: local
Expand Down
3 changes: 2 additions & 1 deletion tests/integration_tests/config/production_showers_only.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ CTA_SIMPIPE:
APPLICATION: simtools-production
TEST_NAME: showers_only
CONFIGURATION:
PRODUCTIONCONFIG: ./tests/resources/prod_config_test.yml
SIMULATION_CONFIGURATION: ./tests/resources/prod_config_test.yml
MODEL_VERSION: prod6
TASK: simulate
SHOWERS_ONLY: true
SUBMIT_COMMAND: local
DATA_DIRECTORY: simtools-output
OUTPUT_PATH: simtools-output
LOG_LEVEL: debug
INTEGRATION_TESTS:
- OUTPUT_FILE: |
corsika-data/North/proton/data/run000001/corsika_run000001_proton_za020deg_azm000deg_North_
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ CTA_SIMPIPE:
PRIMARY: proton
VictorBarbosaMartins marked this conversation as resolved.
Show resolved Hide resolved
MODEL_VERSION: prod6
NRUNS: 2
NEVENTS: 10000
TEST: true
NEVENTS: 2
SUBMIT_COMMAND: local
DATA_DIRECTORY: simtools-output
OUTPUT_PATH: simtools-output
INTEGRATION_TESTS:
- OUTPUT_FILE: |
sim_showers_for_trigger_rates/corsika-data/North/proton/data/run000001/corsika_run000001_proton_za020deg_azm000deg_North_4LST_sim_showers_for_trigger_rates.zst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
CTA_SIMPIPE:
APPLICATION: simtools-sim-showers-for-trigger-rates
TEST_NAME: run_south
CONFIGURATION:
ARRAY: 4MST
SITE: South
PRIMARY: proton
MODEL_VERSION: prod6
NRUNS: 2
NEVENTS: 2
SUBMIT_COMMAND: local
DATA_DIRECTORY: simtools-output
OUTPUT_PATH: simtools-output
INTEGRATION_TESTS:
- OUTPUT_FILE: |
sim_showers_for_trigger_rates/corsika-data/South/proton/data/run000001/corsika_run000001_proton_za020deg_azm000deg_South_4MST_sim_showers_for_trigger_rates.zst
3 changes: 3 additions & 0 deletions tests/integration_tests/config/simulate_prod_gamma_20_deg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ CTA_SIMPIPE:
NSHOW: 5
DATA_DIRECTORY: simtools-output
OUTPUT_PATH: simtools-output
INTEGRATION_TESTS:
- OUTPUT_FILE: |
test-production/simtel-data/North/gamma/data/run000002_gamma_za020deg_azm000deg_North_TestLayout_test-production.simtel.zst
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@ CTA_SIMPIPE:
DATA_DIRECTORY: simtools-output
OUTPUT_PATH: simtools-output
PACK_FOR_GRID_REGISTER: true
INTEGRATION_TESTS:
- OUTPUT_FILE: |
directory_for_grid_upload/run000002_gamma_za020deg_azm000deg_North_TestLayout_test-production.log_hist.tar.gz
- OUTPUT_FILE: |
directory_for_grid_upload/run000002_gamma_za020deg_azm000deg_North_TestLayout_test-production.simtel.zst
2 changes: 1 addition & 1 deletion tests/integration_tests/test_applications_from_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def validate_application_output(config):
# First check if the output is in the data directory (simtel_array related),
# Then check if the file is in the output directory (remaining tools).
logger.info(f"PATH {config['CONFIGURATION']['OUTPUT_PATH']}")
logger.info(f"File{integration_test['OUTPUT_FILE']}")
logger.info(f"File {integration_test['OUTPUT_FILE']}")
try:
assert (
Path(config["CONFIGURATION"]["DATA_DIRECTORY"])
Expand Down