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 Down Expand Up @@ -55,13 +54,10 @@ overrides:
# re-simulation when data already exists.
- 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
8 changes: 4 additions & 4 deletions llms-full.txt
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ AUTO-GENERATED by PyAutoBuild — do not edit by hand; regenerate with generate.
- Contents: Overview & Docs URL, All Profiles (Survey), Stellar Mass Detailed Example, Dark Mass Detailed Example, NFW Variants, Combined Light + Mass Profiles (`al.lmp`), Linear Combined Light + Mass (`al.lmp_linear`), Composing a Decomposed Bulge+Halo Model, Model Instance from Decomposed Model, Remaining Profiles Walkthrough, Back-References
- [Mass Profiles](scripts/guides/profiles/mass.py): This guide is the single-page tour of every lensing mass profile available in **PyAutoLens** (re-exported from **PyAutoGalaxy**): how to construct each one, how to evaluate its convergence and deflections on a grid, how to compose it into a model, and how to pull an instance back out of that model.
- Contents: Overview & Docs URL, All Mass Profiles (Survey), Detailed Example: Isothermal, Mass Sheets, Point Mass, Mass Profile in a Model, Model Instance from Mass Profile, Multipole Mass Profile, Remaining Profiles Walkthrough, Follow-Up
- [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: Interferometer, Aggregator, Fits via Aggregator, Modification, Visualization Customization
- [Results: Galaxies and Fits](scripts/guides/results/aggregator/galaxies_fits.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 All @@ -510,11 +510,11 @@ AUTO-GENERATED by PyAutoBuild — do not edit by hand; regenerate with generate.
- [Results: Start Here](scripts/guides/results/start_here.py): After a lens model-fit completes, nearly everything a user could need is written to the `output/` folder. Most of it can be loaded back into full Python objects with a single line of code, via either `.json` files (for model objects like the `Tracer`, `Model` and samples) or `.fits` files (for imaging products like the model image, residuals and source-plane images).
- Contents: Model Fit, Info
- [Results: CSV](scripts/guides/results/workflow/csv_make.py): This example is a results workflow example, which means it provides tool to set up an effective workflow inspecting and interpreting the large libraries of modeling results.
- Contents: Interferometer, Database File, Model Fit, Unique Tag, Workflow Paths, Aggregator, Model Paths, Adding CSV Columns, Saving the CSV, Customizing CSV Headers, Maximum Likelihood Values, Errors, Column Label List, Latent Variables, Computed Columns
- Contents: Interferometer, Database File, Model Fit, Workflow Paths, Aggregator, Model Paths, Adding CSV Columns, Saving the CSV, Customizing CSV Headers, Maximum Likelihood Values, Errors, Column Label List, Latent Variables, Computed Columns
- [Results: Fits Make](scripts/guides/results/workflow/fits_make.py): This example is a results workflow example, which means it provides tool to set up an effective workflow inspecting and interpreting the large libraries of modeling results.
- Contents: Interferometer, Database File, Model Fit, Unique Tag, Workflow Paths, Aggregator, Extract Images, Output Single Fits, Output to Folder, Naming Convention, CSV Files, Add Extra Fits, Custom Fits Files in Analysis, Path Navigation
- Contents: Interferometer, Database File, Model Fit, Workflow Paths, Aggregator, Extract Images, Output Single Fits, Output to Folder, Naming Convention, CSV Files, Add Extra Fits, Custom Fits Files in Analysis, Path Navigation
- [Results: PNG Make](scripts/guides/results/workflow/png_make.py): This example is a results workflow example, which means it provides tool to set up an effective workflow inspecting and interpreting the large libraries of modeling results.
- Contents: Interferometer, Database File, Model Fit, Unique Tag, Workflow Paths, Aggregator, Extract Images, Output Single Png, Output to Folder, Naming Convention, Combine Images From Subplots, Custom Subplots in Analysis, Path Navigation
- Contents: Interferometer, Database File, Model Fit, Workflow Paths, Aggregator, Extract Images, Output Single Png, Output to Folder, Naming Convention, Combine Images From Subplots, Custom Subplots in Analysis, Path Navigation
- [Fits](scripts/guides/tracer.py): This tutorial inspects an inferred model using the `Tracer` object inferred by the non-linear search. This allows us to visualize and interpret its results.
- Contents: Units, Data Structures, Other Models, Grids, Light Profiles, Mass Profiles, Galaxies, Ray Tracing, Log10, Extending Objects, Attributes, Lensing Quantities, Grid Choices, Sub Gridding, Positions Grid, Scalar Lensing Quantities, Vector Quantities, Other Vector Lensing Quantities, Other Quantities
- [Units and Cosmology](scripts/guides/units/cosmology.py): This tutorial illustrates how to perform unit conversions from **PyAutoLens**'s internal units (e.g. arc-seconds, electrons per second, dimensionless mass units) to physical units (e.g. kiloparsecs, magnitudes, solar masses).
Expand Down
106 changes: 76 additions & 30 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__no_lens_light`` imaging, isothermal lens + MGE source), but the\n",
Expand All @@ -27,19 +28,22 @@
"metadata": {},
"source": [
"\n",
"from pathlib import Path\n",
"import shutil\n",
"import sys\n",
"\n",
"from autoconf.test_mode import with_test_mode_segment\n",
"from pathlib import Path\n",
"\n",
"\n",
"def has_imaging_dataset(results_path):\n",
" return any(results_path.glob(\"**/image/dataset.fits\"))\n",
"def has_workflow_results(results_path):\n",
" return (\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",
"\n",
"\n",
"results_path = with_test_mode_segment(Path(\"output\")) / \"results_folder\"\n",
"if has_imaging_dataset(results_path):\n",
"results_path = Path(\"output\") / \"results_folder\"\n",
"if has_workflow_results(results_path):\n",
" sys.exit(0)\n",
"\n",
"if results_path.exists():\n",
Expand All @@ -48,17 +52,19 @@
"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 autolens as al\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__no_lens_light\"\n",
"dataset_path = Path(\"dataset\") / \"imaging\" / dataset_name\n",
Expand Down Expand Up @@ -97,23 +103,63 @@
"\n",
"model = af.Collection(\n",
" galaxies=af.Collection(\n",
" lens=af.Model(al.Galaxy, redshift=0.5, mass=al.mp.Isothermal),\n",
" lens=af.Model(\n",
" al.Galaxy,\n",
" redshift=0.5,\n",
" mass=al.mp.Isothermal,\n",
" shear=al.mp.ExternalShear,\n",
" ),\n",
" source=af.Model(al.Galaxy, redshift=1.0, bulge=bulge, disk=None),\n",
" ),\n",
")\n",
"\n",
"search = af.Nautilus(\n",
" path_prefix=Path(\"results_folder\"),\n",
" name=\"results\",\n",
" unique_tag=dataset_name,\n",
" n_live=100,\n",
" n_batch=50,\n",
" n_like_max=300,\n",
")\n",
"\n",
"analysis = al.AnalysisImaging(dataset=dataset, use_jax=True)\n",
"class LatentShear(al.Latent):\n",
" \"\"\"\n",
" Custom latent catalogue reporting the lens external-shear magnitude and\n",
" angle for the workflow CSV example.\n",
" \"\"\"\n",
"\n",
" @staticmethod\n",
" def keys(analysis):\n",
" return [\n",
" \"galaxies.lens.shear.magnitude\",\n",
" \"galaxies.lens.shear.angle\",\n",
" ]\n",
"\n",
" @staticmethod\n",
" def variables(analysis, parameters, model):\n",
" instance = model.instance_from_vector(vector=parameters)\n",
"\n",
" import jax.numpy as jnp\n",
"\n",
" magnitude, angle = al.convert.shear_magnitude_and_angle_from(\n",
" gamma_1=instance.galaxies.lens.shear.gamma_1,\n",
" gamma_2=instance.galaxies.lens.shear.gamma_2,\n",
" xp=jnp,\n",
" )\n",
"\n",
" return (magnitude, angle)\n",
"\n",
"\n",
"class AnalysisLatent(al.AnalysisImaging):\n",
" Latent = LatentShear\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_live=100,\n",
" n_batch=50,\n",
" iterations_per_quick_update=10000,\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
3 changes: 1 addition & 2 deletions notebooks/guides/results/aggregator/data_fitting.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"import os\n",
"from pathlib import Path\n",
"\n",
"from autoconf.test_mode import with_test_mode_segment\n",
"import autofit as af\n",
"import autolens as al\n",
"import autolens.plot as aplt"
Expand All @@ -71,7 +70,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 any(results_path.glob(\"**/image/dataset.fits\")):\n",
" import subprocess\n",
" import sys\n",
Expand Down
7 changes: 3 additions & 4 deletions notebooks/guides/results/aggregator/galaxies_fits.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
"import numpy as np\n",
"from pathlib import Path\n",
"\n",
"from autoconf.test_mode import with_test_mode_segment\n",
"import autofit as af\n",
"import autolens as al\n",
"import autolens.plot as aplt"
Expand All @@ -91,7 +90,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 any(results_path.glob(\"**/image/dataset.fits\")):\n",
" import subprocess\n",
" import sys\n",
Expand Down Expand Up @@ -229,7 +228,7 @@
"Using the API introduced in the first tutorial, we can also refit the data locally. \n",
"\n",
"This allows us to inspect how the tracer changes for models with similar log likelihoods. We create and plot\n",
"the tracer of the 100th last accepted model by Nautilus."
"the tracer of the tenth-last accepted model by Nautilus."
]
},
{
Expand Down Expand Up @@ -334,7 +333,7 @@
"Using the API introduced in the first tutorial, we can also refit the data locally. \n",
"\n",
"This allows us to inspect how the fit changes for models with similar log likelihoods. Below, we refit and plot\n",
"the fit of the 100th last accepted model by Nautilus."
"the fit of the tenth-last accepted model by Nautilus."
]
},
{
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 @@ -33,8 +33,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 autolens as al\n",
"import autolens.plot as aplt"
Expand All @@ -57,7 +55,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 any(results_path.glob(\"**/image/dataset.fits\")):\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 @@ -34,7 +34,6 @@
"\n",
"from pathlib import Path\n",
"\n",
"from autoconf.test_mode import with_test_mode_segment\n",
"import autofit as af\n",
"import autolens as al\n"
],
Expand All @@ -56,7 +55,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 any(results_path.glob(\"**/image/dataset.fits\")):\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 autolens as al\n",
"import autolens.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 any(results_path.glob(\"**/image/dataset.fits\")):\n",
" import subprocess\n",
" import sys\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
"\n",
"from pathlib import Path\n",
"\n",
"from autoconf.test_mode import with_test_mode_segment\n",
"import autofit as af\n",
"import autolens.plot as aplt"
],
Expand Down Expand Up @@ -114,7 +113,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 any(results_path.glob(\"**/image/dataset.fits\")):\n",
" import subprocess\n",
" import sys\n",
Expand Down
3 changes: 2 additions & 1 deletion notebooks/guides/results/start_here.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@
" noise_map_hdu=2,\n",
" psf_hdu=3,\n",
" pixel_scales=0.1,\n",
" check_noise_map=False,\n",
" )\n",
"\n",
"if (image_path / \"tracer.fits\").exists():\n",
Expand Down Expand Up @@ -519,7 +520,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