Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 4 additions & 9 deletions config/build/env_vars.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 26 additions & 0 deletions notebooks/chapter_1_introduction/tutorial_0_visualization.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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": {},
Expand Down
18 changes: 14 additions & 4 deletions notebooks/chapter_1_introduction/tutorial_7_fitting.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion notebooks/chapter_2_lens_modeling/tutorial_7_results.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion notebooks/chapter_4_pixelizations/tutorial_2_mappers.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion notebooks/chapter_4_pixelizations/tutorial_5_borders.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
11 changes: 10 additions & 1 deletion notebooks/chapter_4_pixelizations/tutorial_6_lens_modeling.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion notebooks/chapter_optional/tutorial_searches.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
15 changes: 15 additions & 0 deletions scripts/chapter_1_introduction/tutorial_0_visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
Expand Down
18 changes: 14 additions & 4 deletions scripts/chapter_1_introduction/tutorial_7_fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading
Loading