### Install Panchangam Source: https://context7.com/fusionstrings/panchangam/llms.txt Commands to install the library via Deno or NPM. ```bash # Deno deno add jsr:@fusionstrings/panchangam # Node.js / Bun npm install @fusionstrings/panchangam ``` -------------------------------- ### Run Library Examples Source: https://github.com/fusionstrings/panchangam/blob/creation/README.md Commands to execute the provided demonstration scripts. ```bash # Basic Features (Daily Panchang, Planets, etc.) deno run -A examples/demo.ts # Advanced Features (Vargas, Shadbala, Jaimini) deno run -A examples/demo_advanced.ts # Ashtakavarga & Special Points deno run -A examples/demo_ashtakavarga.ts ``` -------------------------------- ### Installation Source: https://context7.com/fusionstrings/panchangam/llms.txt Install the Panchangam library using JSR for Deno or NPM for Node.js/Bun. ```bash # Deno denp add jsr:@fusionstrings/panchangam # Node.js / Bun npm install @fusionstrings/panchangam ``` -------------------------------- ### Install Panchangam with npm Source: https://github.com/fusionstrings/panchangam/blob/creation/README.md Install the Panchangam library for Node.js or Bun projects using npm. ```bash npm install @fusionstrings/panchangam ``` -------------------------------- ### Install Panchangam with Deno Source: https://github.com/fusionstrings/panchangam/blob/creation/README.md Add the Panchangam library to your Deno project using the JSR package manager. ```bash deno add jsr:@fusionstrings/panchangam ``` -------------------------------- ### Calculate Planetary Positions and Dignity Source: https://github.com/fusionstrings/panchangam/blob/creation/README.md Get precise sidereal positions, dignity status, and speed for all planets on a given Julian day. Requires the p_julday function to convert date/time to Julian Day and specify the Ayanamsa mode (1 for Lahiri). ```typescript import { calculate_planets, p_julday } from "@fusionstrings/panchangam"; // Julian Day for calculation const jd = p_julday(2024, 1, 1, 12.0, 1); // Noon UT // Calculate Sidereal positions (Mode 1 = Lahiri) const planets = calculate_planets(jd, 1); planets.forEach((p) => { console.log(`${p.name}: ${p.longitude.toFixed(2)}°`); console.log(` Dignity: ${p.dignity}`); // Exalted, Own Sign, Friend, etc. console.log(` Speed: ${p.speed.toFixed(4)}/day`); if (p.is_retrograde) console.log(" [Retrograde]"); }); ``` -------------------------------- ### Build Project from Source Source: https://github.com/fusionstrings/panchangam/blob/creation/README.md Commands to build the library from source using Deno. ```bash deno task build ``` -------------------------------- ### Run Verification Tests Source: https://github.com/fusionstrings/panchangam/blob/creation/README.md Command to execute the library's test suite. ```bash deno task test ``` -------------------------------- ### Initialize Location Source: https://context7.com/fusionstrings/panchangam/llms.txt Create a geographic location instance with latitude, longitude, and altitude for astronomical calculations. ```typescript import { Location } from "@fusionstrings/panchangam"; // New Delhi: 28.6139°N, 77.209°E, 225m elevation const delhi = new Location(28.6139, 77.2090, 225.0); // Bangalore: 12.9716°N, 77.5946°E, 920m elevation const bangalore = new Location(12.9716, 77.5946, 920.0); // Access properties console.log(delhi.latitude); // 28.6139 console.log(delhi.longitude); // 77.209 console.log(delhi.altitude); // 225.0 ``` -------------------------------- ### Identify active Yogas in a chart Source: https://context7.com/fusionstrings/panchangam/llms.txt Uses planetary and house data to determine active planetary combinations. Requires pre-calculated planet and house objects. ```typescript import { find_active_yogas, calculate_planets, calculate_houses, p_julday } from "@fusionstrings/panchangam"; const jd = p_julday(1990, 1, 1, 12.0, 1); const planets = calculate_planets(jd, 1); const houses = calculate_houses(jd, 28.6139, 77.2090, "W", 1); // Parameters: (planets, ascendant) const yogas = find_active_yogas(planets, houses.ascendant); console.log(`Found ${yogas.length} active Yogas:`); yogas.forEach((yoga) => { console.log(`\n${yoga.name}`); console.log(` Category: ${yoga.category}`); console.log(` Description: ${yoga.description}`); console.log(` Involved Planets: ${yoga.involved_planets.join(", ")}`); }); ``` -------------------------------- ### Initialize Live Terminal Component Source: https://github.com/fusionstrings/panchangam/blob/creation/index.html Defines a custom HTML element 'live-terminal' that integrates the Panchangam engine. It handles user input, command execution, and output display within a terminal-like interface. Requires the 'panchangam' module to be imported. ```javascript import * as panchangam from "panchangam"; class LiveTerminal extends HTMLElement { constructor() { super(); this.history = []; } connectedCallback() { const root = this.shadowRoot; const input = root.getElementById("input"); const output = root.getElementById("output"); input.addEventListener("keydown", async (e) => { if (e.key === "Enter") { const cmd = input.value.trim(); if (cmd) { input.value = ""; await this.executeCommand(cmd, output); } } }); // Auto-focus input on click anywhere in terminal this.addEventListener("click", () => input.focus()); // WASM is already initialized in the inline build this.appendOutput("✅ WASM Module Initialized", "system"); this.appendOutput( `Engine: Swiss Ephemeris v${panchangam.get_swisseph_version()}`, "system", ); } appendOutput(text, type = "normal") { const output = this.shadowRoot.getElementById("output"); const div = document.createElement("div"); div.className = "cmd-output"; if (type === "system") div.style.color = "#7c7c8c"; div.innerHTML = text.replace(/\n/g, "
"); output.appendChild(div); output.scrollTop = output.scrollHeight; } async executeCommand(cmd, output) { const echo = document.createElement("div"); echo.className = "cmd-echo"; echo.textContent = `❯ ${cmd}`; output.appendChild(echo); try { const result = await this.processCommand(cmd); this.appendOutput(result); } catch (err) { this.appendOutput(`❌ Error: ${err.message}`, "error"); } } async processCommand(cmd) { const [action, ...args] = cmd.split(" "); switch (action.toLowerCase()) { case "help": return `Available commands: - version: Show library versions - sunrise [lat] [lon]: Calculate sunrise for Ayodhya (default) - tithi: Calculate current Tithi - clear: Clear terminal`; case "version": return `Panchangam: ${panchangam.get_version()} Swiss Ephemeris: ${panchangam.get_swisseph_version()}`; case "tithi": const jd = 2460331.791065; // Mocking JD for demo const tithi = panchangam.calculate_tithi(jd); const res = `Tithi: ${tithi.name} (${tithi.paksha_name} Paksha) Completion: ${(tithi.completion * 100).toFixed(1)}%`; tithi.free(); return res; case "sunrise": const loc = new panchangam.Location(26.7922, 82.1998, 0); const sr = panchangam.calculate_sunrise(2024, 1, 22, loc); const date = new Date(sr).toLocaleString(); loc.free(); return `Sunrise in Ayodhya: ${date}`; case "clear": this.shadowRoot.getElementById("output").innerHTML = ""; return "Terminal cleared."; default: return `Unknown command: ${action}. Type 'help' for assistance.`; } } } customElements.define("live-terminal", LiveTerminal); ``` -------------------------------- ### calculate_prastara_ashtakavarga Source: https://context7.com/fusionstrings/panchangam/llms.txt Calculates the detailed Prastara (contribution grid) for a specific planet's Ashtakavarga. ```APIDOC ## calculate_prastara_ashtakavarga ### Description Calculates the detailed Prastara (contribution grid) for a specific planet's Ashtakavarga. ### Method Not specified (likely a function call within a library) ### Endpoint N/A (Library function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```typescript import { calculate_prastara_ashtakavarga, calculate_planets, calculate_houses, p_julday } from "@fusionstrings/panchangam"; const jd = p_julday(2024, 1, 15, 5.0, 1); const lat = 28.6139, lon = 77.2090; const planets = calculate_planets(jd, 1); const houses = calculate_houses(jd, lat, lon, "W", 1); // Parameters: (planet_id, planets, ascendant) // Planet IDs: 0=Sun, 1=Moon, 2=Mercury, 3=Venus, 4=Mars, 5=Jupiter, 6=Saturn const prastara = calculate_prastara_ashtakavarga(0, planets, houses.ascendant); // Grid is 8 rows (contributors) x 12 signs = 96 elements console.log(`Prastara Grid for Sun (${prastara.grid.length} elements)`); console.log("Row 0 (Sun's contribution):", prastara.grid.slice(0, 12)); console.log("Row 1 (Moon's contribution):", prastara.grid.slice(12, 24)); ``` ### Response #### Success Response (200) - **grid** (Array) - A 2D array representing the Prastara grid. #### Response Example ```json { "grid": [ [0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], // ... more rows and columns ] } ``` ``` -------------------------------- ### calculate_sunrise / calculate_sunset Source: https://context7.com/fusionstrings/panchangam/llms.txt Calculates precise sunrise and sunset times. ```APIDOC ## calculate_sunrise / calculate_sunset ### Description Calculates precise sunrise and sunset times accounting for atmospheric refraction and elevation. ### Parameters - **year** (number) - Required - The year. - **month** (number) - Required - The month (1-12). - **day** (number) - Required - The day of the month. - **location** (Location object) - Required - An object with latitude, longitude, and elevation. ### Returns - (number) - Unix timestamp in milliseconds for sunrise or sunset. ### Example ```typescript import { calculate_sunrise, calculate_sunset, Location } from "@fusionstrings/panchangam"; const loc = new Location(28.6139, 77.2090, 225.0); // New Delhi with elevation const sunrise_ms = calculate_sunrise(2024, 1, 1, loc); const sunset_ms = calculate_sunset(2024, 1, 1, loc); console.log(`Sunrise: ${new Date(sunrise_ms).toISOString()}`); console.log(`Sunset: ${new Date(sunset_ms).toISOString()}`); // Calculate day duration const day_length_hours = (sunset_ms - sunrise_ms) / 3600000; console.log(`Day Length: ${day_length_hours.toFixed(2)} hours`); ``` ``` -------------------------------- ### Retrieve library and Swiss Ephemeris versions Source: https://context7.com/fusionstrings/panchangam/llms.txt Displays the current version of the Panchangam library and the underlying Swiss Ephemeris engine. ```typescript import { get_version, get_swisseph_version } from "@fusionstrings/panchangam"; console.log(`Panchangam Version: ${get_version()}`); console.log(`Swiss Ephemeris Version: ${get_swisseph_version()}`); // Output: // Panchangam Version: 0.2.1 // Swiss Ephemeris Version: 2.10.03 ``` -------------------------------- ### Calculate Reduced Ashtakavarga and Shodya Pinda Source: https://context7.com/fusionstrings/panchangam/llms.txt Performs Ashtakavarga reductions (Trikona and Ekadhipatya Shodhana) and calculates Shodya Pinda. Requires the SAV totals and planet tuples. ```typescript import { calculate_ashtakavarga, calculate_reduced_ashtakavarga, calculate_planets, calculate_houses, p_julday } from "@fusionstrings/panchangam"; const jd = p_julday(2024, 1, 15, 5.0, 1); const lat = 28.6139, lon = 77.2090; const planets = calculate_planets(jd, 1); const houses = calculate_houses(jd, lat, lon, "W", 1); const sav = calculate_ashtakavarga(planets, houses.ascendant); // Create planet tuples [id, longitude] const planet_tuples = planets.map((p) => [p.id, p.longitude]); // Parameters: (bindus_array, planet_tuples) const reduced = calculate_reduced_ashtakavarga(sav.totals, planet_tuples); console.log("Reduced Bindus:", reduced.reduced_bindus); console.log("Shodya Pinda:", reduced.shodaya_pinda); ``` -------------------------------- ### Run Panchangam Browser Integration Test Source: https://github.com/fusionstrings/panchangam/blob/creation/tests/browser_test.html Executes a daily panchang calculation and displays the results in the DOM. Requires the panchangam library to be available in the project path. ```javascript import { calculate_daily_panchang, get_swisseph_version, Location, } from "./lib/browser/panchangam.js"; try { const loc = new Location(12.97, 77.59, 920); const result = calculate_daily_panchang(2026, 1, 5, loc, 1); const version = get_swisseph_version(); const output = document.getElementById("output"); output.innerHTML = `

