diff --git a/AI_POLICY.md b/AI_POLICY.md new file mode 100644 index 0000000..7b2ac72 --- /dev/null +++ b/AI_POLICY.md @@ -0,0 +1,5 @@ +# PyAuto AI Policy + +PyAutoLabs uses one AI policy across all of its repositories. + +Read the [canonical PyAuto AI Policy](https://github.com/PyAutoLabs/PyAutoScientist/blob/main/AI_POLICY.md). diff --git a/README.md b/README.md index 634ed22..4e94a20 100644 --- a/README.md +++ b/README.md @@ -1,143 +1,45 @@ # PyAutoReduce Workspace -[PyAutoReduce](https://github.com/PyAutoLabs/PyAutoReduce) | -[PyAutoLens](https://github.com/PyAutoLabs/PyAutoLens) | -[autolens_workspace](https://github.com/PyAutoLabs/autolens_workspace) | -[PyAutoGalaxy](https://github.com/PyAutoLabs/PyAutoGalaxy) - -Welcome to the **PyAutoReduce** Workspace! - -**PyAutoReduce** reduces raw archival telescope data into **modeling-ready datasets** for -[PyAutoLens](https://github.com/PyAutoLabs/PyAutoLens) and -[PyAutoGalaxy](https://github.com/PyAutoLabs/PyAutoGalaxy). Given a target (a strong lens, a -galaxy), it downloads the archive exposures, reduces them with the instrument's standard pipeline -tooling, and emits the exact products the modeling stack loads via `al.Imaging.from_fits`: - -| Product | Description | -|---------|-------------| -| `data.fits` | Science cutout at the modeling pixel scale | -| `noise_map.fits` | Per-pixel RMS noise, correlated-noise corrected | -| `psf.fits` / `psf_full.fits` | Reduction-consistent PSF estimate (compact + extended) | -| `reduction.json` | Full provenance: exposures, pipeline dials, diagnostics, software versions | - -A reduction is *declared*, not scripted: you build a `TargetSpec`, call `reduce_target`, and the -pipeline is a pure function of that spec plus the archive. Every script in this workspace is a -narrated, runnable walk through one instrument's reduction. - -## Instrument Coverage - -Each instrument folder is anchored to a real target reduced end-to-end and validated against a -published literature reduction — the workspace's quality bar: - -| Folder | Instrument | Validation anchor | Literature quality bar | -|--------|-----------|-------------------|------------------------| -| `scripts/hst_acs` | HST ACS/WFC | SLACS J0008-0004 (prop. 10886) | SLACS, Bolton et al. 2008 | -| `scripts/hst_wfc3_uvis` | HST WFC3/UVIS | SDSS J0252+0039 F390W | Bayer et al. (arXiv:1803.05952) | -| `scripts/hst_wfc3_ir` | HST WFC3/IR | J0252+0039 IR snapshot | WFC3 Data Handbook conventions | -| `scripts/jwst_nircam` | JWST NIRCam (SW + LW) | COSMOS-Web ring (prop. 1727) | Mercier et al. 2024 (arXiv:2309.15986) | -| `scripts/keck_nirc2` | Keck NIRC2 LGS-AO | B1938+666 | SHARP, Lagattuta et al. 2012; Chen et al. 2019 | -| `scripts/alma` | ALMA (visibilities) | G09v1.40 (2016.1.00282.S) | uv-plane practice, e.g. Hezaveh et al. 2016 | -| `scripts/surveys` | Legacy Surveys / SDSS / Pan-STARRS cutouts | SLACS J0008-0004 field | Colour context only — **not** modeling data | +Example scripts for preparing telescope observations for modeling with **PyAutoLens** and **PyAutoGalaxy**. Start with an introduction to data reduction, then explore the examples for your instrument. ## Getting Started -Install the core package, then the extras for the instrument(s) you reduce: +- **[Start with the introduction](https://github.com/PyAutoLabs/autoreduce_workspace/blob/main/scripts/start_here.py)** — follow an HST imaging reduction, from archival exposures to a dataset ready for modeling. +- **[Explore PyAutoReduce](https://github.com/PyAutoLabs/PyAutoReduce)** — find the library and installation information. +- **[Read the guides](https://github.com/PyAutoLabs/autoreduce_workspace/tree/main/scripts/guides)** — learn about target settings, noise maps and the files a reduction produces. -```bash -pip install pyautoreduce # core (numpy, astropy, astroquery, photutils, PyYAML) -``` +See [Find Your Examples](#find-your-examples) below to choose where to start. -| Extra | Installs | Needed for | -|-------|----------|------------| -| `pyautoreduce[hst]` | drizzlepac, drizzle | HST ACS + WFC3 (the AstroDrizzle combine) | -| `pyautoreduce[keck]` | pykoa, drizzle | Keck NIRC2 (KOA acquisition + native combine) | -| `pyautoreduce[psf]` | psfr, stpsf | High-fidelity PSF back-ends | -| `pyautoreduce[starred]` | starred-astro | The STARRED super-sampled ePSF back-end (GPL + JAX) | -| `pyautoreduce[frames]` | deepCR | Per-frame cosmic-ray masking (`cr_method="deepcr"`, frame products) | +You can read the examples without running them. Running a reduction requires the instrument’s software, network access and space for downloaded exposures; the first run can take minutes to hours. -Two stacks are deliberately **not** pip extras and are installed separately: +## Find Your Examples -- **JWST**: `pip install jwst==1.14.0` (the pipeline is pinned to this version) plus `crds`, - with `CRDS_PATH` / `CRDS_SERVER_URL` set for lazy reference syncing. -- **ALMA**: modular CASA — `pip install casatools casatasks` — for the visibility branch. +Examples live in `scripts/`, grouped by instrument. -**Be honest with yourself about what running these scripts involves**: every reduction downloads -real exposures from an archive (MAST, KOA, the ALMA archive) and runs the instrument's heavy -reduction stack. Scripts need network access, several GB of cache space, and minutes-to-hours of -runtime on the first run of a target. They are written to *read* as documentation even when you -cannot run them. +| I want to… | Start here | +|---|---| +| Reduce Hubble ACS imaging | [HST ACS](https://github.com/PyAutoLabs/autoreduce_workspace/tree/main/scripts/hst_acs) | +| Reduce Hubble WFC3 ultraviolet or visible imaging | [HST WFC3 UVIS](https://github.com/PyAutoLabs/autoreduce_workspace/tree/main/scripts/hst_wfc3_uvis) | +| Reduce Hubble WFC3 infrared imaging | [HST WFC3 IR](https://github.com/PyAutoLabs/autoreduce_workspace/tree/main/scripts/hst_wfc3_ir) | +| Reduce James Webb NIRCam imaging | [JWST NIRCam](https://github.com/PyAutoLabs/autoreduce_workspace/tree/main/scripts/jwst_nircam) | +| Reduce Keck adaptive-optics imaging | [Keck NIRC2](https://github.com/PyAutoLabs/autoreduce_workspace/tree/main/scripts/keck_nirc2) | +| Prepare ALMA interferometer data | [ALMA](https://github.com/PyAutoLabs/autoreduce_workspace/tree/main/scripts/alma) | +| Download survey images for visual context | [Survey cutouts](https://github.com/PyAutoLabs/autoreduce_workspace/tree/main/scripts/surveys) | -## New Users +Each instrument folder has a README explaining its examples. Reduced datasets are written to `output/`; downloaded exposures and reference files are stored in `cache/`. -New users should read `scripts/start_here.py`. It explains why reduction quality matters for lens -modeling, walks a complete HST/ACS reduction of a SLACS lens end-to-end, and routes you to the -right instrument folder for your data. +Survey cutouts provide visual context around a target; they are not prepared for scientific model fitting. -The `scripts/guides` folder then covers the pieces every instrument shares: the output contract -(`output_contract.py`), noise-map construction (`noise_maps.py`) and the `TargetSpec` declaration -(`target_spec.py`) — the last two run offline. +## Understand Your Results -## Workspace Structure +For imaging reductions, the main outputs are a science image, a noise map and a point spread function (PSF), which describes how the telescope blurs the image. A reduction record stores the settings and processing details. -The workspace includes the following main directories: +The [output guide](https://github.com/PyAutoLabs/autoreduce_workspace/blob/main/scripts/guides/output_contract.py) explains these files, the different outputs for individual exposures and interferometer data, and how to load them for modeling. -- `scripts`: **PyAutoReduce** examples written as Python scripts, one folder per instrument. -- `notebooks`: Jupyter notebook versions, generated from `scripts` at release time. -- `config`: Build/CI configuration only — **PyAutoReduce** itself needs no config files. -- `dataset`: Per-target `TargetSpec` YAML files you may add (no FITS is ever committed). -- `output`: Where reduced datasets land, one folder per target (not committed). -- `cache`: Downloaded exposures + CRDS references, re-used across runs (not committed). +## Community and Contributing -The instrument packages include the following types of example: +Ask questions, suggest improvements and share your work in [PyAutoLabs Discussions](https://github.com/orgs/PyAutoLabs/discussions), or chat with us on [Slack](https://join.slack.com/t/pyautolens/shared_invite/zt-2cufp4eyf-fXfgMxRGuvg~bMrI3uOAxg). -- `start_here`: The default pipeline end-to-end on the instrument's validation anchor. -- `step_by_step`: Every reduction step in as much granularity as the public API allows, taught - with the instrument handbook and the literature. -- `individual`: Per-exposure frame products — modeling native frames instead of a mosaic. -- `psf`: The PSF story for that instrument — star selection, tiers, back-ends, diagnostics. -- `simulator`: Synthetic-source injection into real frames, and flux-recovery closure tests. +## License -The `README.md` files distributed throughout the workspace describe what is in each folder. - -## Community & Contributing - -**PyAutoLens** is built in the open by its users: everyone is welcome to ask questions, -share what they have made with it, and contribute. - -Questions, ideas and bug reports: the [PyAutoLabs Discussions](https://github.com/orgs/PyAutoLabs/discussions). -Chat with us on [Slack](https://join.slack.com/t/pyautolens/shared_invite/zt-2cufp4eyf-fXfgMxRGuvg~bMrI3uOAxg). - -Community-built tools and tutorials, and how to contribute: the [**PyAutoLens** community page](https://pyautolens.readthedocs.io/en/latest/general/community.html). - -Tutorial notebooks are generated from the `.py` scripts in each `scripts` folder — edit those (the `# %%` marker alternates code and markdown cells), not the notebooks. - -## The Reduction Domain Ladder: Mosaics, Frames, Visibilities and Cutouts - -**PyAutoReduce** organises reductions into a ladder of four data domains. What changes as you -climb is not the instrument but the *form* the modeling-ready dataset takes: - -- An **imaging mosaic** (`hst_acs`, `hst_wfc3_uvis`, `hst_wfc3_ir`, `jwst_nircam`, `keck_nirc2`) - is the default rung: dithered exposures combined onto a single resampled grid, with a matching - noise map and a PSF built through the identical resampling. Resampling correlates the noise — - which is why the noise map carries the Casertano correlated-noise correction. - -- **Per-exposure frames** (`frame_products=True`; the `individual.py` scripts) sidestep the - mosaic: every calibrated exposure ships as its own native-pixel dataset with per-frame PSFs and - a manifest. Modeling the frames jointly costs more bookkeeping but the noise in each frame is - *uncorrelated* — no drizzle, no correction factor. - -- **Visibilities** (`alma`) skip images entirely: the dataset is the calibrated interferometer - visibilities themselves — `data.fits` / `uv_wavelengths.fits` / `noise_map.fits`, each an - `(N_vis, 2)` array loaded via `al.Interferometer.from_fits` — because fitting in the uv-plane - keeps the noise independent and the likelihood well-defined. - -- **Survey cutouts** (`surveys`) are the context rung: pre-reduced coadd cutouts fetched from - Legacy Surveys / SDSS / Pan-STARRS services for colour context around a target. They ship no - PSF and are **not** modeling data. - -## Build Configuration - -The `config/build/` directory contains files used by the automated build and test system (CI, -smoke tests). These are not relevant to normal workspace usage — see `config/README.md`. Because -every script here needs network access and a heavy instrument stack, no script currently runs in -CI smoke tests (see `smoke_tests.txt` for the per-script reasons). +See the [PyAutoReduce license](https://github.com/PyAutoLabs/PyAutoReduce/blob/main/LICENSE).