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
12 changes: 3 additions & 9 deletions notebooks/chapter_1_introduction/tutorial_0_visualization.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,9 @@
"cell_type": "code",
"metadata": {},
"source": [
"if ag.util.dataset.should_simulate(str(dataset_path)):\n",
" import subprocess\n",
" import sys\n",
"\n",
" # Use the same Python interpreter as this tutorial.\n",
" subprocess.run(\n",
" [sys.executable, \"scripts/simulators/sersic.py\"],\n",
" check=True,\n",
" )\n"
"ag.util.dataset.simulate_if_needed(\n",
" dataset_path, simulator=\"scripts/simulators/sersic.py\"\n",
")\n"
],
"outputs": [],
"execution_count": null
Expand Down
11 changes: 3 additions & 8 deletions notebooks/chapter_1_introduction/tutorial_2_data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -647,14 +647,9 @@
"source": [
"dataset_path = Path(\"dataset\") / \"interferometer\" / \"simple\"\n",
"\n",
"if ag.util.dataset.should_simulate(str(dataset_path)):\n",
" import subprocess\n",
" import sys\n",
"\n",
" subprocess.run(\n",
" [sys.executable, \"scripts/simulators/interferometer.py\"],\n",
" check=True,\n",
" )\n",
"ag.util.dataset.simulate_if_needed(\n",
" dataset_path, simulator=\"scripts/simulators/interferometer.py\"\n",
")\n",
"\n",
"real_space_mask = ag.Mask2D.circular(\n",
" shape_native=(100, 100),\n",
Expand Down
22 changes: 6 additions & 16 deletions notebooks/chapter_1_introduction/tutorial_3_fitting.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,9 @@
"cell_type": "code",
"metadata": {},
"source": [
"if ag.util.dataset.should_simulate(str(dataset_path)):\n",
" import subprocess\n",
" import sys\n",
"\n",
" subprocess.run(\n",
" [sys.executable, \"scripts/chapter_1_introduction/tutorial_2_data.py\"],\n",
" check=True,\n",
" )\n",
"ag.util.dataset.simulate_if_needed(\n",
" dataset_path, simulator=\"scripts/chapter_1_introduction/tutorial_2_data.py\"\n",
")\n",
"\n",
"\n",
"dataset = ag.Imaging.from_fits(\n",
Expand Down Expand Up @@ -983,14 +978,9 @@
"dataset_name = \"simple\"\n",
"dataset_path = Path(\"dataset\") / \"imaging\" / dataset_name\n",
"\n",
"if ag.util.dataset.should_simulate(str(dataset_path)):\n",
" import subprocess\n",
" import sys\n",
"\n",
" subprocess.run(\n",
" [sys.executable, \"scripts/simulators/simple.py\"],\n",
" check=True,\n",
" )\n",
"ag.util.dataset.simulate_if_needed(\n",
" dataset_path, simulator=\"scripts/simulators/simple.py\"\n",
")\n",
"\n",
"dataset = ag.Imaging.from_fits(\n",
" data_path=dataset_path / \"data.fits\",\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,9 @@
"\n",
"dataset_name = \"simple__sersic\"\n",
"dataset_path = Path(\"dataset\") / \"imaging\" / dataset_name\n",
"if ag.util.dataset.should_simulate(str(dataset_path)):\n",
" import subprocess\n",
" import sys\n",
"\n",
" subprocess.run([sys.executable, \"scripts/simulators/sersic.py\"], check=True)\n",
"ag.util.dataset.simulate_if_needed(\n",
" dataset_path, simulator=\"scripts/simulators/sersic.py\"\n",
")\n",
"\n",
"dataset = ag.Imaging.from_fits(\n",
" data_path=dataset_path / \"data.fits\",\n",
Expand Down
8 changes: 3 additions & 5 deletions notebooks/chapter_2_modeling/tutorial_2_practicalities.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,9 @@
"\n",
"dataset_name = \"simple\"\n",
"dataset_path = Path(\"dataset\") / \"imaging\" / dataset_name\n",
"if ag.util.dataset.should_simulate(str(dataset_path)):\n",
" import subprocess\n",
" import sys\n",
"\n",
" subprocess.run([sys.executable, \"scripts/simulators/simple.py\"], check=True)\n",
"ag.util.dataset.simulate_if_needed(\n",
" dataset_path, simulator=\"scripts/simulators/simple.py\"\n",
")\n",
"\n",
"dataset = ag.Imaging.from_fits(\n",
" data_path=dataset_path / \"data.fits\",\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,9 @@
"\n",
"dataset_name = \"simple\"\n",
"dataset_path = Path(\"dataset\") / \"imaging\" / dataset_name\n",
"if ag.util.dataset.should_simulate(str(dataset_path)):\n",
" import subprocess\n",
" import sys\n",
"\n",
" subprocess.run([sys.executable, \"scripts/simulators/simple.py\"], check=True)\n",
"ag.util.dataset.simulate_if_needed(\n",
" dataset_path, simulator=\"scripts/simulators/simple.py\"\n",
")\n",
"\n",
"dataset = ag.Imaging.from_fits(\n",
" data_path=dataset_path / \"data.fits\",\n",
Expand Down
8 changes: 3 additions & 5 deletions notebooks/chapter_2_modeling/tutorial_4_linear_profiles.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,9 @@
"\n",
"dataset_name = \"simple\"\n",
"dataset_path = Path(\"dataset\") / \"imaging\" / dataset_name\n",
"if ag.util.dataset.should_simulate(str(dataset_path)):\n",
" import subprocess\n",
" import sys\n",
"\n",
" subprocess.run([sys.executable, \"scripts/simulators/simple.py\"], check=True)\n",
"ag.util.dataset.simulate_if_needed(\n",
" dataset_path, simulator=\"scripts/simulators/simple.py\"\n",
")\n",
"\n",
"dataset = ag.Imaging.from_fits(\n",
" data_path=dataset_path / \"data.fits\",\n",
Expand Down
16 changes: 6 additions & 10 deletions notebooks/chapter_2_modeling/tutorial_5_data_and_likelihoods.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,9 @@
"\n",
"dataset_name = \"simple__sersic\"\n",
"dataset_path = Path(\"dataset\") / \"imaging\" / dataset_name\n",
"if ag.util.dataset.should_simulate(str(dataset_path)):\n",
" import subprocess\n",
" import sys\n",
"\n",
" subprocess.run([sys.executable, \"scripts/simulators/sersic.py\"], check=True)\n",
"ag.util.dataset.simulate_if_needed(\n",
" dataset_path, simulator=\"scripts/simulators/sersic.py\"\n",
")\n",
"\n",
"dataset = ag.Imaging.from_fits(\n",
" data_path=dataset_path / \"data.fits\",\n",
Expand Down Expand Up @@ -209,11 +207,9 @@
"\n",
"dataset_name = \"extra_galaxy\"\n",
"dataset_path = Path(\"dataset\") / \"imaging\" / dataset_name\n",
"if ag.util.dataset.should_simulate(str(dataset_path)):\n",
" import subprocess\n",
" import sys\n",
"\n",
" subprocess.run([sys.executable, \"scripts/simulators/extra_galaxy.py\"], check=True)\n",
"ag.util.dataset.simulate_if_needed(\n",
" dataset_path, simulator=\"scripts/simulators/extra_galaxy.py\"\n",
")\n",
"dataset = ag.Imaging.from_fits(\n",
" data_path=dataset_path / \"data.fits\",\n",
" noise_map_path=dataset_path / \"noise_map.fits\",\n",
Expand Down
8 changes: 3 additions & 5 deletions notebooks/chapter_2_modeling/tutorial_6_search_chaining.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,9 @@
"\n",
"dataset_name = \"extra_galaxy\"\n",
"dataset_path = Path(\"dataset\") / \"imaging\" / dataset_name\n",
"if ag.util.dataset.should_simulate(str(dataset_path)):\n",
" import subprocess\n",
" import sys\n",
"\n",
" subprocess.run([sys.executable, \"scripts/simulators/extra_galaxy.py\"], check=True)\n",
"ag.util.dataset.simulate_if_needed(\n",
" dataset_path, simulator=\"scripts/simulators/extra_galaxy.py\"\n",
")\n",
"\n",
"dataset = ag.Imaging.from_fits(\n",
" data_path=dataset_path / \"data.fits\",\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,9 @@
"import autoarray.plot as aaplt\n",
"\n",
"dataset_path = Path(\"dataset\") / \"imaging\" / \"simple\"\n",
"if ag.util.dataset.should_simulate(str(dataset_path)):\n",
" subprocess.run([sys.executable, \"scripts/simulators/simple.py\"], check=True)\n",
"ag.util.dataset.simulate_if_needed(\n",
" dataset_path, simulator=\"scripts/simulators/simple.py\"\n",
")\n",
"dataset = ag.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 @@ -94,8 +94,9 @@
"import autoarray.plot as aaplt\n",
"\n",
"dataset_path = Path(\"dataset\") / \"imaging\" / \"simple\"\n",
"if ag.util.dataset.should_simulate(str(dataset_path)):\n",
" subprocess.run([sys.executable, \"scripts/simulators/simple.py\"], check=True)\n",
"ag.util.dataset.simulate_if_needed(\n",
" dataset_path, simulator=\"scripts/simulators/simple.py\"\n",
")\n",
"dataset = ag.Imaging.from_fits(\n",
" data_path=dataset_path / \"data.fits\",\n",
" noise_map_path=dataset_path / \"noise_map.fits\",\n",
Expand Down
5 changes: 3 additions & 2 deletions notebooks/chapter_3_pixelizations/tutorial_3_model_fit.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@
"import autoarray.plot as aaplt\n",
"\n",
"dataset_path = Path(\"dataset\") / \"imaging\" / \"simple\"\n",
"if ag.util.dataset.should_simulate(str(dataset_path)):\n",
" subprocess.run([sys.executable, \"scripts/simulators/simple.py\"], check=True)\n",
"ag.util.dataset.simulate_if_needed(\n",
" dataset_path, simulator=\"scripts/simulators/simple.py\"\n",
")\n",
"dataset = ag.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 @@ -145,14 +145,9 @@
"cell_type": "code",
"metadata": {},
"source": [
"if ag.util.dataset.should_simulate(str(dataset_path)):\n",
" import subprocess\n",
" import sys\n",
"\n",
" subprocess.run(\n",
" [sys.executable, \"scripts/simulators/extra_galaxy.py\"],\n",
" check=True,\n",
" )\n",
"ag.util.dataset.simulate_if_needed(\n",
" dataset_path, simulator=\"scripts/simulators/extra_galaxy.py\"\n",
")\n",
"\n",
"dataset = ag.Imaging.from_fits(\n",
" data_path=dataset_path / \"data.fits\",\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,9 @@
"dataset_name = \"sersic_x2\"\n",
"dataset_path = Path(\"dataset\") / \"imaging\" / dataset_name\n",
"\n",
"if ag.util.dataset.should_simulate(str(dataset_path)):\n",
" import subprocess\n",
" import sys\n",
"\n",
" subprocess.run(\n",
" [sys.executable, \"scripts/simulators/sersic_x2.py\"],\n",
" check=True,\n",
" )\n",
"ag.util.dataset.simulate_if_needed(\n",
" dataset_path, simulator=\"scripts/simulators/sersic_x2.py\"\n",
")\n",
"\n",
"dataset = ag.Imaging.from_fits(\n",
" data_path=dataset_path / \"data.fits\",\n",
Expand Down
11 changes: 3 additions & 8 deletions notebooks/chapter_4_scaling_up_galaxies/tutorial_3_cluster.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,9 @@
"cell_type": "code",
"metadata": {},
"source": [
"if ag.util.dataset.should_simulate(str(dataset_path)):\n",
" import subprocess\n",
" import sys\n",
"\n",
" subprocess.run(\n",
" [sys.executable, \"scripts/simulators/cluster.py\"],\n",
" check=True,\n",
" )\n",
"ag.util.dataset.simulate_if_needed(\n",
" dataset_path, simulator=\"scripts/simulators/cluster.py\"\n",
")\n",
"\n",
"\n",
"dataset = ag.Imaging.from_fits(\n",
Expand Down
8 changes: 3 additions & 5 deletions notebooks/chapter_optional/tutorial_searches.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,9 @@
"\n",
"dataset_name = \"simple__sersic\"\n",
"dataset_path = Path(\"dataset\") / \"imaging\" / dataset_name\n",
"if ag.util.dataset.should_simulate(str(dataset_path)):\n",
" import subprocess\n",
" import sys\n",
"\n",
" subprocess.run([sys.executable, \"scripts/simulators/sersic.py\"], check=True)\n",
"ag.util.dataset.simulate_if_needed(\n",
" dataset_path, simulator=\"scripts/simulators/sersic.py\"\n",
")\n",
"\n",
"dataset = ag.Imaging.from_fits(\n",
" data_path=dataset_path / \"data.fits\",\n",
Expand Down
12 changes: 3 additions & 9 deletions scripts/chapter_1_introduction/tutorial_0_visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,9 @@
The next cell runs the simulator if the example dataset needs to be generated. You do not need to run the
simulator separately.
"""
if ag.util.dataset.should_simulate(str(dataset_path)):
import subprocess
import sys

# Use the same Python interpreter as this tutorial.
subprocess.run(
[sys.executable, "scripts/simulators/sersic.py"],
check=True,
)
ag.util.dataset.simulate_if_needed(
dataset_path, simulator="scripts/simulators/sersic.py"
)


"""
Expand Down
11 changes: 3 additions & 8 deletions scripts/chapter_1_introduction/tutorial_2_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,14 +380,9 @@
"""
dataset_path = Path("dataset") / "interferometer" / "simple"

if ag.util.dataset.should_simulate(str(dataset_path)):
import subprocess
import sys

subprocess.run(
[sys.executable, "scripts/simulators/interferometer.py"],
check=True,
)
ag.util.dataset.simulate_if_needed(
dataset_path, simulator="scripts/simulators/interferometer.py"
)

real_space_mask = ag.Mask2D.circular(
shape_native=(100, 100),
Expand Down
22 changes: 6 additions & 16 deletions scripts/chapter_1_introduction/tutorial_3_fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,9 @@
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 ag.util.dataset.should_simulate(str(dataset_path)):
import subprocess
import sys

subprocess.run(
[sys.executable, "scripts/chapter_1_introduction/tutorial_2_data.py"],
check=True,
)
ag.util.dataset.simulate_if_needed(
dataset_path, simulator="scripts/chapter_1_introduction/tutorial_2_data.py"
)


dataset = ag.Imaging.from_fits(
Expand Down Expand Up @@ -572,14 +567,9 @@
dataset_name = "simple"
dataset_path = Path("dataset") / "imaging" / dataset_name

if ag.util.dataset.should_simulate(str(dataset_path)):
import subprocess
import sys

subprocess.run(
[sys.executable, "scripts/simulators/simple.py"],
check=True,
)
ag.util.dataset.simulate_if_needed(
dataset_path, simulator="scripts/simulators/simple.py"
)

dataset = ag.Imaging.from_fits(
data_path=dataset_path / "data.fits",
Expand Down
8 changes: 3 additions & 5 deletions scripts/chapter_2_modeling/tutorial_1_non_linear_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,9 @@

dataset_name = "simple__sersic"
dataset_path = Path("dataset") / "imaging" / dataset_name
if ag.util.dataset.should_simulate(str(dataset_path)):
import subprocess
import sys

subprocess.run([sys.executable, "scripts/simulators/sersic.py"], check=True)
ag.util.dataset.simulate_if_needed(
dataset_path, simulator="scripts/simulators/sersic.py"
)

dataset = ag.Imaging.from_fits(
data_path=dataset_path / "data.fits",
Expand Down
8 changes: 3 additions & 5 deletions scripts/chapter_2_modeling/tutorial_2_practicalities.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,9 @@

dataset_name = "simple"
dataset_path = Path("dataset") / "imaging" / dataset_name
if ag.util.dataset.should_simulate(str(dataset_path)):
import subprocess
import sys

subprocess.run([sys.executable, "scripts/simulators/simple.py"], check=True)
ag.util.dataset.simulate_if_needed(
dataset_path, simulator="scripts/simulators/simple.py"
)

dataset = ag.Imaging.from_fits(
data_path=dataset_path / "data.fits",
Expand Down
Loading
Loading