Skip to content

Commit f6e9767

Browse files
authored
Merge pull request #365 from OpenPIV/copilot/add-copilot-instructions-file
Onboard repository to Copilot cloud agent with accurate instructions and setup steps
2 parents 80a798f + 77f96dc commit f6e9767

2 files changed

Lines changed: 102 additions & 46 deletions

File tree

.github/copilot-instructions.md

Lines changed: 68 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# OpenPIV Python
22

3-
OpenPIV is a Python and Cython library for Particle Image Velocimetry (PIV) analysis of fluid flow images. It provides tools for scripting and executing PIV analysis on image pairs to extract velocity fields from particle-seeded flow visualizations. The library includes both computational algorithms and optional Qt/Tk graphical user interfaces.
3+
OpenPIV is a Python library for Particle Image Velocimetry (PIV) analysis of fluid flow images. It provides tools for scripting and executing PIV analysis on image pairs to extract velocity fields from particle-seeded flow visualizations. The library includes both computational algorithms and optional Qt/Tk graphical user interfaces.
44

55
**Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.**
66

77
## Working Effectively
88

99
### Bootstrap and Install Dependencies
1010
- **Primary method (recommended)**: Use Poetry for development:
11-
- Install Poetry: `pip install poetry`
11+
- Install Poetry: `pip install poetry`
1212
- Install dependencies: `poetry install` -- takes ~10 seconds. NEVER CANCEL.
1313
- All development commands should use `poetry run <command>`
1414

@@ -18,9 +18,9 @@ OpenPIV is a Python and Cython library for Particle Image Velocimetry (PIV) anal
1818
- **Build from source**: `python setup.py build_ext --inplace` -- takes <1 second (no Cython extensions in current setup)
1919

2020
### Build and Test the Repository
21-
- **Run tests**: `poetry run pytest openpiv -v` -- takes ~12 seconds, 198 tests pass, 12 skipped. NEVER CANCEL. Set timeout to 30+ minutes for safety.
21+
- **Run tests**: `poetry run pytest openpiv -v` -- takes ~10 seconds, 216 tests pass. NEVER CANCEL. Set timeout to 30+ minutes for safety.
2222
- **Test import**: `poetry run python -c "import openpiv; print('OpenPIV imported successfully')"`
23-
- **Test core functionality**: `poetry run python -c "import openpiv.piv as piv; import numpy as np; frame_a = np.random.rand(64, 64); frame_b = np.random.rand(64, 64); result = piv.simple_piv(frame_a, frame_b); print('PIV analysis completed, returned:', len(result), 'outputs')"`
23+
- **Test core functionality**: `poetry run python -c "import openpiv.piv as piv; import numpy as np; frame_a = np.random.rand(64, 64); frame_b = np.random.rand(64, 64); result = piv.simple_piv(frame_a, frame_b, plot=False); print('PIV analysis completed, returned:', len(result), 'outputs')"`
2424

2525
### Run Example Workflows
2626
- **Tutorial 1**: `poetry run python openpiv/tutorials/tutorial1.py` -- demonstrates complete PIV analysis workflow
@@ -31,7 +31,7 @@ OpenPIV is a Python and Cython library for Particle Image Velocimetry (PIV) anal
3131
### ALWAYS run these validation steps after making changes:
3232
1. **Import test**: Verify basic import works: `poetry run python -c "import openpiv"`
3333
2. **Core functionality test**: Run simple PIV analysis to ensure algorithms work
34-
3. **Full test suite**: `poetry run pytest openpiv -v` -- NEVER CANCEL, takes ~12 seconds but allow 30+ minutes timeout
34+
3. **Full test suite**: `poetry run pytest openpiv -v` -- NEVER CANCEL, takes ~10 seconds but allow 30+ minutes timeout
3535
4. **Tutorial execution**: Run `poetry run python openpiv/tutorials/tutorial1.py` to test complete workflow
3636

3737
### Critical User Scenarios to Test
@@ -43,76 +43,98 @@ After making changes, ALWAYS test these scenarios:
4343

4444
### CI/CD Validation
4545
- The repository has GitHub Actions workflows in `.github/workflows/`:
46-
- `testing.yml`: Runs tests on Python 3.10, 3.11, 3.12 with Poetry
47-
- `build.yml`: Builds and publishes to PyPI on releases
46+
- `testing.yml`: Runs tests on Python 3.10, 3.11, 3.12, 3.13, 3.14 with Poetry
47+
- `build.yml`: Builds and publishes to PyPI on releases triggered by version tags
4848
- No linting tools are configured (no black, flake8, etc.)
4949

5050
## Common Tasks
5151

