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
18 changes: 7 additions & 11 deletions config/build/env_vars_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@
# an earlier step, a developer's local shell, ...). Pinning everything here
# makes the profile self-contained regardless of the caller's environment.
#
# "overrides" then only ever `set:` a var to flip it away from this profile's
# own default for specific scripts — never `unset:` a var that "defaults"
# already pins, since unsetting just re-exposes the same inherited-env gap
# `defaults` exists to close.
# "overrides" should normally `set:` a var away from this profile's own default.
# Use `unset:` only when the script genuinely needs the variable absent, such as
# guides that must not run under PyAuto test mode at all.
#
# Pattern convention (same as no_run.yaml):
# - Patterns containing '/' do a substring match against the file path
Expand All @@ -43,13 +42,10 @@ overrides:
# datasets to avoid shape mismatch with pre-existing 100x100 data.
- pattern: "guides/"
set: { PYAUTO_SMALL_DATASETS: "0" }
# guides/results/start_here.py: no override needed under this profile —
# PYAUTO_TEST_MODE="1" already runs a real (if reduced) sampler, and
# PYAUTO_SKIP_FIT_OUTPUT="0" already writes real output, so
# `output/results_folder` is non-empty for the aggregator without help.
# (Under the smoke profile, PYAUTO_TEST_MODE defaults to "2" (bypass) and
# PYAUTO_SKIP_FIT_OUTPUT to "1", which is why env_vars.yaml needs an
# explicit override here and this file does not.)
# Results guides require the samples promised by their explicit n_like_max
# caps and read them back from the normal output tree.
- pattern: "guides/results/"
unset: [PYAUTO_TEST_MODE]
#
# fits_make / png_make produce .fits / .png outputs from real fits, so they
# need PYAUTO_FAST_PLOTS forced off (it would otherwise close every figure
Expand Down
2 changes: 1 addition & 1 deletion llms-full.txt
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ AUTO-GENERATED by PyAutoBuild — do not edit by hand; regenerate with generate.
- Contents: Dataset, Figures, Customization, Log10, Configs, Subplots, Visuals, Searches
- [Light Profiles](scripts/guides/profiles/light.py): This guide is the single-page tour of every light profile **PyAutoGalaxy** ships with: how to construct each one, how to evaluate its image on a grid, how to compose it into a model, and how to retrieve an instance from that model. Once you have read this guide you should be able to recognise every profile referenced by the modelling examples and the API reference, and you should know which family (standard / linear / operated / multipole / basis) any given profile belongs to.
- Contents: Overview & Docs URL, All Light Profiles (Survey), Detailed Example: Sersic Image, Linear Light Profiles, Operated Light Profiles, Basis, Light Profile in a Model, Model Instance from Light Profile, Multipole Light Profiles, Remaining Profiles Walkthrough
- [Results: Quick Fit Helper](scripts/guides/results/_quick_fit.py): Internal helper invoked via subprocess from the tutorials in this folder (``start_here.py`` and everything under ``aggregator/``). Produces a fast, capped Nautilus fit at ``output/results_folder/`` so the aggregator examples have a populated results directory to read from.
- [Results: Quick Fit Helper](scripts/guides/results/_quick_fit.py): Internal helper invoked via subprocess from the tutorials in this folder. Produces two fast, capped Nautilus fits at ``output/results_folder/`` so the aggregator and workflow examples have a populated results directory to read from.
- [Results: Data Fitting](scripts/guides/results/aggregator/data_fitting.py): In this tutorial, we use the aggregator to load models and data from a non-linear search and use them to perform fits to the data.
- Contents: Aggregator, Fits via Aggregator, Modification, Visualization Customization, Errors (Random draws from PDF)
- [Results: Galaxies and Fits](scripts/guides/results/aggregator/galaxies_fit.py): This tutorial inspects an inferred model using galaxies inferred by the non-linear search. This allows us to visualize and interpret its results.
Expand Down
83 changes: 58 additions & 25 deletions notebooks/guides/results/_quick_fit.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
"Results: Quick Fit Helper\n",
"=========================\n",
"\n",
"Internal helper invoked via subprocess from the tutorials in this folder\n",
"(``start_here.py`` and everything under ``aggregator/``). Produces a fast,\n",
"capped Nautilus fit at ``output/results_folder/`` so the aggregator examples\n",
"have a populated results directory to read from.\n",
"Internal helper invoked via subprocess from the tutorials in this folder.\n",
"Produces two fast, capped Nautilus fits at ``output/results_folder/`` so the\n",
"aggregator and workflow examples have a populated results directory to read\n",
"from.\n",
"\n",
"Idempotent: exits immediately if ``output/results_folder/`` already exists,\n",
"so concurrent or repeated invocations are cheap.\n",
"Idempotent: exits immediately if ``output/results_folder/`` already contains\n",
"the two completed imaging fits, so concurrent or repeated invocations are\n",
"cheap.\n",
"\n",
"Not a tutorial. The model and dataset mirror those used in ``start_here.py``\n",
"(simple imaging, single galaxy, Sersic bulge + Exponential disk), but the\n",
Expand All @@ -27,29 +28,38 @@
"metadata": {},
"source": [
"\n",
"import shutil\n",
"import sys\n",
"from pathlib import Path\n",
"\n",
"from autoconf.test_mode import with_test_mode_segment\n",
"results_path = Path(\"output\") / \"results_folder\"\n",
"if (\n",
" len(list(results_path.glob(\"**/image/dataset.fits\"))) >= 2\n",
" and len(list(results_path.glob(\"**/files/latent/latent_summary.json\"))) >= 2\n",
" and len(list(results_path.glob(\"**/image/fit.png\"))) >= 2\n",
" and len(list(results_path.glob(\"**/image/fit.fits\"))) >= 2\n",
"):\n",
" sys.exit(0)\n",
"\n",
"results_path = with_test_mode_segment(Path(\"output\")) / \"results_folder\"\n",
"if results_path.exists():\n",
" sys.exit(0)\n",
" shutil.rmtree(results_path)\n",
"\n",
"import os\n",
"\n",
"# The aggregator tutorials that invoke this helper read image/dataset.fits via\n",
"# fit.value(\"dataset\"). Smoke-mode env vars (PYAUTO_TEST_MODE>=2,\n",
"# PYAUTO_SKIP_VISUALIZATION) suppress the visualizer that writes that file, so\n",
"# neutralize them here.\n",
"mode = os.environ.get(\"PYAUTO_TEST_MODE\", \"0\")\n",
"if mode in (\"2\", \"3\"):\n",
" os.environ[\"PYAUTO_TEST_MODE\"] = \"1\"\n",
"# fit.value(\"dataset\"). Visualization-skipping environment variables suppress\n",
"# the visualizer that writes that file, so neutralize them here.\n",
"os.environ.pop(\"PYAUTO_SKIP_VISUALIZATION\", None)\n",
"os.environ.pop(\"PYAUTO_SKIP_FIT_OUTPUT\", None)\n",
"os.environ.pop(\"PYAUTO_FAST_PLOTS\", None)\n",
"\n",
"import autofit as af\n",
"import autogalaxy as ag\n",
"from autoconf import conf\n",
"\n",
"# This deliberately shallow helper must retain its exploratory samples because\n",
"# the results tutorials demonstrate indexed sample access.\n",
"conf.instance[\"output\"][\"samples_weight_threshold\"] = None\n",
"\n",
"dataset_name = \"simple\"\n",
"dataset_path = Path(\"dataset\") / \"imaging\" / dataset_name\n",
Expand Down Expand Up @@ -83,18 +93,41 @@
"\n",
"model = af.Collection(galaxies=af.Collection(galaxy=galaxy))\n",
"\n",
"search = af.Nautilus(\n",
" path_prefix=Path(\"results_folder\"),\n",
" name=\"results\",\n",
" unique_tag=dataset_name,\n",
" n_batch=50,\n",
" n_live=100,\n",
" n_like_max=300,\n",
")\n",
"\n",
"analysis = ag.AnalysisImaging(dataset=dataset, use_jax=True)\n",
"class LatentSersicIndex(ag.Latent):\n",
" \"\"\"\n",
" Custom latent catalogue reporting a derived Sersic-index quantity for the\n",
" workflow CSV example.\n",
" \"\"\"\n",
"\n",
" @staticmethod\n",
" def keys(analysis):\n",
" return [\"galaxies.galaxy.bulge.sersic_index_x2\"]\n",
"\n",
" @staticmethod\n",
" def variables(analysis, parameters, model):\n",
" instance = model.instance_from_vector(vector=parameters)\n",
"\n",
" return (instance.galaxies.galaxy.bulge.sersic_index * 2.0,)\n",
"\n",
"\n",
"class AnalysisLatent(ag.AnalysisImaging):\n",
" Latent = LatentSersicIndex\n",
"\n",
"\n",
"analysis = AnalysisLatent(dataset=dataset, use_jax=True)\n",
"\n",
"for i in range(2):\n",
" search = af.Nautilus(\n",
" path_prefix=Path(\"results_folder\"),\n",
" name=\"results\",\n",
" unique_tag=f\"{dataset_name}_{i}\",\n",
" n_batch=50,\n",
" n_live=100,\n",
" n_like_max=300,\n",
" )\n",
"\n",
"search.fit(model=model, analysis=analysis)\n"
" search.fit(model=model, analysis=analysis)\n"
],
"outputs": [],
"execution_count": null
Expand Down
4 changes: 1 addition & 3 deletions notebooks/guides/results/aggregator/data_fitting.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@
"import os\n",
"from pathlib import Path\n",
"\n",
"from autoconf.test_mode import with_test_mode_segment\n",
"\n",
"import autofit as af\n",
"import autogalaxy as ag\n",
"import autogalaxy.plot as aplt"
Expand All @@ -80,7 +78,7 @@
"source": [
"from autofit.aggregator.aggregator import Aggregator\n",
"\n",
"results_path = with_test_mode_segment(Path(\"output\")) / \"results_folder\"\n",
"results_path = Path(\"output\") / \"results_folder\"\n",
"if not results_path.exists():\n",
" import subprocess\n",
" import sys\n",
Expand Down
3 changes: 1 addition & 2 deletions notebooks/guides/results/aggregator/galaxies_fit.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
"\n",
"from pathlib import Path\n",
"\n",
"from autoconf.test_mode import with_test_mode_segment\n",
"import autofit as af\n",
"import autogalaxy as ag\n",
"import autogalaxy.plot as aplt"
Expand All @@ -83,7 +82,7 @@
"cell_type": "code",
"metadata": {},
"source": [
"results_path = with_test_mode_segment(Path(\"output\")) / \"results_folder\"\n",
"results_path = Path(\"output\") / \"results_folder\"\n",
"if not results_path.exists():\n",
" import subprocess\n",
" import sys\n",
Expand Down
4 changes: 1 addition & 3 deletions notebooks/guides/results/aggregator/models.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@
"\n",
"from pathlib import Path\n",
"\n",
"from autoconf.test_mode import with_test_mode_segment\n",
"\n",
"import autofit as af\n",
"import autogalaxy as ag\n",
"import autogalaxy.plot as aplt\n"
Expand All @@ -68,7 +66,7 @@
"source": [
"from autofit.aggregator.aggregator import Aggregator\n",
"\n",
"results_path = with_test_mode_segment(Path(\"output\")) / \"results_folder\"\n",
"results_path = Path(\"output\") / \"results_folder\"\n",
"if not results_path.exists():\n",
" import subprocess\n",
" import sys\n",
Expand Down
3 changes: 1 addition & 2 deletions notebooks/guides/results/aggregator/queries.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"\n",
"from pathlib import Path\n",
"\n",
"from autoconf.test_mode import with_test_mode_segment\n",
"import autofit as af\n",
"import autogalaxy as ag"
],
Expand All @@ -65,7 +64,7 @@
"source": [
"from autofit.aggregator.aggregator import Aggregator\n",
"\n",
"results_path = with_test_mode_segment(Path(\"output\")) / \"results_folder\"\n",
"results_path = Path(\"output\") / \"results_folder\"\n",
"if not results_path.exists():\n",
" import subprocess\n",
" import sys\n",
Expand Down
3 changes: 1 addition & 2 deletions notebooks/guides/results/aggregator/samples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
"\n",
"from pathlib import Path\n",
"\n",
"from autoconf.test_mode import with_test_mode_segment\n",
"import autofit as af\n",
"import autogalaxy as ag\n",
"import autogalaxy.plot as aplt"
Expand All @@ -79,7 +78,7 @@
"cell_type": "code",
"metadata": {},
"source": [
"results_path = with_test_mode_segment(Path(\"output\")) / \"results_folder\"\n",
"results_path = Path(\"output\") / \"results_folder\"\n",
"if not results_path.exists():\n",
" import subprocess\n",
" import sys\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
"\n",
"from pathlib import Path\n",
"\n",
"from autoconf.test_mode import with_test_mode_segment\n",
"import autofit as af\n",
"import autogalaxy.plot as aplt"
],
Expand Down Expand Up @@ -105,7 +104,7 @@
"source": [
"from autofit.aggregator.aggregator import Aggregator\n",
"\n",
"results_path = with_test_mode_segment(Path(\"output\")) / \"results_folder\"\n",
"results_path = Path(\"output\") / \"results_folder\"\n",
"if not results_path.exists():\n",
" import subprocess\n",
" import sys\n",
Expand Down
2 changes: 1 addition & 1 deletion notebooks/guides/results/start_here.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@
"cell_type": "code",
"metadata": {},
"source": [
"workflow_path = Path(\"output\") / \"results_folder_csv_png_fits\" / \"workflow_make_example\"\n",
"workflow_path = Path(\"output\") / \"results_folder\" / \"workflow_make_example\"\n",
"\n",
"agg_csv = af.AggregateCSV(aggregator=agg)\n",
"agg_csv.add_variable(\n",
Expand Down
Loading
Loading