Closed nodeperson closed 2 years ago
Hi nodeperson, sweph
is a simple wrapper for the swiss ephemeris library created by astro.com / astrodienst, so in order to learn how to use it, you should refer to their official documentations found here:
https://www.astro.com/swisseph/swisseph.htm
https://www.astro.com/swisseph/swephprg.htm
From the above documentation, the steps would be like this:
set_ephe_path
function to point the library to the correct folder (example the file sepl_18.se1
is valid for all major planets from year 1800 to 2400)utc_to_jd
to convert the birth time into a "julian day" number. this function gives you two numbers, one for UT and one for ETcalc
functions once for each planet you wish to calculatehouses
functions with the UT number to calculate the housesexample in code using this library:
const { set_ephe_path, utc_to_jd, calc, houses } = require("sweph");
set_ephe_path("./ephemeris"); // folder where the downloaded ephemeris files are
// get JD values from a UTC/GMT-0 date
const JD = utc_to_jd(2005, 11, 15, 13, 45, 0, 1) // year, month, day, hour, minute, second, calendar system (1 = gregorian calendar, valid for all dates after year 1582)
const JDET = JD[0]; // for use in calc functions
const JDUT = JD[1]; // for use in calc_ut functions and houses functions
const planets = [0,1,2,3,4,5,6,7,8,9] // planet IDs, 0 = sun, 1 = moon, 2 = mercury, etc...
for(const planetID of planets) {
// calculate each planet individually
const calculated = calc(JDET, planetID, 2); // third parameter contains the calculation options, 2 = default options
console.log(`logging planet ${planetID}`, calculated);
}
// coordinates must be in decimal degrees
const latitude = 53.2352; // approx 53º10N
const longitude = -145.235; // approx 145º10W
const result = houses(JDUT, latitude, longitude, "P"); // P = placidus house system
console.log("logging houses:", result);
The results from the calc and houses functions return values in "celestial longitude" by default. To convert those into astrological signs, you must divide it in 12 parts of 30 degrees. For example if a planet's longitude is 124.2352 that means, from 0-30 is aries, from 30-60 is taurus, from 60-90 is gemini, from 90-120 is cancer, from 120-150 is leo, that planet is at 4.2353 degrees of leo.
Thats basically the extent of what i can help you with on here, you must figure out timezones, coordinates and graphics by yourself, i can only help you with understanding the technicalities of the raw ephemeris data here.
To create something like a graphical chart, you will need a drawing system like canvas or svg and knowledge of trigonometry to perform the necessary graphical calculations, for example drawing a circle and then drawing a point at X degrees of the circle, etc...
You might also want to take a look at this: https://github.com/milanpredic/astrochart instead of reinventing the wheel.
Excellent! Thank you!
You might also want to take a look at this: https://github.com/milanpredic/astrochart instead of reinventing the wheel.
Do you know of any other libraries like this one that are simple to use just for astrological charts, the one you pointed out won't install for me
Hello! It would be great if you could give us a little simple example of how we - newbies - can use your library to build a little simple astrological chart. Anyway, thanks for your efforts!