astronomy icon indicating copy to clipboard operation
astronomy copied to clipboard

Help in finding planetary position for astrology

Open bizprat opened this issue 2 years ago • 10 comments

I am not an astronomy student. But I want to find the degrees of planets at a particular time.

I used the GeoVector method, but it gives me x, y & z dimensions, not degrees.

Here is the javascript code:

const Astronomy = require('astronomy-engine');
const GeoVector = Astronomy.GeoVector(Astronomy.Body.Moon, new Date(), false);
console.log(result);

I want the output something like on this site

bizprat avatar Aug 05 '22 09:08 bizprat

Hi @bizprat and welcome to the Astronomy Engine project! I looked at the website you referenced, and I'm having trouble figuring out what the "position" angle is on that website. I thought it might be an ecliptic longitude, but the numbers do not make sense.

For example, it shows the Sun's "position" as 109 degrees, 4 minutes. This does not match the ecliptic longitude (132.936 degrees), the right ascension angle (9.03 hours = 135.45 degrees), or my local azimuth angle (132.41 degrees).

So I am not yet sure how to help you. Can you tell me more what kind of angle you want, and what problem you are trying to solve? Then I will better understand what to suggest.

cosinekitty avatar Aug 05 '22 16:08 cosinekitty

Hi @bizprat and welcome to the Astronomy Engine project! I looked at the website you referenced, and I'm having trouble figuring out what the "position" angle is on that website. I thought it might be an ecliptic longitude, but the numbers do not make sense.

For example, it shows the Sun's "position" as 109 degrees, 4 minutes. This does not match the ecliptic longitude (132.936 degrees), the right ascension angle (9.03 hours = 135.45 degrees), or my local azimuth angle (132.41 degrees).

So I am not yet sure how to help you. Can you tell me more what kind of angle you want, and what problem you are trying to solve? Then I will better understand what to suggest.

Thank you for the response @cosinekitty

Sorry, I did not mention that the website I referred to uses sidereal astrology system in which ayanamsa should be deducted in the ecliptic longitude.

I have found a way to get an ecliptic angle, here it is ( correct me if I am wrong )

const geoVector = Astronomy.GeoVector(Astronomy.Body.Sun, new Date(), false);
const eclipticAngle = Astronomy.Ecliptic(geoVector)

Now the value of ayanamsa is 23.857 degrees (average), so we will deduct it in ecliptic longitude. Ex: Ecliptic longitude of the sun is 132.936. After deduction ayanamsa 132.936 - 23.857 = 109.079 degrees

Now, my problem is that:

  1. I am unable to know whether the planet is retrograde.
  2. How to calculate ecliptic angle of Rahu & Ketu (Lunar Node)
  3. Is there any way to calculate the Ascendant in this library

I am trying to build an app based on Vedic astrology.

bizprat avatar Aug 06 '22 09:08 bizprat

OK, that explains why I didn't understand the angle 109 degrees. About your code, it is very close, but the Astronomy.Ecliptic does not return just the ecliptic longitude; it returns an object that contains several things: see EclipticCoordinates. So your second line of code should look like:

const eclipticLongitude = Astronomy.Ecliptic(geoVector).elon;

One way to detect whether a planet is in prograde or retrograde movement is to calculate its ecliptic longitude as seen from the Earth at two slightly different times. For example, you can calculate its current ecliptic longitude and its ecliptic longitude one minute in the future. If you have an AstroTime object, you can calculate another AstroTime object using the method AddDays. For example:

const time1 = Astronomy.MakeTime(new Date());
const time2 = time1.AddDays(1/1440);   // time2 is one minute after time1

Use those two times to calculate two ecliptic longitudes of the same planet. Then subtract the two ecliptic longitudes. If the ecliptic longitude is increasing (the difference is positive), the planet is in prograde motion. If the difference is negative, the planet is in retrograde.

It sounds like Rahu & Ketu are names for lunar nodes, i.e., when the Moon passes through the ecliptic plane. You can find lunar nodes using the functions SearchMoonNode and NextMoonNode.