Success!

`; console.log("Test Passed", result); } catch (e) { const output = document.getElementById("output"); output.innerHTML = `

Failed! ${e.message}

`; console.error(e); } ``` -------------------------------- ### get_version / get_swisseph_version Source: https://context7.com/fusionstrings/panchangam/llms.txt Retrieves the current library version and the underlying Swiss Ephemeris version. ```APIDOC ## get_version / get_swisseph_version ### Description Returns the version strings for the library and the integrated Swiss Ephemeris engine. ### Response - **version** (string) - The current version of the @fusionstrings/panchangam library. - **swisseph_version** (string) - The version of the underlying Swiss Ephemeris. ``` -------------------------------- ### p_calc_ut Source: https://context7.com/fusionstrings/panchangam/llms.txt Low-level wrapper for calculating raw tropical planetary positions using Swiss Ephemeris. ```APIDOC ## p_calc_ut ### Description Calculates raw planetary positions (tropical) for a given Julian Day. ### Parameters - **julian_day** (number) - Required - The Julian Day number. - **planet_id** (number) - Required - The ID of the planet (0=Sun, 1=Moon, etc.). - **flags** (number) - Required - Swiss Ephemeris calculation flags (e.g., 256 for speed). ### Response - **longitude** (number) - The planetary longitude. - **latitude** (number) - The planetary latitude. - **distance** (number) - The distance in AU. - **speed_long** (number) - The longitudinal speed in degrees per day. ``` -------------------------------- ### calculate_yogini Source: https://context7.com/fusionstrings/panchangam/llms.txt Calculates Yogini Dasha, an alternative planetary period system. ```APIDOC ## calculate_yogini ### Description Calculates Yogini Dasha, an alternative planetary period system. ### Parameters - **birth_moon_longitude** (number) - Required - The sidereal longitude of the Moon at birth. - **birth_time_ms** (number) - Required - The birth time as a Unix timestamp in milliseconds. - **current_time_ms** (number) - Required - The current time as a Unix timestamp in milliseconds. ### Returns - (Object) - An object containing the current Yogini Dasha and sub-period names. ### Example ```typescript import { calculate_yogini } from "@fusionstrings/panchangam"; const birth_moon_longitude = 45.5; const birth_time_ms = new Date("1990-01-01T06:00:00Z").getTime(); const current_time_ms = Date.now(); const yogini = calculate_yogini(birth_moon_longitude, birth_time_ms, current_time_ms); console.log(`Current Yogini: ${yogini.yogini_name}`); console.log(`Sub-Period: ${yogini.sub_yogini_name}`); ``` ``` -------------------------------- ### Calculate Sunrise and Sunset Times Source: https://context7.com/fusionstrings/panchangam/llms.txt The `calculate_sunrise` and `calculate_sunset` functions provide precise times for these events, considering atmospheric refraction and elevation. They return Unix timestamps in milliseconds. ```typescript import { calculate_sunrise, calculate_sunset, Location } from "@fusionstrings/panchangam"; const loc = new Location(28.6139, 77.2090, 225.0); // New Delhi // Parameters: (year, month, day, location) // Returns: Unix timestamp in milliseconds const sunrise_ms = calculate_sunrise(2024, 1, 1, loc); const sunset_ms = calculate_sunset(2024, 1, 1, loc); console.log(`Sunrise: ${new Date(sunrise_ms).toISOString()}`); console.log(`Sunset: ${new Date(sunset_ms).toISOString()}`); // Calculate day duration const day_length_hours = (sunset_ms - sunrise_ms) / 3600000; console.log(`Day Length: ${day_length_hours.toFixed(2)} hours`); ``` -------------------------------- ### calculate_houses Source: https://context7.com/fusionstrings/panchangam/llms.txt Calculates house cusps, Ascendant, and Midheaven using various house systems. ```APIDOC ## calculate_houses ### Description Calculates the Ascendant (Lagna), Midheaven (MC), and all 12 house cusps using various house systems. ### Parameters - **jd** (number) - Required - The Julian Day number. - **latitude** (number) - Required - The latitude of the location. - **longitude** (number) - Required - The longitude of the location. - **house_system** (string) - Required - The house system to use ('P'=Placidus, 'W'=Whole Sign, 'E'=Equal, 'K'=Koch). - **ayanamsha_mode** (number) - Required - The Ayanamsha mode (e.g., 1=Lahiri, -1=Tropical). ### Returns - (Object) - An object containing the Ascendant, MC, and an array of house cusps. ### Example ```typescript import { calculate_houses, Location, p_julday } from "@fusionstrings/panchangam"; const jd = p_julday(2024, 1, 1, 12.0, 1); const loc = new Location(28.6139, 77.2090, 0.0); // Example location (New Delhi) // Whole Sign houses with Lahiri Ayanamsha const houses = calculate_houses(jd, loc.latitude, loc.longitude, "W", 1); console.log(`Ascendant (Lagna): ${houses.ascendant.toFixed(2)}°`); console.log(`Midheaven (MC): ${houses.mc.toFixed(2)}°`); houses.cusps.forEach((cusp, i) => { console.log(`House ${(i + 1).toString().padStart(2)}: ${cusp.toFixed(2)}°`); }); ``` ``` -------------------------------- ### Calculate Prastara Ashtakavarga Source: https://context7.com/fusionstrings/panchangam/llms.txt Computes the contribution grid for a planet's Ashtakavarga. The resulting grid contains 96 elements representing 8 contributors across 12 signs. ```typescript import { calculate_prastara_ashtakavarga, calculate_planets, calculate_houses, p_julday } from "@fusionstrings/panchangam"; const jd = p_julday(2024, 1, 15, 5.0, 1); const lat = 28.6139, lon = 77.2090; const planets = calculate_planets(jd, 1); const houses = calculate_houses(jd, lat, lon, "W", 1); // Parameters: (planet_id, planets, ascendant) // Planet IDs: 0=Sun, 1=Moon, 2=Mercury, 3=Venus, 4=Mars, 5=Jupiter, 6=Saturn const prastara = calculate_prastara_ashtakavarga(0, planets, houses.ascendant); // Grid is 8 rows (contributors) x 12 signs = 96 elements console.log(`Prastara Grid for Sun (${prastara.grid.length} elements)`); console.log("Row 0 (Sun's contribution):", prastara.grid.slice(0, 12)); console.log("Row 1 (Moon's contribution):", prastara.grid.slice(12, 24)); ``` -------------------------------- ### calculate_reduced_ashtakavarga Source: https://context7.com/fusionstrings/panchangam/llms.txt Calculates Ashtakavarga reductions (Trikona and Ekadhipatya Shodhana) and Shodya Pinda. ```APIDOC ## calculate_reduced_ashtakavarga ### Description Calculates Ashtakavarga reductions (Trikona and Ekadhipatya Shodhana) and Shodya Pinda. ### Parameters - **bindus_array** (Array) - Required - Array of bindu totals. - **planet_tuples** (Array) - Required - Array of [id, longitude] tuples. ``` -------------------------------- ### Calculate Yogini Dasha Source: https://context7.com/fusionstrings/panchangam/llms.txt Calculate the Yogini Dasha, an alternative planetary period system, using the `calculate_yogini` function. Similar to Vimshottari, it uses Moon's longitude and birth/current times. ```typescript import { calculate_yogini } from "@fusionstrings/panchangam"; const birth_moon_longitude = 45.5; const birth_time_ms = new Date("1990-01-01T06:00:00Z").getTime(); const current_time_ms = Date.now(); const yogini = calculate_yogini(birth_moon_longitude, birth_time_ms, current_time_ms); console.log(`Current Yogini: ${yogini.yogini_name}`); console.log(`Sub-Period: ${yogini.sub_yogini_name}`); ``` -------------------------------- ### calculate_planets Source: https://context7.com/fusionstrings/panchangam/llms.txt Calculates sidereal planetary positions for Vedic astrology. ```APIDOC ## calculate_planets ### Description Calculates sidereal planetary positions for all 9 Vedic planets (Sun through Ketu) including longitude, latitude, speed, retrograde status, and dignity. ### Parameters - **julian_day** (number) - Required - The Julian Day number obtained from `p_julday`. - **ayanamsha_mode** (number) - Required - The mode for Ayanamsha calculation (e.g., 1 for Lahiri). ### Returns - (Array) - An array of planet objects, each containing name, longitude, latitude, speed, retrograde status, rashi name, and dignity. ### Example ```typescript import { calculate_planets, p_julday } from "@fusionstrings/panchangam"; const jd = p_julday(2024, 1, 1, 12.0, 1); // Noon UT const planets = calculate_planets(jd, 1); // 1 = Lahiri Ayanamsha planets.forEach((p) => { console.log(`${p.name.padEnd(8)}: ${p.longitude.toFixed(2)}°`); console.log(` Rashi: ${p.rashi_name}`); console.log(` Dignity: ${p.dignity}`); // Exalted, Own Sign, Friend, Enemy, etc. console.log(` Speed: ${p.speed.toFixed(4)}°/day`); if (p.is_retrograde) { console.log(" [RETROGRADE]"); } }); ``` ``` -------------------------------- ### calculate_vimshottari Source: https://context7.com/fusionstrings/panchangam/llms.txt Calculates the current Vimshottari Dasha (planetary period system). ```APIDOC ## calculate_vimshottari ### Description Calculates the current Vimshottari Dasha (planetary period system) based on Moon's natal position. ### Parameters - **moon_longitude** (number) - Required - The sidereal longitude of the Moon at birth. - **birth_time_ms** (number) - Required - The birth time as a Unix timestamp in milliseconds. - **current_time_ms** (number) - Required - The current time as a Unix timestamp in milliseconds. ### Returns - (Object) - An object containing current Mahadasha, Antardasha, Pratyantardasha, and their end dates. ### Example ```typescript import { calculate_vimshottari } from "@fusionstrings/panchangam"; const birth_moon_longitude = 45.5; // Moon at 45.5° sidereal const birth_time_ms = new Date("1990-01-01T06:00:00Z").getTime(); const current_time_ms = Date.now(); const dasha = calculate_vimshottari(birth_moon_longitude, birth_time_ms, current_time_ms); console.log(`Current Mahadasha: ${dasha.mahadasha}`); console.log(`Current Antardasha: ${dasha.antardasha}`); console.log(`Current Pratyantardasha: ${dasha.pratyantardasha}`); console.log(`Pratyantardasha Ends: ${new Date(dasha.pratyantardasha_end_date).toLocaleDateString()}`); console.log(`Antardasha Ends: ${new Date(dasha.antardasha_end_date).toLocaleDateString()}`); console.log(`Mahadasha Ends: ${new Date(dasha.mahadasha_end_date).toLocaleDateString()}`); ``` ``` -------------------------------- ### Calculate Vimshottari Dasha Source: https://context7.com/fusionstrings/panchangam/llms.txt Determine the current Vimshottari Dasha (planetary period) using `calculate_vimshottari`. This requires the Moon's sidereal longitude, birth time, and current time. ```typescript import { calculate_vimshottari } from "@fusionstrings/panchangam"; // Parameters: (moon_longitude, birth_time_ms, current_time_ms) const birth_moon_longitude = 45.5; // Moon at 45.5° sidereal const birth_time_ms = new Date("1990-01-01T06:00:00Z").getTime(); const current_time_ms = Date.now(); const dasha = calculate_vimshottari(birth_moon_longitude, birth_time_ms, current_time_ms); console.log(`Current Mahadasha: ${dasha.mahadasha}`); console.log(`Current Antardasha: ${dasha.antardasha}`); console.log(`Current Pratyantardasha: ${dasha.pratyantardasha}`); console.log(`Pratyantardasha Ends: ${new Date(dasha.pratyantardasha_end_date).toLocaleDateString()}`); console.log(`Antardasha Ends: ${new Date(dasha.antardasha_end_date).toLocaleDateString()}`); console.log(`Mahadasha Ends: ${new Date(dasha.mahadasha_end_date).toLocaleDateString()}`); ``` -------------------------------- ### calculate_ashtakavarga Source: https://context7.com/fusionstrings/panchangam/llms.txt Calculates Sarvashtakavarga (SAV) totals showing bindus (benefic points) for each sign. ```APIDOC ## calculate_ashtakavarga ### Description Calculates Sarvashtakavarga (SAV) totals showing bindus (benefic points) for each sign. ### Parameters - **planets** (Array) - Required - List of planet objects. - **ascendant** (object) - Required - The calculated ascendant object. ``` -------------------------------- ### Daily Panchang Data Structure Source: https://github.com/fusionstrings/panchangam/blob/creation/spec.md Defines the structure for daily Panchang data, including calculated times, the five Angas (Tithi, Nakshatra, Yoga, Karana, Vara), astronomical details like Ayanamsha and planetary data, and specific Muhurat timings. ```typescript interface DailyPanchang { // Calculated Times sunrise: number; // Unix ms sunset: number; // The 5 Angas (With precise Start/End times) tithi: { index: number; name: string; startTime: number | null; endTime: number | null; }; nakshatra: { index: number; name: string; startTime: number | null; endTime: number | null; }; yoga: { index: number; name: string; startTime: number | null; endTime: number | null; }; karana: { index: number; name: string; startTime: number | null; endTime: number | null; }; vara: string; // Astronomy ayanamshaValue: number; planets: PlanetData[]; // Includes Dignity // Muhurats muhurats: { rahuKalam: { start: number; end: number }; yamaganda: { start: number; end: number }; gulika: { start: number; end: number }; brahmaMuhurta: { start: number; end: number }; abhijitMuhurta: { start: number; end: number }; }; } ``` -------------------------------- ### Calculate raw planetary positions Source: https://context7.com/fusionstrings/panchangam/llms.txt Provides low-level access to Swiss Ephemeris for tropical planetary calculations. Requires a Julian Day and specific flags for configuration. ```typescript import { p_calc_ut, p_julday } from "@fusionstrings/panchangam"; const jd = p_julday(2024, 1, 1, 12.0, 1); // Parameters: (julian_day, planet_id, flags) // Planet IDs: 0=Sun, 1=Moon, 2=Mercury, 3=Venus, 4=Mars, 5=Jupiter, 6=Saturn // Flags: 256 = SEFLG_SPEED (include speed), 2 = SEFLG_SIDEREAL const result = p_calc_ut(jd, 0, 256); // Sun with speed console.log("Raw Sun Position (Tropical):"); console.log(` Longitude: ${result.longitude.toFixed(6)}°`); console.log(` Latitude: ${result.latitude.toFixed(6)}°`); console.log(` Distance: ${result.distance.toFixed(6)} AU`); console.log(` Speed (Long): ${result.speed_long.toFixed(6)}°/day`); ``` -------------------------------- ### Calculate Full Shadbala (Six-Fold Strength) Source: https://context7.com/fusionstrings/panchangam/llms.txt Computes the Shadbala, a measure of planetary strength, for all seven classical planets. Requires planet data, Julian day, and ascendant position. ```typescript import { calculate_full_shadbala, calculate_houses, calculate_planets, Location, p_julday } from "@fusionstrings/panchangam"; const jd = p_julday(1990, 1, 1, 12.0, 1); const loc = new Location(12.9716, 77.5946, 920.0); const planets = calculate_planets(jd, 1); const houses = calculate_houses(jd, loc.latitude, loc.longitude, "W", 1); const ascendant = houses.ascendant; // Parameters: (planets, julian_day, ascendant) const shadbala = calculate_full_shadbala(planets, jd, ascendant); const print_strength = (name, data) => { console.log(`${name.padEnd(8)}: ${data.total_rupas.toFixed(2)} Rupas`); console.log(` Ishta Phala: ${data.ishta_phala.toFixed(2)}`); console.log(` Kashta Phala: ${data.kashta_phala.toFixed(2)}`); }; print_strength("Sun", shadbala.sun); print_strength("Moon", shadbala.moon); print_strength("Mars", shadbala.mars); print_strength("Mercury", shadbala.mercury); print_strength("Jupiter", shadbala.jupiter); print_strength("Venus", shadbala.venus); print_strength("Saturn", shadbala.saturn); ``` -------------------------------- ### Calculate Chara Dasha Periods Source: https://context7.com/fusionstrings/panchangam/llms.txt Calculates Jaimini Chara Dasha periods using sign positions and planetary data. ```typescript import { calculate_chara_dasha_periods, calculate_planets, calculate_houses, Location, p_julday } from "@fusionstrings/panchangam"; const jd = p_julday(1990, 1, 1, 12.0, 1); const loc = new Location(12.9716, 77.5946, 920.0); const planets = calculate_planets(jd, 1); const houses = calculate_houses(jd, loc.latitude, loc.longitude, "W", 1); // Ascendant sign (1-12) const asc_sign = Math.floor(houses.ascendant / 30) + 1; // Create planet tuples [id, longitude] const planet_tuples = planets.map((p) => [p.id, p.longitude]); // Parameters: (planet_tuples, ascendant_sign, start_year) const periods = calculate_chara_dasha_periods(planet_tuples, asc_sign, 1990); console.log("Chara Dasha Periods:"); periods.slice(0, 5).forEach((p) => { console.log(`Sign ${p.sign_id}: ${p.start_year.toFixed(1)} - ${p.end_year.toFixed(1)} (${p.duration_years} years)`); }); ``` -------------------------------- ### Calculate Vimshottari Dasha Source: https://github.com/fusionstrings/panchangam/blob/creation/README.md Determines the current ruling planetary periods based on birth moon longitude and time. ```typescript import { calculate_vimshottari } from "@fusionstrings/panchangam"; // Birth details const birth_moon_long = 45.5; // Example longitude const birth_time_ms = new Date("1990-01-01").getTime(); const current_time_ms = Date.now(); const dasha = calculate_vimshottari( birth_moon_long, birth_time_ms, current_time_ms, ); console.log(`Current Mahadasha: ${dasha.mahadasha}`); console.log(`Current Antardasha: ${dasha.antardasha}`); console.log(`Current Pratyantardasha: ${dasha.pratyantardasha}`); console.log( `Ends: ${new Date(dasha.pratyantardasha_end_date).toLocaleDateString()}`, ); ``` -------------------------------- ### Calculate Special Lagnas Source: https://context7.com/fusionstrings/panchangam/llms.txt Computes Hora Lagna, Ghati Lagna, and Sree Lagna based on birth time and sunrise data. ```typescript import { calculate_special_lagnas, calculate_planets, calculate_houses, calculate_sunrise, Location, p_julday } from "@fusionstrings/panchangam"; const year = 2024, month = 1, day = 15; const loc = new Location(28.6139, 77.2090, 225.0); // Calculate sunrise const sunrise_ms = calculate_sunrise(year, month, day, loc); const sunrise_jd = (sunrise_ms / 86400000.0) + 2440587.5; // Birth time: 10:30 AM local (IST = UTC+5:30) const birth_hour_ut = 10.5 - 5.5; // Convert to UT const birth_jd = p_julday(year, month, day, birth_hour_ut, 1); // Get planetary data const planets_sunrise = calculate_planets(sunrise_jd, 1); const planets_birth = calculate_planets(birth_jd, 1); const houses = calculate_houses(birth_jd, loc.latitude, loc.longitude, "W", 1); const sun_sunrise = planets_sunrise.find((p) => p.id === 0)?.longitude || 0; const moon_birth = planets_birth.find((p) => p.id === 1)?.longitude || 0; // Parameters: (birth_jd, sunrise_jd, sun_at_sunrise, ascendant, moon_at_birth) const special = calculate_special_lagnas( birth_jd, sunrise_jd, sun_sunrise, houses.ascendant, moon_birth ); console.log(`Hora Lagna (HL): ${special.hora_lagna.toFixed(2)}°`); console.log(`Ghati Lagna (GL): ${special.ghati_lagna.toFixed(2)}°`); console.log(`Sree Lagna (SL): ${special.sree_lagna.toFixed(2)}°`); ``` -------------------------------- ### Calculate Sarvashtakavarga (SAV) Totals Source: https://context7.com/fusionstrings/panchangam/llms.txt Calculates the Sarvashtakavarga totals, which represent benefic points (bindus) for each zodiac sign. Requires planet data and the ascendant position. ```typescript import { calculate_ashtakavarga, calculate_houses, calculate_planets, p_julday } from "@fusionstrings/panchangam"; const jd = p_julday(2024, 1, 15, 5.0, 1); // 10:30 AM IST (5:00 UT) const lat = 28.6139, lon = 77.2090; const planets = calculate_planets(jd, 1); const houses = calculate_houses(jd, lat, lon, "W", 1); // Parameters: (planets, ascendant) const sav = calculate_ashtakavarga(planets, houses.ascendant); console.log("Sarvashtakavarga Totals (Aries to Pisces):"); const signs = ["Aries", "Taurus", "Gemini", "Cancer", "Leo", "Virgo", "Libra", "Scorpio", "Sagittarius", "Capricorn", "Aquarius", "Pisces"]; sav.totals.forEach((bindus, i) => { console.log(`${signs[i].padEnd(12)}: ${bindus} bindus`); }); ``` -------------------------------- ### calculate_full_shadbala Source: https://context7.com/fusionstrings/panchangam/llms.txt Calculates the complete Shadbala (six-fold strength) profile for all seven classical planets. ```APIDOC ## calculate_full_shadbala ### Description Calculates the complete Shadbala (six-fold strength) profile for all seven classical planets. ### Parameters - **planets** (Array) - Required - List of planet objects. - **julian_day** (number) - Required - The Julian day. - **ascendant** (object) - Required - The calculated ascendant object. ``` -------------------------------- ### Calculate Divisional Charts (Varga) Source: https://context7.com/fusionstrings/panchangam/llms.txt Computes positions for various Vargas (divisional charts) for detailed astrological analysis. Supports different calculation methods and a range of Vargas. ```typescript import { calculate_planets, calculate_varga, p_julday } from "@fusionstrings/panchangam"; const jd = p_julday(1990, 1, 1, 12.0, 1); const planets = calculate_planets(jd, 1); // Varga configuration (optional) const config = { d9_method: 0, // 0=Parashara, 1=Iyer d10_method: 0 // 0=Parashara, 1=Iyer }; // Supported Vargas: 1(D1), 2(D2), 3(D3), 4(D4), 7(D7), 9(D9), 10(D10), // 12(D12), 16(D16), 20(D20), 24(D24), 27(D27), 30(D30), // 40(D40), 45(D45), 60(D60) console.log("--- Navamsha (D9) Chart ---"); planets.forEach((p) => { const d9 = calculate_varga(p.longitude, 9, config); console.log(`${p.name}: D1=${p.longitude.toFixed(2)}° -> D9 Sign=${d9.sign} (${d9.sign_name})`); }); console.log("\n--- Dashamsha (D10) Chart ---"); planets.forEach((p) => { const d10 = calculate_varga(p.longitude, 10, config); console.log(`${p.name}: D10 Sign=${d10.sign}`); }); ``` -------------------------------- ### Calculate Daily Panchang Source: https://context7.com/fusionstrings/panchangam/llms.txt Compute the five-limbed calendar data for a specific date and location. ```typescript import { calculate_daily_panchang, Location } from "@fusionstrings/panchangam"; const loc = new Location(28.6139, 77.2090, 225.0); // New Delhi // Parameters: (year, month, day, location, ayanamsha_mode) // Ayanamsha modes: 1=Lahiri, 3=Raman, 5=Krishnamurti, 27=TrueCitra const result = calculate_daily_panchang(2024, 1, 1, loc, 1); // Sunrise/Sunset (Unix milliseconds) console.log(`Sunrise: ${new Date(result.sunrise).toLocaleTimeString()}`); console.log(`Sunset: ${new Date(result.sunset).toLocaleTimeString()}`); // Tithi (Lunar Day, 1-30) console.log(`Tithi: ${result.tithi_name} (${result.tithi_index}/30)`); console.log(` Ends at: ${new Date(result.tithi_end_time).toLocaleString()}`); // Nakshatra (Lunar Mansion, 1-27) console.log(`Nakshatra: ${result.nakshatra_name} (${result.nakshatra_index}/27)`); console.log(` Ends at: ${new Date(result.nakshatra_end_time).toLocaleString()}`); // Yoga (Luni-Solar Combination, 1-27) console.log(`Yoga: ${result.yoga_name} (${result.yoga_index}/27)`); console.log(` Ends at: ${new Date(result.yoga_end_time).toLocaleString()}`); // Karana (Half-Tithi) console.log(`Karana: ${result.karana_name}`); // Vara (Weekday based on sunrise) console.log(`Vara: ${result.vara_name}`); // Ayanamsha value used console.log(`Ayanamsha: ${result.ayanamsha_value.toFixed(6)}°`); // Ascendant and MC at sunrise console.log(`Ascendant: ${result.ascendant.toFixed(2)}°`); console.log(`MC: ${result.mc.toFixed(2)}°`); ``` -------------------------------- ### find_active_yogas Source: https://context7.com/fusionstrings/panchangam/llms.txt Identifies active planetary combinations (Yogas) based on calculated planetary positions and the ascendant. ```APIDOC ## find_active_yogas ### Description Identifies active planetary combinations (Yogas) in a chart based on provided planetary data and the ascendant. ### Parameters - **planets** (object) - Required - The planetary data object calculated via calculate_planets. - **ascendant** (number) - Required - The ascendant value calculated via calculate_houses. ### Response - **yogas** (array) - A list of active Yoga objects containing name, category, description, and involved_planets. ``` -------------------------------- ### Calculate Muhurat Time Windows Source: https://github.com/fusionstrings/panchangam/blob/creation/README.md Accesses auspicious and inauspicious time periods from a daily panchang result object. ```typescript // Accessed via the daily panchang result const muhurats = result.muhurats; console.log("--- Inauspicious Periods ---"); console.log( `Rahu Kalam: ${new Date(muhurats.rahu_kalam.start).toLocaleTimeString()} - ${ new Date(muhurats.rahu_kalam.end).toLocaleTimeString() }`, ); console.log( `Yamaganda: ${new Date(muhurats.yamaganda.start).toLocaleTimeString()} - ${ new Date(muhurats.yamaganda.end).toLocaleTimeString() }`, ); console.log("--- Auspicious Periods ---"); console.log( `Brahma Muhurta: ${ new Date(muhurats.brahma_muhurta.start).toLocaleTimeString() }`, ); console.log( `Abhijit Muhurta: ${ new Date(muhurats.abhijit_muhurta.start).toLocaleTimeString() }`, ); ``` -------------------------------- ### Calculate House Cusps Source: https://github.com/fusionstrings/panchangam/blob/creation/README.md Computes Ascendant and house cusps for specific systems like Placidus, Whole Sign, or Equal. ```typescript import { calculate_houses, Location, p_julday, } from "@fusionstrings/panchangam"; const jd = p_julday(2024, 1, 1, 12.0, 1); const loc = new Location(28.6139, 77.2090, 0.0); // 'P' = Placidus, 'W' = Whole Sign, 'E' = Equal // Mode 1 = Lahiri Ayanamsha (Sidereal) const houses = calculate_houses(jd, loc.latitude, loc.longitude, "P", 1); console.log(`Ascendant: ${houses.ascendant.toFixed(2)}°`); houses.cusps.forEach((cusp, i) => { console.log(`House ${i + 1}: ${cusp.toFixed(2)}°`); }); ```