astronomia icon indicating copy to clipboard operation
astronomia copied to clipboard

Question about horizontal position / change of coordinates for moon

Open covidnineteen opened this issue 5 years ago • 2 comments

Hello - thank you for all the work that has gone into this library.

I wonder if you could help me understand an example of calculating the horizontal alt/az of the moon given a geographic position. Or: "Where is the moon?"

I can't get the output to match an Ephemeris from NASA : https://ssd.jpl.nasa.gov/horizons.cgi thought this is very definitely my implementation error.

Would you be able to help me out?

Assuming I import various things:

import Moonposition from "astronomia/src/moonposition";
import {Coord} from "astronomia/src/globe";
import {Ecliptic} from "astronomia/src/coord";
import Julian from "astronomia/src/julian";
import Sidereal from "astronomia/src/sidereal";
import {nutation} from "astronomia/src/nutation";

Define my coordinates as such:

// get the device's geographicCoordinates - or a fallback:

      let geographicCoordinates = new Coord(
        this.deviceCoordinates.latitude / 180 * Math.PI,
        this.deviceCoordinates.longitude / 180 * Math.PI
      );

I think I then:

  1. Get the ecliptic Moon position
  2. Convert this to Equatorial, by knowledge of the obliquity
  3. Convert this to Horizontal by knowledge of siderealTime + my location
      let calendar = new Julian.Calendar().fromDate(date)
      let jd = calendar.toJD()
      let jde = calendar.toJDE()
      let siderealTime = Sidereal.apparent0UT(jd);
      let eclipticMoonPosition = Moonposition.position(jde);
      let obliquity = nutation(jde)[1];

      let equatorialMoonPosition = new Ecliptic(
        eclipticMoonPosition.lat,
        eclipticMoonPosition.lon
      ).toEquatorial(obliquity);

      let horizontalMoonPosition = equatorialMoonPosition.toHorizontal(
        geographicCoordinates,
        siderealTime
      );

      return horizontalMoonPosition;

covidnineteen avatar Jun 26 '20 09:06 covidnineteen

Here is an example of why I want to do this; I used a different library to build that example - it's based of Meeus

covidnineteen avatar Jun 26 '20 09:06 covidnineteen

Let's try to match the NASA Horizons output here: https://ssd.jpl.nasa.gov/horizons.cgi Do it for "central London" : Topocentric ( 0°07'40.1''W, 51°30'26.6''N ) On January 1st 2020 at 00:00:00

Quantity NASA code (in context of above) astronomia agreement
Julian Day 2458849.5 calendar.toJD() 2458849.5 🆗
Right Ascension 348.38086 eclipticMoonPosition._ra / Math.PI * 180 346.143595306839331 :x:
Declination -10.73621 eclipticMoonPosition._dec / Math.PI * 180 -4.89415732560423 :x:

Bit stuck - not sure quite what I'm doing wrong

covidnineteen avatar Jun 29 '20 10:06 covidnineteen