Calculating the ascendant will be more difficult. Fortunately, I have some example source code that solves one of the hardest parts of the problem. Take a look at horizon.js. This program contains a function FindEclipticCrossings that figures out where the ecliptic intersects with a given observer's horizon. It figures out the ascending and descending ecliptic and horizontal coordinates. That should be very close to what you need.

I hope this helps, and please let me know if I can provide any more information.

cosinekitty avatar Aug 06 '22 18:08 cosinekitty

Hi, I was able to find the retrograde and prograde motion of the bodies. Thank you.

But for Lunar Nodes, I tried SearchMoonNode and NextMoonNode methods, but it gives UT and TT of the node event. But I need ecliptic longitude like I was able to calculate for other bodies.

bizprat avatar Aug 07 '22 12:08 bizprat

That's great about retrograde/prograde. Glad that worked for you.

Yes you are right about SearchMoonNode/NextMoonNode. Now, once you know the time of the event, you can call EclipticGeoMoon to obtain the Moon's ecliptic angular coordinates at that time. EclipticGeoMoon returns the type Spherical. So your code might look something like this:

const startTime = Astronomy.MakeTime(new Date());
const node = Astronomy.SearchMoonNode(startTime);
const eclip = Astronomy.EclipticGeoMoon(node.time);
console.log(`${Astronomy.NodeEventKind[node.kind]} node at ecliptic longitude ${eclip.lon}`);
// prints "Ascending node at ecliptic longitude 47.17104464994921"

cosinekitty avatar Aug 07 '22 14:08 cosinekitty

I just thought of something I need to add to my remarks above. As you know, the Earth's axis and equator are always drifting. I'm not sure whether you want ecliptic longitude relative to the Earth's equator at the given time, or relative to the year 2000. The first kind is called "the equator of date", the second one is called the J2000 equator. The EclipticGeoMoon function returns the eclilptic longitude measured against the equator of date.

This may be a little confusing, but the idea is that the "equinox point" is the place in the sky where the Earth's equator intersects with the ecliptic (the plane of the Earth's orbit around the Sun). This happens in two places in the sky, so we conventionally choose the one where the Earth is at the March equinox. This March equinox point is always moving, and it was a different place on the ecliptic plane in 2000 than it is now in 2022.

So instead of calling EclipticGeoMoon, you might instead want to calculate the J2000 ecliptic longitude:

const vec = Astronomy.GeoMoon(node.time);   // J2000 equatorial vector

Then convert the vector to ecliptic coordinates the same way you did the planets. I'm not sure which way is better for what you are trying to do.

cosinekitty avatar Aug 07 '22 16:08 cosinekitty

I tried both methods you mentioned, "the equator of date" and "the J2000 equator". Both are giving approximate same value which I need. I match those values with some other authentic existing softwares, after deducting the ayanamsa value from my output.

The angular difference between the vernal equinoctial point and the sidereal zodiac is known as Ayanamsa. Many astronomers/astrologers have given their own ayanamsa value and calculation methods, which fall between 22 to 24 degrees. The most famous one which most softwares are using is Lahari Ayanamsa (given by N.C. Lahari). More about it here.

Lahari Ayanamsa is based on the Chitra star (Chitra "the bright one", a name of Spica).

Here is the ayanamsa calculator by different astronomers from one of those famous sites I use.

Is there any way to calculate this in the astronomy engine?

Now, the website I mentioned earlier which calculates the ecliptic longitudinal values of planets and lunar nodes uses swiss ephemeris, here is the code of the software/website

The SWISS EPHEMERIS is the high-precision ephemeris developed by Astrodienst, largely based upon the DExxx ephemerides from NASA's JPL. More about it here

The values from those softwares/websites and your code do have a slight difference of about 4-5 minutes, which makes a big difference in the Astro chart.

Can you explain why is it happening?

Please remember that the ayanamsa value should be deducted from the ecliptical longitude values of planets and lunar nodes to get the actual value. You can get the ayanamsa value from the calculator I have given above. Most software uses Lahari Ayanamsa.

