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

Added Sidereal Year System #28

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
967 changes: 967 additions & 0 deletions 1.json

Large diffs are not rendered by default.

66 changes: 63 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,25 @@ In UTC: `1993-08-06T20:50:00Z`

Then, you need to select the house system from the houses system table.. in this case for the placidus system you need to send the `P` value in the `houseSystem` query param.

For SideReal Year System You have to send `S` for Tropical `T` in the `yearSystem` query param.

also Send Ayanamsha value as per given below table suppose `"Lahiri" SE_SIDM_LAHIRI` ayanamsha
you want to used the add `1` as `ayanamsa` query param.

Now you can send this...

##### Using cURL

```bash
# escaped
curl --request GET \
--url 'http://localhost:3000/horoscope?time=1993-08-06T16%3A50%3A00-04%3A00&latitude=-33.41167&longitude=-70.66647&houseSystem=P'
--url 'http://localhost:3000/horoscope?time=1993-08-06T16%3A50%3A00-04%3A00&latitude=-33.41167&longitude=-70.66647&houseSystem=P&yearSystem=S&ayanamsa=1'
```

```bash
# in utc
curl --request GET \
--url 'http://localhost:3000/horoscope?time=1993-08-06T20:50:00Z&latitude=-33.41167&longitude=-70.66647&houseSystem=P'
--url 'http://localhost:3000/horoscope?time=1993-08-06T20:50:00Z&latitude=-33.41167&longitude=-70.66647&houseSystem=P&yearSystem=S&ayanamsa=1'
```


Expand Down Expand Up @@ -97,4 +102,59 @@ The values from each house system is extracted from sweph source code
| V | equal/Vehlow |
| W | equal/ whole sign |
| X | axial rotation system/Meridian houses |
| Y | APC houses |
| Y | APC houses |


### Ayanamsha Value table

The values from each Ayanamsha is extracted from sweph source code

