Skip to content

Deep Sky Object: Compute topocentric position#226

Merged
rhannequin merged 1 commit intomainfrom
deep-sky-object-topocentric-position
Oct 21, 2025
Merged

Deep Sky Object: Compute topocentric position#226
rhannequin merged 1 commit intomainfrom
deep-sky-object-topocentric-position

Conversation

@rhannequin
Copy link
Owner

@rhannequin rhannequin commented Oct 16, 2025

This supports the topocentric position of a deep sky object, meaning as seen as an observer on Earth.

time = Time.utc(2025, 10, 1)
instant = Astronoby::Instant.from_time(time)
ephem = Astronoby::Ephem.load("inpop19a.bsp")
equatorial_coordinates = Astronoby::Coordinates::Equatorial.new(
  right_ascension: Astronoby::Angle.from_hms(18, 36, 56.33635),
  declination: Astronoby::Angle.from_dms(38, 47, 1.2802),
  epoch: Astronoby::JulianDate::J2000
)
observer = Astronoby::Observer.new(
  latitude: Astronoby::Angle.from_degrees(48.856614),
  longitude: Astronoby::Angle.from_degrees(2.3522219)
)

dso = Astronoby::DeepSkyObject.new(
  instant: instant,
  equatorial_coordinates: equatorial_coordinates,
  ephem: ephem,
  proper_motion_ra: Astronoby::AngularVelocity
    .from_milliarcseconds_per_year(200.94),
  proper_motion_dec: Astronoby::AngularVelocity
    .from_milliarcseconds_per_year(286.23),
  parallax: Astronoby::Angle.from_degree_arcseconds(130.23 / 1000.0),
  radial_velocity: Astronoby::Velocity.from_kilometers_per_second(-13.5)
)
topocentric = dso.observed_by(observer)

topocentric.equatorial.right_ascension.str(:hms)
# => "18h 37m 48.7215s"

topocentric.equatorial.declination.str(:dms)
# => "+38° 48′ 41.4879″"

topocentric.horizontal.altitude.str(:dms)
# => "+26° 30′ 5.1834″"

topocentric.horizontal.azimuth.str(:dms)
# => "+299° 35′ 15.3519″"

It also works without ephem and without proper motion parameters:

time = Time.utc(2025, 10, 1)
instant = Astronoby::Instant.from_time(time)
equatorial_coordinates = Astronoby::Coordinates::Equatorial.new(
  right_ascension: Astronoby::Angle.from_hms(18, 36, 56.33635),
  declination: Astronoby::Angle.from_dms(38, 47, 1.2802),
  epoch: Astronoby::JulianDate::J2000
)
observer = Astronoby::Observer.new(
  latitude: Astronoby::Angle.from_degrees(48.856614),
  longitude: Astronoby::Angle.from_degrees(2.3522219)
)

dso = Astronoby::DeepSkyObject.new(
  instant: instant,
  equatorial_coordinates: equatorial_coordinates
)
topocentric = dso.observed_by(observer)

topocentric.equatorial.right_ascension.str(:hms)
# => "18h 37m 48.2804s"

topocentric.equatorial.declination.str(:dms)
# => "+38° 48′ 16.0412″"

topocentric.horizontal.altitude.str(:dms)
# => "+26° 29′ 44.1232″"

topocentric.horizontal.azimuth.str(:dms)
# => "+299° 34′ 58.3848″"

Not using ephem and proper motion parameters increases performance but reduces precision by about 0.5 arcminutes. This can be useful when used in algorithms like rising and setting times, while very precise horizontal coordinates might be useful when pointing exactly the object.

@rhannequin rhannequin self-assigned this Oct 16, 2025
@rhannequin rhannequin force-pushed the use-last-for-hour-angle branch from 933f5b0 to 7417f77 Compare October 20, 2025 15:16
Base automatically changed from use-last-for-hour-angle to main October 21, 2025 07:35
This supports the topocentric position of a deep sky object, meaning as
seen as an observer on Earth.
@rhannequin rhannequin force-pushed the deep-sky-object-topocentric-position branch from 4d830e7 to 72e5ae5 Compare October 21, 2025 07:36
@rhannequin rhannequin merged commit ca5ae14 into main Oct 21, 2025
43 checks passed
@rhannequin rhannequin deleted the deep-sky-object-topocentric-position branch October 21, 2025 08:02
@rhannequin rhannequin mentioned this pull request Oct 25, 2025
rhannequin added a commit that referenced this pull request Oct 31, 2025
## 0.9.0 - 2025-10-31

_If you are upgrading: please see [UPGRADING.md]._

### Features

* Add `#approaching_primary?` and `#receding_from_primary?` to solar system bodies ([#211])
* Calculate apoapsis and periapsis events ([#213])
* Improve precision of ΔT ([#219])
* Deep Sky Object: Compute astrometric position ([#217])
* Deep Sky Object: Compute apparent position ([#220])
* Deep Sky Object: Handle velocities properly ([#222])
* Deep Sky Object: Compute topocentric position ([#226])
* Deep Sky Object: difference between the body and the position ([#227])
* Deep Sky Object: Add support for RiseTransitSetCalculator ([#228])

### Improvements

* Drop `Astronoby::Apparent#angular_diameter` ([#221])
* Bump rubyzip from 3.0.2 to 3.2.1 by @dependabot ([#210], [#215], [#223], [#233])
* Bump standard from 1.50.0 to 1.51.1 by @dependabot ([#212], [#214])
* Be proud about the precision achieved ([#218])
* Use local apparent instead of local mean sidereal time for hour angle ([#225])
* Bump rspec from 3.13.1 to 3.13.2 by @dependabot ([#229])
* Bump benchmark from 0.4.1 to 0.5.0 by @dependabot ([#230])
* Add documentation for deep-sky objects ([#232])
* Bump rake from 13.3.0 to 13.3.1 by @dependabot ([#235])

### Backward-incompatible changes

* Drop `Astronoby::Apparent#angular_diameter` ([#221])
* Use local apparent instead of local mean sidereal time for hour angle ([#225])

**Full Changelog**: v0.8.0...v0.9.0

[#210]: #210
[#211]: #211
[#212]: #212
[#213]: #213
[#214]: #214
[#215]: #215
[#217]: #217
[#218]: #218
[#219]: #219
[#220]: #220
[#221]: #221
[#222]: #222
[#223]: #223
[#225]: #225
[#226]: #226
[#227]: #227
[#228]: #228
[#229]: #229
[#230]: #230
[#232]: #232
[#233]: #233
[#235]: #235
[UPGRADING.md]: https://github.com/rhannequin/astronoby/blob/main/UPGRADING.md
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.

1 participant