Skip to content

Commit d8890e1

Browse files
committed
rm linetools prompt and edit CLAUDE.md
1 parent 9f84ca3 commit d8890e1

File tree

2 files changed

+63
-215
lines changed

2 files changed

+63
-215
lines changed

CLAUDE.md

Lines changed: 63 additions & 208 deletions
Original file line numberDiff line numberDiff line change
@@ -1,244 +1,99 @@
1-
# CLAUDE.md
1+
# PypeIt
22

3-
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4-
5-
## About PypeIt
6-
7-
PypeIt is a Python package for semi-automated reduction of astronomical spectroscopic data. It supports data from many different spectrographs (Keck, Gemini, VLT, Magellan, etc.) through a plugin architecture. The package builds on decades of data reduction pipeline development and is designed for both expert spectroscopists and astronomers new to data reduction.
3+
PypeIt is a pure Python package for processing raw spectroscopic data from
4+
astronomical telescopes into calibrated spectra for scientific analysis.
85

96
## Development Setup
107

11-
### Installation for Development
12-
13-
Install from your fork in editable mode with all development dependencies:
14-
15-
```bash
16-
pip install -e ".[dev]"
17-
```
18-
19-
The `[dev]` optional dependencies install testing, documentation, and development tools.
20-
21-
### Git Workflow
22-
23-
- **Main branches**: `release` (production), `develop` (integration)
24-
- Create feature branches from `develop`
25-
- Submit PRs to `develop` branch
26-
- Keep your fork updated: `git fetch upstream` regularly
27-
28-
## Common Commands
29-
30-
### Testing
31-
32-
```bash
33-
# Run all tests
34-
pytest --pyargs pypeit
35-
36-
# Run specific test file
37-
pytest pypeit/tests/test_wavecalib.py
38-
39-
# Run single test
40-
pytest pypeit/tests/test_wavecalib.py::test_function_name
41-
42-
# Run tests with coverage
43-
pytest --pyargs pypeit --cov pypeit --cov-config=pyproject.toml
44-
45-
# Run tests using tox (multiple Python versions)
46-
tox -e 3.12-test-alldeps
47-
```
48-
49-
Test configuration is in `pyproject.toml` under `[tool.pytest.ini_options]`.
50-
51-
### Code Style
52-
53-
```bash
54-
# Check for critical style errors (E9 errors)
55-
pycodestyle pypeit --count --select=E9
56-
```
57-
58-
### Documentation
59-
60-
```bash
61-
cd doc
62-
make html # Build full documentation
63-
make htmlonly # Build without regenerating API docs
64-
make clean # Clean build files
65-
```
66-
67-
Documentation is built with Sphinx and hosted on ReadTheDocs.
8+
- Create and activate a fresh python environment
689