5252
### Repository Structure
5353
```
5454
openpiv/
55-
├── __init__.py # Main package initialization
56-
├── piv.py # High-level PIV analysis functions
57-
├── pyprocess.py # Core PIV processing algorithms
58-
├── pyprocess3D.py # 3D PIV algorithms
59-
├── tools.py # Utility functions for I/O and visualization
60-
├── validation.py # Signal validation and filtering
61-
├── filters.py # Outlier detection and replacement
62-
├── windef.py # Window deformation PIV
63-
├── scaling.py # Coordinate scaling and transformation
64-
├── preprocess.py # Image preprocessing
65-
├── smoothn.py # Smoothing algorithms
66-
├── data/ # Sample test data
67-
├── test/ # Comprehensive test suite (210 tests)
68-
├── tutorials/ # Example scripts
69-
└── docs/ # Documentation source
55+
├── __init__.py # Package init; exposes __version__ via importlib.metadata
56+
├── piv.py # High-level PIV workflows: simple_piv(), piv_example(), process_pair()
57+
├── pyprocess.py # Core cross-correlation algorithms: extended_search_area_piv(), get_coordinates()
58+
├── pyprocess3D.py # 3D PIV algorithms
59+
├── tools.py # I/O and visualization: imread(), save(), display_vector_field(), transform_coordinates()
60+
├── validation.py # Spurious vector detection: global_val(), global_std(), sig2noise_val()
61+
├── filters.py # Outlier replacement: replace_outliers() (calls lib.replace_nans internally)
62+
├── lib.py # Low-level NaN inpainting: replace_nans() (used by filters)
63+
├── windef.py # Window-deformation iterative PIV: multipass_img_deform(), piv()
64+
├── settings.py # PIVSettings dataclass -- required by windef batch processing
65+
├── scaling.py # Coordinate scaling and transformation
66+
├── preprocess.py # Image preprocessing (background subtraction, masking)
67+
├── smoothn.py # Smoothing algorithms (robust spline smoothing)
68+
├── phase_separation.py # Solid-phase / liquid tracer separation utilities
69+
├── PIV_3D_plotting.py # 3D vector field plotting helpers
70+
├── data/ # Bundled sample PIV image pairs (test1/)
71+
├── test/ # Test suite (~216 tests); conftest.py disables matplotlib GUI
72+
├── tutorials/ # Example scripts (tutorial1.py, tutorial2.py, windef_tutorial.py, masking_tutorial.py)
73+
└── docs/ # Sphinx documentation source
7074
```
7175

7276
### Key APIs and Usage Patterns
73-
- **Simple PIV**: `piv.simple_piv(frame_a, frame_b)` returns `(x, y, u, v, s2n)`
74-
- **Extended search area**: `pyprocess.extended_search_area_piv()` for higher accuracy
75-
- **Window deformation**: `windef` module for advanced PIV with iterative refinement
76-
- **File I/O**: `tools.imread()`, `tools.save()`, `tools.display_vector_field()`
77-
- **Validation**: `validation.sig2noise_val()`, `validation.global_val()`
78-
- **Filtering**: `filters.replace_outliers()` for cleaning velocity fields
77+
- **Simple PIV** (quickest path): `piv.simple_piv(frame_a, frame_b, plot=False)``(x, y, u, v, s2n)`
78+
- **Complete workflow**: `piv.process_pair(frame_a, frame_b)``(x, y, u, v, mask)`
79+
- **Core cross-correlation**: `pyprocess.extended_search_area_piv(im1, im2, window_size, overlap, search_area_size)``(u, v, s2n)`
80+
- **Coordinates**: `pyprocess.get_coordinates(image_size, search_area_size, overlap)``(x, y)`
81+
- **Window deformation (batch)**: `windef.piv(settings)` where `settings` is a `PIVSettings` instance
82+
- **File I/O**: `tools.imread(path)`, `tools.save(x, y, u, v, mask, filename)`, `tools.display_vector_field(filename)`
83+
- **Validation**: `validation.global_val(u, v, u_thresholds, v_thresholds)`, `validation.sig2noise_val(s2n, threshold)`
84+
- **Filtering**: `filters.replace_outliers(u, v, mask, method='localmean', kernel_size=1)`
85+
- **Coordinate transform**: `tools.transform_coordinates(x, y, u, v)` — always call before saving/displaying
86+
87+
### PIVSettings (for windef batch processing)
88+
`settings.PIVSettings` is a dataclass with defaults that point to the bundled test data. Key fields:
89+
```python
90+
from openpiv.settings import PIVSettings
91+
s = PIVSettings()
92+
s.filepath_images = pathlib.Path('path/to/images')
93+
s.frame_pattern_a = 'frame_a_*.tif'
94+
s.frame_pattern_b = 'frame_b_*.tif'
95+
s.windowsizes = (64, 32, 16) # multi-pass window sizes
96+
s.overlap = (32, 16, 8) # corresponding overlaps
97+
s.num_iterations = 3
98+
```
7999

