diff --git a/notebooks/chapter_4_pixelizations/tutorial_3_inversions.ipynb b/notebooks/chapter_4_pixelizations/tutorial_3_inversions.ipynb index 39df2b6..78a6080 100644 --- a/notebooks/chapter_4_pixelizations/tutorial_3_inversions.ipynb +++ b/notebooks/chapter_4_pixelizations/tutorial_3_inversions.ipynb @@ -296,7 +296,33 @@ "metadata": {}, "source": [ "dataset_name = \"source_complex\"\n", - "dataset_path = Path(\"dataset\") / \"imaging\" / dataset_name\n", + "dataset_path = Path(\"dataset\") / \"imaging\" / dataset_name" + ], + "outputs": [], + "execution_count": null + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "__Dataset Auto-Simulation__\n", + "\n", + "If the dataset does not already exist on your system, it will be created by running the corresponding\n", + "simulator script. This ensures that all example scripts can be run without manually simulating data first." + ] + }, + { + "cell_type": "code", + "metadata": {}, + "source": [ + "if al.util.dataset.should_simulate(str(dataset_path)):\n", + " import subprocess\n", + " import sys\n", + "\n", + " subprocess.run(\n", + " [sys.executable, \"scripts/simulator/source_complex.py\"],\n", + " check=True,\n", + " )\n", "\n", "dataset = al.Imaging.from_fits(\n", " data_path=dataset_path / \"data.fits\",\n", diff --git a/notebooks/chapter_4_pixelizations/tutorial_5_borders.ipynb b/notebooks/chapter_4_pixelizations/tutorial_5_borders.ipynb index 9c35e81..440b2bb 100644 --- a/notebooks/chapter_4_pixelizations/tutorial_5_borders.ipynb +++ b/notebooks/chapter_4_pixelizations/tutorial_5_borders.ipynb @@ -444,7 +444,33 @@ "metadata": {}, "source": [ "dataset_name = \"x2_lens_galaxies\"\n", - "dataset_path = Path(\"dataset\") / \"imaging\" / dataset_name\n", + "dataset_path = Path(\"dataset\") / \"imaging\" / dataset_name" + ], + "outputs": [], + "execution_count": null + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "__Dataset Auto-Simulation__\n", + "\n", + "If the dataset does not already exist on your system, it will be created by running the corresponding\n", + "simulator script. This ensures that all example scripts can be run without manually simulating data first." + ] + }, + { + "cell_type": "code", + "metadata": {}, + "source": [ + "if al.util.dataset.should_simulate(str(dataset_path)):\n", + " import subprocess\n", + " import sys\n", + "\n", + " subprocess.run(\n", + " [sys.executable, \"scripts/simulator/lens_x2.py\"],\n", + " check=True,\n", + " )\n", "\n", "dataset = al.Imaging.from_fits(\n", " data_path=dataset_path / \"data.fits\",\n", diff --git a/scripts/chapter_4_pixelizations/tutorial_3_inversions.py b/scripts/chapter_4_pixelizations/tutorial_3_inversions.py index 5e18954..e473626 100644 --- a/scripts/chapter_4_pixelizations/tutorial_3_inversions.py +++ b/scripts/chapter_4_pixelizations/tutorial_3_inversions.py @@ -152,6 +152,21 @@ dataset_name = "source_complex" dataset_path = Path("dataset") / "imaging" / dataset_name +""" +__Dataset Auto-Simulation__ + +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 al.util.dataset.should_simulate(str(dataset_path)): + import subprocess + import sys + + subprocess.run( + [sys.executable, "scripts/simulator/source_complex.py"], + check=True, + ) + dataset = al.Imaging.from_fits( data_path=dataset_path / "data.fits", noise_map_path=dataset_path / "noise_map.fits", diff --git a/scripts/chapter_4_pixelizations/tutorial_5_borders.py b/scripts/chapter_4_pixelizations/tutorial_5_borders.py index 67b83bb..fc8904f 100644 --- a/scripts/chapter_4_pixelizations/tutorial_5_borders.py +++ b/scripts/chapter_4_pixelizations/tutorial_5_borders.py @@ -279,6 +279,21 @@ def perform_fit_with_source_galaxy_mask_and_border( dataset_name = "x2_lens_galaxies" dataset_path = Path("dataset") / "imaging" / dataset_name +""" +__Dataset Auto-Simulation__ + +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 al.util.dataset.should_simulate(str(dataset_path)): + import subprocess + import sys + + subprocess.run( + [sys.executable, "scripts/simulator/lens_x2.py"], + check=True, + ) + dataset = al.Imaging.from_fits( data_path=dataset_path / "data.fits", noise_map_path=dataset_path / "noise_map.fits",