69-
## Architecture Overview
10+
- Clone your fork of the main pypeit repo, hosted at
11+
[GitHub](https://github.com/pypeit/PypeIt), and add a remote git connection to
12+
the main repo called `upstream`.
7013

71-
### Core Pipeline Flow
14+
- Install pypeit using the zshell (or bash equivalent) command `pip install -e ".[dev]"`.
7215

73-
The main reduction pipeline follows this sequence:
16+
- Create a new git branch, where simple bug fixes branch from `release` and all
17+
other development branches from `develop`.
7418

75-
1. **PypeIt File Parsing** (`inputfiles.py`): Parse `.pypeit` file containing reduction parameters and file list
76-
2. **Metadata Construction** (`metadata.py`): Build metadata table from raw FITS headers
77-
3. **Calibrations** (`calibrations.py`): Generate calibration frames (bias, flat, arc, tilt, etc.)
78-
4. **Science Processing** (`pypeit.py`): Main driver class coordinating the full reduction
79-
5. **Object Finding** (`find_objects.py`): Detect and trace objects in 2D spectra
80-
6. **Extraction** (`extraction.py`): Extract 1D spectra from 2D frames
81-
7. **Flux Calibration** (`fluxcalibrate.py`, `sensfunc.py`): Apply flux calibration
19+
- Frequently fetch changes to the upstream base branch (`release` or `develop`)
20+
and rebase, as necessary.
8221

83-
### Key Architectural Components
22+
- Additional development guidelines is provided in `doc/dev/development.rst`.
8423

85-
#### Spectrograph Classes (`pypeit/spectrographs/`)
24+
## Key Architectural Components
8625

87-
All instrument support is implemented via the `Spectrograph` abstract base class in `spectrographs/spectrograph.py`. Each instrument has its own module (e.g., `keck_deimos.py`, `gemini_gmos.py`).
26+
- PypeIt implements three primary processing paths, depending on the format of
27+
the spectrograph used to collect the raw data:
8828

89-
Key responsibilities:
90-
- Define detector properties (gain, read noise, etc.) via `DetectorContainer`
91-
- Provide metadata mapping from FITS headers to PypeIt metadata model
92-
- Override reduction parameter defaults
93-
- Implement instrument-specific processing (e.g., bad pixel masks, file naming)
29+
- **MultiSlit**: Standard long-slit and multi-slit spectrographs
30+
- **Echelle**: Cross-dispersed echelle spectrographs
31+
- **SlicerIFU**: Slicer-based integral-field units
9432

95-
To add a new spectrograph, subclass `Spectrograph` and implement required methods.
33+
- Instrument specifications and data-processing considerations that are specific
34+
to each spectrograph (including the processing path that should be used) are
35+
isolated in their respective spectrograph classes, all of which inherit from
36+
`pypeit.spectrographs.spectrograph.Spectrograph`.
9637

97-
#### Parameter System (`pypeit/par/`)
38+
- Users primarily modify the code performance via user-level parameters held by
39+
the `pypeit.par.pypeitpar.PypeItPar` class, which packages the hierarchy of
40+
parameter sets used throughout the code.
9841

99-
The `pypeitpar.py` module defines all reduction parameters using a hierarchical `ParSet` structure. Parameters cascade from defaults to user overrides specified in `.pypeit` files.
42+
- Core processing modules, particularly for calibrations, produce FITS files
43+
that are saved to disk and reused as necessary. These modules commonly use
44+
`pypeit.datamodel.DataContainer` as a base class to enforce strict adherence
45+
to a well-defined datamodel and to provide a common IO interface.
10046

101-
Main parameter classes:
102-
- `PypeItPar`: Top-level container for all parameters
103-
- `CalibrationsPar`: Calibration-specific parameters
104-
- `ReducePar`: Science reduction parameters
105-
- Each processing step has its own parameter class
47+
- Significant portions of the `pypeit/data` directory are not included in the
48+
package distribution of the code, but rely on a cache system that downloads
49+
files as needed for processing.
10650

107-
#### Data Model (`datamodel.py`)
51+
## Testing
10852

109-
PypeIt uses `DataContainer` objects to enforce strict data models for all data products. All data classes inherit from `DataContainer` and define a `datamodel` class attribute specifying the structure.
53+
- All tests are collected in the `pypeit/tests` directory.
11054

111-
Key data containers:
112-
- `PypeItImage`: Raw or processed 2D image with metadata
113-
- `SlitTraceSet`: Slit edge traces
114-
- `WaveCalib`: Wavelength calibration solution
115-
- `SpecObj`: Single extracted spectrum
116-
- `SpecObjs`: Collection of extracted spectra
55+
- Tests in `pypeit/tests` should be limited to unit tests that do not require
56+
the use of large data files.
11757

118-
#### Calibration Framework (`calibrations.py`)
58+
- Tests should be deterministic; i.e., all random-number generators should use a
59+
fixed seed.
11960

120-
The `Calibrations` class orchestrates all calibration processing:
121-
- **Edge Tracing** (`edgetrace.py`): Find slit edges
122-
- **Flat Fielding** (`flatfield.py`): Pixel and illumination flats
123-
- **Wavelength Calibration** (`wavecalib.py`): Arc line identification
124-
- **Tilts** (`wavetilts.py`): Spectral tilt along spatial direction
61+
- Test coverage is supplemented by the PypeIt development suite, hosted at
62+
https://github.com/pypeit/PypeIt-development-suite, which requires data files
63+
hosted on Google Drive; see README.rst for the link.
12564

126-
Calibrations are cached and reused based on calibration groups defined by header keywords.
65+
## Documentation
12766

128-
#### Image Processing (`pypeit/images/`)
67+
- All functions and classes, except for tests in `pypeit/tests` should include
68+
docstrings that explain their purpose, input arguments, and output objects.
12969

130-
Image handling classes:
131-
- `RawImage`: Interface to raw detector data
132-
- `PypeItImage`: Processed image with error and mask arrays
133-
- `BuildImage`: Combine multiple raw images (bias, flat, arc, etc.)
134-
- `DetectorContainer`: Detector properties and geometry
70+
- The docstring style is currently not consistent within the repository, but
71+
Numpy style docstrings are preferred; see
72+
https://www.sphinx-doc.org/en/master/usage/extensions/example_numpy.html
13573

136-
#### Core Algorithms (`pypeit/core/`)
74+
- Package documentation for users is held in the `doc` directory, which is built
75+
using Sphinx and hosted on ReadTheDocs at https://pypeit.readthedocs.io/.
13776

138-
Low-level algorithmic functions organized by task:
139-
- `wavecal/`: Wavelength calibration algorithms
140-
- `arc.py`: Arc line detection and identification
141-
- `extract.py`: Optimal extraction algorithms
142-
- `skysub.py`: Sky subtraction
143-
- `flexure.py`: Flexure correction
144-
- `flat.py`: Flat field processing
145-
- `trace.py`: Object tracing
77+
- A complete rebuild of the documentation is performed by executing the bash
78+
command `cd doc; make clean ; make html`. This requires access to the
79+
internet and the `PYPEIT_DEV` environmental variable, which points to the
80+
directory containing containing the `RAW_DATA` directory copied from the
81+
PypeIt development suite Google Drive (see "Testing" above). If these
82+
requirements are not met, a limited rebuild of the documentation can be
83+
achieved by executing `cd doc ; make htmlonly`.
14684

147-
### Pipeline Types
85+
- Documentation should be updated with each GitHub pull request.
14886

149-
PypeIt supports different pipeline configurations:
150-
- **MultiSlit**: Standard long-slit and multi-slit reduction
151-
- **Echelle**: Cross-dispersed echelle spectrograph reduction
152-
- **IFU**: Integral field unit data cubes (via `coadd3d.py`)
153-
- **SlitLess**: Slitless spectroscopy (limited support)
87+
## Usage
15488

155-
The pipeline type is set via the `Spectrograph.pypeline` attribute.
89+
- Users interact with the code base via execution of the command-line scripts
90+
found in `pypeit/scripts`.
15691

157-
### Script Entry Points
158-
159-
All command-line scripts are in `pypeit/scripts/` and registered in `pyproject.toml` under `[project.scripts]`. Each script subclasses `ScriptBase` and implements an `entry_point()` classmethod.
160-
161-
Main scripts:
162-
- `run_pypeit`: Primary reduction driver
163-
- `pypeit_setup`: Initialize reduction directory structure
164-
- `pypeit_coadd_1dspec`: Coadd 1D spectra
165-
- `pypeit_flux_calib`: Apply flux calibration
166-
- `pypeit_sensfunc`: Generate sensitivity function
167-
168-
## Important Development Guidelines
169-
170-
### Data Container Pattern
171-
172-
When creating new data products:
173-
1. Inherit from `DataContainer`
174-
2. Define `datamodel` class attribute with types and descriptions
175-
3. Implement `_bundle()` to organize data for FITS output
176-
4. Implement `_parse()` to read data from FITS
177-
5. All attributes should be in the datamodel or set in `__init__`/`_validate()`
178-
179-
### Spectrograph Support
180-
181-
Adding or modifying spectrograph support:
182-
- Detector numbering starts at 1 (not 0)
183-
- The `meta` dict maps FITS header keywords to PypeIt metadata
184-
- Test with data from the PypeIt-development-suite
185-
- Update documentation in `doc/spectrographs/`
186-
187-
### Testing Strategy
188-
189-
- Unit tests in `pypeit/tests/` and `pypeit/*/tests/`
190-
- Integration tests use data from PypeIt-development-suite
191-
- Use `tstutils.py` helper functions for test data
192-
- Tests should be deterministic and fast when possible
193-
- Mark slow tests with `@pytest.mark.slow`
194-
195-
### Calibration File Versioning
196-
197-
Calibration files (e.g., arc line lists, sensitivity functions) are stored in `pypeit/data/`. These files:
198-
- Are version controlled in the repository
199-
- Can also be cached from AWS S3 (see `cache.py`)
200-
- Use strict versioning to ensure reproducibility
201-
202-
### Messages and Logging
203-
204-
Use the `msgs` module (`pypeit.pypmsgs`) for all user-facing output:
205-
- `msgs.info()`: Informational messages
206-
- `msgs.warn()`: Warnings
207-
- `msgs.error()`: Errors (raises exception)
208-
- Never use `print()` in production code
209-
210-
### Code Structure Conventions
211-
212-
- Import `IPython.embed` for debugging but remove before committing
213-
- Use numpy docstring format for all functions/classes
214-
- Type hints encouraged but not required
215-
- Avoid circular imports by importing within functions if needed
216-
217-
## Configuration Files
218-
219-
- `pyproject.toml`: Project metadata, dependencies, build config, pytest settings
220-
- `tox.ini`: Multi-environment testing configuration
221-
- `.github/workflows/ci_tests.yml`: CI/CD configuration
222-
- `doc/conf.py`: Sphinx documentation configuration
223-
224-
## Data Directory Structure
225-
226-
- `pypeit/data/arc_lines/`: Wavelength calibration line lists
227-
- `pypeit/data/standards/`: Standard star spectra and sensitivity functions
228-
- `pypeit/data/telluric/`: Telluric correction templates
229-
- `pypeit/data/static_calibs/`: Static calibration files (bad pixel masks, etc.)
230-
- `pypeit/data/tests/`: Test data fixtures
92+
- The primary data-processing script is `run_pypeit.py`, which primarily
93+
instantiates the `pypeit.pypeit.PypeIt` class and runs its methods.
23194

23295
## External Resources
23396

23497
- **Documentation**: https://pypeit.readthedocs.io/
235-
- **User Slack**: https://pypeit-users.slack.com
23698
- **Development Suite**: https://github.com/pypeit/PypeIt-development-suite
237-
- **Example Data**: Google Drive folder (see README.rst for link)
238-
239-
## Communication
24099

241-
Before starting major development:
242-
1. Discuss in PypeIt Users Slack or open a GitHub issue
243-
2. Coordinate with core team to avoid duplicate work
244-
3. Follow the development guidelines in `doc/dev/development.rst`

prompts/linetools.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)