From 83ff37fd4633147b7a954d1d20d5b28deb51e6cd Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Mon, 6 Jul 2026 21:38:45 +0100 Subject: [PATCH 1/4] fix: preserve release result samples --- config/build/env_vars_release.yaml | 11 ++++------- notebooks/guides/results/_quick_fit.ipynb | 5 +++++ scripts/guides/results/_quick_fit.py | 5 +++++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/config/build/env_vars_release.yaml b/config/build/env_vars_release.yaml index 22f2d341..d18bda30 100644 --- a/config/build/env_vars_release.yaml +++ b/config/build/env_vars_release.yaml @@ -43,13 +43,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/" + set: { PYAUTO_TEST_MODE: "0" } # # 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 diff --git a/notebooks/guides/results/_quick_fit.ipynb b/notebooks/guides/results/_quick_fit.ipynb index 9f5b832c..5428a53e 100644 --- a/notebooks/guides/results/_quick_fit.ipynb +++ b/notebooks/guides/results/_quick_fit.ipynb @@ -50,6 +50,11 @@ "\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", diff --git a/scripts/guides/results/_quick_fit.py b/scripts/guides/results/_quick_fit.py index 0e012e32..6dc3d4ba 100644 --- a/scripts/guides/results/_quick_fit.py +++ b/scripts/guides/results/_quick_fit.py @@ -40,6 +40,11 @@ import autofit as af import autogalaxy as ag +from autoconf import conf + +# This deliberately shallow helper must retain its exploratory samples because +# the results tutorials demonstrate indexed sample access. +conf.instance["output"]["samples_weight_threshold"] = None dataset_name = "simple" dataset_path = Path("dataset") / "imaging" / dataset_name From 9b076331f30db45d4b70232fc927a83ab450d3d3 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Tue, 7 Jul 2026 18:31:32 +0100 Subject: [PATCH 2/4] Unset test mode for results release guides --- config/build/env_vars_release.yaml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/config/build/env_vars_release.yaml b/config/build/env_vars_release.yaml index d18bda30..8faf5846 100644 --- a/config/build/env_vars_release.yaml +++ b/config/build/env_vars_release.yaml @@ -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 @@ -46,7 +45,7 @@ overrides: # 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/" - set: { PYAUTO_TEST_MODE: "0" } + 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 From 0d598a1809c33d64954e31f8f73278ebced8b273 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Tue, 7 Jul 2026 18:56:42 +0100 Subject: [PATCH 3/4] Centralize results workflow quick fits --- llms-full.txt | 2 +- notebooks/guides/results/_quick_fit.ipynb | 68 +++++++--- notebooks/guides/results/start_here.ipynb | 2 +- .../guides/results/workflow/csv_make.ipynb | 121 ++++-------------- .../guides/results/workflow/fits_make.ipynb | 116 ++++------------- .../guides/results/workflow/png_make.ipynb | 116 ++++------------- scripts/guides/results/_quick_fit.py | 68 +++++++--- scripts/guides/results/start_here.py | 2 +- scripts/guides/results/workflow/csv_make.py | 119 ++++------------- scripts/guides/results/workflow/fits_make.py | 114 ++++------------- scripts/guides/results/workflow/png_make.py | 115 ++++------------- workspace_index.json | 8 +- 12 files changed, 254 insertions(+), 597 deletions(-) diff --git a/llms-full.txt b/llms-full.txt index 014e88d5..1c778129 100644 --- a/llms-full.txt +++ b/llms-full.txt @@ -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. diff --git a/notebooks/guides/results/_quick_fit.ipynb b/notebooks/guides/results/_quick_fit.ipynb index 5428a53e..231cacb6 100644 --- a/notebooks/guides/results/_quick_fit.ipynb +++ b/notebooks/guides/results/_quick_fit.ipynb @@ -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", @@ -27,15 +28,24 @@ "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", "\n", "results_path = with_test_mode_segment(Path(\"output\")) / \"results_folder\"\n", - "if results_path.exists():\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", + "if results_path.exists():\n", + " shutil.rmtree(results_path)\n", + "\n", "import os\n", "\n", "# The aggregator tutorials that invoke this helper read image/dataset.fits via\n", @@ -47,6 +57,7 @@ " os.environ[\"PYAUTO_TEST_MODE\"] = \"1\"\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", @@ -88,18 +99,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 diff --git a/notebooks/guides/results/start_here.ipynb b/notebooks/guides/results/start_here.ipynb index 0ae56c66..d80c9403 100644 --- a/notebooks/guides/results/start_here.ipynb +++ b/notebooks/guides/results/start_here.ipynb @@ -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", diff --git a/notebooks/guides/results/workflow/csv_make.ipynb b/notebooks/guides/results/workflow/csv_make.ipynb index 993464c4..635793aa 100644 --- a/notebooks/guides/results/workflow/csv_make.ipynb +++ b/notebooks/guides/results/workflow/csv_make.ipynb @@ -17,7 +17,7 @@ "\n", "__Contents__\n", "\n", - "- **Model Fit:** Perform model-fits whose results are output for CSV extraction.\n", + "- **Model Fit:** Run the shared quick-fit helper if results have not already been created.\n", "- **Workflow Paths:** Set the output path for workflow files.\n", "- **Aggregator:** Load results using the Aggregator.\n", "- **Adding CSV Columns:** Add columns to the CSV file for specific model parameters.\n", @@ -34,7 +34,7 @@ "Workflow functionality closely mirrors the `png_make.py` and `fits_make.py` examples, which load results of\n", "model-fits and output th em as .png files and .fits files to quickly summarise results.\n", "\n", - "The same initial fit creating results in a folder called `results_folder_csv_png_fits` is therefore used.\n", + "The shared `_quick_fit.py` helper creates these results in `results_folder`. If you have older outputs under `results_folder_csv_png_fits`, use `results_folder` for these examples instead.\n", "\n", "__Interferometer__\n", "\n", @@ -69,7 +69,6 @@ "from autoconf import setup_notebook; setup_notebook()\n", "\n", "from pathlib import Path\n", - "from pathlib import Path\n", "\n", "import autofit as af\n", "import autogalaxy as ag" @@ -83,99 +82,32 @@ "source": [ "__Model Fit__\n", "\n", - "The code below performs a model-fit using nautilus. \n", - "\n", - "You should be familiar with modeling already, if not read the `modeling/start_here.py` script before reading this one!\n", - "\n", - "__Unique Tag__\n", - "\n", - "One thing to note is that the `unique_tag` of the search is given the name of the dataset with an index for the\n", - "fit of 0 and 1. \n", + "These workflow examples reuse the shared ``_quick_fit.py`` helper instead of\n", + "performing model-fits in every script. The helper creates two capped Nautilus\n", + "fits, including the latent quantities used below, in ``output/results_folder/``.\n", "\n", - "This `unique_tag` names the fit in a descriptive and human-readable way, which we will exploit to make our .csv files\n", - "more descriptive and easier to interpret." + "Older versions of these workflow examples used ``output/results_folder_csv_png_fits/``;\n", + "use ``output/results_folder/`` for the centralized setup here." ] }, { "cell_type": "code", "metadata": {}, "source": [ - "for i in range(2):\n", - " dataset_name = f\"simple\"\n", - " dataset_path = Path(\"dataset\") / \"imaging\" / dataset_name\n", - "\n", - " \"\"\"\n", - " __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.\n", - " \"\"\"\n", - " if not dataset_path.exists():\n", - " import subprocess\n", - " import sys\n", - "\n", - " subprocess.run(\n", - " [sys.executable, \"scripts/imaging/simulator.py\"],\n", - " check=True,\n", - " )\n", - "\n", - " dataset = ag.Imaging.from_fits(\n", - " data_path=dataset_path / \"data.fits\",\n", - " psf_path=dataset_path / \"psf.fits\",\n", - " noise_map_path=dataset_path / \"noise_map.fits\",\n", - " pixel_scales=0.1,\n", - " )\n", - "\n", - " mask = ag.Mask2D.circular(\n", - " shape_native=dataset.shape_native, pixel_scales=dataset.pixel_scales, radius=3.0\n", - " )\n", - "\n", - " dataset = dataset.apply_mask(mask=mask)\n", - "\n", - " bulge = af.Model(ag.lp_linear.Sersic)\n", - " disk = af.Model(ag.lp_linear.Exponential)\n", - " bulge.centre = disk.centre\n", - "\n", - " galaxy = af.Model(ag.Galaxy, redshift=0.5, bulge=bulge, disk=disk)\n", - "\n", - " model = af.Collection(galaxies=af.Collection(galaxy=galaxy))\n", - "\n", - " \"\"\"\n", - " __N Like Max__\n", - "\n", - " `n_like_max=300` caps the search at 300 likelihood evaluations so this workflow example runs in\n", - " seconds and produces the .csv files it demonstrates without waiting for a full Nautilus\n", - " convergence. Remove the cap (or raise it substantially) for a real model fit.\n", - " \"\"\"\n", - " search = af.Nautilus(\n", - " path_prefix=Path(\"results_folder_csv_png_fits\"),\n", - " name=\"results\",\n", - " unique_tag=f\"simple_{i}\",\n", - " n_live=100,\n", - " n_batch=50,\n", - " n_like_max=300, # samples capped for quick result generation\n", - " )\n", - "\n", - " class LatentSersicIndex(ag.Latent):\n", - " \"\"\"Custom catalogue replacing library defaults; subclass ag.Latent (base) and override keys/variables;\n", - " declare via Latent = LatentSersicIndex; note: subclass ag.LatentGalaxy instead to keep library latents.\"\"\"\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", - " class AnalysisLatent(ag.AnalysisImaging):\n", - " Latent = LatentSersicIndex\n", - "\n", - " analysis = AnalysisLatent(dataset=dataset)\n", - "\n", - " result = search.fit(model=model, analysis=analysis)" + "import subprocess\n", + "import sys\n", + "\n", + "results_path = Path(\"output\") / \"results_folder\"\n", + "if (\n", + " len(list(results_path.glob(\"**/image/dataset.fits\"))) < 2\n", + " or len(list(results_path.glob(\"**/files/latent/latent_summary.json\"))) < 2\n", + " or len(list(results_path.glob(\"**/image/fit.png\"))) < 2\n", + " or len(list(results_path.glob(\"**/image/fit.fits\"))) < 2\n", + "):\n", + " subprocess.run(\n", + " [sys.executable, \"scripts/guides/results/_quick_fit.py\"],\n", + " check=True,\n", + " )" ], "outputs": [], "execution_count": null @@ -196,7 +128,7 @@ "cell_type": "code", "metadata": {}, "source": [ - "workflow_path = Path(\"output\") / \"results_folder_csv_png_fits\" / \"workflow_make_example\"" + "workflow_path = Path(\"output\") / \"results_folder\" / \"workflow_make_example\"" ], "outputs": [], "execution_count": null @@ -217,7 +149,7 @@ "from autofit.aggregator.aggregator import Aggregator\n", "\n", "agg = Aggregator.from_directory(\n", - " directory=Path(\"output\") / \"results_folder_csv_png_fits\",\n", + " directory=Path(\"output\") / \"results_folder\",\n", ")" ], "outputs": [], @@ -253,8 +185,7 @@ "\n", "Note the API for the `centre`, which is a tuple parameter and therefore needs for `centre_0` to be specified.\n", "\n", - "The `results_folder_csv_png_fits` contained two model-fits to two different datasets, meaning that each `add_variable` \n", - "call will add three rows, corresponding to the three model-fits.\n", + "The `results_folder` contains two model-fits, meaning that each `add_variable` call adds two rows.\n", "\n", "This adds the median PDF value of the parameter to the .csv file, we show how to add other values later in this script." ] @@ -277,7 +208,7 @@ "\n", "We can now output the results of all our model-fits to the .csv file, using the `save` method.\n", "\n", - "This will output in your current working directory (e.g. the `autogalaxy_workspace/output.results_folder_csv_png_fits`) \n", + "This will output in your current working directory (e.g. the `autogalaxy_workspace/output/results_folder`)\n", "as a .csv file containing the median PDF values of the parameters, have a quick look now to see the format of \n", "the .csv file." ] @@ -399,7 +330,7 @@ "which dataset each row corresponds to.\n", "\n", "To make this list, we use the `Aggregator` to loop over the `search` objects and extract their `unique_tag`'s, which \n", - "when we fitted the model above used the dataset names. This API can also be used to extract the `name` or `path_prefix`\n", + "which the helper set from the dataset names. This API can also be used to extract the `name` or `path_prefix`\n", "of the search and build an informative list for the names of the subplots.\n", "\n", "We then pass the column `name` and this list to the `add_label_column` method, which will add a column to the .csv file." diff --git a/notebooks/guides/results/workflow/fits_make.ipynb b/notebooks/guides/results/workflow/fits_make.ipynb index 322a6fba..553bc3a1 100644 --- a/notebooks/guides/results/workflow/fits_make.ipynb +++ b/notebooks/guides/results/workflow/fits_make.ipynb @@ -29,7 +29,7 @@ "\n", "__Contents__\n", "\n", - "- **Model Fit:** Perform model-fits whose results are output for FITS extraction.\n", + "- **Model Fit:** Run the shared quick-fit helper if results have not already been created.\n", "- **Workflow Paths:** Set the output path for workflow FITS files.\n", "- **Aggregator:** Load results using the Aggregator.\n", "- **Extract Images:** Extract specific HDU images from fit.fits files.\n", @@ -44,7 +44,7 @@ "Workflow functionality closely mirrors the `png_make.py` and `fits_make.py` examples, which load results of\n", "model-fits and output th em as .png files and .fits files to quickly summarise results.\n", "\n", - "The same initial fit creating results in a folder called `results_folder_csv_png_fits` is therefore used.\n", + "The shared `_quick_fit.py` helper creates these results in `results_folder`. If you have older outputs under `results_folder_csv_png_fits`, use `results_folder` for these examples instead.\n", "\n", "__Interferometer__\n", "\n", @@ -79,7 +79,6 @@ "from autoconf import setup_notebook; setup_notebook()\n", "\n", "from pathlib import Path\n", - "from pathlib import Path\n", "\n", "import autofit as af\n", "import autogalaxy as ag\n", @@ -94,99 +93,32 @@ "source": [ "__Model Fit__\n", "\n", - "The code below performs a model-fit using nautilus. \n", - "\n", - "You should be familiar with modeling already, if not read the `modeling/start_here.py` script before reading this one!\n", - "\n", - "__Unique Tag__\n", - "\n", - "One thing to note is that the `unique_tag` of the search is given the name of the dataset with an index for the\n", - "fit of 0 and 1. \n", + "These workflow examples reuse the shared ``_quick_fit.py`` helper instead of\n", + "performing model-fits in every script. The helper creates two capped Nautilus\n", + "fits, including the latent quantities used below, in ``output/results_folder/``.\n", "\n", - "This `unique_tag` names the fit in a descriptive and human-readable way, which we will exploit to make our .fits files\n", - "more descriptive and easier to interpret." + "Older versions of these workflow examples used ``output/results_folder_csv_png_fits/``;\n", + "use ``output/results_folder/`` for the centralized setup here." ] }, { "cell_type": "code", "metadata": {}, "source": [ - "for i in range(2):\n", - " dataset_name = f\"simple\"\n", - " dataset_path = Path(\"dataset\") / \"imaging\" / dataset_name\n", - "\n", - " \"\"\"\n", - " __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.\n", - " \"\"\"\n", - " if not dataset_path.exists():\n", - " import subprocess\n", - " import sys\n", - "\n", - " subprocess.run(\n", - " [sys.executable, \"scripts/imaging/simulator.py\"],\n", - " check=True,\n", - " )\n", - "\n", - " dataset = ag.Imaging.from_fits(\n", - " data_path=dataset_path / \"data.fits\",\n", - " psf_path=dataset_path / \"psf.fits\",\n", - " noise_map_path=dataset_path / \"noise_map.fits\",\n", - " pixel_scales=0.1,\n", - " )\n", - "\n", - " mask = ag.Mask2D.circular(\n", - " shape_native=dataset.shape_native, pixel_scales=dataset.pixel_scales, radius=3.0\n", - " )\n", - "\n", - " dataset = dataset.apply_mask(mask=mask)\n", - "\n", - " bulge = af.Model(ag.lp_linear.Sersic)\n", - " disk = af.Model(ag.lp_linear.Exponential)\n", - " bulge.centre = disk.centre\n", - "\n", - " galaxy = af.Model(ag.Galaxy, redshift=0.5, bulge=bulge, disk=disk)\n", - "\n", - " model = af.Collection(galaxies=af.Collection(galaxy=galaxy))\n", - "\n", - " \"\"\"\n", - " __N Like Max__\n", - "\n", - " `n_like_max=300` caps the search at 300 likelihood evaluations so this workflow example runs in\n", - " seconds and produces the .fits files it demonstrates without waiting for a full Nautilus\n", - " convergence. Remove the cap (or raise it substantially) for a real model fit.\n", - " \"\"\"\n", - " search = af.Nautilus(\n", - " path_prefix=Path(\"results_folder_csv_png_fits\"),\n", - " name=\"results\",\n", - " unique_tag=f\"simple_{i}\",\n", - " n_live=100,\n", - " n_batch=50,\n", - " n_like_max=300, # samples capped for quick result generation\n", - " )\n", - "\n", - " class LatentSersicIndex(ag.Latent):\n", - " \"\"\"Custom catalogue replacing library defaults; subclass ag.Latent (base) and override keys/variables;\n", - " declare via Latent = LatentSersicIndex; note: subclass ag.LatentGalaxy instead to keep library latents.\"\"\"\n", - "\n", - " @staticmethod\n", - " def keys(analysis):\n", - " return [\"galaxies.galaxy.bulge.sersic_index\"]\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", - " class AnalysisLatent(ag.AnalysisImaging):\n", - " Latent = LatentSersicIndex\n", - "\n", - " analysis = AnalysisLatent(dataset=dataset)\n", - "\n", - " result = search.fit(model=model, analysis=analysis)" + "import subprocess\n", + "import sys\n", + "\n", + "results_path = Path(\"output\") / \"results_folder\"\n", + "if (\n", + " len(list(results_path.glob(\"**/image/dataset.fits\"))) < 2\n", + " or len(list(results_path.glob(\"**/files/latent/latent_summary.json\"))) < 2\n", + " or len(list(results_path.glob(\"**/image/fit.png\"))) < 2\n", + " or len(list(results_path.glob(\"**/image/fit.fits\"))) < 2\n", + "):\n", + " subprocess.run(\n", + " [sys.executable, \"scripts/guides/results/_quick_fit.py\"],\n", + " check=True,\n", + " )" ], "outputs": [], "execution_count": null @@ -208,7 +140,7 @@ "cell_type": "code", "metadata": {}, "source": [ - "workflow_path = Path(\"output\") / \"results_folder_csv_png_fits\" / \"workflow_make_example\"" + "workflow_path = Path(\"output\") / \"results_folder\" / \"workflow_make_example\"" ], "outputs": [], "execution_count": null @@ -229,7 +161,7 @@ "from autofit.aggregator.aggregator import Aggregator\n", "\n", "agg = Aggregator.from_directory(\n", - " directory=Path(\"output\") / \"results_folder_csv_png_fits\",\n", + " directory=Path(\"output\") / \"results_folder\",\n", ")" ], "outputs": [], @@ -325,7 +257,7 @@ "files are going to be output.\n", "\n", "One way to name the .fits files is to use the `unique_tag` of the search, which is unique to every model-fit. For\n", - "the search above, the `unique_tag` was `simple_0` and `simple_1`, therefore this will informatively name the .fits\n", + "the helper-generated `unique_tag` values are `simple_0` and `simple_1`, therefore this will informatively name the .fits\n", "files the names of the datasets.\n", "\n", "We achieve this behaviour by inputting `name=\"unique_tag\"` to the `output_to_folder` method. " diff --git a/notebooks/guides/results/workflow/png_make.ipynb b/notebooks/guides/results/workflow/png_make.ipynb index 923cffa2..5d23a5e5 100644 --- a/notebooks/guides/results/workflow/png_make.ipynb +++ b/notebooks/guides/results/workflow/png_make.ipynb @@ -31,7 +31,7 @@ "\n", "__Contents__\n", "\n", - "- **Model Fit:** Perform model-fits whose results are output for PNG extraction.\n", + "- **Model Fit:** Run the shared quick-fit helper if results have not already been created.\n", "- **Workflow Paths:** Set the output path for workflow PNG files.\n", "- **Aggregator:** Load results using the Aggregator.\n", "- **Extract Images:** Extract specific images from subplot PNG files.\n", @@ -48,7 +48,7 @@ "Workflow functionality closely mirrors the `png_make.py` and `fits_make.py` examples, which load results of\n", "model-fits and output th em as .png files and .fits files to quickly summarise results.\n", "\n", - "The same initial fit creating results in a folder called `results_folder_csv_png_fits` is therefore used.\n", + "The shared `_quick_fit.py` helper creates these results in `results_folder`. If you have older outputs under `results_folder_csv_png_fits`, use `results_folder` for these examples instead.\n", "\n", "__Interferometer__\n", "\n", @@ -83,7 +83,6 @@ "from autoconf import setup_notebook; setup_notebook()\n", "\n", "from pathlib import Path\n", - "from pathlib import Path\n", "from PIL import Image\n", "\n", "import autofit as af\n", @@ -99,99 +98,32 @@ "source": [ "__Model Fit__\n", "\n", - "The code below performs a model-fit using nautilus. \n", - "\n", - "You should be familiar with modeling already, if not read the `modeling/start_here.py` script before reading this one!\n", - "\n", - "__Unique Tag__\n", - "\n", - "One thing to note is that the `unique_tag` of the search is given the name of the dataset with an index for the\n", - "fit of 0 and 1. \n", + "These workflow examples reuse the shared ``_quick_fit.py`` helper instead of\n", + "performing model-fits in every script. The helper creates two capped Nautilus\n", + "fits, including the latent quantities used below, in ``output/results_folder/``.\n", "\n", - "This `unique_tag` names the fit in a descriptive and human-readable way, which we will exploit to make our .png files\n", - "more descriptive and easier to interpret." + "Older versions of these workflow examples used ``output/results_folder_csv_png_fits/``;\n", + "use ``output/results_folder/`` for the centralized setup here." ] }, { "cell_type": "code", "metadata": {}, "source": [ - "for i in range(2):\n", - " dataset_name = f\"simple\"\n", - " dataset_path = Path(\"dataset\") / \"imaging\" / dataset_name\n", - "\n", - " \"\"\"\n", - " __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.\n", - " \"\"\"\n", - " if not dataset_path.exists():\n", - " import subprocess\n", - " import sys\n", - "\n", - " subprocess.run(\n", - " [sys.executable, \"scripts/imaging/simulator.py\"],\n", - " check=True,\n", - " )\n", - "\n", - " dataset = ag.Imaging.from_fits(\n", - " data_path=dataset_path / \"data.fits\",\n", - " psf_path=dataset_path / \"psf.fits\",\n", - " noise_map_path=dataset_path / \"noise_map.fits\",\n", - " pixel_scales=0.1,\n", - " )\n", - "\n", - " mask = ag.Mask2D.circular(\n", - " shape_native=dataset.shape_native, pixel_scales=dataset.pixel_scales, radius=3.0\n", - " )\n", - "\n", - " dataset = dataset.apply_mask(mask=mask)\n", - "\n", - " bulge = af.Model(ag.lp_linear.Sersic)\n", - " disk = af.Model(ag.lp_linear.Exponential)\n", - " bulge.centre = disk.centre\n", - "\n", - " galaxy = af.Model(ag.Galaxy, redshift=0.5, bulge=bulge, disk=disk)\n", - "\n", - " model = af.Collection(galaxies=af.Collection(galaxy=galaxy))\n", - "\n", - " \"\"\"\n", - " __N Like Max__\n", - "\n", - " `n_like_max=300` caps the search at 300 likelihood evaluations so this workflow example runs in\n", - " seconds and produces the .png files it demonstrates without waiting for a full Nautilus\n", - " convergence. Remove the cap (or raise it substantially) for a real model fit.\n", - " \"\"\"\n", - " search = af.Nautilus(\n", - " path_prefix=Path(\"results_folder_csv_png_fits\"),\n", - " name=\"results\",\n", - " unique_tag=f\"simple_{i}\",\n", - " n_live=100,\n", - " n_batch=50,\n", - " n_like_max=300, # samples capped for quick result generation\n", - " )\n", - "\n", - " class LatentSersicIndex(ag.Latent):\n", - " \"\"\"Custom catalogue replacing library defaults; subclass ag.Latent (base) and override keys/variables;\n", - " declare via Latent = LatentSersicIndex; note: subclass ag.LatentGalaxy instead to keep library latents.\"\"\"\n", - "\n", - " @staticmethod\n", - " def keys(analysis):\n", - " return [\"galaxies.galaxy.bulge.sersic_index\"]\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", - " class AnalysisLatent(ag.AnalysisImaging):\n", - " Latent = LatentSersicIndex\n", - "\n", - " analysis = AnalysisLatent(dataset=dataset)\n", - "\n", - " result = search.fit(model=model, analysis=analysis)\n" + "import subprocess\n", + "import sys\n", + "\n", + "results_path = Path(\"output\") / \"results_folder\"\n", + "if (\n", + " len(list(results_path.glob(\"**/image/dataset.fits\"))) < 2\n", + " or len(list(results_path.glob(\"**/files/latent/latent_summary.json\"))) < 2\n", + " or len(list(results_path.glob(\"**/image/fit.png\"))) < 2\n", + " or len(list(results_path.glob(\"**/image/fit.fits\"))) < 2\n", + "):\n", + " subprocess.run(\n", + " [sys.executable, \"scripts/guides/results/_quick_fit.py\"],\n", + " check=True,\n", + " )" ], "outputs": [], "execution_count": null @@ -213,7 +145,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", "folder_path = workflow_path.parent if workflow_path.suffix else workflow_path\n", "folder_path.mkdir(parents=True, exist_ok=True)" ], @@ -236,7 +168,7 @@ "from autofit.aggregator.aggregator import Aggregator\n", "\n", "agg = Aggregator.from_directory(\n", - " directory=Path(\"output\") / \"results_folder_csv_png_fits\",\n", + " directory=Path(\"output\") / \"results_folder\",\n", ")" ], "outputs": [], @@ -335,7 +267,7 @@ "files are going to be output.\n", "\n", "One way to name the .png files is to use the `unique_tag` of the search, which is unique to every model-fit. For\n", - "the search above, the `unique_tag` was `simple_0` and `simple_1`, therefore this will informatively name the .png\n", + "the helper-generated `unique_tag` values are `simple_0` and `simple_1`, therefore this will informatively name the .png\n", "files the names of the datasets.\n", "\n", "We achieve this behaviour by inputting `name=\"unique_tag\"` to the `output_to_folder` method. " diff --git a/scripts/guides/results/_quick_fit.py b/scripts/guides/results/_quick_fit.py index 6dc3d4ba..439fdb03 100644 --- a/scripts/guides/results/_quick_fit.py +++ b/scripts/guides/results/_quick_fit.py @@ -2,13 +2,14 @@ Results: Quick Fit Helper ========================= -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. +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. -Idempotent: exits immediately if ``output/results_folder/`` already exists, -so concurrent or repeated invocations are cheap. +Idempotent: exits immediately if ``output/results_folder/`` already contains +the two completed imaging fits, so concurrent or repeated invocations are +cheap. Not a tutorial. The model and dataset mirror those used in ``start_here.py`` (simple imaging, single galaxy, Sersic bulge + Exponential disk), but the @@ -17,15 +18,24 @@ fast enough to fit inside the per-script CI timeout. """ +import shutil import sys from pathlib import Path from autoconf.test_mode import with_test_mode_segment results_path = with_test_mode_segment(Path("output")) / "results_folder" -if results_path.exists(): +if ( + len(list(results_path.glob("**/image/dataset.fits"))) >= 2 + and len(list(results_path.glob("**/files/latent/latent_summary.json"))) >= 2 + and len(list(results_path.glob("**/image/fit.png"))) >= 2 + and len(list(results_path.glob("**/image/fit.fits"))) >= 2 +): sys.exit(0) +if results_path.exists(): + shutil.rmtree(results_path) + import os # The aggregator tutorials that invoke this helper read image/dataset.fits via @@ -37,6 +47,7 @@ os.environ["PYAUTO_TEST_MODE"] = "1" os.environ.pop("PYAUTO_SKIP_VISUALIZATION", None) os.environ.pop("PYAUTO_SKIP_FIT_OUTPUT", None) +os.environ.pop("PYAUTO_FAST_PLOTS", None) import autofit as af import autogalaxy as ag @@ -78,15 +89,38 @@ model = af.Collection(galaxies=af.Collection(galaxy=galaxy)) -search = af.Nautilus( - path_prefix=Path("results_folder"), - name="results", - unique_tag=dataset_name, - n_batch=50, - n_live=100, - n_like_max=300, -) -analysis = ag.AnalysisImaging(dataset=dataset, use_jax=True) +class LatentSersicIndex(ag.Latent): + """ + Custom latent catalogue reporting a derived Sersic-index quantity for the + workflow CSV example. + """ + + @staticmethod + def keys(analysis): + return ["galaxies.galaxy.bulge.sersic_index_x2"] + + @staticmethod + def variables(analysis, parameters, model): + instance = model.instance_from_vector(vector=parameters) + + return (instance.galaxies.galaxy.bulge.sersic_index * 2.0,) + + +class AnalysisLatent(ag.AnalysisImaging): + Latent = LatentSersicIndex + + +analysis = AnalysisLatent(dataset=dataset, use_jax=True) + +for i in range(2): + search = af.Nautilus( + path_prefix=Path("results_folder"), + name="results", + unique_tag=f"{dataset_name}_{i}", + n_batch=50, + n_live=100, + n_like_max=300, + ) -search.fit(model=model, analysis=analysis) + search.fit(model=model, analysis=analysis) diff --git a/scripts/guides/results/start_here.py b/scripts/guides/results/start_here.py index 28a4d163..97180486 100644 --- a/scripts/guides/results/start_here.py +++ b/scripts/guides/results/start_here.py @@ -373,7 +373,7 @@ The `workflow_path` specifies where these files are output, in this case the .csv files which summarise the results, and the code below can easily be adapted to output the .png and .fits files. """ -workflow_path = Path("output") / "results_folder_csv_png_fits" / "workflow_make_example" +workflow_path = Path("output") / "results_folder" / "workflow_make_example" agg_csv = af.AggregateCSV(aggregator=agg) agg_csv.add_variable( diff --git a/scripts/guides/results/workflow/csv_make.py b/scripts/guides/results/workflow/csv_make.py index 3dbd26c2..97e855e5 100644 --- a/scripts/guides/results/workflow/csv_make.py +++ b/scripts/guides/results/workflow/csv_make.py @@ -12,7 +12,7 @@ __Contents__ -- **Model Fit:** Perform model-fits whose results are output for CSV extraction. +- **Model Fit:** Run the shared quick-fit helper if results have not already been created. - **Workflow Paths:** Set the output path for workflow files. - **Aggregator:** Load results using the Aggregator. - **Adding CSV Columns:** Add columns to the CSV file for specific model parameters. @@ -29,7 +29,7 @@ Workflow functionality closely mirrors the `png_make.py` and `fits_make.py` examples, which load results of model-fits and output th em as .png files and .fits files to quickly summarise results. -The same initial fit creating results in a folder called `results_folder_csv_png_fits` is therefore used. +The shared `_quick_fit.py` helper creates these results in `results_folder`. If you have older outputs under `results_folder_csv_png_fits`, use `results_folder` for these examples instead. __Interferometer__ @@ -58,7 +58,6 @@ # from autoconf import setup_notebook; setup_notebook() -from pathlib import Path from pathlib import Path import autofit as af @@ -67,95 +66,28 @@ """ __Model Fit__ -The code below performs a model-fit using nautilus. - -You should be familiar with modeling already, if not read the `modeling/start_here.py` script before reading this one! - -__Unique Tag__ +These workflow examples reuse the shared ``_quick_fit.py`` helper instead of +performing model-fits in every script. The helper creates two capped Nautilus +fits, including the latent quantities used below, in ``output/results_folder/``. -One thing to note is that the `unique_tag` of the search is given the name of the dataset with an index for the -fit of 0 and 1. - -This `unique_tag` names the fit in a descriptive and human-readable way, which we will exploit to make our .csv files -more descriptive and easier to interpret. +Older versions of these workflow examples used ``output/results_folder_csv_png_fits/``; +use ``output/results_folder/`` for the centralized setup here. """ -for i in range(2): - dataset_name = f"simple" - dataset_path = Path("dataset") / "imaging" / dataset_name - - """ - __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. - """ - if not dataset_path.exists(): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/imaging/simulator.py"], - check=True, - ) - - dataset = ag.Imaging.from_fits( - data_path=dataset_path / "data.fits", - psf_path=dataset_path / "psf.fits", - noise_map_path=dataset_path / "noise_map.fits", - pixel_scales=0.1, - ) - - mask = ag.Mask2D.circular( - shape_native=dataset.shape_native, pixel_scales=dataset.pixel_scales, radius=3.0 - ) - - dataset = dataset.apply_mask(mask=mask) - - bulge = af.Model(ag.lp_linear.Sersic) - disk = af.Model(ag.lp_linear.Exponential) - bulge.centre = disk.centre - - galaxy = af.Model(ag.Galaxy, redshift=0.5, bulge=bulge, disk=disk) - - model = af.Collection(galaxies=af.Collection(galaxy=galaxy)) - - """ - __N Like Max__ - - `n_like_max=300` caps the search at 300 likelihood evaluations so this workflow example runs in - seconds and produces the .csv files it demonstrates without waiting for a full Nautilus - convergence. Remove the cap (or raise it substantially) for a real model fit. - """ - search = af.Nautilus( - path_prefix=Path("results_folder_csv_png_fits"), - name="results", - unique_tag=f"simple_{i}", - n_live=100, - n_batch=50, - n_like_max=300, # samples capped for quick result generation +import subprocess +import sys + +results_path = Path("output") / "results_folder" +if ( + len(list(results_path.glob("**/image/dataset.fits"))) < 2 + or len(list(results_path.glob("**/files/latent/latent_summary.json"))) < 2 + or len(list(results_path.glob("**/image/fit.png"))) < 2 + or len(list(results_path.glob("**/image/fit.fits"))) < 2 +): + subprocess.run( + [sys.executable, "scripts/guides/results/_quick_fit.py"], + check=True, ) - class LatentSersicIndex(ag.Latent): - """Custom catalogue replacing library defaults; subclass ag.Latent (base) and override keys/variables; - declare via Latent = LatentSersicIndex; note: subclass ag.LatentGalaxy instead to keep library latents.""" - - @staticmethod - def keys(analysis): - return ["galaxies.galaxy.bulge.sersic_index_x2"] - - @staticmethod - def variables(analysis, parameters, model): - instance = model.instance_from_vector(vector=parameters) - - return (instance.galaxies.galaxy.bulge.sersic_index * 2.0,) - - class AnalysisLatent(ag.AnalysisImaging): - Latent = LatentSersicIndex - - analysis = AnalysisLatent(dataset=dataset) - - result = search.fit(model=model, analysis=analysis) - """ __Workflow Paths__ @@ -164,7 +96,7 @@ class AnalysisLatent(ag.AnalysisImaging): The `workflow_path` specifies where these files are output, in this case the .csv files which summarise the results. """ -workflow_path = Path("output") / "results_folder_csv_png_fits" / "workflow_make_example" +workflow_path = Path("output") / "results_folder" / "workflow_make_example" """ __Aggregator__ @@ -174,7 +106,7 @@ class AnalysisLatent(ag.AnalysisImaging): from autofit.aggregator.aggregator import Aggregator agg = Aggregator.from_directory( - directory=Path("output") / "results_folder_csv_png_fits", + directory=Path("output") / "results_folder", ) """ @@ -193,8 +125,7 @@ class AnalysisLatent(ag.AnalysisImaging): Note the API for the `centre`, which is a tuple parameter and therefore needs for `centre_0` to be specified. -The `results_folder_csv_png_fits` contained two model-fits to two different datasets, meaning that each `add_variable` -call will add three rows, corresponding to the three model-fits. +The `results_folder` contains two model-fits, meaning that each `add_variable` call adds two rows. This adds the median PDF value of the parameter to the .csv file, we show how to add other values later in this script. """ @@ -206,7 +137,7 @@ class AnalysisLatent(ag.AnalysisImaging): We can now output the results of all our model-fits to the .csv file, using the `save` method. -This will output in your current working directory (e.g. the `autogalaxy_workspace/output.results_folder_csv_png_fits`) +This will output in your current working directory (e.g. the `autogalaxy_workspace/output/results_folder`) as a .csv file containing the median PDF values of the parameters, have a quick look now to see the format of the .csv file. """ @@ -284,7 +215,7 @@ class AnalysisLatent(ag.AnalysisImaging): which dataset each row corresponds to. To make this list, we use the `Aggregator` to loop over the `search` objects and extract their `unique_tag`'s, which -when we fitted the model above used the dataset names. This API can also be used to extract the `name` or `path_prefix` +which the helper set from the dataset names. This API can also be used to extract the `name` or `path_prefix` of the search and build an informative list for the names of the subplots. We then pass the column `name` and this list to the `add_label_column` method, which will add a column to the .csv file. diff --git a/scripts/guides/results/workflow/fits_make.py b/scripts/guides/results/workflow/fits_make.py index ed9588e7..fe068ad1 100644 --- a/scripts/guides/results/workflow/fits_make.py +++ b/scripts/guides/results/workflow/fits_make.py @@ -24,7 +24,7 @@ __Contents__ -- **Model Fit:** Perform model-fits whose results are output for FITS extraction. +- **Model Fit:** Run the shared quick-fit helper if results have not already been created. - **Workflow Paths:** Set the output path for workflow FITS files. - **Aggregator:** Load results using the Aggregator. - **Extract Images:** Extract specific HDU images from fit.fits files. @@ -39,7 +39,7 @@ Workflow functionality closely mirrors the `png_make.py` and `fits_make.py` examples, which load results of model-fits and output th em as .png files and .fits files to quickly summarise results. -The same initial fit creating results in a folder called `results_folder_csv_png_fits` is therefore used. +The shared `_quick_fit.py` helper creates these results in `results_folder`. If you have older outputs under `results_folder_csv_png_fits`, use `results_folder` for these examples instead. __Interferometer__ @@ -68,7 +68,6 @@ # from autoconf import setup_notebook; setup_notebook() -from pathlib import Path from pathlib import Path import autofit as af @@ -78,95 +77,28 @@ """ __Model Fit__ -The code below performs a model-fit using nautilus. - -You should be familiar with modeling already, if not read the `modeling/start_here.py` script before reading this one! - -__Unique Tag__ +These workflow examples reuse the shared ``_quick_fit.py`` helper instead of +performing model-fits in every script. The helper creates two capped Nautilus +fits, including the latent quantities used below, in ``output/results_folder/``. -One thing to note is that the `unique_tag` of the search is given the name of the dataset with an index for the -fit of 0 and 1. - -This `unique_tag` names the fit in a descriptive and human-readable way, which we will exploit to make our .fits files -more descriptive and easier to interpret. +Older versions of these workflow examples used ``output/results_folder_csv_png_fits/``; +use ``output/results_folder/`` for the centralized setup here. """ -for i in range(2): - dataset_name = f"simple" - dataset_path = Path("dataset") / "imaging" / dataset_name - - """ - __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. - """ - if not dataset_path.exists(): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/imaging/simulator.py"], - check=True, - ) - - dataset = ag.Imaging.from_fits( - data_path=dataset_path / "data.fits", - psf_path=dataset_path / "psf.fits", - noise_map_path=dataset_path / "noise_map.fits", - pixel_scales=0.1, - ) - - mask = ag.Mask2D.circular( - shape_native=dataset.shape_native, pixel_scales=dataset.pixel_scales, radius=3.0 - ) - - dataset = dataset.apply_mask(mask=mask) - - bulge = af.Model(ag.lp_linear.Sersic) - disk = af.Model(ag.lp_linear.Exponential) - bulge.centre = disk.centre - - galaxy = af.Model(ag.Galaxy, redshift=0.5, bulge=bulge, disk=disk) - - model = af.Collection(galaxies=af.Collection(galaxy=galaxy)) - - """ - __N Like Max__ - - `n_like_max=300` caps the search at 300 likelihood evaluations so this workflow example runs in - seconds and produces the .fits files it demonstrates without waiting for a full Nautilus - convergence. Remove the cap (or raise it substantially) for a real model fit. - """ - search = af.Nautilus( - path_prefix=Path("results_folder_csv_png_fits"), - name="results", - unique_tag=f"simple_{i}", - n_live=100, - n_batch=50, - n_like_max=300, # samples capped for quick result generation +import subprocess +import sys + +results_path = Path("output") / "results_folder" +if ( + len(list(results_path.glob("**/image/dataset.fits"))) < 2 + or len(list(results_path.glob("**/files/latent/latent_summary.json"))) < 2 + or len(list(results_path.glob("**/image/fit.png"))) < 2 + or len(list(results_path.glob("**/image/fit.fits"))) < 2 +): + subprocess.run( + [sys.executable, "scripts/guides/results/_quick_fit.py"], + check=True, ) - class LatentSersicIndex(ag.Latent): - """Custom catalogue replacing library defaults; subclass ag.Latent (base) and override keys/variables; - declare via Latent = LatentSersicIndex; note: subclass ag.LatentGalaxy instead to keep library latents.""" - - @staticmethod - def keys(analysis): - return ["galaxies.galaxy.bulge.sersic_index"] - - @staticmethod - def variables(analysis, parameters, model): - instance = model.instance_from_vector(vector=parameters) - - return (instance.galaxies.galaxy.bulge.sersic_index * 2.0,) - - class AnalysisLatent(ag.AnalysisImaging): - Latent = LatentSersicIndex - - analysis = AnalysisLatent(dataset=dataset) - - result = search.fit(model=model, analysis=analysis) - """ __Workflow Paths__ @@ -176,7 +108,7 @@ class AnalysisLatent(ag.AnalysisImaging): The `workflow_path` specifies where these files are output, in this case the .fits files containing the key results we require. """ -workflow_path = Path("output") / "results_folder_csv_png_fits" / "workflow_make_example" +workflow_path = Path("output") / "results_folder" / "workflow_make_example" """ __Aggregator__ @@ -186,7 +118,7 @@ class AnalysisLatent(ag.AnalysisImaging): from autofit.aggregator.aggregator import Aggregator agg = Aggregator.from_directory( - directory=Path("output") / "results_folder_csv_png_fits", + directory=Path("output") / "results_folder", ) """ @@ -243,7 +175,7 @@ class AnalysisLatent(ag.AnalysisImaging): files are going to be output. One way to name the .fits files is to use the `unique_tag` of the search, which is unique to every model-fit. For -the search above, the `unique_tag` was `simple_0` and `simple_1`, therefore this will informatively name the .fits +the helper-generated `unique_tag` values are `simple_0` and `simple_1`, therefore this will informatively name the .fits files the names of the datasets. We achieve this behaviour by inputting `name="unique_tag"` to the `output_to_folder` method. diff --git a/scripts/guides/results/workflow/png_make.py b/scripts/guides/results/workflow/png_make.py index e995368e..2d0b3b59 100644 --- a/scripts/guides/results/workflow/png_make.py +++ b/scripts/guides/results/workflow/png_make.py @@ -26,7 +26,7 @@ __Contents__ -- **Model Fit:** Perform model-fits whose results are output for PNG extraction. +- **Model Fit:** Run the shared quick-fit helper if results have not already been created. - **Workflow Paths:** Set the output path for workflow PNG files. - **Aggregator:** Load results using the Aggregator. - **Extract Images:** Extract specific images from subplot PNG files. @@ -43,7 +43,7 @@ Workflow functionality closely mirrors the `png_make.py` and `fits_make.py` examples, which load results of model-fits and output th em as .png files and .fits files to quickly summarise results. -The same initial fit creating results in a folder called `results_folder_csv_png_fits` is therefore used. +The shared `_quick_fit.py` helper creates these results in `results_folder`. If you have older outputs under `results_folder_csv_png_fits`, use `results_folder` for these examples instead. __Interferometer__ @@ -72,7 +72,6 @@ # from autoconf import setup_notebook; setup_notebook() -from pathlib import Path from pathlib import Path from PIL import Image @@ -83,96 +82,28 @@ """ __Model Fit__ -The code below performs a model-fit using nautilus. - -You should be familiar with modeling already, if not read the `modeling/start_here.py` script before reading this one! - -__Unique Tag__ +These workflow examples reuse the shared ``_quick_fit.py`` helper instead of +performing model-fits in every script. The helper creates two capped Nautilus +fits, including the latent quantities used below, in ``output/results_folder/``. -One thing to note is that the `unique_tag` of the search is given the name of the dataset with an index for the -fit of 0 and 1. - -This `unique_tag` names the fit in a descriptive and human-readable way, which we will exploit to make our .png files -more descriptive and easier to interpret. +Older versions of these workflow examples used ``output/results_folder_csv_png_fits/``; +use ``output/results_folder/`` for the centralized setup here. """ -for i in range(2): - dataset_name = f"simple" - dataset_path = Path("dataset") / "imaging" / dataset_name - - """ - __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. - """ - if not dataset_path.exists(): - import subprocess - import sys - - subprocess.run( - [sys.executable, "scripts/imaging/simulator.py"], - check=True, - ) - - dataset = ag.Imaging.from_fits( - data_path=dataset_path / "data.fits", - psf_path=dataset_path / "psf.fits", - noise_map_path=dataset_path / "noise_map.fits", - pixel_scales=0.1, - ) - - mask = ag.Mask2D.circular( - shape_native=dataset.shape_native, pixel_scales=dataset.pixel_scales, radius=3.0 +import subprocess +import sys + +results_path = Path("output") / "results_folder" +if ( + len(list(results_path.glob("**/image/dataset.fits"))) < 2 + or len(list(results_path.glob("**/files/latent/latent_summary.json"))) < 2 + or len(list(results_path.glob("**/image/fit.png"))) < 2 + or len(list(results_path.glob("**/image/fit.fits"))) < 2 +): + subprocess.run( + [sys.executable, "scripts/guides/results/_quick_fit.py"], + check=True, ) - dataset = dataset.apply_mask(mask=mask) - - bulge = af.Model(ag.lp_linear.Sersic) - disk = af.Model(ag.lp_linear.Exponential) - bulge.centre = disk.centre - - galaxy = af.Model(ag.Galaxy, redshift=0.5, bulge=bulge, disk=disk) - - model = af.Collection(galaxies=af.Collection(galaxy=galaxy)) - - """ - __N Like Max__ - - `n_like_max=300` caps the search at 300 likelihood evaluations so this workflow example runs in - seconds and produces the .png files it demonstrates without waiting for a full Nautilus - convergence. Remove the cap (or raise it substantially) for a real model fit. - """ - search = af.Nautilus( - path_prefix=Path("results_folder_csv_png_fits"), - name="results", - unique_tag=f"simple_{i}", - n_live=100, - n_batch=50, - n_like_max=300, # samples capped for quick result generation - ) - - class LatentSersicIndex(ag.Latent): - """Custom catalogue replacing library defaults; subclass ag.Latent (base) and override keys/variables; - declare via Latent = LatentSersicIndex; note: subclass ag.LatentGalaxy instead to keep library latents.""" - - @staticmethod - def keys(analysis): - return ["galaxies.galaxy.bulge.sersic_index"] - - @staticmethod - def variables(analysis, parameters, model): - instance = model.instance_from_vector(vector=parameters) - - return (instance.galaxies.galaxy.bulge.sersic_index * 2.0,) - - class AnalysisLatent(ag.AnalysisImaging): - Latent = LatentSersicIndex - - analysis = AnalysisLatent(dataset=dataset) - - result = search.fit(model=model, analysis=analysis) - - """ __Workflow Paths__ @@ -182,7 +113,7 @@ class AnalysisLatent(ag.AnalysisImaging): The `workflow_path` specifies where these files are output, in this case the .png files containing the key results we require. """ -workflow_path = Path("output") / "results_folder_csv_png_fits" / "workflow_make_example" +workflow_path = Path("output") / "results_folder" / "workflow_make_example" folder_path = workflow_path.parent if workflow_path.suffix else workflow_path folder_path.mkdir(parents=True, exist_ok=True) @@ -194,7 +125,7 @@ class AnalysisLatent(ag.AnalysisImaging): from autofit.aggregator.aggregator import Aggregator agg = Aggregator.from_directory( - directory=Path("output") / "results_folder_csv_png_fits", + directory=Path("output") / "results_folder", ) """ @@ -255,7 +186,7 @@ class AnalysisLatent(ag.AnalysisImaging): files are going to be output. One way to name the .png files is to use the `unique_tag` of the search, which is unique to every model-fit. For -the search above, the `unique_tag` was `simple_0` and `simple_1`, therefore this will informatively name the .png +the helper-generated `unique_tag` values are `simple_0` and `simple_1`, therefore this will informatively name the .png files the names of the datasets. We achieve this behaviour by inputting `name="unique_tag"` to the `output_to_folder` method. diff --git a/workspace_index.json b/workspace_index.json index 552f8dec..c05f9472 100644 --- a/workspace_index.json +++ b/workspace_index.json @@ -460,7 +460,7 @@ ], "notebook": "notebooks/guides/results/_quick_fit.ipynb", "path": "scripts/guides/results/_quick_fit.py", - "summary": "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.", + "summary": "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.", "title": "Results: Quick Fit Helper" }, { @@ -749,8 +749,8 @@ "Computed Columns" ], "cross_refs": [ + "_quick_fit.py", "fits_make.py", - "modeling/start_here.py", "png_make.py", "start_here.py" ], @@ -772,7 +772,7 @@ "Custom Fits Files in Analysis" ], "cross_refs": [ - "modeling/start_here.py", + "_quick_fit.py", "png_make.py", "start_here.py" ], @@ -796,8 +796,8 @@ "Custom Subplots in Analysis" ], "cross_refs": [ + "_quick_fit.py", "fits_make.py", - "modeling/start_here.py", "start_here.py" ], "notebook": "notebooks/guides/results/workflow/png_make.ipynb", From 63ecaa7b1a2cc1297941a28fac3ec3ba3ed9504a Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Tue, 7 Jul 2026 21:15:29 +0100 Subject: [PATCH 4/4] Remove workspace test mode path handling --- notebooks/guides/results/_quick_fit.ipynb | 12 +++--------- .../guides/results/aggregator/data_fitting.ipynb | 4 +--- .../guides/results/aggregator/galaxies_fit.ipynb | 3 +-- notebooks/guides/results/aggregator/models.ipynb | 4 +--- notebooks/guides/results/aggregator/queries.ipynb | 3 +-- notebooks/guides/results/aggregator/samples.ipynb | 3 +-- .../results/aggregator/samples_via_aggregator.ipynb | 3 +-- scripts/guides/results/_quick_fit.py | 12 +++--------- scripts/guides/results/aggregator/data_fitting.py | 4 +--- scripts/guides/results/aggregator/galaxies_fit.py | 3 +-- scripts/guides/results/aggregator/models.py | 4 +--- scripts/guides/results/aggregator/queries.py | 3 +-- scripts/guides/results/aggregator/samples.py | 3 +-- .../results/aggregator/samples_via_aggregator.py | 3 +-- 14 files changed, 18 insertions(+), 46 deletions(-) diff --git a/notebooks/guides/results/_quick_fit.ipynb b/notebooks/guides/results/_quick_fit.ipynb index 231cacb6..400b6b60 100644 --- a/notebooks/guides/results/_quick_fit.ipynb +++ b/notebooks/guides/results/_quick_fit.ipynb @@ -32,9 +32,7 @@ "import sys\n", "from pathlib import Path\n", "\n", - "from autoconf.test_mode import with_test_mode_segment\n", - "\n", - "results_path = with_test_mode_segment(Path(\"output\")) / \"results_folder\"\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", @@ -49,12 +47,8 @@ "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", diff --git a/notebooks/guides/results/aggregator/data_fitting.ipynb b/notebooks/guides/results/aggregator/data_fitting.ipynb index 7ef186e3..42a61c79 100644 --- a/notebooks/guides/results/aggregator/data_fitting.ipynb +++ b/notebooks/guides/results/aggregator/data_fitting.ipynb @@ -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" @@ -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", diff --git a/notebooks/guides/results/aggregator/galaxies_fit.ipynb b/notebooks/guides/results/aggregator/galaxies_fit.ipynb index 109d7e79..348ebc84 100644 --- a/notebooks/guides/results/aggregator/galaxies_fit.ipynb +++ b/notebooks/guides/results/aggregator/galaxies_fit.ipynb @@ -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" @@ -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", diff --git a/notebooks/guides/results/aggregator/models.ipynb b/notebooks/guides/results/aggregator/models.ipynb index dcb1a191..f5f3be83 100644 --- a/notebooks/guides/results/aggregator/models.ipynb +++ b/notebooks/guides/results/aggregator/models.ipynb @@ -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" @@ -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", diff --git a/notebooks/guides/results/aggregator/queries.ipynb b/notebooks/guides/results/aggregator/queries.ipynb index 29ba278b..4e2a88d4 100644 --- a/notebooks/guides/results/aggregator/queries.ipynb +++ b/notebooks/guides/results/aggregator/queries.ipynb @@ -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" ], @@ -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", diff --git a/notebooks/guides/results/aggregator/samples.ipynb b/notebooks/guides/results/aggregator/samples.ipynb index 80292cf6..bed8bef1 100644 --- a/notebooks/guides/results/aggregator/samples.ipynb +++ b/notebooks/guides/results/aggregator/samples.ipynb @@ -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" @@ -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", diff --git a/notebooks/guides/results/aggregator/samples_via_aggregator.ipynb b/notebooks/guides/results/aggregator/samples_via_aggregator.ipynb index 6055c017..baacd7c5 100644 --- a/notebooks/guides/results/aggregator/samples_via_aggregator.ipynb +++ b/notebooks/guides/results/aggregator/samples_via_aggregator.ipynb @@ -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" ], @@ -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", diff --git a/scripts/guides/results/_quick_fit.py b/scripts/guides/results/_quick_fit.py index 439fdb03..4962fb8d 100644 --- a/scripts/guides/results/_quick_fit.py +++ b/scripts/guides/results/_quick_fit.py @@ -22,9 +22,7 @@ import sys from pathlib import Path -from autoconf.test_mode import with_test_mode_segment - -results_path = with_test_mode_segment(Path("output")) / "results_folder" +results_path = Path("output") / "results_folder" if ( len(list(results_path.glob("**/image/dataset.fits"))) >= 2 and len(list(results_path.glob("**/files/latent/latent_summary.json"))) >= 2 @@ -39,12 +37,8 @@ import os # The aggregator tutorials that invoke this helper read image/dataset.fits via -# fit.value("dataset"). Smoke-mode env vars (PYAUTO_TEST_MODE>=2, -# PYAUTO_SKIP_VISUALIZATION) suppress the visualizer that writes that file, so -# neutralize them here. -mode = os.environ.get("PYAUTO_TEST_MODE", "0") -if mode in ("2", "3"): - os.environ["PYAUTO_TEST_MODE"] = "1" +# fit.value("dataset"). Visualization-skipping environment variables suppress +# the visualizer that writes that file, so neutralize them here. os.environ.pop("PYAUTO_SKIP_VISUALIZATION", None) os.environ.pop("PYAUTO_SKIP_FIT_OUTPUT", None) os.environ.pop("PYAUTO_FAST_PLOTS", None) diff --git a/scripts/guides/results/aggregator/data_fitting.py b/scripts/guides/results/aggregator/data_fitting.py index 6b512436..b3e27d19 100644 --- a/scripts/guides/results/aggregator/data_fitting.py +++ b/scripts/guides/results/aggregator/data_fitting.py @@ -46,8 +46,6 @@ import os from pathlib import Path -from autoconf.test_mode import with_test_mode_segment - import autofit as af import autogalaxy as ag import autogalaxy.plot as aplt @@ -59,7 +57,7 @@ """ from autofit.aggregator.aggregator import Aggregator -results_path = with_test_mode_segment(Path("output")) / "results_folder" +results_path = Path("output") / "results_folder" if not results_path.exists(): import subprocess import sys diff --git a/scripts/guides/results/aggregator/galaxies_fit.py b/scripts/guides/results/aggregator/galaxies_fit.py index 17af5fa3..10fbe3da 100644 --- a/scripts/guides/results/aggregator/galaxies_fit.py +++ b/scripts/guides/results/aggregator/galaxies_fit.py @@ -49,7 +49,6 @@ from pathlib import Path -from autoconf.test_mode import with_test_mode_segment import autofit as af import autogalaxy as ag import autogalaxy.plot as aplt @@ -62,7 +61,7 @@ in this folder) have results to work with. When that folder already exists the helper exits immediately, so re-running this tutorial is cheap. """ -results_path = with_test_mode_segment(Path("output")) / "results_folder" +results_path = Path("output") / "results_folder" if not results_path.exists(): import subprocess import sys diff --git a/scripts/guides/results/aggregator/models.py b/scripts/guides/results/aggregator/models.py index 8f6ac64b..71b93197 100644 --- a/scripts/guides/results/aggregator/models.py +++ b/scripts/guides/results/aggregator/models.py @@ -34,8 +34,6 @@ from pathlib import Path -from autoconf.test_mode import with_test_mode_segment - import autofit as af import autogalaxy as ag import autogalaxy.plot as aplt @@ -48,7 +46,7 @@ """ from autofit.aggregator.aggregator import Aggregator -results_path = with_test_mode_segment(Path("output")) / "results_folder" +results_path = Path("output") / "results_folder" if not results_path.exists(): import subprocess import sys diff --git a/scripts/guides/results/aggregator/queries.py b/scripts/guides/results/aggregator/queries.py index cc0fd0bb..1160012c 100644 --- a/scripts/guides/results/aggregator/queries.py +++ b/scripts/guides/results/aggregator/queries.py @@ -32,7 +32,6 @@ from pathlib import Path -from autoconf.test_mode import with_test_mode_segment import autofit as af import autogalaxy as ag @@ -44,7 +43,7 @@ """ from autofit.aggregator.aggregator import Aggregator -results_path = with_test_mode_segment(Path("output")) / "results_folder" +results_path = Path("output") / "results_folder" if not results_path.exists(): import subprocess import sys diff --git a/scripts/guides/results/aggregator/samples.py b/scripts/guides/results/aggregator/samples.py index 56a14259..b098c4f8 100644 --- a/scripts/guides/results/aggregator/samples.py +++ b/scripts/guides/results/aggregator/samples.py @@ -45,7 +45,6 @@ from pathlib import Path -from autoconf.test_mode import with_test_mode_segment import autofit as af import autogalaxy as ag import autogalaxy.plot as aplt @@ -58,7 +57,7 @@ in this folder) have results to work with. When that folder already exists the helper exits immediately, so re-running this tutorial is cheap. """ -results_path = with_test_mode_segment(Path("output")) / "results_folder" +results_path = Path("output") / "results_folder" if not results_path.exists(): import subprocess import sys diff --git a/scripts/guides/results/aggregator/samples_via_aggregator.py b/scripts/guides/results/aggregator/samples_via_aggregator.py index 06bd7e7f..276708b0 100644 --- a/scripts/guides/results/aggregator/samples_via_aggregator.py +++ b/scripts/guides/results/aggregator/samples_via_aggregator.py @@ -48,7 +48,6 @@ from pathlib import Path -from autoconf.test_mode import with_test_mode_segment import autofit as af import autogalaxy.plot as aplt @@ -84,7 +83,7 @@ """ from autofit.aggregator.aggregator import Aggregator -results_path = with_test_mode_segment(Path("output")) / "results_folder" +results_path = Path("output") / "results_folder" if not results_path.exists(): import subprocess import sys