| Ayanamsha Name | Ayanamsha value | Ayanamsha constant |
|--------------------- | ----------------- |--------------------
|"Fagan/Bradley”, | 0 | SE_SIDM_FAGAN_BRADLEY |
|"Lahiri”, | 1 | SE_SIDM_LAHIRI |
|"De Luce”, | 2 | SE_SIDM_DELUCE |
|"Raman”, | 3 | SE_SIDM_RAMAN |
|"Usha/Shashi”, | 4 | SE_SIDM_USHASHASHI |
|"Krishnamurti”, | 5 | SE_SIDM_KRISHNAMURTI
|"Djwhal Khul”, | 6 | SE_SIDM_DJWHAL_KHUL
|"Yukteshwar”, | 7 | SE_SIDM_YUKTESHWAR
"J.N. Bhasin”, | 8 | SE_SIDM_JN_BHASIN
"Babylonian/Kugler 1”, | 9 | SE_SIDM_BABYL_KUGLER1
"Babylonian/Kugler 2”, | 10 | SE_SIDM_BABYL_KUGLER2
"Babylonian/Kugler 3”, | 11 | SE_SIDM_BABYL_KUGLER3
"Babylonian/Huber”, | 12 | SE_SIDM_BABYL_HUBER
"Babylonian/Eta Piscium”, | 13 | SE_SIDM_BABYL_ETPSC
"Babylonian/Aldebaran = 15 Tau”, | 14 | SE_SIDM_ALDEBARAN_15TAU
"Hipparchos”, | 15 | SE_SIDM_HIPPARCHOS
"Sassanian”, | 16 | SE_SIDM_SASSANIAN
"Galact. Center = 0 Sag”, | 17 | SE_SIDM_GALCENT_0SAG
"J2000”, | 18 | SE_SIDM_J2000
"J1900”, | 19 | SE_SIDM_J1900
"B1950”, | 20 | SE_SIDM_B1950
"Suryasiddhanta”, | 21 | SE_SIDM_SURYASIDDHANTA
"Suryasiddhanta, mean Sun”, | 22 | SE_SIDM_SURYASIDDHANTA_MSUN
"Aryabhata”, | 23 | SE_SIDM_ARYABHATA
"Aryabhata, mean Sun”, | 24 | SE_SIDM_ARYABHATA_MSUN
"SS Revati”, | 25 | SE_SIDM_SS_REVATI
"SS Citra”, | 26 | SE_SIDM_SS_CITRA
"True Citra”, | 27 | SE_SIDM_TRUE_CITRA
"True Revati”, | 28 | SE_SIDM_TRUE_REVATI
"True Pushya (PVRN Rao) ”, | 29 | SE_SIDM_TRUE_PUSHYA
"Galactic Center (Gil Brand) ”, | 30 | SE_SIDM_GALCENT_RGBRAND
"Galactic Equator (IAU1958) ”, | 31 | SE_SIDM_GALEQU_IAU1958
"Galactic Equator”, | 32 | SE_SIDM_GALEQU_TRUE
"Galactic Equator mid-Mula”, | 33 | SE_SIDM_GALEQU_MULA
"Skydram (Mardyks) ”, | 34 | SE_SIDM_GALALIGN_MARDYKS
"True Mula (Chandra Hari) ”, | 35 | SE_SIDM_TRUE_MULA
"Dhruva/Gal.Center/Mula (Wilhelm) ”, | 36 | SE_SIDM_GALCENT_MULA_WILHELM
"Aryabhata 522”, | 37 | SE_SIDM_ARYABHATA_522
"Babylonian/Britton”, | 38 | SE_SIDM_BABYL_BRITTON
"\"Vedic\"/Sheoran | 39 | SE_SIDM_TRUE_SHEORAN
"Cochrane (Gal.Center = 0 Cap)" | 40 | SE_SIDM_GALCENT_COCHRANE
"Galactic Equator (Fiorenza)", | 41 | SE_SIDM_GALEQU_FIORENZA
"Vettius Valens", | 42 | SE_SIDM_VALENS_MOON
"Lahiri 1940", | 43 | SE_SIDM_LAHIRI_1940
"Lahiri VP285", | 44 | SE_SIDM_LAHIRI_VP285
"Krishnamurti-Senthilathiban", | 45 | SE_SIDM_KRISHNAMURTI_VP291
"Lahiri ICRC", | 46 | SE_SIDM_LAHIRI_ICRC
101 changes: 99 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"express-promise-router": "^3.0.3",
"helmet": "^3.21.3",
"morgan": "^1.9.1",
"node-geocoder": "^4.2.0",
"sweph": "^2.10.0-5"
}
}
4 changes: 2 additions & 2 deletions src/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ router.get('/', async (req, res) => res.status(200).json({ message: 'Welcome to

router.get('/horoscope', async (req, res) => {
const date = new Date(req.query.time)
const { latitude, longitude, houseSystem } = req.query
const { latitude, longitude, houseSystem, yearSystem, ayanamsa } = req.query

const chart = astrologer.natalChart(date, latitude, longitude, houseSystem)
const chart = astrologer.natalChart(date, latitude, longitude, houseSystem, yearSystem, ayanamsa)

res.status(200).json({
data: chart
Expand Down
54 changes: 41 additions & 13 deletions src/astrologer/astros.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
const sweph = require('sweph')
const { utcToJulianEt, zodiacSign, degreesToDms } = require('./utils')
const { utcToJulianEt, zodiacSign, degreesToDms, nakshatra } = require('./utils')
const path = require('path')

sweph.set_ephe_path(path.join(__dirname, '/../../eph'))

var yearSystem
var ayanamsha
const {
SE_SUN,
SE_MOON,
Expand All @@ -21,9 +20,14 @@ const {
SE_CHIRON,
SE_CERES,
SE_PALLAS,
SEFLG_SIDEREAL,
SEFLG_SPEED,
SEFLG_SWIEPH,
SEFLG_SPEED
} = sweph.constants
SE_MEAN_NODE
} = require('./swephConstants')

sweph.set_ephe_path(path.join(__dirname, '/../../eph'))


const PLANETS = {
sun: SE_SUN,
Expand All @@ -41,7 +45,9 @@ const PLANETS = {
ceres: SE_CERES,
vesta: SE_VESTA,
pallas: SE_PALLAS,
juno: SE_JUNO
juno: SE_JUNO,
rahu: SE_MEAN_NODE,
ketu: SE_MEAN_NODE
}

const planetsByType = {
Expand All @@ -60,19 +66,37 @@ const planetsByType = {
ceres: 'other',
vesta: 'other',
pallas: 'other',
juno: 'other'
juno: 'other',
rahu: 'personal', // Lunar North Node
ketu: 'personal' // Lunar South Node
}

const FLAG = SEFLG_SPEED | SEFLG_SWIEPH
var FLAG = SEFLG_SPEED | SEFLG_SWIEPH

const getPositionOfAstro = (astro, julianDay) => sweph.calc(julianDay, PLANETS[astro], FLAG)

const getPositionOfAstro = (astro, julianDay) =>
{
// Condition For SideReal Chart Positions
// setting ayanamsha and sidereal flag
if (yearSystem == 'S') {
sweph.set_sid_mode(Number(ayanamsha), 0, 0)
FLAG = SEFLG_SIDEREAL
}
return sweph.calc(julianDay, PLANETS[astro], FLAG)
}

const isRetrograde = (speed) => speed < 0

const position = (astrologyObject, moment) => {
const julianDay = utcToJulianEt(moment)
const { data } = getPositionOfAstro(astrologyObject, julianDay)
const longitude = data[0]
var longitude = data[0]

//To calculate South Node (Ketu) opposite to North Node
if(astrologyObject == 'ketu') {
longitude = ( longitude + 180 ) % 360
}

const speed = data[3]
const dms = degreesToDms(longitude)
const retrograde = isRetrograde(speed)
Expand All @@ -84,11 +108,15 @@ const position = (astrologyObject, moment) => {
},
speed,
retrograde,
sign: zodiacSign(longitude)
sign: zodiacSign(longitude),
nakshatra: nakshatra(longitude),
}
}

const planets = (date) => {
const planets = (date, yearSystemValue, aynamshaValue) => {
// sets the YearSystem and Ayanamsha values
yearSystem = yearSystemValue
ayanamsha = aynamshaValue
return Object.keys(PLANETS)
.reduce(
(accumulator, name) => {
Expand Down
Loading