Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
3510aba
Merge pull request #17 from mtpenny/dev
mtpenny Nov 4, 2025
b2c0ba9
rename Asrc* to musrc* to distinguish it from A meaning gulls relativ…
AmberLee2427 Nov 10, 2025
c5417ae
Add my extra variables back
Nov 17, 2025
e4f8e61
Enhance astrometric capabilities in photometry and lightcurve generation
AmberLee2427 Dec 26, 2025
1016e85
Update documentation/source/astrometry.rst
AmberLee2427 Dec 27, 2025
5b245c5
Update src/photometry.cpp
AmberLee2427 Dec 27, 2025
beaba00
Update src/pllxLightcurveGeneratorMultiple.cpp
AmberLee2427 Dec 27, 2025
255abd7
Update src/readParamfile.cpp
AmberLee2427 Dec 27, 2025
403e855
Update src/pllxLightcurveGeneratorMultiple.cpp
AmberLee2427 Dec 27, 2025
7cea02f
Initial plan
Copilot Dec 27, 2025
f5241b8
Update src/pllxLightcurveGenerator.cpp
AmberLee2427 Dec 27, 2025
69e141f
Update README.md
AmberLee2427 Dec 27, 2025
ef2823e
Update src/photometry.cpp
AmberLee2427 Dec 27, 2025
e719719
Update src/pllxLightcurveGeneratorMultiple.cpp
AmberLee2427 Dec 27, 2025
c140da1
Update documentation/source/astrometry.rst
AmberLee2427 Dec 27, 2025
ca5d23a
Add thE validation check to prevent division by zero in astrometry
Copilot Dec 27, 2025
c8b34cf
Fix typo: 'abient' -> 'ambient'
Copilot Dec 27, 2025
99005fe
Complete thE validation check implementation
Copilot Dec 27, 2025
41c9420
Remove CodeQL artifact and add to .gitignore
Copilot Dec 27, 2025
2795513
Merge branch 'feature/astrometry-for-testing' into copilot/sub-pr-5
AmberLee2427 Dec 27, 2025
64789a6
Merge pull request #6 from AmberLee2427/copilot/sub-pr-5
AmberLee2427 Dec 27, 2025
668753e
Enhance photometry function to handle multiple companion sources for …
AmberLee2427 Dec 27, 2025
6e344c9
tidying indentation to search for missing closing bracket
AmberLee2427 Dec 27, 2025
466a698
Update version to 2.1.0 and add comprehensive release notes
AmberLee2427 Dec 27, 2025
a77f9af
Initial plan
Copilot Dec 27, 2025
efcfcc0
Add version 2.1.0 release notes and changelog entry
Copilot Dec 27, 2025
f4dffbe
Merge pull request #8 from AmberLee2427/copilot/sub-pr-5-another-one
AmberLee2427 Dec 27, 2025
c56736c
Release version 2.1.0
AmberLee2427 Dec 27, 2025
701577f
Reorganize workflow steps: move documentation build and cleanup outputs
AmberLee2427 Dec 27, 2025
12721c5
Refactor release workflow: add cleanup step and build documentation
AmberLee2427 Dec 27, 2025
5ca07b7
Refactor release workflow: enhance cleanup step and improve documenta…
AmberLee2427 Dec 27, 2025
d4d9094
Update Python version requirement to 3.11 in environment.yml
AmberLee2427 Dec 27, 2025
d9e78f8
Add astrometry section to documentation table of contents
AmberLee2427 Dec 27, 2025
764b5bb
Pin Python version to 3.12 and Sphinx version to 6.2 in environment.y…
AmberLee2427 Dec 27, 2025
fa85e6f
Update CHANGELOG.md: pin Sphinx version due to incompatibility with v…
AmberLee2427 Dec 27, 2025
d3707f1
Add astrometry parameters to smoke test configuration files
AmberLee2427 Dec 27, 2025
87ea327
Initial plan
Copilot Dec 27, 2025
13e497c
Add version-aware astrometry column validation for smoke tests
Copilot Dec 27, 2025
396930a
Add debug output for detected gulls version
Copilot Dec 27, 2025
79bd66d
Merge pull request #9 from AmberLee2427/copilot/sub-pr-5-another-one
AmberLee2427 Dec 27, 2025
10ffeeb
Add minimal astrometry plotting function and integrate into lightcurv…
AmberLee2427 Dec 27, 2025
72c6364
Initial plan
Copilot Dec 30, 2025
4edfb00
Fix segfault: correct loop iteration in photometry companion flux cal…
Copilot Dec 30, 2025
0ac211b
Fix PSF initialization check to prevent adding stars when uninitializ…
AmberLee2427 Dec 30, 2025
170971f
Merge pull request #10 from AmberLee2427/copilot/sub-pr-5-yet-again
AmberLee2427 Dec 30, 2025
1e18fac
Merge branch 'dev' into feature/astrometry-for-testing
AmberLee2427 Dec 30, 2025
6a76236
Initial plan
Copilot Dec 30, 2025
cee935a
Fix merge conflict: add missing closing brace in readParamfile.cpp
Copilot Dec 30, 2025
d1446a0
Fix merge conflict: restore missing closing brace in readParamfile.cpp
AmberLee2427 Dec 30, 2025
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
32 changes: 22 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,38 @@ jobs:
conda env create -f environment.yml
conda activate gulls
conda list



