From 64d07a1f0923b09ed8c13bb9e5c960177dc89a65 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 1 Nov 2026 17:00:17 +0000 Subject: [PATCH] refactor: auto-simulate datasets with ac.util.dataset.simulate_if_needed Replace the 8-line should_simulate + subprocess.run block with the one-line ac.util.dataset.simulate_if_needed(dataset_path, simulator=...) helper (PyAutoArray#670; ac.util.dataset re-exports autoarray's dataset_util): 43 blocks in 39 scripts. Mechanical rewrite: dataset and simulator paths kept exactly; CRLF line endings preserved. Notebook regeneration is blocked for this workspace (autocti is not in COLAB_PROJECTS, see AGENTS.md), so notebooks are not touched. check_dataset_allowlist reports the same guarded call-site count before and after (43). Requires the PyAutoArray release that carries #670. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016nhQ8NyQo2s3YUk8eUrrB3 --- .../advanced/database/start_here.py | 12 ++++------ scripts/dataset_1d/advanced/temporal/fit.py | 11 +++------ scripts/dataset_1d/correction/start_here.py | 11 +++------ scripts/dataset_1d/extract.py | 11 +++------ .../dataset_1d/modeling/customize/priors.py | 11 +++------ .../modeling/features/species_x3.py | 11 +++------ .../modeling/features/visualize_full.py | 11 +++------ scripts/dataset_1d/modeling/start_here.py | 11 +++------ scripts/dataset_1d/results/examples/cti.py | 11 +++------ scripts/dataset_1d/results/examples/fits.py | 11 +++------ .../dataset_1d/results/examples/samples.py | 11 +++------ scripts/dataset_1d/results/start_here.py | 11 +++------ .../advanced/chaining/pipelines/parallel.py | 11 +++------ .../pipelines/parallel_x2__serial_x2.py | 12 ++++------ .../advanced/chaining/pipelines/serial.py | 11 +++------ .../chaining/x1_species_to_x2_species.py | 11 +++------ scripts/imaging_ci/correction/start_here.py | 11 +++------ .../examples/bias_subtraction.py | 11 +++------ .../examples/cosmic_ray_flagging.py | 11 +++------ .../data_preparation/examples/pre_cti.py | 11 +++------ .../examples/pre_cti_and_cosmics.py | 11 +++------ .../data_preparation/examples/serial_cti.py | 11 +++------ .../imaging_ci/data_preparation/start_here.py | 22 +++++------------- scripts/imaging_ci/extract.py | 11 +++------ .../modeling/features/cosmic_rays.py | 11 +++------ .../modeling/features/non_uniform.py | 11 +++------ .../modeling/features/serial_cti.py | 11 +++------ .../modeling/features/visualize_full.py | 11 +++------ scripts/imaging_ci/modeling/start_here.py | 11 +++------ .../overview_4_charge_injection_data.py | 23 ++++++------------- scripts/overview/overview_5_fitting.py | 22 +++++------------- .../overview/overview_6_cti_calibration.py | 22 +++++------------- .../diagnostics/imaging_ci/well_filling.py | 11 +++------ scripts/plot/plotters/Dataset1dPlotter.py | 11 +++------ scripts/plot/plotters/FitDataset1dPlotter.py | 11 +++------ scripts/plot/plotters/FitImagingCIPlotter.py | 11 +++------ scripts/plot/plotters/ImagingCIPlotter.py | 11 +++------ scripts/plot/plotters/MultiFigurePlotter.py | 11 +++------ scripts/plot/start_here.py | 11 +++------ 39 files changed, 132 insertions(+), 344 deletions(-) diff --git a/scripts/dataset_1d/advanced/database/start_here.py b/scripts/dataset_1d/advanced/database/start_here.py index 0759300..f6c8a55 100644 --- a/scripts/dataset_1d/advanced/database/start_here.py +++ b/scripts/dataset_1d/advanced/database/start_here.py @@ -46,14 +46,10 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if ac.util.dataset.should_simulate(path.join("dataset", "dataset_1d", "simple")): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/dataset_1d/simulators/start_here.py"], - check=True, - ) +ac.util.dataset.simulate_if_needed( + path.join("dataset", "dataset_1d", "simple"), + simulator="scripts/dataset_1d/simulators/start_here.py", +) norm_list = [100, 5000, 25000, 200000] diff --git a/scripts/dataset_1d/advanced/temporal/fit.py b/scripts/dataset_1d/advanced/temporal/fit.py index 8cb5b76..3aa7143 100644 --- a/scripts/dataset_1d/advanced/temporal/fit.py +++ b/scripts/dataset_1d/advanced/temporal/fit.py @@ -49,14 +49,9 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if ac.util.dataset.should_simulate(dataset_path): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/dataset_1d/simulators/examples/temporal.py"], - check=True, - ) +ac.util.dataset.simulate_if_needed( + dataset_path, simulator="scripts/dataset_1d/simulators/examples/temporal.py" +) """ __Layout__ diff --git a/scripts/dataset_1d/correction/start_here.py b/scripts/dataset_1d/correction/start_here.py index c7fd5b4..f3a78e5 100644 --- a/scripts/dataset_1d/correction/start_here.py +++ b/scripts/dataset_1d/correction/start_here.py @@ -34,14 +34,9 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if ac.util.dataset.should_simulate(dataset_path): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/dataset_1d/simulators/start_here.py"], - check=True, - ) +ac.util.dataset.simulate_if_needed( + dataset_path, simulator="scripts/dataset_1d/simulators/start_here.py" +) """ __Shape__ diff --git a/scripts/dataset_1d/extract.py b/scripts/dataset_1d/extract.py index 5e1bdfd..1f616d3 100644 --- a/scripts/dataset_1d/extract.py +++ b/scripts/dataset_1d/extract.py @@ -34,14 +34,9 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if ac.util.dataset.should_simulate(dataset_path): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/dataset_1d/simulators/start_here.py"], - check=True, - ) +ac.util.dataset.simulate_if_needed( + dataset_path, simulator="scripts/dataset_1d/simulators/start_here.py" +) shape_native = (200,) diff --git a/scripts/dataset_1d/modeling/customize/priors.py b/scripts/dataset_1d/modeling/customize/priors.py index 7297c26..84f7fae 100644 --- a/scripts/dataset_1d/modeling/customize/priors.py +++ b/scripts/dataset_1d/modeling/customize/priors.py @@ -47,14 +47,9 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if ac.util.dataset.should_simulate(dataset_path): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/dataset_1d/simulators/start_here.py"], - check=True, - ) +ac.util.dataset.simulate_if_needed( + dataset_path, simulator="scripts/dataset_1d/simulators/start_here.py" +) """ __Shape__ diff --git a/scripts/dataset_1d/modeling/features/species_x3.py b/scripts/dataset_1d/modeling/features/species_x3.py index af60a40..bb002f1 100644 --- a/scripts/dataset_1d/modeling/features/species_x3.py +++ b/scripts/dataset_1d/modeling/features/species_x3.py @@ -36,14 +36,9 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if ac.util.dataset.should_simulate(dataset_path): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/dataset_1d/simulators/examples/species_x3.py"], - check=True, - ) +ac.util.dataset.simulate_if_needed( + dataset_path, simulator="scripts/dataset_1d/simulators/examples/species_x3.py" +) """ __Shape__ diff --git a/scripts/dataset_1d/modeling/features/visualize_full.py b/scripts/dataset_1d/modeling/features/visualize_full.py index d3004d9..364027f 100644 --- a/scripts/dataset_1d/modeling/features/visualize_full.py +++ b/scripts/dataset_1d/modeling/features/visualize_full.py @@ -38,14 +38,9 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if ac.util.dataset.should_simulate(dataset_path): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/dataset_1d/simulators/start_here.py"], - check=True, - ) +ac.util.dataset.simulate_if_needed( + dataset_path, simulator="scripts/dataset_1d/simulators/start_here.py" +) """ __Shape__ diff --git a/scripts/dataset_1d/modeling/start_here.py b/scripts/dataset_1d/modeling/start_here.py index 9acf3af..6988b70 100644 --- a/scripts/dataset_1d/modeling/start_here.py +++ b/scripts/dataset_1d/modeling/start_here.py @@ -51,14 +51,9 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if ac.util.dataset.should_simulate(dataset_path): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/dataset_1d/simulators/start_here.py"], - check=True, - ) +ac.util.dataset.simulate_if_needed( + dataset_path, simulator="scripts/dataset_1d/simulators/start_here.py" +) """ __Shape__ diff --git a/scripts/dataset_1d/results/examples/cti.py b/scripts/dataset_1d/results/examples/cti.py index 7984acf..a71d65d 100644 --- a/scripts/dataset_1d/results/examples/cti.py +++ b/scripts/dataset_1d/results/examples/cti.py @@ -26,14 +26,9 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if ac.util.dataset.should_simulate(dataset_path): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/dataset_1d/simulators/start_here.py"], - check=True, - ) +ac.util.dataset.simulate_if_needed( + dataset_path, simulator="scripts/dataset_1d/simulators/start_here.py" +) shape_native = (200,) diff --git a/scripts/dataset_1d/results/examples/fits.py b/scripts/dataset_1d/results/examples/fits.py index 365d7af..fb86629 100644 --- a/scripts/dataset_1d/results/examples/fits.py +++ b/scripts/dataset_1d/results/examples/fits.py @@ -46,14 +46,9 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if ac.util.dataset.should_simulate(dataset_path): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/dataset_1d/simulators/start_here.py"], - check=True, - ) +ac.util.dataset.simulate_if_needed( + dataset_path, simulator="scripts/dataset_1d/simulators/start_here.py" +) shape_native = (200,) diff --git a/scripts/dataset_1d/results/examples/samples.py b/scripts/dataset_1d/results/examples/samples.py index 7028a6d..e003273 100644 --- a/scripts/dataset_1d/results/examples/samples.py +++ b/scripts/dataset_1d/results/examples/samples.py @@ -39,14 +39,9 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if ac.util.dataset.should_simulate(dataset_path): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/dataset_1d/simulators/start_here.py"], - check=True, - ) +ac.util.dataset.simulate_if_needed( + dataset_path, simulator="scripts/dataset_1d/simulators/start_here.py" +) shape_native = (200,) diff --git a/scripts/dataset_1d/results/start_here.py b/scripts/dataset_1d/results/start_here.py index 843c838..a3105e1 100644 --- a/scripts/dataset_1d/results/start_here.py +++ b/scripts/dataset_1d/results/start_here.py @@ -40,14 +40,9 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if ac.util.dataset.should_simulate(dataset_path): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/dataset_1d/simulators/start_here.py"], - check=True, - ) +ac.util.dataset.simulate_if_needed( + dataset_path, simulator="scripts/dataset_1d/simulators/start_here.py" +) shape_native = (200,) diff --git a/scripts/imaging_ci/advanced/chaining/pipelines/parallel.py b/scripts/imaging_ci/advanced/chaining/pipelines/parallel.py index 49d131f..d46aef6 100644 --- a/scripts/imaging_ci/advanced/chaining/pipelines/parallel.py +++ b/scripts/imaging_ci/advanced/chaining/pipelines/parallel.py @@ -29,14 +29,9 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if ac.util.dataset.should_simulate(dataset_path): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/imaging_ci/simulators/start_here.py"], - check=True, - ) +ac.util.dataset.simulate_if_needed( + dataset_path, simulator="scripts/imaging_ci/simulators/start_here.py" +) """ __Layout__ diff --git a/scripts/imaging_ci/advanced/chaining/pipelines/parallel_x2__serial_x2.py b/scripts/imaging_ci/advanced/chaining/pipelines/parallel_x2__serial_x2.py index f01992f..b64696d 100644 --- a/scripts/imaging_ci/advanced/chaining/pipelines/parallel_x2__serial_x2.py +++ b/scripts/imaging_ci/advanced/chaining/pipelines/parallel_x2__serial_x2.py @@ -29,14 +29,10 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if ac.util.dataset.should_simulate(dataset_path): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/imaging_ci/simulators/examples/parallel_and_serial.py"], - check=True, - ) +ac.util.dataset.simulate_if_needed( + dataset_path, + simulator="scripts/imaging_ci/simulators/examples/parallel_and_serial.py", +) """ __Layout__ diff --git a/scripts/imaging_ci/advanced/chaining/pipelines/serial.py b/scripts/imaging_ci/advanced/chaining/pipelines/serial.py index bdeb71e..39bee10 100644 --- a/scripts/imaging_ci/advanced/chaining/pipelines/serial.py +++ b/scripts/imaging_ci/advanced/chaining/pipelines/serial.py @@ -29,14 +29,9 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if ac.util.dataset.should_simulate(dataset_path): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/imaging_ci/simulators/examples/serial_cti.py"], - check=True, - ) +ac.util.dataset.simulate_if_needed( + dataset_path, simulator="scripts/imaging_ci/simulators/examples/serial_cti.py" +) """ __Layout__ diff --git a/scripts/imaging_ci/advanced/chaining/x1_species_to_x2_species.py b/scripts/imaging_ci/advanced/chaining/x1_species_to_x2_species.py index 1e50981..d4bb2f4 100644 --- a/scripts/imaging_ci/advanced/chaining/x1_species_to_x2_species.py +++ b/scripts/imaging_ci/advanced/chaining/x1_species_to_x2_species.py @@ -48,14 +48,9 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if ac.util.dataset.should_simulate(dataset_path): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/imaging_ci/simulators/start_here.py"], - check=True, - ) +ac.util.dataset.simulate_if_needed( + dataset_path, simulator="scripts/imaging_ci/simulators/start_here.py" +) """ __Layout__ diff --git a/scripts/imaging_ci/correction/start_here.py b/scripts/imaging_ci/correction/start_here.py index 7b1eb9b..9ad668d 100644 --- a/scripts/imaging_ci/correction/start_here.py +++ b/scripts/imaging_ci/correction/start_here.py @@ -34,14 +34,9 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if ac.util.dataset.should_simulate(dataset_path): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/imaging_ci/simulators/start_here.py"], - check=True, - ) +ac.util.dataset.simulate_if_needed( + dataset_path, simulator="scripts/imaging_ci/simulators/start_here.py" +) """ __Layout__ diff --git a/scripts/imaging_ci/data_preparation/examples/bias_subtraction.py b/scripts/imaging_ci/data_preparation/examples/bias_subtraction.py index f30d6b5..05ffda8 100644 --- a/scripts/imaging_ci/data_preparation/examples/bias_subtraction.py +++ b/scripts/imaging_ci/data_preparation/examples/bias_subtraction.py @@ -41,14 +41,9 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if ac.util.dataset.should_simulate(dataset_path): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/imaging_ci/simulators/examples/bias_uncorrected.py"], - check=True, - ) +ac.util.dataset.simulate_if_needed( + dataset_path, simulator="scripts/imaging_ci/simulators/examples/bias_uncorrected.py" +) shape_native = (2000, 100) diff --git a/scripts/imaging_ci/data_preparation/examples/cosmic_ray_flagging.py b/scripts/imaging_ci/data_preparation/examples/cosmic_ray_flagging.py index a0471ef..3b26d97 100644 --- a/scripts/imaging_ci/data_preparation/examples/cosmic_ray_flagging.py +++ b/scripts/imaging_ci/data_preparation/examples/cosmic_ray_flagging.py @@ -40,14 +40,9 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if ac.util.dataset.should_simulate(dataset_path): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/imaging_ci/simulators/examples/cosmic_rays.py"], - check=True, - ) +ac.util.dataset.simulate_if_needed( + dataset_path, simulator="scripts/imaging_ci/simulators/examples/cosmic_rays.py" +) shape_native = (2000, 100) diff --git a/scripts/imaging_ci/data_preparation/examples/pre_cti.py b/scripts/imaging_ci/data_preparation/examples/pre_cti.py index d163d4a..88055f4 100644 --- a/scripts/imaging_ci/data_preparation/examples/pre_cti.py +++ b/scripts/imaging_ci/data_preparation/examples/pre_cti.py @@ -52,14 +52,9 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if ac.util.dataset.should_simulate(dataset_path): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/imaging_ci/simulators/examples/non_uniform.py"], - check=True, - ) +ac.util.dataset.simulate_if_needed( + dataset_path, simulator="scripts/imaging_ci/simulators/examples/non_uniform.py" +) shape_native = (2000, 100) diff --git a/scripts/imaging_ci/data_preparation/examples/pre_cti_and_cosmics.py b/scripts/imaging_ci/data_preparation/examples/pre_cti_and_cosmics.py index f3d6aa8..2487b00 100644 --- a/scripts/imaging_ci/data_preparation/examples/pre_cti_and_cosmics.py +++ b/scripts/imaging_ci/data_preparation/examples/pre_cti_and_cosmics.py @@ -51,14 +51,9 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if ac.util.dataset.should_simulate(dataset_path): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/imaging_ci/simulators/examples/cosmic_rays.py"], - check=True, - ) +ac.util.dataset.simulate_if_needed( + dataset_path, simulator="scripts/imaging_ci/simulators/examples/cosmic_rays.py" +) shape_native = (2000, 100) diff --git a/scripts/imaging_ci/data_preparation/examples/serial_cti.py b/scripts/imaging_ci/data_preparation/examples/serial_cti.py index f831215..1adb27e 100644 --- a/scripts/imaging_ci/data_preparation/examples/serial_cti.py +++ b/scripts/imaging_ci/data_preparation/examples/serial_cti.py @@ -42,14 +42,9 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if ac.util.dataset.should_simulate(dataset_path): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/imaging_ci/simulators/examples/serial_cti.py"], - check=True, - ) +ac.util.dataset.simulate_if_needed( + dataset_path, simulator="scripts/imaging_ci/simulators/examples/serial_cti.py" +) shape_native = (2000, 100) diff --git a/scripts/imaging_ci/data_preparation/start_here.py b/scripts/imaging_ci/data_preparation/start_here.py index bbb99c4..d10024e 100644 --- a/scripts/imaging_ci/data_preparation/start_here.py +++ b/scripts/imaging_ci/data_preparation/start_here.py @@ -42,14 +42,9 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if ac.util.dataset.should_simulate(dataset_path): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/imaging_ci/simulators/examples/non_uniform.py"], - check=True, - ) +ac.util.dataset.simulate_if_needed( + dataset_path, simulator="scripts/imaging_ci/simulators/examples/non_uniform.py" +) """ __Shape__ @@ -253,14 +248,9 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if ac.util.dataset.should_simulate(dataset_path): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/imaging_ci/simulators/examples/cosmic_rays.py"], - check=True, - ) +ac.util.dataset.simulate_if_needed( + dataset_path, simulator="scripts/imaging_ci/simulators/examples/cosmic_rays.py" +) cosmic_ray_map = ac.Array2D.from_fits( file_path=path.join(dataset_path, f"norm_{int(norm)}", "cosmic_ray_map.fits"), diff --git a/scripts/imaging_ci/extract.py b/scripts/imaging_ci/extract.py index 21488b2..beea6bb 100644 --- a/scripts/imaging_ci/extract.py +++ b/scripts/imaging_ci/extract.py @@ -35,14 +35,9 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if ac.util.dataset.should_simulate(dataset_path): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/imaging_ci/simulators/start_here.py"], - check=True, - ) +ac.util.dataset.simulate_if_needed( + dataset_path, simulator="scripts/imaging_ci/simulators/start_here.py" +) shape_native = (2000, 100) diff --git a/scripts/imaging_ci/modeling/features/cosmic_rays.py b/scripts/imaging_ci/modeling/features/cosmic_rays.py index b094ab9..124493b 100644 --- a/scripts/imaging_ci/modeling/features/cosmic_rays.py +++ b/scripts/imaging_ci/modeling/features/cosmic_rays.py @@ -66,14 +66,9 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if ac.util.dataset.should_simulate(dataset_path): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/imaging_ci/simulators/examples/cosmic_rays.py"], - check=True, - ) +ac.util.dataset.simulate_if_needed( + dataset_path, simulator="scripts/imaging_ci/simulators/examples/cosmic_rays.py" +) """ __Layout__ diff --git a/scripts/imaging_ci/modeling/features/non_uniform.py b/scripts/imaging_ci/modeling/features/non_uniform.py index 5a620af..7967b8a 100644 --- a/scripts/imaging_ci/modeling/features/non_uniform.py +++ b/scripts/imaging_ci/modeling/features/non_uniform.py @@ -36,14 +36,9 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if ac.util.dataset.should_simulate(dataset_path): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/imaging_ci/simulators/examples/non_uniform.py"], - check=True, - ) +ac.util.dataset.simulate_if_needed( + dataset_path, simulator="scripts/imaging_ci/simulators/examples/non_uniform.py" +) """ __Layout__ diff --git a/scripts/imaging_ci/modeling/features/serial_cti.py b/scripts/imaging_ci/modeling/features/serial_cti.py index b353103..32e7f31 100644 --- a/scripts/imaging_ci/modeling/features/serial_cti.py +++ b/scripts/imaging_ci/modeling/features/serial_cti.py @@ -36,14 +36,9 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if ac.util.dataset.should_simulate(dataset_path): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/imaging_ci/simulators/examples/serial_cti.py"], - check=True, - ) +ac.util.dataset.simulate_if_needed( + dataset_path, simulator="scripts/imaging_ci/simulators/examples/serial_cti.py" +) """ __Layout__ diff --git a/scripts/imaging_ci/modeling/features/visualize_full.py b/scripts/imaging_ci/modeling/features/visualize_full.py index 294f49d..f25c7ef 100644 --- a/scripts/imaging_ci/modeling/features/visualize_full.py +++ b/scripts/imaging_ci/modeling/features/visualize_full.py @@ -39,14 +39,9 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if ac.util.dataset.should_simulate(dataset_path): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/imaging_ci/simulators/start_here.py"], - check=True, - ) +ac.util.dataset.simulate_if_needed( + dataset_path, simulator="scripts/imaging_ci/simulators/start_here.py" +) """ __Layout__ diff --git a/scripts/imaging_ci/modeling/start_here.py b/scripts/imaging_ci/modeling/start_here.py index 407c2a8..57fa961 100644 --- a/scripts/imaging_ci/modeling/start_here.py +++ b/scripts/imaging_ci/modeling/start_here.py @@ -50,14 +50,9 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if ac.util.dataset.should_simulate(dataset_path): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/imaging_ci/simulators/start_here.py"], - check=True, - ) +ac.util.dataset.simulate_if_needed( + dataset_path, simulator="scripts/imaging_ci/simulators/start_here.py" +) """ __Shape__ diff --git a/scripts/overview/overview_4_charge_injection_data.py b/scripts/overview/overview_4_charge_injection_data.py index 79a40d4..32331c9 100644 --- a/scripts/overview/overview_4_charge_injection_data.py +++ b/scripts/overview/overview_4_charge_injection_data.py @@ -128,14 +128,9 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if ac.util.dataset.should_simulate(dataset_path): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/imaging_ci/simulators/overview/uniform.py"], - check=True, - ) +ac.util.dataset.simulate_if_needed( + dataset_path, simulator="scripts/imaging_ci/simulators/overview/uniform.py" +) dataset = ac.ImagingCI.from_fits( data_path=path.join(dataset_path, f"norm_{int(norm)}", "data.fits"), @@ -256,14 +251,10 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if ac.util.dataset.should_simulate(dataset_path): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/imaging_ci/simulators/overview/non_uniform_cosmic_rays.py"], - check=True, - ) +ac.util.dataset.simulate_if_needed( + dataset_path, + simulator="scripts/imaging_ci/simulators/overview/non_uniform_cosmic_rays.py", +) dataset = ac.ImagingCI.from_fits( data_path=path.join(dataset_path, f"norm_{int(norm)}", "data.fits"), diff --git a/scripts/overview/overview_5_fitting.py b/scripts/overview/overview_5_fitting.py index 70ffd81..308ac8a 100644 --- a/scripts/overview/overview_5_fitting.py +++ b/scripts/overview/overview_5_fitting.py @@ -62,14 +62,9 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if ac.util.dataset.should_simulate(dataset_path): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/imaging_ci/simulators/overview/calibrate.py"], - check=True, - ) +ac.util.dataset.simulate_if_needed( + dataset_path, simulator="scripts/imaging_ci/simulators/overview/calibrate.py" +) dataset = ac.ImagingCI.from_fits( data_path=path.join(dataset_path, f"norm_{int(norm)}", "data.fits"), @@ -273,14 +268,9 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if ac.util.dataset.should_simulate(dataset_path): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/dataset_1d/simulators/examples/overview.py"], - check=True, - ) +ac.util.dataset.simulate_if_needed( + dataset_path, simulator="scripts/dataset_1d/simulators/examples/overview.py" +) dataset = ac.Dataset1D.from_fits( data_path=path.join(dataset_path, f"norm_{int(norm)}", "data.fits"), diff --git a/scripts/overview/overview_6_cti_calibration.py b/scripts/overview/overview_6_cti_calibration.py index 0c0a40e..2f6e37a 100644 --- a/scripts/overview/overview_6_cti_calibration.py +++ b/scripts/overview/overview_6_cti_calibration.py @@ -72,14 +72,9 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if ac.util.dataset.should_simulate(dataset_path): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/imaging_ci/simulators/overview/calibrate.py"], - check=True, - ) +ac.util.dataset.simulate_if_needed( + dataset_path, simulator="scripts/imaging_ci/simulators/overview/calibrate.py" +) dataset_list = [ ac.ImagingCI.from_fits( @@ -263,14 +258,9 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if ac.util.dataset.should_simulate(dataset_path): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/dataset_1d/simulators/examples/overview.py"], - check=True, - ) +ac.util.dataset.simulate_if_needed( + dataset_path, simulator="scripts/dataset_1d/simulators/examples/overview.py" +) dataset_list = [ ac.Dataset1D.from_fits( diff --git a/scripts/plot/diagnostics/imaging_ci/well_filling.py b/scripts/plot/diagnostics/imaging_ci/well_filling.py index c19425c..dbac20d 100644 --- a/scripts/plot/diagnostics/imaging_ci/well_filling.py +++ b/scripts/plot/diagnostics/imaging_ci/well_filling.py @@ -31,14 +31,9 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if ac.util.dataset.should_simulate(dataset_path): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/imaging_ci/simulators/start_here.py"], - check=True, - ) +ac.util.dataset.simulate_if_needed( + dataset_path, simulator="scripts/imaging_ci/simulators/start_here.py" +) shape_native = (2000, 100) diff --git a/scripts/plot/plotters/Dataset1dPlotter.py b/scripts/plot/plotters/Dataset1dPlotter.py index fd6edc7..125834d 100644 --- a/scripts/plot/plotters/Dataset1dPlotter.py +++ b/scripts/plot/plotters/Dataset1dPlotter.py @@ -27,14 +27,9 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if ac.util.dataset.should_simulate(dataset_path): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/dataset_1d/simulators/start_here.py"], - check=True, - ) +ac.util.dataset.simulate_if_needed( + dataset_path, simulator="scripts/dataset_1d/simulators/start_here.py" +) shape_native = (200, 1) diff --git a/scripts/plot/plotters/FitDataset1dPlotter.py b/scripts/plot/plotters/FitDataset1dPlotter.py index c643aa3..0d1a2db 100644 --- a/scripts/plot/plotters/FitDataset1dPlotter.py +++ b/scripts/plot/plotters/FitDataset1dPlotter.py @@ -27,14 +27,9 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if ac.util.dataset.should_simulate(dataset_path): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/dataset_1d/simulators/start_here.py"], - check=True, - ) +ac.util.dataset.simulate_if_needed( + dataset_path, simulator="scripts/dataset_1d/simulators/start_here.py" +) shape_native = (200, 1) diff --git a/scripts/plot/plotters/FitImagingCIPlotter.py b/scripts/plot/plotters/FitImagingCIPlotter.py index ed2f8e0..059cff2 100644 --- a/scripts/plot/plotters/FitImagingCIPlotter.py +++ b/scripts/plot/plotters/FitImagingCIPlotter.py @@ -30,14 +30,9 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if ac.util.dataset.should_simulate(dataset_path): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/imaging_ci/simulators/start_here.py"], - check=True, - ) +ac.util.dataset.simulate_if_needed( + dataset_path, simulator="scripts/imaging_ci/simulators/start_here.py" +) parallel_overscan = ac.Region2D((1980, 2000, 5, 95)) serial_prescan = ac.Region2D((0, 2000, 0, 5)) diff --git a/scripts/plot/plotters/ImagingCIPlotter.py b/scripts/plot/plotters/ImagingCIPlotter.py index c0382bf..de3a217 100644 --- a/scripts/plot/plotters/ImagingCIPlotter.py +++ b/scripts/plot/plotters/ImagingCIPlotter.py @@ -30,14 +30,9 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if ac.util.dataset.should_simulate(dataset_path): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/imaging_ci/simulators/start_here.py"], - check=True, - ) +ac.util.dataset.simulate_if_needed( + dataset_path, simulator="scripts/imaging_ci/simulators/start_here.py" +) parallel_overscan = ac.Region2D((1980, 2000, 5, 95)) serial_prescan = ac.Region2D((0, 2000, 0, 5)) diff --git a/scripts/plot/plotters/MultiFigurePlotter.py b/scripts/plot/plotters/MultiFigurePlotter.py index d9db3c1..7d978c5 100644 --- a/scripts/plot/plotters/MultiFigurePlotter.py +++ b/scripts/plot/plotters/MultiFigurePlotter.py @@ -37,14 +37,9 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if ac.util.dataset.should_simulate(dataset_path): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/imaging_ci/simulators/start_here.py"], - check=True, - ) +ac.util.dataset.simulate_if_needed( + dataset_path, simulator="scripts/imaging_ci/simulators/start_here.py" +) parallel_overscan = ac.Region2D((1980, 2000, 5, 95)) serial_prescan = ac.Region2D((0, 2000, 0, 5)) diff --git a/scripts/plot/start_here.py b/scripts/plot/start_here.py index f047f04..e8f44fc 100644 --- a/scripts/plot/start_here.py +++ b/scripts/plot/start_here.py @@ -47,14 +47,9 @@ If the dataset does not already exist on your system, it will be created by running the corresponding simulator script. This ensures that all example scripts can be run without manually simulating data first. """ -if ac.util.dataset.should_simulate(dataset_path): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/dataset_1d/simulators/start_here.py"], - check=True, - ) +ac.util.dataset.simulate_if_needed( + dataset_path, simulator="scripts/dataset_1d/simulators/start_here.py" +) shape_native = (200,) prescan = ac.Region1D(region=(0, 10))