Skip to content

feat(transforms): add cosmological redshift and Doppler shift support (Issue #28)#46

Open
Akshat1000Sharma wants to merge 1 commit intoJuliaAstro:mainfrom
Akshat1000Sharma:redshift-doppler
Open

feat(transforms): add cosmological redshift and Doppler shift support (Issue #28)#46
Akshat1000Sharma wants to merge 1 commit intoJuliaAstro:mainfrom
Akshat1000Sharma:redshift-doppler

Conversation

@Akshat1000Sharma
Copy link

Closes #28

Summary

This PR adds cosmological redshift and Doppler shift support to Spectra.jl, including mutating and non-mutating APIs. It also fixes a Unitful velocity conversion issue in this implementation, adds comprehensive tests, and updates docs. The full test suite passes with no regressions.


Issue

Issue #28 (“Tokyo Shift”) requested redshift functionality. Spectra.jl previously had no API to shift the spectral axis by redshift z or radial velocity v.

During implementation, I identified and fixed a Unitful bug where velocities in km/s were incorrectly scaled due to stripping units without explicit conversion to m/s.


Resolution

Added

  • redshift, redshift!
  • doppler_shift, doppler_shift!
  • Documentation in transforms.md
  • 45 new tests (formulas, Unitful support, @inferred, roundtrip, metadata, mutability)

Fix

Explicit Unitful conversion before stripping:

_velocity_ratio(v::Quantity) = ustrip(u"m/s", v) / _c_mps

Review Commands

Run full test suite:

julia --project -e 'using Pkg; Pkg.test()'

Run only redshift tests:

julia --project -e 'using Pkg; Pkg.test("Spectra"; test_args="--testset transforms/redshift")'

Test Results

Test Summary: | Pass  Total   Time
  Overall     |  269    269  57.1s
    SUCCESS
     Testing Spectra tests passed

All 269 tests pass (including 45 new redshift tests).
No regressions.


Please let me know if any adjustments are needed.

…rms; fix Unitful velocity conversion; add docs and tests (Issue JuliaAstro#28)
@codecov
Copy link

codecov bot commented Mar 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.71%. Comparing base (58828d3) to head (9d8d246).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #46      +/-   ##
==========================================
+ Coverage   90.74%   91.71%   +0.97%     
==========================================
  Files           8        9       +1     
  Lines         162      181      +19     
==========================================
+ Hits          147      166      +19     
  Misses         15       15              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tokyo Shift

1 participant