- name: Cleanup previous outputs
shell: bash -l {0}
run: |
rm -rf smoke_test/output/*
rm -rf documentation/build/*
rm -rf bin/*
rm -rf release_plots/*


- name: Build documentation
shell: bash -l {0}
run: |
conda activate gulls
cd documentation
make html
cd ..

- name: Configure CMake
shell: bash -l {0}
run: |
conda activate gulls
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release

- name: Build
- name: Build Gulls
shell: bash -l {0}
run: |
conda activate gulls
cmake --build build --parallel


- name: Run smoke tests and generate plots
shell: bash -l {0}
run: |
Expand All @@ -56,14 +75,7 @@ jobs:
# List what we found
echo "Generated plots for release:"
ls -la release_plots/


- name: Build documentation
shell: bash -l {0}
run: |
conda activate gulls
cd documentation
make html


- name: Create release archive
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,4 @@ documentation/build/

# PSF files (generated in workflow/smoke tests)
smoke_test/assets/observatories/WFI_PSF.psf
_codeql_detected_source_root
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,39 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [2.1.0] - 2025-12-27

### Added
- Basic astrometry support for microlensing simulations
- Six new output columns for centroid positions and uncertainties (true and observed)
- `ASTROMETRY_ON` parameter to enable/disable astrometric computations (default: 0)
- `ASTROMETRIC_SYS_FLOOR` parameter for systematic uncertainty floor in mas (default: 0.1)
- Comprehensive astrometry documentation (`documentation/source/astrometry.rst`)
- Centroid calculation using VBMicrolensing low-level functions (`BinaryMag2`, `MultiMag2`)
- Noise model implementation based on Gould & Yee (2014)
- Flux-weighted blending for centroids with lens and ambient stars
- Support for single and binary source configurations in astrometry

### Changed
- Variable naming: renamed `Asrc1`/`Asrc2` to `musrc1`/`musrc2` for consistency with magnification nomenclature
- Enhanced photometry module to compute astrometric uncertainties from photometric precision
- Updated lightcurve generators to compute and store true centroid positions

### Fixed
- Potential division by zero when θ_E (Einstein radius) is very small
- Added validation check with warning for events with θ_E < 1e-10 mas
- Spelling errors in comments: "oposite" → "opposite", "shif" → "shift", "abient" → "ambient"
- Buffer overflow in `snprintf` call (missing buffer size argument)
- Unbalanced parenthesis in documentation formula
- Trailing whitespace in parameter reading code
- Step numbering in astrometry documentation
- Pinned Sphinx version; `sphinx` and `sphinx-rtd-theme` became incompatable at version 7.


### Security
- Added validation to prevent division by zero in astrometric calculations
- Fixed buffer overflow vulnerability in string formatting

## [2.0.0] - 2025-10-20

### Added
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ Inspect images in ds9 using zscale to check for:
- **Automated testing** - CI runs tests automatically
- **Better error messages** - Clear feedback when things go wrong
- **Version management** - Automated releases with smart release notes (uses `RELEASE_NOTES.md` if present)
- **Astrometry** (v2.1.0) - Basic astrometry implementation using low-level VBM functions, Gould & Yee (2014) noise approximations andminimal transformation. Values are expressed in the lens-frame in units of theta E. See [astrometry.rst](documentation/source/astrometry.rst) for more details.

**See [CONTRIBUTING.md](CONTRIBUTING.md) for a gradual adoption guide.**

Expand Down
241 changes: 160 additions & 81 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,118 +1,197 @@
# Gulls v2.0.0 Release Notes
# Gulls v2.1.0 Release Notes

**Release Date:** October 2025
**Release Date:** December 27, 2025

## Major Release - Documentation and Testing Overhaul
## Feature Release - Basic Astrometry Support

This is a major release that significantly improves the usability and maintainability of Gulls for the broader microlensing community.
This release adds basic astrometric capabilities to Gulls, enabling the simulation of centroid motion for microlensing events. This feature allows users to model and predict the astrometric signatures of lensed sources, which is critical for follow-up observations and event characterization.

## What's New

### 📚 Comprehensive Documentation
- **Complete documentation system** with Sphinx/Read the Docs integration
- **Input file format specifications** for all file types (catalogs, observatories, sequences)
- **Parameter reference** with detailed descriptions of all configuration options
- **Installation guides** with both CMake and traditional Makefile approaches
- **Troubleshooting guides** for common issues

### 🔍 Input Validation System
- **Comprehensive validation** of input catalogs and configuration files
- **File existence checks** - ensures all referenced files exist
- **Data format validation** - checks column headers, data types, ranges
- **Compatibility checks** - validates source/lens distance relationships
- **Binary source validation** - ensures required columns when using multiple sources
- **Clear error messages** with actionable fixes

### 🧪 Testing and CI/CD
- **Smoke test suite** with automated testing of core functionality
- **GitHub Actions CI** with multi-platform testing (Ubuntu, macOS)
- **Automated validation** in CI pipeline
- **Example configurations** for different simulation types
- **Visual validation outputs** with smoke test output figures in Release Notes

### 🛠️ Developer Experience
- **CMake build system** alongside traditional Makefile
- **Contributing guidelines** for community contributions
- **Version management** with automated bumping and release workflows
- **Code quality improvements** with better error handling
- **Simplified release workflow**: patch > edit changelog > release

### 🎯 PSF Generation Improvements
- **Smoke tests generate PSF files on-demand** instead of requiring pre-committed files
### 🎯 Astrometry Implementation
- **Centroid calculation** for lensed sources in the lens frame
- **Noise modeling** based on photometric precision and seeing conditions
- **VBMicrolensing integration** using low-level functions for astrometric offsets
- **Gould & Yee (2014) noise approximations** for realistic uncertainty estimates
- **Configurable systematic floor** for astrometric uncertainties
- **Support for single and binary source configurations** with flux-weighted blending

### 📊 New Output Columns
The following columns are added to lightcurve outputs when astrometry is enabled:
- `true_x_centroid` - True centroid position (x-axis, Einstein radii)
- `true_y_centroid` - True centroid position (y-axis, Einstein radii)
- `x_centroid` - Observed centroid with noise (x-axis, Einstein radii)
- `y_centroid` - Observed centroid with noise (y-axis, Einstein radii)
- `x_centroid_err` - Uncertainty on x centroid (Einstein radii)
- `y_centroid_err` - Uncertainty on y centroid (Einstein radii)

### ⚙️ New Configuration Parameters
- **ASTROMETRY_ON** (default: 0)
- Enable/disable astrometric computation and outputs
- When disabled, all astrometry columns are written as 0.0

- **ASTROMETRIC_SYS_FLOOR** (default: 0.1 mas)
- Per-axis systematic floor for astrometric uncertainty
- Combined in quadrature with photon-limited uncertainties

### 📚 Documentation
- **Comprehensive astrometry guide** (`documentation/source/astrometry.rst`)
- Detailed parameter descriptions
- Coordinate system explanations
- Noise model implementation details
- Column naming conventions

## Technical Details

### Coordinate System
Astrometric outputs are currently provided in the **lens frame** (VBM coordinate system):
- x-axis (x1): along the binary lens axis
- y-axis (x2): perpendicular to the binary lens axis
- Units: Einstein radii (θ_E)

Future releases will add sky-frame (North/East) and absolute RA/Dec outputs.

### Noise Model
The astrometric uncertainty follows Gould & Yee (2014):

1. Compute fractional photometric error: `σ_phot = A_err / max(A_obs, 1e-12)`
2. Convert PSF FWHM to Einstein radii: `FWHM_er = (FWHM_arcsec * 1000) / θ_E_mas`
3. Photon-limited uncertainty: `σ_astro = FWHM_er * σ_phot / sqrt(ln(256))`
4. Total uncertainty: `σ_total = sqrt(σ_astro² + (sys_floor / θ_E_mas)²)`

Random Gaussian noise is added to true centroids based on these uncertainties.

### Blending
For events with blended light:
- Source centroids are flux-weighted across all blending components
- Includes contributions from the lens star and ambient field stars
- Properly accounts for variable source brightness during magnification

## Code Changes

### Modified Files
- `src/structures.h` - Added astrometry parameters to Paramfile structure
- `src/readParamfile.cpp` - Parse new astrometry configuration parameters
- `src/pllxLightcurveGenerator.cpp` - Compute centroids for single-source events
- `src/pllxLightcurveGeneratorMultiple.cpp` - Compute centroids for multi-source events
- `src/photometry.cpp` - Apply noise model and compute observed values
- `documentation/source/astrometry.rst` - New comprehensive documentation
- `README.md` - Added feature description

### Bug Fixes
- Fixed potential division by zero when θ_E is very small
- Added validation check with warning for events with θ_E < 1e-10 mas
- Fixed variable naming consistency (`Asrc` → `musrc` for magnification)
- Corrected spelling errors in comments
- Fixed buffer overflow issues in string formatting

## Usage Example

To enable astrometry in your parameter file:

```
ASTROMETRY_ON 1
ASTROMETRIC_SYS_FLOOR 0.05
```

Output files will then include the six new centroid columns alongside existing photometric data.

## Limitations and Future Work

### Current Limitations
- **Lens-frame only**: Outputs are in Einstein radii in the lens frame
- **No sky-frame transformation**: North/East and absolute RA/Dec not yet implemented
- **No orbital motion effects**: Assumes static lens-source geometry per epoch
- **Single lens assumption**: Blending assumes lens is a single point source

### Planned for Future Releases
- Sky-frame (North/East) astrometric outputs
- Absolute RA/Dec centroid positions
- Proper motion and parallax effects in sky frame
- Extended source effects for very large sources
- Higher-order astrometric terms

## Breaking Changes

- **Buffer size fixes** - Fixed potential buffer overflows in path handling
- **Input validation** - Stricter validation may catch previously ignored configuration errors
- **Documentation structure** - New documentation format (RST instead of markdown)
None. This is a feature addition with backward compatibility. Existing parameter files will work unchanged with `ASTROMETRY_ON` defaulting to 0.

## Migration Guide

### For Existing Users
1. **Update your build process** - CMake is now recommended over Makefile
2. **Validate your input files** - Run `python scripts/validate_inputs.py your_file.prm` before simulations
3. **Check documentation** - New comprehensive guides available at [Read the Docs](https://gulls.readthedocs.io)
1. **No action required** if you don't need astrometry
2. **Add two parameters** to enable astrometry:
- `ASTROMETRY_ON 1`
- `ASTROMETRIC_SYS_FLOOR 0.1` (or your preferred systematic floor)
3. **Update output parsing** to handle new columns if you enable astrometry
4. **Review documentation** at `documentation/source/astrometry.rst`

### For Developers
1. **Use the new validation system** - Add validation for new error conditions
2. **Follow contributing guidelines** - See `CONTRIBUTING.md` for development workflow
3. **Update version numbers** - Use `python scripts/bump_version.py` for releases
1. **Astrometry values** are computed in the lightcurve generator and photometry modules
2. **VBM low-level functions** are used: `BinaryMag2()` and `MultiMag2()`
3. **True centroids** are stored in Event structure during lightcurve generation
4. **Noise addition** occurs in the photometry module based on observed magnitudes

## Technical Improvements
## Performance Impact

### Bug Fixes
- Fixed infinite loop in random number generation CI stub
- Fixed uninitialized memory issues in binary source calculations
- Fixed off-by-one errors in catalog parsing
- Fixed buffer overflows in file path construction (required change for successful CI runs)
- Fixed failure to build docs in the release workflow on GitHub
- Fixed PSF generation in CI environments (removed hardcoded local machine paths)
- Fixed PSF file size issues (now generates proper 68MB files with subpixel sampling)
- Fixed simulation crashes due to missing or malformed PSF files

### Performance
- Improved error handling and user feedback
- Optimized validation routines
- Smart PSF caching reduces redundant file generation

### Security
- Fixed potential buffer overflows
- Improved input sanitization
- Better error handling to prevent crashes
Minimal performance impact when astrometry is disabled (default). When enabled:
- Slight increase in computation time (~5-10%) due to centroid calculations
- Increased output file size due to six additional columns per epoch

## Known Issues

- Very small Einstein radii (θ_E < 1e-10 mas) may cause numerical instability
- A warning is now issued when this occurs
- Such events are physically unrealistic and typically filtered in validation
- Sky-frame outputs are not yet available (planned for v2.2.0)

## Testing

This release has undergone basic validation:
- Code review via automated PR checks
- Syntax and compilation verified
- Security scanning with CodeQL
- **Note**: Full smoke testing recommended before production use

## Community Impact

This release makes Gulls significantly more accessible to the broader microlensing community:
This release enables the microlensing community to:
- **Simulate astrometric signatures** for event characterization
- **Plan follow-up observations** with accurate uncertainty predictions
- **Compare predicted and observed centroids** for model validation
- **Prepare for future astrometry missions** (e.g., WFIRST/Roman)

## Scientific References

- **Gould, A. & Yee, J. C. (2014)** - "μFUN Collaboration VIII. Astrometric Method"
- Provides the noise model implementation used in this release
- Reference for photon-limited astrometric precision

- **Easier installation** with better dependency management
- **Clear documentation** for new users
- **Robust validation** prevents common configuration errors
- **Professional development workflow** for contributors
- **Automated testing** ensures reliability
- **Improved CI/CD** with proper documentation builds and PSF handling
- **Penny et al. (2013, 2014, 2019)** - Original Gulls papers
- Core microlensing simulation methodology

## Acknowledgments

This release represents a major community effort to improve Gulls' usability and maintainability. Special thanks to all contributors who helped with documentation, testing, and code improvements.
This release adds an important capability for astrometric microlensing studies. The implementation leverages the VBMicrolensing library's low-level functions for efficient centroid calculations.

## Getting Started

1. **Install Gulls** - See the [Installation Guide](https://gulls.readthedocs.io/en/latest/install_gulls.html)
2. **Validate your inputs** - Use `python scripts/validate_inputs.py your_file.prm`
3. **Run simulations** - See the [Running Guide](https://gulls.readthedocs.io/en/latest/run_simulations.html)
4. **Get help** - Check the [Troubleshooting Guide](https://gulls.readthedocs.io/en/latest/basic_troubleshooting.html)
1. **Update Gulls** - Pull or download v2.1.0
2. **Review documentation** - See `documentation/source/astrometry.rst`
3. **Enable astrometry** - Add parameters to your `.prm` file
4. **Run simulations** - Output files will include new centroid columns
5. **Get help** - Open an issue or check the documentation

## What's Included

- **Source code**: Complete Gulls source with CMake build system
- **Binaries**: Linux executables (GSL fallbacks - testing only)
- **Documentation**: Built HTML documentation
- **Smoke test plots**: Visual proof that the release works
- **Source code**: Complete Gulls source with astrometry support
- **Documentation**: Updated user guide with astrometry details
- **Example configurations**: See documentation for parameter examples

## Full Changelog

See [CHANGELOG.md](CHANGELOG.md) for the complete list of changes.

---

**Previous Release:** v1.0.0 (2013-2025)
**Previous Release:** v2.0.0 (October 2025)
**Next Planned Release:** v2.2.0 (Sky-frame astrometry support)
Loading
Loading