diff --git a/config/build/env_vars.yaml b/config/build/env_vars.yaml index 1e393e1..47ffaac 100644 --- a/config/build/env_vars.yaml +++ b/config/build/env_vars.yaml @@ -30,15 +30,10 @@ overrides: unset: [PYAUTO_SMALL_DATASETS] - pattern: "multi/start_here" unset: [PYAUTO_SMALL_DATASETS] - # Non-simulator scripts that load committed FITS data need full-size - # datasets to avoid shape mismatch with pre-existing 100x100 data. - # Simulators run first and regenerate data at the capped size, but - # scripts using the old `if not dataset_path.exists()` pattern skip - # re-simulation when data already exists. - - pattern: "howtolens/" - unset: [PYAUTO_SMALL_DATASETS] - - pattern: "guides/" - unset: [PYAUTO_SMALL_DATASETS] + # (Removed the dead `howtolens/` + `guides/` PYAUTO_SMALL_DATASETS-unset + # workarounds: they matched no files here, and the tutorials now use + # `al.util.dataset.should_simulate` which deletes + re-simulates stale + # data under the cap, so the chapters run correctly at 16x16.) # guides/results/start_here.py must produce real samples so the example # scripts that read from `output/results_folder` afterwards # (data_fitting, queries, models, samples_via_aggregator) find a diff --git a/notebooks/chapter_1_introduction/tutorial_0_visualization.ipynb b/notebooks/chapter_1_introduction/tutorial_0_visualization.ipynb index 1ad2df3..3bed9c3 100644 --- a/notebooks/chapter_1_introduction/tutorial_0_visualization.ipynb +++ b/notebooks/chapter_1_introduction/tutorial_0_visualization.ipynb @@ -116,6 +116,32 @@ "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 is created by running the corresponding\n", + "simulator script. This ensures every example script 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/no_lens_light.py\"],\n", + " check=True,\n", + " )" + ], + "outputs": [], + "execution_count": null + }, { "cell_type": "markdown", "metadata": {}, diff --git a/notebooks/chapter_1_introduction/tutorial_7_fitting.ipynb b/notebooks/chapter_1_introduction/tutorial_7_fitting.ipynb index c41ef65..87db002 100644 --- a/notebooks/chapter_1_introduction/tutorial_7_fitting.ipynb +++ b/notebooks/chapter_1_introduction/tutorial_7_fitting.ipynb @@ -129,20 +129,21 @@ "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." + "The `howtolens` dataset is the one built up and saved in tutorial 6 (`tutorial_6_data.py`). If it does\n", + "not already exist on your system, it is created by running that script. This ensures every example\n", + "script can be run without manually simulating data first." ] }, { "cell_type": "code", "metadata": {}, "source": [ - "if not dataset_path.exists():\n", + "if al.util.dataset.should_simulate(str(dataset_path)):\n", " import subprocess\n", " import sys\n", "\n", " subprocess.run(\n", - " [sys.executable, \"scripts/simulator/no_lens_light__mass_sis.py\"],\n", + " [sys.executable, \"scripts/chapter_1_introduction/tutorial_6_data.py\"],\n", " check=True,\n", " )\n", "\n", @@ -1025,6 +1026,15 @@ "dataset_name = \"simple__no_lens_light__mass_sis\"\n", "dataset_path = Path(\"dataset\") / \"imaging\" / dataset_name\n", "\n", + "if al.util.dataset.should_simulate(str(dataset_path)):\n", + " import subprocess\n", + " import sys\n", + "\n", + " subprocess.run(\n", + " [sys.executable, \"scripts/simulator/no_lens_light__mass_sis.py\"],\n", + " check=True,\n", + " )\n", + "\n", "dataset = al.Imaging.from_fits(\n", " data_path=dataset_path / \"data.fits\",\n", " psf_path=dataset_path / \"psf.fits\",\n", diff --git a/notebooks/chapter_2_lens_modeling/tutorial_1_non_linear_search.ipynb b/notebooks/chapter_2_lens_modeling/tutorial_1_non_linear_search.ipynb index c332057..40ae485 100644 --- a/notebooks/chapter_2_lens_modeling/tutorial_1_non_linear_search.ipynb +++ b/notebooks/chapter_2_lens_modeling/tutorial_1_non_linear_search.ipynb @@ -281,7 +281,7 @@ "cell_type": "code", "metadata": {}, "source": [ - "if not dataset_path.exists():\n", + "if al.util.dataset.should_simulate(str(dataset_path)):\n", " import subprocess\n", " import sys\n", "\n", diff --git a/notebooks/chapter_2_lens_modeling/tutorial_2_practicalities.ipynb b/notebooks/chapter_2_lens_modeling/tutorial_2_practicalities.ipynb index 3290267..5a354b4 100644 --- a/notebooks/chapter_2_lens_modeling/tutorial_2_practicalities.ipynb +++ b/notebooks/chapter_2_lens_modeling/tutorial_2_practicalities.ipynb @@ -191,7 +191,7 @@ "cell_type": "code", "metadata": {}, "source": [ - "if not dataset_path.exists():\n", + "if al.util.dataset.should_simulate(str(dataset_path)):\n", " import subprocess\n", " import sys\n", "\n", diff --git a/notebooks/chapter_2_lens_modeling/tutorial_3_realism_and_complexity.ipynb b/notebooks/chapter_2_lens_modeling/tutorial_3_realism_and_complexity.ipynb index cc7aa85..8a4abb6 100644 --- a/notebooks/chapter_2_lens_modeling/tutorial_3_realism_and_complexity.ipynb +++ b/notebooks/chapter_2_lens_modeling/tutorial_3_realism_and_complexity.ipynb @@ -129,7 +129,7 @@ "cell_type": "code", "metadata": {}, "source": [ - "if not dataset_path.exists():\n", + "if al.util.dataset.should_simulate(str(dataset_path)):\n", " import subprocess\n", " import sys\n", "\n", diff --git a/notebooks/chapter_2_lens_modeling/tutorial_4_dealing_with_failure.ipynb b/notebooks/chapter_2_lens_modeling/tutorial_4_dealing_with_failure.ipynb index 3556e1b..6356c34 100644 --- a/notebooks/chapter_2_lens_modeling/tutorial_4_dealing_with_failure.ipynb +++ b/notebooks/chapter_2_lens_modeling/tutorial_4_dealing_with_failure.ipynb @@ -125,7 +125,7 @@ "cell_type": "code", "metadata": {}, "source": [ - "if not dataset_path.exists():\n", + "if al.util.dataset.should_simulate(str(dataset_path)):\n", " import subprocess\n", " import sys\n", "\n", diff --git a/notebooks/chapter_2_lens_modeling/tutorial_5_linear_profiles.ipynb b/notebooks/chapter_2_lens_modeling/tutorial_5_linear_profiles.ipynb index 3cee1ee..5e3ae89 100644 --- a/notebooks/chapter_2_lens_modeling/tutorial_5_linear_profiles.ipynb +++ b/notebooks/chapter_2_lens_modeling/tutorial_5_linear_profiles.ipynb @@ -139,7 +139,7 @@ "cell_type": "code", "metadata": {}, "source": [ - "if not dataset_path.exists():\n", + "if al.util.dataset.should_simulate(str(dataset_path)):\n", " import subprocess\n", " import sys\n", "\n", diff --git a/notebooks/chapter_2_lens_modeling/tutorial_6_masking_and_positions.ipynb b/notebooks/chapter_2_lens_modeling/tutorial_6_masking_and_positions.ipynb index 76ba81b..03a37aa 100644 --- a/notebooks/chapter_2_lens_modeling/tutorial_6_masking_and_positions.ipynb +++ b/notebooks/chapter_2_lens_modeling/tutorial_6_masking_and_positions.ipynb @@ -112,7 +112,7 @@ "cell_type": "code", "metadata": {}, "source": [ - "if not dataset_path.exists():\n", + "if al.util.dataset.should_simulate(str(dataset_path)):\n", " import subprocess\n", " import sys\n", "\n", diff --git a/notebooks/chapter_2_lens_modeling/tutorial_7_results.ipynb b/notebooks/chapter_2_lens_modeling/tutorial_7_results.ipynb index 112afb0..f106cf2 100644 --- a/notebooks/chapter_2_lens_modeling/tutorial_7_results.ipynb +++ b/notebooks/chapter_2_lens_modeling/tutorial_7_results.ipynb @@ -107,7 +107,7 @@ "cell_type": "code", "metadata": {}, "source": [ - "if not dataset_path.exists():\n", + "if al.util.dataset.should_simulate(str(dataset_path)):\n", " import subprocess\n", " import sys\n", "\n", diff --git a/notebooks/chapter_3_search_chaining/tutorial_1_search_chaining.ipynb b/notebooks/chapter_3_search_chaining/tutorial_1_search_chaining.ipynb index af0df0e..0ae5352 100644 --- a/notebooks/chapter_3_search_chaining/tutorial_1_search_chaining.ipynb +++ b/notebooks/chapter_3_search_chaining/tutorial_1_search_chaining.ipynb @@ -146,7 +146,7 @@ "cell_type": "code", "metadata": {}, "source": [ - "if not dataset_path.exists():\n", + "if al.util.dataset.should_simulate(str(dataset_path)):\n", " import subprocess\n", " import sys\n", "\n", diff --git a/notebooks/chapter_3_search_chaining/tutorial_2_prior_passing.ipynb b/notebooks/chapter_3_search_chaining/tutorial_2_prior_passing.ipynb index 6290e44..9d083ec 100644 --- a/notebooks/chapter_3_search_chaining/tutorial_2_prior_passing.ipynb +++ b/notebooks/chapter_3_search_chaining/tutorial_2_prior_passing.ipynb @@ -121,7 +121,7 @@ "cell_type": "code", "metadata": {}, "source": [ - "if not dataset_path.exists():\n", + "if al.util.dataset.should_simulate(str(dataset_path)):\n", " import subprocess\n", " import sys\n", "\n", diff --git a/notebooks/chapter_3_search_chaining/tutorial_3_lens_and_source.ipynb b/notebooks/chapter_3_search_chaining/tutorial_3_lens_and_source.ipynb index fe84d72..0c03fdb 100644 --- a/notebooks/chapter_3_search_chaining/tutorial_3_lens_and_source.ipynb +++ b/notebooks/chapter_3_search_chaining/tutorial_3_lens_and_source.ipynb @@ -148,7 +148,7 @@ "cell_type": "code", "metadata": {}, "source": [ - "if not dataset_path.exists():\n", + "if al.util.dataset.should_simulate(str(dataset_path)):\n", " import subprocess\n", " import sys\n", "\n", diff --git a/notebooks/chapter_3_search_chaining/tutorial_4_x2_lens_galaxies.ipynb b/notebooks/chapter_3_search_chaining/tutorial_4_x2_lens_galaxies.ipynb index ebe7f44..abe43cd 100644 --- a/notebooks/chapter_3_search_chaining/tutorial_4_x2_lens_galaxies.ipynb +++ b/notebooks/chapter_3_search_chaining/tutorial_4_x2_lens_galaxies.ipynb @@ -120,7 +120,7 @@ "cell_type": "code", "metadata": {}, "source": [ - "if not dataset_path.exists():\n", + "if al.util.dataset.should_simulate(str(dataset_path)):\n", " import subprocess\n", " import sys\n", "\n", diff --git a/notebooks/chapter_3_search_chaining/tutorial_5_complex_source.ipynb b/notebooks/chapter_3_search_chaining/tutorial_5_complex_source.ipynb index 0a24fc8..923c147 100644 --- a/notebooks/chapter_3_search_chaining/tutorial_5_complex_source.ipynb +++ b/notebooks/chapter_3_search_chaining/tutorial_5_complex_source.ipynb @@ -117,7 +117,7 @@ "cell_type": "code", "metadata": {}, "source": [ - "if not dataset_path.exists():\n", + "if al.util.dataset.should_simulate(str(dataset_path)):\n", " import subprocess\n", " import sys\n", "\n", diff --git a/notebooks/chapter_4_pixelizations/tutorial_10_brightness_adaption.ipynb b/notebooks/chapter_4_pixelizations/tutorial_10_brightness_adaption.ipynb index f4d7ace..5027076 100644 --- a/notebooks/chapter_4_pixelizations/tutorial_10_brightness_adaption.ipynb +++ b/notebooks/chapter_4_pixelizations/tutorial_10_brightness_adaption.ipynb @@ -121,7 +121,7 @@ "cell_type": "code", "metadata": {}, "source": [ - "if not dataset_path.exists():\n", + "if al.util.dataset.should_simulate(str(dataset_path)):\n", " import subprocess\n", " import sys\n", "\n", diff --git a/notebooks/chapter_4_pixelizations/tutorial_11_adaptive_regularization.ipynb b/notebooks/chapter_4_pixelizations/tutorial_11_adaptive_regularization.ipynb index fdd7250..a7bd7e3 100644 --- a/notebooks/chapter_4_pixelizations/tutorial_11_adaptive_regularization.ipynb +++ b/notebooks/chapter_4_pixelizations/tutorial_11_adaptive_regularization.ipynb @@ -113,7 +113,7 @@ "cell_type": "code", "metadata": {}, "source": [ - "if not dataset_path.exists():\n", + "if al.util.dataset.should_simulate(str(dataset_path)):\n", " import subprocess\n", " import sys\n", "\n", diff --git a/notebooks/chapter_4_pixelizations/tutorial_2_mappers.ipynb b/notebooks/chapter_4_pixelizations/tutorial_2_mappers.ipynb index cbdf863..3d26490 100644 --- a/notebooks/chapter_4_pixelizations/tutorial_2_mappers.ipynb +++ b/notebooks/chapter_4_pixelizations/tutorial_2_mappers.ipynb @@ -112,7 +112,7 @@ "cell_type": "code", "metadata": {}, "source": [ - "if not dataset_path.exists():\n", + "if al.util.dataset.should_simulate(str(dataset_path)):\n", " import subprocess\n", " import sys\n", "\n", diff --git a/notebooks/chapter_4_pixelizations/tutorial_3_inversions.ipynb b/notebooks/chapter_4_pixelizations/tutorial_3_inversions.ipynb index e467e30..eec1e8c 100644 --- a/notebooks/chapter_4_pixelizations/tutorial_3_inversions.ipynb +++ b/notebooks/chapter_4_pixelizations/tutorial_3_inversions.ipynb @@ -114,7 +114,7 @@ "cell_type": "code", "metadata": {}, "source": [ - "if not dataset_path.exists():\n", + "if al.util.dataset.should_simulate(str(dataset_path)):\n", " import subprocess\n", " import sys\n", "\n", diff --git a/notebooks/chapter_4_pixelizations/tutorial_4_bayesian_regularization.ipynb b/notebooks/chapter_4_pixelizations/tutorial_4_bayesian_regularization.ipynb index 181ada2..d37ce0f 100644 --- a/notebooks/chapter_4_pixelizations/tutorial_4_bayesian_regularization.ipynb +++ b/notebooks/chapter_4_pixelizations/tutorial_4_bayesian_regularization.ipynb @@ -117,7 +117,7 @@ "cell_type": "code", "metadata": {}, "source": [ - "if not dataset_path.exists():\n", + "if al.util.dataset.should_simulate(str(dataset_path)):\n", " import subprocess\n", " import sys\n", "\n", diff --git a/notebooks/chapter_4_pixelizations/tutorial_5_borders.ipynb b/notebooks/chapter_4_pixelizations/tutorial_5_borders.ipynb index f7d6b0b..3c5afdd 100644 --- a/notebooks/chapter_4_pixelizations/tutorial_5_borders.ipynb +++ b/notebooks/chapter_4_pixelizations/tutorial_5_borders.ipynb @@ -111,7 +111,7 @@ "cell_type": "code", "metadata": {}, "source": [ - "if not dataset_path.exists():\n", + "if al.util.dataset.should_simulate(str(dataset_path)):\n", " import subprocess\n", " import sys\n", "\n", diff --git a/notebooks/chapter_4_pixelizations/tutorial_6_lens_modeling.ipynb b/notebooks/chapter_4_pixelizations/tutorial_6_lens_modeling.ipynb index 12e3aed..dcda030 100644 --- a/notebooks/chapter_4_pixelizations/tutorial_6_lens_modeling.ipynb +++ b/notebooks/chapter_4_pixelizations/tutorial_6_lens_modeling.ipynb @@ -118,7 +118,7 @@ "cell_type": "code", "metadata": {}, "source": [ - "if not dataset_path.exists():\n", + "if al.util.dataset.should_simulate(str(dataset_path)):\n", " import subprocess\n", " import sys\n", "\n", @@ -319,6 +319,15 @@ "dataset_name = \"lens_sersic\"\n", "dataset_path = Path(\"dataset\") / \"imaging\" / dataset_name\n", "\n", + "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_sersic.py\"],\n", + " check=True,\n", + " )\n", + "\n", "dataset = al.Imaging.from_fits(\n", " data_path=dataset_path / \"data.fits\",\n", " noise_map_path=dataset_path / \"noise_map.fits\",\n", diff --git a/notebooks/chapter_4_pixelizations/tutorial_7_adaptive_pixelization.ipynb b/notebooks/chapter_4_pixelizations/tutorial_7_adaptive_pixelization.ipynb index b3bb758..da003a4 100644 --- a/notebooks/chapter_4_pixelizations/tutorial_7_adaptive_pixelization.ipynb +++ b/notebooks/chapter_4_pixelizations/tutorial_7_adaptive_pixelization.ipynb @@ -113,7 +113,7 @@ "cell_type": "code", "metadata": {}, "source": [ - "if not dataset_path.exists():\n", + "if al.util.dataset.should_simulate(str(dataset_path)):\n", " import subprocess\n", " import sys\n", "\n", diff --git a/notebooks/chapter_optional/tutorial_searches.ipynb b/notebooks/chapter_optional/tutorial_searches.ipynb index 2627dc1..08653ef 100644 --- a/notebooks/chapter_optional/tutorial_searches.ipynb +++ b/notebooks/chapter_optional/tutorial_searches.ipynb @@ -112,7 +112,7 @@ "cell_type": "code", "metadata": {}, "source": [ - "if not dataset_path.exists():\n", + "if al.util.dataset.should_simulate(str(dataset_path)):\n", " import subprocess\n", " import sys\n", "\n", diff --git a/scripts/chapter_1_introduction/tutorial_0_visualization.py b/scripts/chapter_1_introduction/tutorial_0_visualization.py index 7063770..c37fee3 100644 --- a/scripts/chapter_1_introduction/tutorial_0_visualization.py +++ b/scripts/chapter_1_introduction/tutorial_0_visualization.py @@ -45,6 +45,21 @@ dataset_path = Path("dataset") / "imaging" / "simple__no_lens_light" +""" +__Dataset Auto-Simulation__ + +If the dataset does not already exist on your system, it is created by running the corresponding +simulator script. This ensures every example script 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/no_lens_light.py"], + check=True, + ) + """ We now load this dataset from .fits files and create an instance of an `Imaging` object. """ diff --git a/scripts/chapter_1_introduction/tutorial_7_fitting.py b/scripts/chapter_1_introduction/tutorial_7_fitting.py index c10c8a0..406c272 100644 --- a/scripts/chapter_1_introduction/tutorial_7_fitting.py +++ b/scripts/chapter_1_introduction/tutorial_7_fitting.py @@ -66,15 +66,16 @@ """ __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. +The `howtolens` dataset is the one built up and saved in tutorial 6 (`tutorial_6_data.py`). If it does +not already exist on your system, it is created by running that script. This ensures every example +script can be run without manually simulating data first. """ -if not dataset_path.exists(): +if al.util.dataset.should_simulate(str(dataset_path)): import subprocess import sys subprocess.run( - [sys.executable, "scripts/simulator/no_lens_light__mass_sis.py"], + [sys.executable, "scripts/chapter_1_introduction/tutorial_6_data.py"], check=True, ) @@ -616,6 +617,15 @@ dataset_name = "simple__no_lens_light__mass_sis" dataset_path = Path("dataset") / "imaging" / dataset_name +if al.util.dataset.should_simulate(str(dataset_path)): + import subprocess + import sys + + subprocess.run( + [sys.executable, "scripts/simulator/no_lens_light__mass_sis.py"], + check=True, + ) + dataset = al.Imaging.from_fits( data_path=dataset_path / "data.fits", psf_path=dataset_path / "psf.fits", diff --git a/scripts/chapter_2_lens_modeling/tutorial_1_non_linear_search.py b/scripts/chapter_2_lens_modeling/tutorial_1_non_linear_search.py index dbf3e7d..0920b77 100644 --- a/scripts/chapter_2_lens_modeling/tutorial_1_non_linear_search.py +++ b/scripts/chapter_2_lens_modeling/tutorial_1_non_linear_search.py @@ -201,7 +201,7 @@ 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 not dataset_path.exists(): +if al.util.dataset.should_simulate(str(dataset_path)): import subprocess import sys diff --git a/scripts/chapter_2_lens_modeling/tutorial_2_practicalities.py b/scripts/chapter_2_lens_modeling/tutorial_2_practicalities.py index 5a03572..68a6da9 100755 --- a/scripts/chapter_2_lens_modeling/tutorial_2_practicalities.py +++ b/scripts/chapter_2_lens_modeling/tutorial_2_practicalities.py @@ -111,7 +111,7 @@ 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 not dataset_path.exists(): +if al.util.dataset.should_simulate(str(dataset_path)): import subprocess import sys diff --git a/scripts/chapter_2_lens_modeling/tutorial_3_realism_and_complexity.py b/scripts/chapter_2_lens_modeling/tutorial_3_realism_and_complexity.py index bfc36d9..acf4ea7 100644 --- a/scripts/chapter_2_lens_modeling/tutorial_3_realism_and_complexity.py +++ b/scripts/chapter_2_lens_modeling/tutorial_3_realism_and_complexity.py @@ -61,7 +61,7 @@ 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 not dataset_path.exists(): +if al.util.dataset.should_simulate(str(dataset_path)): import subprocess import sys diff --git a/scripts/chapter_2_lens_modeling/tutorial_4_dealing_with_failure.py b/scripts/chapter_2_lens_modeling/tutorial_4_dealing_with_failure.py index e303564..ff06247 100644 --- a/scripts/chapter_2_lens_modeling/tutorial_4_dealing_with_failure.py +++ b/scripts/chapter_2_lens_modeling/tutorial_4_dealing_with_failure.py @@ -57,7 +57,7 @@ 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 not dataset_path.exists(): +if al.util.dataset.should_simulate(str(dataset_path)): import subprocess import sys diff --git a/scripts/chapter_2_lens_modeling/tutorial_5_linear_profiles.py b/scripts/chapter_2_lens_modeling/tutorial_5_linear_profiles.py index a825a72..c96e6de 100644 --- a/scripts/chapter_2_lens_modeling/tutorial_5_linear_profiles.py +++ b/scripts/chapter_2_lens_modeling/tutorial_5_linear_profiles.py @@ -71,7 +71,7 @@ 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 not dataset_path.exists(): +if al.util.dataset.should_simulate(str(dataset_path)): import subprocess import sys diff --git a/scripts/chapter_2_lens_modeling/tutorial_6_masking_and_positions.py b/scripts/chapter_2_lens_modeling/tutorial_6_masking_and_positions.py index 8c99a6c..f1e0929 100644 --- a/scripts/chapter_2_lens_modeling/tutorial_6_masking_and_positions.py +++ b/scripts/chapter_2_lens_modeling/tutorial_6_masking_and_positions.py @@ -44,7 +44,7 @@ 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 not dataset_path.exists(): +if al.util.dataset.should_simulate(str(dataset_path)): import subprocess import sys diff --git a/scripts/chapter_2_lens_modeling/tutorial_7_results.py b/scripts/chapter_2_lens_modeling/tutorial_7_results.py index cf4429e..11b7cd2 100644 --- a/scripts/chapter_2_lens_modeling/tutorial_7_results.py +++ b/scripts/chapter_2_lens_modeling/tutorial_7_results.py @@ -39,7 +39,7 @@ 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 not dataset_path.exists(): +if al.util.dataset.should_simulate(str(dataset_path)): import subprocess import sys diff --git a/scripts/chapter_3_search_chaining/tutorial_1_search_chaining.py b/scripts/chapter_3_search_chaining/tutorial_1_search_chaining.py index 3220bf7..a85bd93 100644 --- a/scripts/chapter_3_search_chaining/tutorial_1_search_chaining.py +++ b/scripts/chapter_3_search_chaining/tutorial_1_search_chaining.py @@ -78,7 +78,7 @@ 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 not dataset_path.exists(): +if al.util.dataset.should_simulate(str(dataset_path)): import subprocess import sys diff --git a/scripts/chapter_3_search_chaining/tutorial_2_prior_passing.py b/scripts/chapter_3_search_chaining/tutorial_2_prior_passing.py index 0b1123f..0fa346d 100644 --- a/scripts/chapter_3_search_chaining/tutorial_2_prior_passing.py +++ b/scripts/chapter_3_search_chaining/tutorial_2_prior_passing.py @@ -53,7 +53,7 @@ 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 not dataset_path.exists(): +if al.util.dataset.should_simulate(str(dataset_path)): import subprocess import sys diff --git a/scripts/chapter_3_search_chaining/tutorial_3_lens_and_source.py b/scripts/chapter_3_search_chaining/tutorial_3_lens_and_source.py index edf9a8a..5b8d6ce 100644 --- a/scripts/chapter_3_search_chaining/tutorial_3_lens_and_source.py +++ b/scripts/chapter_3_search_chaining/tutorial_3_lens_and_source.py @@ -79,7 +79,7 @@ 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 not dataset_path.exists(): +if al.util.dataset.should_simulate(str(dataset_path)): import subprocess import sys diff --git a/scripts/chapter_3_search_chaining/tutorial_4_x2_lens_galaxies.py b/scripts/chapter_3_search_chaining/tutorial_4_x2_lens_galaxies.py index 849c1f0..ff3c9a4 100644 --- a/scripts/chapter_3_search_chaining/tutorial_4_x2_lens_galaxies.py +++ b/scripts/chapter_3_search_chaining/tutorial_4_x2_lens_galaxies.py @@ -52,7 +52,7 @@ 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 not dataset_path.exists(): +if al.util.dataset.should_simulate(str(dataset_path)): import subprocess import sys diff --git a/scripts/chapter_3_search_chaining/tutorial_5_complex_source.py b/scripts/chapter_3_search_chaining/tutorial_5_complex_source.py index fae71f7..24e167e 100644 --- a/scripts/chapter_3_search_chaining/tutorial_5_complex_source.py +++ b/scripts/chapter_3_search_chaining/tutorial_5_complex_source.py @@ -49,7 +49,7 @@ 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 not dataset_path.exists(): +if al.util.dataset.should_simulate(str(dataset_path)): import subprocess import sys diff --git a/scripts/chapter_4_pixelizations/tutorial_10_brightness_adaption.py b/scripts/chapter_4_pixelizations/tutorial_10_brightness_adaption.py index 22ac1a5..ca7d405 100644 --- a/scripts/chapter_4_pixelizations/tutorial_10_brightness_adaption.py +++ b/scripts/chapter_4_pixelizations/tutorial_10_brightness_adaption.py @@ -53,7 +53,7 @@ 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 not dataset_path.exists(): +if al.util.dataset.should_simulate(str(dataset_path)): import subprocess import sys diff --git a/scripts/chapter_4_pixelizations/tutorial_11_adaptive_regularization.py b/scripts/chapter_4_pixelizations/tutorial_11_adaptive_regularization.py index 62fdf10..05b67cf 100644 --- a/scripts/chapter_4_pixelizations/tutorial_11_adaptive_regularization.py +++ b/scripts/chapter_4_pixelizations/tutorial_11_adaptive_regularization.py @@ -45,7 +45,7 @@ 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 not dataset_path.exists(): +if al.util.dataset.should_simulate(str(dataset_path)): import subprocess import sys diff --git a/scripts/chapter_4_pixelizations/tutorial_2_mappers.py b/scripts/chapter_4_pixelizations/tutorial_2_mappers.py index ce628e2..085b7e7 100644 --- a/scripts/chapter_4_pixelizations/tutorial_2_mappers.py +++ b/scripts/chapter_4_pixelizations/tutorial_2_mappers.py @@ -44,7 +44,7 @@ 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 not dataset_path.exists(): +if al.util.dataset.should_simulate(str(dataset_path)): import subprocess import sys diff --git a/scripts/chapter_4_pixelizations/tutorial_3_inversions.py b/scripts/chapter_4_pixelizations/tutorial_3_inversions.py index 4a5b95d..3557df4 100644 --- a/scripts/chapter_4_pixelizations/tutorial_3_inversions.py +++ b/scripts/chapter_4_pixelizations/tutorial_3_inversions.py @@ -46,7 +46,7 @@ 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 not dataset_path.exists(): +if al.util.dataset.should_simulate(str(dataset_path)): import subprocess import sys diff --git a/scripts/chapter_4_pixelizations/tutorial_4_bayesian_regularization.py b/scripts/chapter_4_pixelizations/tutorial_4_bayesian_regularization.py index 74a080b..42e6d94 100644 --- a/scripts/chapter_4_pixelizations/tutorial_4_bayesian_regularization.py +++ b/scripts/chapter_4_pixelizations/tutorial_4_bayesian_regularization.py @@ -49,7 +49,7 @@ 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 not dataset_path.exists(): +if al.util.dataset.should_simulate(str(dataset_path)): import subprocess import sys diff --git a/scripts/chapter_4_pixelizations/tutorial_5_borders.py b/scripts/chapter_4_pixelizations/tutorial_5_borders.py index 7c9c601..9ea0ec9 100644 --- a/scripts/chapter_4_pixelizations/tutorial_5_borders.py +++ b/scripts/chapter_4_pixelizations/tutorial_5_borders.py @@ -43,7 +43,7 @@ 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 not dataset_path.exists(): +if al.util.dataset.should_simulate(str(dataset_path)): import subprocess import sys diff --git a/scripts/chapter_4_pixelizations/tutorial_6_lens_modeling.py b/scripts/chapter_4_pixelizations/tutorial_6_lens_modeling.py index f87d689..fc65e92 100644 --- a/scripts/chapter_4_pixelizations/tutorial_6_lens_modeling.py +++ b/scripts/chapter_4_pixelizations/tutorial_6_lens_modeling.py @@ -50,7 +50,7 @@ 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 not dataset_path.exists(): +if al.util.dataset.should_simulate(str(dataset_path)): import subprocess import sys @@ -208,6 +208,15 @@ def perform_fit_with_lens__source_galaxy(dataset, lens_galaxy, source_galaxy): dataset_name = "lens_sersic" dataset_path = Path("dataset") / "imaging" / dataset_name +if al.util.dataset.should_simulate(str(dataset_path)): + import subprocess + import sys + + subprocess.run( + [sys.executable, "scripts/simulator/lens_sersic.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_7_adaptive_pixelization.py b/scripts/chapter_4_pixelizations/tutorial_7_adaptive_pixelization.py index ddd6687..7c388b9 100644 --- a/scripts/chapter_4_pixelizations/tutorial_7_adaptive_pixelization.py +++ b/scripts/chapter_4_pixelizations/tutorial_7_adaptive_pixelization.py @@ -45,7 +45,7 @@ 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 not dataset_path.exists(): +if al.util.dataset.should_simulate(str(dataset_path)): import subprocess import sys diff --git a/scripts/chapter_optional/tutorial_searches.py b/scripts/chapter_optional/tutorial_searches.py index 28c21eb..35d2289 100644 --- a/scripts/chapter_optional/tutorial_searches.py +++ b/scripts/chapter_optional/tutorial_searches.py @@ -44,7 +44,7 @@ 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 not dataset_path.exists(): +if al.util.dataset.should_simulate(str(dataset_path)): import subprocess import sys diff --git a/workspace_index.json b/workspace_index.json index 7e99c09..3136ee0 100644 --- a/workspace_index.json +++ b/workspace_index.json @@ -109,7 +109,9 @@ "Model Fitting", "Wrap Up" ], - "cross_refs": [], + "cross_refs": [ + "tutorial_6_data.py" + ], "notebook": "notebooks/chapter_1_introduction/tutorial_7_fitting.ipynb", "path": "scripts/chapter_1_introduction/tutorial_7_fitting.py", "summary": "In previous tutorials, we used light profiles to create simulated images of tracer and visualized how these images would appear when captured by a CCD detector on a telescope like the Hubble Space Telescope.",