Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about horizontal position / change of coordinates for moon #17

Open
covidnineteen opened this issue Jun 26, 2020 · 2 comments
Open

Comments

@covidnineteen
Copy link

covidnineteen commented Jun 26, 2020

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
Copy link
Author

covidnineteen commented Jun 26, 2020

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
Copy link
Author

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
Declination -10.73621 eclipticMoonPosition._dec / Math.PI * 180 -4.89415732560423

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

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

No branches or pull requests

1 participant