Coder Social home page Coder Social logo

Comments (8)

timotejroiko avatar timotejroiko commented on May 29, 2024 1

hmmm, i'm not understanding the round trip you're doing with the house position, is there any reason for that?

I tested it here like this and i got the correct result:

...
const JD = utc_to_jd(utcDate.year, utcDate.month, utcDate.day, utcDate.hour, utcDate.minute, utcDate.second, constants.SE_GREG_CAL);
const [ JDET, JDUT ] = JD.data; // [ 2443609.9582081484, 2443609.95764303 ]

const calcs = calc_ut(JDUT, planet_id, constants.SEFLG_SWIEPH); // there is no SEFLG_TROPICAL, tropical is default
const deg = calcs.data[0]; // 258.19397969291236
const SPLITTED_POS = split_deg(deg, constants.SE_SPLIT_DEG_ROUND_SEC + constants.SE_SPLIT_DEG_ZODIACAL);

console.log(SPLITTED_POS) // { degree: 18, minute: 11, second: 38, fraction: 0, sign: 8 }

from sweph.

timotejroiko avatar timotejroiko commented on May 29, 2024 1

you need the SPEED flag to return speeds:

const calcs = calc_ut(JDUT, planet_id, constants.SEFLG_SWIEPH + constants.SEFLG_SPEED);

from sweph.

mephitrpg avatar mephitrpg commented on May 29, 2024 1

works like a charm! thank you

from sweph.

timotejroiko avatar timotejroiko commented on May 29, 2024 1

hi @Hrsikesa108 , there should an example on how to get the positions of planets and houses in the beginning of index.d.ts, which you can also access by hovering the main sweph export when you import the library.

if you need further assistance, kindly open a new issue, i'm gonna go ahead and close this one.

from sweph.

timotejroiko avatar timotejroiko commented on May 29, 2024

Hi, could you please double check your Astro.com input?

The position 16 degrees 6 minutes does not seem correct for Neptune for that date.

from sweph.

mephitrpg avatar mephitrpg commented on May 29, 2024

you're right, I updated the script with the correct Astro.com result, however the results remain different.

from sweph.

mephitrpg avatar mephitrpg commented on May 29, 2024

You're right, I was unnecessarily complicating the issue! Thanks!
But why the retrograde result is still false instead of true?
PS: the calcs.flag is still 2

const sweph = require('sweph');
const luxon = require('luxon');

const { constants, utc_to_jd, houses, house_pos, calc, calc_ut, split_deg } = sweph;
const { DateTime } = luxon;

sweph.set_ephe_path('ephe');

const planet_name = 'Neptune'
const planet_id = constants.SE_NEPTUNE;

const params = {
    year: 1978,
    month: 4,
    day: 11,
    hours: 11,
    minutes: 59,
    zone:  'Europe/Rome',
    // Camposampiero, ITALY, 45n34 11e56
    lat:  45.566667,
    lon: 11.933333
}

const localDate = DateTime.local(params.year, params.month, params.day, params.hours, params.minutes, { zone: params.zone });
const utcDate = localDate.toUTC();

const JD = utc_to_jd(utcDate.year, utcDate.month, utcDate.day, utcDate.hour, utcDate.minute, utcDate.second, constants.SE_GREG_CAL);
if (JD.flag !== constants.OK) { throw new Error(JD.error); }
const [ JDET, JDUT ] = JD.data;

const HOUSES = houses(JDUT, Number(params.lat), Number(params.lon), 'P');
if (HOUSES.flag !== constants.OK) { throw new Error(HOUSES.flag); }
const armc = HOUSES.data.points[2];

const ECLIPTIC = calc_ut(JDUT, constants.SE_ECL_NUT, 0);
const eps = ECLIPTIC.data[0];

const calcs = calc_ut(JDUT, planet_id, constants.SEFLG_SWIEPH);
// if (calcs.flag !== constants.OK) { throw new Error(JSON.stringify(calcs)); }
const deg = calcs.data[0]; // 258.19397969291236
const xpin = calcs.data.slice(0, 2);

let retrograde;
switch (planet_id) {
    case constants.SE_SUN:
    case constants.SE_MOON:
        retrograde = "Not applicable";
        break;
    case constants.SE_TRUE_NODE:
        retrograde = "Always";
        break;
    default:
        retrograde = (planet_id > 12) ? "Not a planet" : (calcs[3] < 0);
        break;
}

const HOUSE_POS = house_pos(armc, params.lat, eps, 'P', xpin);

const SPLITTED_POS = split_deg(deg, constants.SE_SPLIT_DEG_ROUND_SEC + constants.SE_SPLIT_DEG_ZODIACAL);

console.log(``);
console.log(`Planet: ${planet_name}`);
console.log(``);
console.log(`SCRIPT RESULT`);
console.log(`sweph.calc pos = ${deg}`);
console.log(`sweph.split_deg = ${JSON.stringify(SPLITTED_POS)}`);
console.log(`Retrograde = ${retrograde}`);
console.log(`sweph.house_pos num = ${Math.floor(HOUSE_POS.data)}`);
console.log(``);
console.log(`ASTRO.COM BIRTCHART RESULT`);
console.log(`deg = {"degree":18,"minute":11,"second":38,"fraction":0,"sign":8}`);
console.log(`Retrograde = true`);
console.log(``);

from sweph.

Hrsikesa108 avatar Hrsikesa108 commented on May 29, 2024

Hi timotejroiko sir,
can you give some guidelines how to run this program locally in node and get planetary details in json ?
i found my intrest in learning astrology and was searching in github repos your repo i found and felt lucky.

Thanks sir

from sweph.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.