Hope I made my point clear to you, please remember I am new to these astronomical terminologies, so please ignore my mistakes.

bizprat avatar Aug 07 '22 17:08 bizprat

This looks like it would be require too much time and research for me to understand Ayanamsa and related topics. I don't think this is something I want to take on as part of this project. However, I am willing to help explain astronomical concepts and answer questions about how my code can calculate specific things. In order to reach your goals in your project, you may need to take the time to study and digest the concepts more. I have found the most difficult parts are not the astrophysics itself, but the many different coordinate systems used to represent it. I will be happy to help you more with this part.

For example, it may be that you want to measure ecliptic longitudes of the Sun, Moon and planets with respect to the star Spica as a fixed point. I believe I could help with that. Or perhaps you want to take a different approach. I'm not sure. But I see my role as helping answer specific questions, rather than trying to research and solve the problem for you. In the long run you will be better served to understand the foundations of your project rather than being dependent on someone else.

Also, about the 4-5 minute discrepancy, part of that is that Astronomy Engine makes a deliberate trade of accuracy for speed and small code size. The goal is to calculate positions within 1 arcminute, which is a much larger angular error tolerance than NASA JPL ephemerides. (They can achieve nearly 2 milli-arcsecond precision!) The 1 arcminute tolerance is perfectly suited to a large number of common astronomy applications such as aiming a backyard telescope, but it is certainly not good enough for NASA missions or professional astronomy work.

cosinekitty avatar Aug 07 '22 19:08 cosinekitty

You are right I need to learn more about this.

I was just trying to explain some terminologies because I think, they can be calculated with your code, I am very close to it to get accurate values (just a difference of a few minutes), and thank you for this.

Could you please help me with these:

  1. Calculate the angle between North Celestial Pole & North Ecliptic Pole for a particular date? Reference Image
  2. Greenwich Apparent Sidereal Time & Greenwich Mean Sidereal Time
  3. Measure ecliptic longitudes of the Sun, Moon, and planets with respect to the star Spica as a fixed point

bizprat avatar Aug 08 '22 00:08 bizprat

Yes, definitely. What you are describing is called the "true obliquity of the ecliptic", in case you want to research it more. There is also a "mean obliquity" which only includes precession of the Earth's axis, not nutation. Precession is the long-term circular gyration that dominates the movement of the axis, whereas nutation is the smaller, short-term wobbling of the axis due to tidal forces from the Moon and Sun.

Here is one way to calculate the true obliquity angle. It works by converting the vector (0, 0, 1), which points to the north celestial pole in equator-of-date coordinates, into equatorial coordinates. The angle is then the inverse cosine of the resulting z-value.

function Obliquity(time) {
    // Vector that points to the north celestial pole in equator-of-date coordinates.
    const north = new Astronomy.Vector(0, 0, 1, time);

    // Rotation matrix that converts equator of date to ecliptic J2000.
    // This will give slightly different x- and y-coordinates than ecliptic of-date,
    // but the z-value will be the same, which is all we care about.
    const rot = Astronomy.Rotation_EQD_ECL(time);

    // Rotate the vector from equatorial to ecliptic.
    const eclip = Astronomy.RotateVector(rot, north);

    // The obliquity is the inverse cosine of the ecliptic z coordinate.
    const angle = Math.acos(eclip.z) * Astronomy.RAD2DEG;
    return angle;
}

I tested this for the current date and time (2022-08-08T00:56:28.854Z) and got the result: 23.440967942486672 degrees.

According to the Neoprogrammics obliquity calculator, the answer is 23.4380418828. This differs from my answer by about 0.176 arcminutes, which is well within my error tolerance. I can see that Neoprogrammics is using the exact same nutation model I do (called IAU 2000B), but their precession formula has more terms. I suspect their formula is slightly more accurate, but it takes about twice as long to calculate. You can see the above link for more details.

cosinekitty avatar Aug 08 '22 01:08 cosinekitty