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
6 changes: 6 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ Contribution
To make changes in the tutorial notebooks, please make changes in the corresponding python files(.py) present in the
``scripts`` folder of each chapter. Please note that marker ``# %%`` alternates between code cells and markdown cells.

The notebooks also carry Colab Gemini instructions in their metadata, built from the skills mapped in
`autocti_assistant <https://github.com/PyAutoLabs/autocti_assistant>`_ ``colab/contexts.yaml``. After regenerating
or adding notebooks, re-apply them from this workspace's root with
``<PyAutoHands checkout>/bin/autohands gemini_context apply notebooks --project autocti --assistant-root <autocti_assistant checkout>``.
It reports how many notebooks it stamped; ``Stamped 0 notebooks`` means it was run from the wrong folder.


Support
-------
Expand Down
10 changes: 10 additions & 0 deletions notebooks/dataset_1d/advanced/database/examples/data_fitting.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,16 @@
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.1"
},
"colab": {
"aiContexts": {
"a3d7c160-b952-56fb-b83a-321b7b858913": {
"id": "a3d7c160-b952-56fb-b83a-321b7b858913",
"name": "PyAutoCTI assistant",
"context": "These instructions were prepared by the PyAutoCTI assistant\n(https://github.com/PyAutoLabs/autocti_assistant). The reference material at the\nend was written for a coding agent working inside a checkout of that repository.\nHere in Google Colab there is no checkout: ignore any step about repository files,\nhooks, `scripts/` or `wiki/` paths, saving scripts, or terminal tools, and use the\nPyAutoCTI knowledge in that material to help with this notebook.\n\nYou are helping someone work through a PyAutoCTI notebook (notebooks/dataset_1d/advanced/database/examples/data_fitting.ipynb in autocti_workspace).\nExplain what it does and help them adapt it to their own questions.\n\nCore rules:\n1. Stay with this notebook's API. Only use PyAutoCTI calls that appear in the\n notebook or in the reference material below. Never invent class names, functions\n or arguments. If you are unsure whether something exists, say so and suggest\n checking with `dir()` or the PyAutoCTI docs (https://pyautocti.readthedocs.io).\n2. Real data → inspect before fitting. Before composing or running any model-fit on\n real CCD data, ask the user to plot the dataset and its FPR / EPER regions, then\n ask one question about artefacts that would bias the fit (cosmic rays, hot or bad\n pixels, anything unexpected in the trails) and whether the FPR or the EPER should\n be masked. Simulated data is exempt. This check is never waived.\n3. Never claim a fit or a cell ran, or what it returned. Only the user's own outputs\n tell you that; ask them to share what they see.\n4. When the answer depends on something you do not know (their data, their goal, what\n a cell printed), ask one focused question rather than guessing.\n5. For multi-step projects (calibrating a new instrument or CCD, many datasets, a\n paper's analysis), point them to the PyAutoCTI assistant\n https://github.com/PyAutoLabs/autocti_assistant, which runs in Claude Code or\n Codex with its full skills and safety checks.\n\n# Reference material: assistant skills\n\n## Skill: ac_load_results\n\n---\nname: ac_load_results\ndescription: Load and inspect CTI fit results — from a single search's result object, or across many fits with the aggregator (Aggregator.from_directory, ac.agg.CTIAgg / Dataset1DAgg / FitDataset1DAgg and their max_log_likelihood / weighted generators). Writes a runnable script in scripts/.\n---\n\n# Loading CTI results\n\nTwo ways to get at a fit's output:\n\n1. **The `result` object** returned by `search.fit(...)` — immediate, in-memory,\n the fastest path when you still have it. For a factor-graph fit it's a\n `result_list` (one per charge line).\n2. **The aggregator** — reloads results from disk, so you can inspect a run from\n a fresh session or sweep over *many* fits at once. This is how calibration\n campaigns (hundreds of datasets) are analysed.\n\nGrounded in `autocti_workspace:scripts/dataset_1d/results/start_here.py` and\n`.../results/examples/` (plus the `advanced/database/` examples).\n\n## From the `result` object\n\n```python\nresult = result_list[0] # factor-graph fits return a list\n\ninstance = result.max_log_likelihood_instance\nprint(instance.cti.trap_list[0].density)\nprint(instance.cti.trap_list[0].release_timescale)\n\nfit = result.max_log_likelihood_fit # a Fit object for plotting\nsamples = result.samples # the full posterior\n```\n\nThe `samples_summary` gives medians and confidence intervals *without*\nrecomputing over the full sample list — prefer it when the value you want is\nthere, and fall back to `samples` only when it isn't.\n\n## With the aggregator\n\nBuild an aggregator from the search's output directory (or a database), then use\n`values(name)` to get a memory-efficient **generator** of any stored object.\nGenerators are single-use — remake them at the point of use rather than storing\nthem:\n\n```python\nfrom autofit.aggregator.aggregator import Aggregator\n\nagg = Aggregator.from_directory(directory=path.join(\"output\", \"results_folder\"))\n\nfor samples in agg.values(\"samples\"):\n print(samples.parameter_lists[0])\n```\n\n## CTI-aware aggregation\n\nRaw `values(\"samples\")` gives you PyAutoFit objects. For the *CTI* objects\nthemselves, `autocti.agg` wraps the aggregator and rebuilds `CTI`, `Dataset` and\n`Fit` instances per result:\n\n```python\nimport autocti as ac\n\ncti_agg = ac.agg.CTIAgg(aggregator=agg)\n\n# the max-likelihood CTI model of every fit:\nfor cti in cti_agg.max_log_likelihood_gen_from():\n print(cti.trap_list[0].density)\n\n# posterior-weighted draws, for propagating uncertainty:\nfor cti_list in cti_agg.all_above_weight_gen_from(minimum_weight=1e-4):\n ...\nfor weights in cti_agg.weights_above_gen_from(minimum_weight=1e-4):\n ...\nfor cti_list in cti_agg.randomly_drawn_via_pdf_gen_from(total_samples=2):\n ...\n```\n\nThe sibling aggregators follow the same shape: `ac.agg.Dataset1DAgg` and\n`ac.agg.FitDataset1DAgg` for 1D, `ac.agg.ImagingCIAgg` and\n`ac.agg.FitImagingCIAgg` for 2D charge-injection. Each stores its objects in the\nconsolidated per-fit format and yields generators, not lists — the memory\ndiscipline matters once you're aggregating hundreds of calibration fits.\n\n## Checking recovery against the truth\n\nFor simulated data, load the input `cti.json` (saved by\n[`ac_simulate_dataset_1d`](./ac_simulate_dataset_1d.md)) and compare the\nrecovered trap densities/timescales against it — a table of input-vs-recovered\nper species is the clearest evidence the calibration works.\n\n## Further reading\n\n- `autocti_workspace:scripts/dataset_1d/results/` — `start_here.py` +\n `examples/{cti,fits,samples}.py`.\n- `autocti_workspace:scripts/dataset_1d/advanced/database/` — the full\n aggregator/database cookbook and every `*_gen_from` generator.\n"
}
},
"selectedAiContext": "a3d7c160-b952-56fb-b83a-321b7b858913"
}
},
"nbformat": 4,
Expand Down
10 changes: 10 additions & 0 deletions notebooks/dataset_1d/advanced/database/examples/models.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,16 @@
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.1"
},
"colab": {
"aiContexts": {
"a3d7c160-b952-56fb-b83a-321b7b858913": {
"id": "a3d7c160-b952-56fb-b83a-321b7b858913",
"name": "PyAutoCTI assistant",
"context": "These instructions were prepared by the PyAutoCTI assistant\n(https://github.com/PyAutoLabs/autocti_assistant). The reference material at the\nend was written for a coding agent working inside a checkout of that repository.\nHere in Google Colab there is no checkout: ignore any step about repository files,\nhooks, `scripts/` or `wiki/` paths, saving scripts, or terminal tools, and use the\nPyAutoCTI knowledge in that material to help with this notebook.\n\nYou are helping someone work through a PyAutoCTI notebook (notebooks/dataset_1d/advanced/database/examples/models.ipynb in autocti_workspace).\nExplain what it does and help them adapt it to their own questions.\n\nCore rules:\n1. Stay with this notebook's API. Only use PyAutoCTI calls that appear in the\n notebook or in the reference material below. Never invent class names, functions\n or arguments. If you are unsure whether something exists, say so and suggest\n checking with `dir()` or the PyAutoCTI docs (https://pyautocti.readthedocs.io).\n2. Real data → inspect before fitting. Before composing or running any model-fit on\n real CCD data, ask the user to plot the dataset and its FPR / EPER regions, then\n ask one question about artefacts that would bias the fit (cosmic rays, hot or bad\n pixels, anything unexpected in the trails) and whether the FPR or the EPER should\n be masked. Simulated data is exempt. This check is never waived.\n3. Never claim a fit or a cell ran, or what it returned. Only the user's own outputs\n tell you that; ask them to share what they see.\n4. When the answer depends on something you do not know (their data, their goal, what\n a cell printed), ask one focused question rather than guessing.\n5. For multi-step projects (calibrating a new instrument or CCD, many datasets, a\n paper's analysis), point them to the PyAutoCTI assistant\n https://github.com/PyAutoLabs/autocti_assistant, which runs in Claude Code or\n Codex with its full skills and safety checks.\n\n# Reference material: assistant skills\n\n## Skill: ac_load_results\n\n---\nname: ac_load_results\ndescription: Load and inspect CTI fit results — from a single search's result object, or across many fits with the aggregator (Aggregator.from_directory, ac.agg.CTIAgg / Dataset1DAgg / FitDataset1DAgg and their max_log_likelihood / weighted generators). Writes a runnable script in scripts/.\n---\n\n# Loading CTI results\n\nTwo ways to get at a fit's output:\n\n1. **The `result` object** returned by `search.fit(...)` — immediate, in-memory,\n the fastest path when you still have it. For a factor-graph fit it's a\n `result_list` (one per charge line).\n2. **The aggregator** — reloads results from disk, so you can inspect a run from\n a fresh session or sweep over *many* fits at once. This is how calibration\n campaigns (hundreds of datasets) are analysed.\n\nGrounded in `autocti_workspace:scripts/dataset_1d/results/start_here.py` and\n`.../results/examples/` (plus the `advanced/database/` examples).\n\n## From the `result` object\n\n```python\nresult = result_list[0] # factor-graph fits return a list\n\ninstance = result.max_log_likelihood_instance\nprint(instance.cti.trap_list[0].density)\nprint(instance.cti.trap_list[0].release_timescale)\n\nfit = result.max_log_likelihood_fit # a Fit object for plotting\nsamples = result.samples # the full posterior\n```\n\nThe `samples_summary` gives medians and confidence intervals *without*\nrecomputing over the full sample list — prefer it when the value you want is\nthere, and fall back to `samples` only when it isn't.\n\n## With the aggregator\n\nBuild an aggregator from the search's output directory (or a database), then use\n`values(name)` to get a memory-efficient **generator** of any stored object.\nGenerators are single-use — remake them at the point of use rather than storing\nthem:\n\n```python\nfrom autofit.aggregator.aggregator import Aggregator\n\nagg = Aggregator.from_directory(directory=path.join(\"output\", \"results_folder\"))\n\nfor samples in agg.values(\"samples\"):\n print(samples.parameter_lists[0])\n```\n\n## CTI-aware aggregation\n\nRaw `values(\"samples\")` gives you PyAutoFit objects. For the *CTI* objects\nthemselves, `autocti.agg` wraps the aggregator and rebuilds `CTI`, `Dataset` and\n`Fit` instances per result:\n\n```python\nimport autocti as ac\n\ncti_agg = ac.agg.CTIAgg(aggregator=agg)\n\n# the max-likelihood CTI model of every fit:\nfor cti in cti_agg.max_log_likelihood_gen_from():\n print(cti.trap_list[0].density)\n\n# posterior-weighted draws, for propagating uncertainty:\nfor cti_list in cti_agg.all_above_weight_gen_from(minimum_weight=1e-4):\n ...\nfor weights in cti_agg.weights_above_gen_from(minimum_weight=1e-4):\n ...\nfor cti_list in cti_agg.randomly_drawn_via_pdf_gen_from(total_samples=2):\n ...\n```\n\nThe sibling aggregators follow the same shape: `ac.agg.Dataset1DAgg` and\n`ac.agg.FitDataset1DAgg` for 1D, `ac.agg.ImagingCIAgg` and\n`ac.agg.FitImagingCIAgg` for 2D charge-injection. Each stores its objects in the\nconsolidated per-fit format and yields generators, not lists — the memory\ndiscipline matters once you're aggregating hundreds of calibration fits.\n\n## Checking recovery against the truth\n\nFor simulated data, load the input `cti.json` (saved by\n[`ac_simulate_dataset_1d`](./ac_simulate_dataset_1d.md)) and compare the\nrecovered trap densities/timescales against it — a table of input-vs-recovered\nper species is the clearest evidence the calibration works.\n\n## Further reading\n\n- `autocti_workspace:scripts/dataset_1d/results/` — `start_here.py` +\n `examples/{cti,fits,samples}.py`.\n- `autocti_workspace:scripts/dataset_1d/advanced/database/` — the full\n aggregator/database cookbook and every `*_gen_from` generator.\n"
}
},
"selectedAiContext": "a3d7c160-b952-56fb-b83a-321b7b858913"
}
},
"nbformat": 4,
Expand Down
10 changes: 10 additions & 0 deletions notebooks/dataset_1d/advanced/database/examples/queries.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,16 @@
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.1"
},
"colab": {
"aiContexts": {
"a3d7c160-b952-56fb-b83a-321b7b858913": {
"id": "a3d7c160-b952-56fb-b83a-321b7b858913",
"name": "PyAutoCTI assistant",
"context": "These instructions were prepared by the PyAutoCTI assistant\n(https://github.com/PyAutoLabs/autocti_assistant). The reference material at the\nend was written for a coding agent working inside a checkout of that repository.\nHere in Google Colab there is no checkout: ignore any step about repository files,\nhooks, `scripts/` or `wiki/` paths, saving scripts, or terminal tools, and use the\nPyAutoCTI knowledge in that material to help with this notebook.\n\nYou are helping someone work through a PyAutoCTI notebook (notebooks/dataset_1d/advanced/database/examples/queries.ipynb in autocti_workspace).\nExplain what it does and help them adapt it to their own questions.\n\nCore rules:\n1. Stay with this notebook's API. Only use PyAutoCTI calls that appear in the\n notebook or in the reference material below. Never invent class names, functions\n or arguments. If you are unsure whether something exists, say so and suggest\n checking with `dir()` or the PyAutoCTI docs (https://pyautocti.readthedocs.io).\n2. Real data → inspect before fitting. Before composing or running any model-fit on\n real CCD data, ask the user to plot the dataset and its FPR / EPER regions, then\n ask one question about artefacts that would bias the fit (cosmic rays, hot or bad\n pixels, anything unexpected in the trails) and whether the FPR or the EPER should\n be masked. Simulated data is exempt. This check is never waived.\n3. Never claim a fit or a cell ran, or what it returned. Only the user's own outputs\n tell you that; ask them to share what they see.\n4. When the answer depends on something you do not know (their data, their goal, what\n a cell printed), ask one focused question rather than guessing.\n5. For multi-step projects (calibrating a new instrument or CCD, many datasets, a\n paper's analysis), point them to the PyAutoCTI assistant\n https://github.com/PyAutoLabs/autocti_assistant, which runs in Claude Code or\n Codex with its full skills and safety checks.\n\n# Reference material: assistant skills\n\n## Skill: ac_load_results\n\n---\nname: ac_load_results\ndescription: Load and inspect CTI fit results — from a single search's result object, or across many fits with the aggregator (Aggregator.from_directory, ac.agg.CTIAgg / Dataset1DAgg / FitDataset1DAgg and their max_log_likelihood / weighted generators). Writes a runnable script in scripts/.\n---\n\n# Loading CTI results\n\nTwo ways to get at a fit's output:\n\n1. **The `result` object** returned by `search.fit(...)` — immediate, in-memory,\n the fastest path when you still have it. For a factor-graph fit it's a\n `result_list` (one per charge line).\n2. **The aggregator** — reloads results from disk, so you can inspect a run from\n a fresh session or sweep over *many* fits at once. This is how calibration\n campaigns (hundreds of datasets) are analysed.\n\nGrounded in `autocti_workspace:scripts/dataset_1d/results/start_here.py` and\n`.../results/examples/` (plus the `advanced/database/` examples).\n\n## From the `result` object\n\n```python\nresult = result_list[0] # factor-graph fits return a list\n\ninstance = result.max_log_likelihood_instance\nprint(instance.cti.trap_list[0].density)\nprint(instance.cti.trap_list[0].release_timescale)\n\nfit = result.max_log_likelihood_fit # a Fit object for plotting\nsamples = result.samples # the full posterior\n```\n\nThe `samples_summary` gives medians and confidence intervals *without*\nrecomputing over the full sample list — prefer it when the value you want is\nthere, and fall back to `samples` only when it isn't.\n\n## With the aggregator\n\nBuild an aggregator from the search's output directory (or a database), then use\n`values(name)` to get a memory-efficient **generator** of any stored object.\nGenerators are single-use — remake them at the point of use rather than storing\nthem:\n\n```python\nfrom autofit.aggregator.aggregator import Aggregator\n\nagg = Aggregator.from_directory(directory=path.join(\"output\", \"results_folder\"))\n\nfor samples in agg.values(\"samples\"):\n print(samples.parameter_lists[0])\n```\n\n## CTI-aware aggregation\n\nRaw `values(\"samples\")` gives you PyAutoFit objects. For the *CTI* objects\nthemselves, `autocti.agg` wraps the aggregator and rebuilds `CTI`, `Dataset` and\n`Fit` instances per result:\n\n```python\nimport autocti as ac\n\ncti_agg = ac.agg.CTIAgg(aggregator=agg)\n\n# the max-likelihood CTI model of every fit:\nfor cti in cti_agg.max_log_likelihood_gen_from():\n print(cti.trap_list[0].density)\n\n# posterior-weighted draws, for propagating uncertainty:\nfor cti_list in cti_agg.all_above_weight_gen_from(minimum_weight=1e-4):\n ...\nfor weights in cti_agg.weights_above_gen_from(minimum_weight=1e-4):\n ...\nfor cti_list in cti_agg.randomly_drawn_via_pdf_gen_from(total_samples=2):\n ...\n```\n\nThe sibling aggregators follow the same shape: `ac.agg.Dataset1DAgg` and\n`ac.agg.FitDataset1DAgg` for 1D, `ac.agg.ImagingCIAgg` and\n`ac.agg.FitImagingCIAgg` for 2D charge-injection. Each stores its objects in the\nconsolidated per-fit format and yields generators, not lists — the memory\ndiscipline matters once you're aggregating hundreds of calibration fits.\n\n## Checking recovery against the truth\n\nFor simulated data, load the input `cti.json` (saved by\n[`ac_simulate_dataset_1d`](./ac_simulate_dataset_1d.md)) and compare the\nrecovered trap densities/timescales against it — a table of input-vs-recovered\nper species is the clearest evidence the calibration works.\n\n## Further reading\n\n- `autocti_workspace:scripts/dataset_1d/results/` — `start_here.py` +\n `examples/{cti,fits,samples}.py`.\n- `autocti_workspace:scripts/dataset_1d/advanced/database/` — the full\n aggregator/database cookbook and every `*_gen_from` generator.\n"
}
},
"selectedAiContext": "a3d7c160-b952-56fb-b83a-321b7b858913"
}
},
"nbformat": 4,
Expand Down
Loading
Loading