80100
### Project Management
81-
- **Dependencies**: Managed via Poetry (`pyproject.toml`) and fallback setuptools (`setup.py`)
82-
- **Package name**: "OpenPIV" (capital letters)
83-
- **Version**: 0.25.3 (defined in both `pyproject.toml` and `setup.py`)
84-
- **Python support**: 3.10, 3.11, 3.12
85-
- **Key dependencies**: numpy, scipy, scikit-image, matplotlib, imageio
101+
- **Dependencies**: Managed via Poetry (`pyproject.toml`); fallback setuptools config in `setup.py`
102+
- **Package name**: `"OpenPIV"` (capital letters on PyPI, lowercase `openpiv` as import)
103+
- **Version**: `0.25.4` (defined in both `pyproject.toml` and `setup.py`; runtime via `importlib.metadata`)
104+
- **Python support**: 3.10, 3.11, 3.12, 3.13, 3.14
105+
- **Key dependencies**: numpy ≥2.0, scipy ≥1.11, scikit-image ≥0.23, matplotlib ≥3.8, imageio ≥2.35, natsort, tqdm
86106

87107
### Development Notes
88-
- Uses `importlib_resources` for accessing package data files
89-
- Test configurations in `openpiv/test/conftest.py` disable plotting for CI
90-
- Sample data includes real PIV image pairs for testing workflows
108+
- **No Cython extensions**: Although the package description still mentions "Cython modules" (legacy), all Cython (`.pyx`) files have been removed and converted to pure Python. `python setup.py build_ext --inplace` takes <1 second with nothing to compile.
109+
- Uses stdlib `importlib.resources.files()` (NOT the third-party `importlib_resources`) to locate bundled data
110+
- Test configurations in `openpiv/test/conftest.py` disable matplotlib GUI (uses `Agg` backend, patches `plt.show`)
111+
- Sample data bundled at `openpiv/data/test1/`; accessed via `files('openpiv.data').joinpath('test1/...')`
112+
- `pyproject.toml` still uses the deprecated `[tool.poetry.dev-dependencies]` section; this generates a warning but is harmless
91113
- Documentation built with Sphinx (source in `openpiv/docs/`)
92114
- External examples repository: [OpenPIV-Python-Examples](https://github.com/OpenPIV/openpiv-python-examples)
93115

94116
### Common Command Reference
95117
```bash
96118
# Development setup
97-
poetry install # ~10 seconds
98-
poetry run pytest openpiv -v # ~12 seconds, 198 tests pass
119+
poetry install # ~10 seconds
120+
poetry run pytest openpiv -v # ~10 seconds, 216 tests pass
99121

100-
# Testing functionality
101-
poetry run python openpiv/tutorials/tutorial1.py # Complete PIV workflow
102-
poetry run python -c "import openpiv.piv as piv; ..." # API test
122+
# Testing functionality
123+
poetry run python openpiv/tutorials/tutorial1.py # Complete PIV workflow
124+
poetry run python -c "import openpiv.piv as piv; ..." # API test
103125

104126
# Alternative installs
105-
pip install openpiv # ~33 seconds
106-
conda install -c conda-forge openpiv # ~46 seconds
127+
pip install openpiv # ~33 seconds
128+
conda install -c conda-forge openpiv # ~46 seconds
107129

108130
# Build from source (minimal - no Cython compilation needed)
109-
python setup.py build_ext --inplace # <1 second
131+
python setup.py build_ext --inplace # <1 second
110132
```
111133

112134
### Timing Expectations and Timeouts
113135
- **Poetry install**: ~10 seconds (set 5+ minute timeout)
114-
- **Test suite**: ~12 seconds (set 30+ minute timeout for safety)
115-
- **Tutorial execution**: ~1-2 seconds
136+
- **Test suite**: ~10 seconds (set 30+ minute timeout for safety)
137+
- **Tutorial execution**: ~1-2 seconds
116138
- **Pip install**: ~33 seconds (set 10+ minute timeout)
117139
- **Conda install**: ~46 seconds (set 15+ minute timeout)
118140
- **Build from source**: <1 second (no Cython compilation currently)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: "Copilot Setup Steps"
2+
3+
# Run automatically when this file changes, and allow manual runs from the Actions tab.
4+
on:
5+
workflow_dispatch:
6+
push:
7+
paths:
8+
- .github/workflows/copilot-setup-steps.yml
9+
pull_request:
10+
paths:
11+
- .github/workflows/copilot-setup-steps.yml
12+
13+
jobs:
14+
# Job name MUST be `copilot-setup-steps` to be picked up by Copilot.
15+
copilot-setup-steps:
16+
runs-on: ubuntu-latest
17+
18+
permissions:
19+
contents: read
20+
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
25+
- name: Set up Python 3.12
26+
uses: actions/setup-python@v5
27+
with:
28+
python-version: "3.12"
29+
30+
- name: Install Poetry
31+
run: pip install poetry
32+
33+
- name: Install project dependencies
34+
run: poetry install

0 commit comments

Comments
 (0)