jyotish-calc 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jyotish-calc",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Comprehensive Vedic Astrology library with Planet Positions, Dashas, Vargas (Divisional Charts), and Shadbala (Strengths)",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -222,13 +222,9 @@ function calculateD9(longitude) {
222
222
  startSign = 3; // Cancer (water)
223
223
  }
224
224
 
225
- // Position within the element's triplicity (0, 1, or 2)
226
- const posInTriplicity = Math.floor(signIndex / 4);
227
-
228
225
  // Calculate final navamsha sign
229
- // Each sign of same element continues from where previous left off
230
- const navamshaOffset = (posInTriplicity * 9) + divisionIndex;
231
- const resultSign = normalizeSign(startSign + navamshaOffset);
226
+ // For each element, the sequence starts from the same starting sign
227
+ const resultSign = normalizeSign(startSign + divisionIndex);
232
228
 
233
229
  return { signIndex: resultSign, degreeInSign, divisionIndex };
234
230
  }
@@ -0,0 +1,162 @@
1
+ /**
2
+ * Test script for Birth Chart: Sep 11, 1998, 4:30 AM, Chennai
3
+ */
4
+
5
+ const jyotish = require('./index');
6
+
7
+ // ============================================================================
8
+ // BIRTH DATA
9
+ // ============================================================================
10
+ const birthData = {
11
+ dateString: '1998-09-11', // YYYY-MM-DD
12
+ timeString: '04:30:00', // HH:MM:SS
13
+ lat: 13.0827,
14
+ lng: 80.2707,
15
+ timezone: 5.5
16
+ };
17
+
18
+ console.log('================================================================');
19
+ console.log(' BIRTH CHART ANALYSIS');
20
+ console.log('================================================================');
21
+ console.log(`Date: ${birthData.dateString}, ${birthData.timeString}`);
22
+ console.log(`Location: Chennai (${birthData.lat}° N, ${birthData.lng}° E)`);
23
+ console.log('----------------------------------------------------------------\n');
24
+
25
+ (async () => {
26
+ try {
27
+ // 1. Calculate Planetary Positions
28
+ console.log('Calculated Positions...');
29
+ const positions = jyotish.grahas.getGrahasPosition(birthData);
30
+
31
+ console.log('PLANETARY POSITIONS (D1 Rashi):');
32
+ console.log('-------------------------------');
33
+
34
+ const rashiNames = [
35
+ 'Aries', 'Taurus', 'Gemini', 'Cancer', 'Leo', 'Virgo',
36
+ 'Libra', 'Scorpio', 'Sagittarius', 'Capricorn', 'Aquarius', 'Pisces'
37
+ ];
38
+
39
+ const planetMap = {
40
+ 'Su': 'Sun', 'Mo': 'Moon', 'Ma': 'Mars', 'Me': 'Mercury',
41
+ 'Ju': 'Jupiter', 'Ve': 'Venus', 'Sa': 'Saturn', 'Ra': 'Rahu', 'Ke': 'Ketu',
42
+ 'La': 'Ascendant'
43
+ };
44
+
45
+ const shadbalaPositions = [];
46
+ const planetLongitudes = {};
47
+ const shadbalaOrder = ['Su', 'Mo', 'Ma', 'Me', 'Ju', 'Ve', 'Sa'];
48
+
49
+ // Process Ascendant
50
+ if (positions.La) {
51
+ const asc = positions.La;
52
+ const signIndex = Math.floor(asc.longitude / 30);
53
+ const degree = asc.longitude % 30;
54
+ console.log(`Ascendant : ${rashiNames[signIndex].padEnd(12)} ${degree.toFixed(2)}°`);
55
+ }
56
+
57
+ // Process Planets
58
+ shadbalaOrder.forEach(key => {
59
+ const p = positions[key];
60
+ const name = planetMap[key];
61
+ if (p) {
62
+ const signIndex = Math.floor(p.longitude / 30);
63
+ const degree = p.longitude % 30;
64
+
65
+ planetLongitudes[name] = p.longitude;
66
+ shadbalaPositions.push([signIndex, degree]);
67
+
68
+ console.log(`${name.padEnd(10)}: ${rashiNames[signIndex].padEnd(12)} ${degree.toFixed(2)}°`);
69
+ }
70
+ });
71
+
72
+ ['Ra', 'Ke'].forEach(key => {
73
+ if (positions[key]) {
74
+ const p = positions[key];
75
+ const name = planetMap[key];
76
+ const signIndex = Math.floor(p.longitude / 30);
77
+ const degree = p.longitude % 30;
78
+ planetLongitudes[name] = p.longitude;
79
+ console.log(`${name.padEnd(10)}: ${rashiNames[signIndex].padEnd(12)} ${degree.toFixed(2)}°`);
80
+ }
81
+ });
82
+
83
+ console.log('\n');
84
+
85
+ // 2. Navamsha (D9)
86
+ console.log('NAVAMSHA CHART (D9):');
87
+ console.log('--------------------');
88
+ try {
89
+ const d9Chart = jyotish.vargas.calculateVargaChart(planetLongitudes, 'D9', { abbrev: false });
90
+ shadbalaOrder.concat(['Ra', 'Ke']).forEach(key => {
91
+ const name = planetMap[key];
92
+ const val = d9Chart[name];
93
+ const display = (typeof val === 'object' && val.sign) ? val.sign : val;
94
+ console.log(`${name.padEnd(10)}: ${display}`);
95
+ });
96
+ } catch (e) {
97
+ console.log('Error calculating Navamsha:', e.message);
98
+ }
99
+ console.log('\n');
100
+
101
+ // 3. Current Dasha (Vimshottari)
102
+ console.log('CURRENT VIMSHOTTARI DASHA:');
103
+ console.log('--------------------------');
104
+ try {
105
+ const moonLong = positions.Mo.longitude;
106
+ const checkDateObj = new Date();
107
+ const birthDateObj = new Date(birthData.dateString);
108
+
109
+ const currentDasha = jyotish.dashas.vimshottari.getDashasForDate(birthDateObj, moonLong, checkDateObj);
110
+
111
+ const checkDateStr = checkDateObj.toISOString().split('T')[0];
112
+ console.log(`Current Date: ${checkDateStr}`);
113
+ // Use endDate instead of end
114
+ console.log(`Mahadasha: ${currentDasha.mahadasha.lord} (ends ${currentDasha.mahadasha.endDate ? new Date(currentDasha.mahadasha.endDate).toLocaleDateString() : 'N/A'})`);
115
+ console.log(`Antardasha: ${currentDasha.antardasha.lord} (ends ${currentDasha.antardasha.endDate ? new Date(currentDasha.antardasha.endDate).toLocaleDateString() : 'N/A'})`);
116
+ console.log(`Pratyantardasha: ${currentDasha.pratyantardasha.lord} (ends ${currentDasha.pratyantardasha.endDate ? new Date(currentDasha.pratyantardasha.endDate).toLocaleDateString() : 'N/A'})`);
117
+ } catch (e) {
118
+ console.log('Error calculating Dasha:', e.message);
119
+ }
120
+
121
+ // 4. Shadbala Strength
122
+ console.log('\nSHADBALA STRENGTHS:');
123
+ console.log('-------------------');
124
+ try {
125
+ const [year, month, date] = birthData.dateString.split('-').map(Number);
126
+ const [hour, min, sec] = birthData.timeString.split(':').map(Number);
127
+
128
+ const localHourDecimal = hour + min / 60;
129
+ const utHourDecimal = localHourDecimal - birthData.timezone;
130
+
131
+ const jdUT = jyotish.strengths.julianDayNumber(
132
+ [year, month, date],
133
+ [Math.floor(utHourDecimal), (utHourDecimal % 1) * 60, 0]
134
+ );
135
+
136
+ const ascSignIndex = positions.La ? Math.floor(positions.La.longitude / 30) : 0;
137
+
138
+ const strengths = jyotish.strengths.calculateShadbala(
139
+ shadbalaPositions,
140
+ ascSignIndex,
141
+ jdUT,
142
+ birthData.lat,
143
+ birthData.lng
144
+ );
145
+
146
+ console.log('Planet | Total (Virupas) | Ratio (Status)');
147
+ console.log('-----------|-----------------|---------------');
148
+ shadbalaOrder.forEach((key, i) => {
149
+ const name = planetMap[key];
150
+ const total = strengths.total[i].toFixed(1);
151
+ const ratio = strengths.strength[i].toFixed(2);
152
+ const status = strengths.strength[i] >= 1.0 ? 'Strong' : 'Weak';
153
+ console.log(`${name.padEnd(10)} | ${total.padStart(15)} | ${ratio} (${status})`);
154
+ });
155
+ } catch (e) {
156
+ console.log('Error calculating Strengths:', e.message);
157
+ }
158
+
159
+ } catch (err) {
160
+ console.error("Critical Error:", err);
161
+ }
162
+ })();