/** * Swiss Ephemeris for Node.js - Modern TypeScript API * * This module provides a modern, type-safe API for Swiss Ephemeris astronomical calculations. * It wraps the native C library with developer-friendly TypeScript interfaces. */ import { CalendarType, CelestialBody, HouseSystem, CalculationFlagInput, EclipseTypeFlagInput, PlanetaryPosition, HouseData, LunarEclipse, SolarEclipse, ExtendedDateTime, RiseTransitSet } from '@swisseph/core'; /** * Set the directory path for ephemeris files * * By default, @swisseph/node uses bundled ephemeris files included with the package. * Call this function only if you want to use custom ephemeris files. * * @param path - Directory path containing ephemeris files, or null/undefined for bundled files * * @example * // Use custom ephemeris files * setEphemerisPath('/path/to/custom/ephemeris'); * * // Revert to bundled files * setEphemerisPath(null); */ export declare function setEphemerisPath(path?: string | null): void; /** * Calculate Julian day number from calendar date * * The Julian day number is a continuous count of days since the beginning * of the Julian period (January 1, 4713 BCE, proleptic Julian calendar). * * @param year - Year (negative for BCE) * @param month - Month (1-12) * @param day - Day (1-31) * @param hour - Hour as decimal (0.0-23.999...) * @param calendarType - Calendar system (default: Gregorian) * @returns Julian day number * * @example * const jd = julianDay(2007, 3, 3); * console.log(jd); // 2454162.5 * * const jdWithTime = julianDay(2007, 3, 3, 14.5); * console.log(jdWithTime); // 2454163.104166667 */ export declare function julianDay(year: number, month: number, day: number, hour?: number, calendarType?: CalendarType): number; /** * Calculate Julian day number from a JavaScript Date object * * Convenience function that converts a JavaScript Date to Julian day number. * The Date is interpreted as UTC. * * @param date - JavaScript Date object (interpreted as UTC) * @param calendarType - Calendar system (default: Gregorian) * @returns Julian day number * * @example * // From Date object * const date = new Date('1990-05-15T14:30:00Z'); * const jd = dateToJulianDay(date); * * // From timestamp * const now = new Date(); * const jdNow = dateToJulianDay(now); * * // Equivalent to julianDay(1990, 5, 15, 14.5) * const jd2 = dateToJulianDay(new Date(Date.UTC(1990, 4, 15, 14, 30))); */ export declare function dateToJulianDay(date: Date, calendarType?: CalendarType): number; /** * Convert Julian day number to calendar date * * @param jd - Julian day number * @param calendarType - Calendar system (default: Gregorian) * @returns DateTime object with year, month, day, and hour * * @example * const date = julianDayToDate(2454162.5); * console.log(date); * // { year: 2007, month: 3, day: 3, hour: 0, calendarType: CalendarType.Gregorian } * * console.log(date.toString()); * // "2007-03-03 0.000000 hours (Gregorian)" */ export declare function julianDayToDate(jd: number, calendarType?: CalendarType): ExtendedDateTime; /** * Calculate planetary positions * * This is the main function for calculating positions of planets, asteroids, * and other celestial bodies. * * @param julianDay - Julian day number in Universal Time * @param body - Celestial body to calculate (use Planet, Asteroid, etc. enums) * @param flags - Calculation flags (default: SwissEphemeris with speed) * @returns PlanetaryPosition object with longitude, latitude, distance, and speeds * * @example * // Calculate Sun position * const sun = calculatePosition(jd, Planet.Sun); * console.log(`Sun longitude: ${sun.longitude}°`); * * // Calculate with specific flags * const moon = calculatePosition( * jd, * Planet.Moon, * CalculationFlag.MoshierEphemeris | CalculationFlag.Speed * ); * * // Using flag builder * import { CalculationFlags } from 'swisseph'; * const flags = CalculationFlags.from( * CalculationFlag.SwissEphemeris, * CalculationFlag.Speed, * CalculationFlag.Equatorial * ); * const mars = calculatePosition(jd, Planet.Mars, flags); */ export declare function calculatePosition(julianDay: number, body: CelestialBody, flags?: CalculationFlagInput): PlanetaryPosition; /** * Calculate house cusps and angles * * Houses divide the ecliptic into 12 sections based on the observer's * location and the time of day. * * @param julianDay - Julian day number in Universal Time * @param latitude - Geographic latitude (positive = north, negative = south) * @param longitude - Geographic longitude (positive = east, negative = west) * @param houseSystem - House system to use (default: Placidus) * @returns HouseData object with cusps and angles * * @example * // Calculate houses for New York * const houses = calculateHouses(jd, 40.7128, -74.0060, HouseSystem.Placidus); * console.log(`Ascendant: ${houses.ascendant}°`); * console.log(`MC: ${houses.mc}°`); * * // Access house cusps * for (let i = 1; i <= 12; i++) { * console.log(`House ${i}: ${houses.cusps[i]}°`); * } * * // Try different house system * const wholeSigns = calculateHouses(jd, 40.7128, -74.0060, HouseSystem.WholeSign); */ export declare function calculateHouses(julianDay: number, latitude: number, longitude: number, houseSystem?: HouseSystem): HouseData; /** * Find the next lunar eclipse * * Searches for the next lunar eclipse after the given Julian day. * * @param startJulianDay - Julian day to start search from * @param flags - Calculation flags (default: SwissEphemeris) * @param eclipseType - Filter by eclipse type (0 = all types) * @param backward - Search backward in time if true * @returns LunarEclipse object with times and convenience methods * * @example * // Find next lunar eclipse * const jd = julianDay(2025, 1, 1); * const eclipse = findNextLunarEclipse(jd); * * console.log(`Eclipse maximum: ${julianDayToDate(eclipse.maximum)}`); * console.log(`Is total: ${eclipse.isTotal()}`); * console.log(`Totality duration: ${eclipse.getTotalityDuration()} hours`); * * // Find previous lunar eclipse * const previousEclipse = findNextLunarEclipse(jd, undefined, 0, true); */ export declare function findNextLunarEclipse(startJulianDay: number, flags?: CalculationFlagInput, eclipseType?: EclipseTypeFlagInput, backward?: boolean): LunarEclipse; /** * Find the next solar eclipse globally * * Searches for the next solar eclipse visible anywhere on Earth. * * @param startJulianDay - Julian day to start search from * @param flags - Calculation flags (default: SwissEphemeris) * @param eclipseType - Filter by eclipse type (0 = all types) * @param backward - Search backward in time if true * @returns SolarEclipse object with times and convenience methods * * @example * // Find next solar eclipse * const jd = julianDay(2025, 1, 1); * const eclipse = findNextSolarEclipse(jd); * * console.log(`Eclipse maximum: ${julianDayToDate(eclipse.maximum)}`); * console.log(`Is total: ${eclipse.isTotal()}`); * console.log(`Is annular: ${eclipse.isAnnular()}`); * console.log(`Is central: ${eclipse.isCentral()}`); */ export declare function findNextSolarEclipse(startJulianDay: number, flags?: CalculationFlagInput, eclipseType?: EclipseTypeFlagInput, backward?: boolean): SolarEclipse; /** * Get the name of a celestial body * * @param body - Celestial body identifier * @returns Name of the body as a string * * @example * const name = getCelestialBodyName(Planet.Mars); * console.log(name); // "Mars" * * const sunName = getCelestialBodyName(Planet.Sun); * console.log(sunName); // "Sun" */ export declare function getCelestialBodyName(body: CelestialBody): string; /** * Set the sidereal mode (ayanamsa system) for sidereal calculations * * This function must be called before calculating sidereal positions with * CalculationFlag.Sidereal. Different ayanamsa systems are used in various * traditions of astrology, particularly in Vedic (Jyotish) astrology. * * @param siderealMode - Ayanamsa system to use (e.g., SiderealMode.Lahiri for Vedic) * @param t0 - Reference date (Julian day) for custom ayanamsa (default: 0) * @param ayanT0 - Initial value of ayanamsa in degrees for custom mode (default: 0) * * @example * import { setSiderealMode, SiderealMode, calculatePosition, CalculationFlag, Planet } from '@swisseph/node'; * * // Set Lahiri ayanamsa (most common in Vedic astrology) * setSiderealMode(SiderealMode.Lahiri); * * // Calculate sidereal position of Sun * const jd = julianDay(2025, 1, 1); * const sun = calculatePosition(jd, Planet.Sun, CalculationFlag.Sidereal | CalculationFlag.Speed); * console.log(`Sidereal Sun: ${sun.longitude}°`); * * // Set Raman ayanamsa * setSiderealMode(SiderealMode.Raman); * * // Set custom ayanamsa * setSiderealMode(SiderealMode.UserDefined, 2451545.0, 23.85); */ export declare function setSiderealMode(siderealMode: number, t0?: number, ayanT0?: number): void; /** * Set the geographic location for topocentric calculations * * This function must be called before calculating topocentric positions with * CalculationFlag.Topocentric. Topocentric positions account for the observer's * location on Earth, which is particularly important for the Moon due to parallax. * * @param longitude - Geographic longitude in degrees (positive = east, negative = west) * @param latitude - Geographic latitude in degrees (positive = north, negative = south) * @param altitude - Altitude above sea level in meters * * @example * import { setTopocentric, calculatePosition, CalculationFlag, Planet } from '@swisseph/node'; * * // Set location to New York City * setTopocentric(-74.0060, 40.7128, 10); // lon, lat, altitude * * // Calculate topocentric Moon position * const jd = julianDay(2025, 1, 1); * const moon = calculatePosition( * jd, * Planet.Moon, * CalculationFlag.Topocentric | CalculationFlag.Speed * ); * console.log(`Topocentric Moon: ${moon.longitude}°`); * * // Set location to Mumbai for Vedic calculations * setTopocentric(72.8777, 19.0760, 14); * setSiderealMode(SiderealMode.Lahiri); * const siderealMoon = calculatePosition( * jd, * Planet.Moon, * CalculationFlag.Sidereal | CalculationFlag.Topocentric | CalculationFlag.Speed * ); */ export declare function setTopocentric(longitude: number, latitude: number, altitude: number): void; /** * Get the ayanamsa (sidereal offset) value for a given date * * The ayanamsa is the distance between the tropical and sidereal zodiacs. * This function returns the current offset in degrees for the ayanamsa system * that was set with setSiderealMode(). * * @param julianDay - Julian day number in Universal Time * @returns Ayanamsa value in degrees * * @example * import { getAyanamsa, setSiderealMode, SiderealMode, julianDay } from '@swisseph/node'; * * // Get Lahiri ayanamsa for a date * setSiderealMode(SiderealMode.Lahiri); * const jd = julianDay(2025, 1, 1); * const ayanamsa = getAyanamsa(jd); * console.log(`Lahiri ayanamsa: ${ayanamsa.toFixed(4)}°`); * * // Compare different ayanamsa systems * setSiderealMode(SiderealMode.Raman); * const ramanAyanamsa = getAyanamsa(jd); * console.log(`Raman ayanamsa: ${ramanAyanamsa.toFixed(4)}°`); * * setSiderealMode(SiderealMode.Krishnamurti); * const kpAyanamsa = getAyanamsa(jd); * console.log(`KP ayanamsa: ${kpAyanamsa.toFixed(4)}°`); */ export declare function getAyanamsa(julianDay: number): number; /** * Calculate rise, transit, or set time for a celestial body * * Finds the time when a celestial body rises, transits (culminates), or sets * for a given location. This is essential for calculating almanac data, * planetary hours, and observational astrology. * * @param startJulianDay - Julian day to start search from * @param body - Celestial body to calculate * @param eventType - Type of event (RiseTransitFlag.Rise, Set, UpperTransit, or LowerTransit) * @param longitude - Geographic longitude in degrees (positive = east, negative = west) * @param latitude - Geographic latitude in degrees (positive = north, negative = south) * @param altitude - Altitude above sea level in meters * @param flags - Calculation flags (default: SwissEphemeris) * @param atmosphericPressure - Atmospheric pressure in millibars (default: 0 = standard) * @param atmosphericTemperature - Atmospheric temperature in Celsius (default: 0 = standard) * @returns RiseTransitSet object with time of event * * @example * import { * calculateRiseTransitSet, * RiseTransitFlag, * Planet, * julianDay, * julianDayToDate * } from '@swisseph/node'; * * // Find sunrise in New York * const jd = julianDay(2025, 1, 1); * const sunrise = calculateRiseTransitSet( * jd, * Planet.Sun, * RiseTransitFlag.Rise, * -74.0060, // New York longitude * 40.7128, // New York latitude * 10 // altitude in meters * ); * console.log(`Sunrise: ${julianDayToDate(sunrise.time)}`); * * // Find moonrise * const moonrise = calculateRiseTransitSet( * jd, * Planet.Moon, * RiseTransitFlag.Rise, * -74.0060, * 40.7128, * 10 * ); * * // Find Sun's upper transit (noon) * const noon = calculateRiseTransitSet( * jd, * Planet.Sun, * RiseTransitFlag.UpperTransit, * -74.0060, * 40.7128, * 10 * ); * * // With atmospheric refraction correction * const preciseRise = calculateRiseTransitSet( * jd, * Planet.Sun, * RiseTransitFlag.Rise, * -74.0060, * 40.7128, * 10, * CalculationFlag.SwissEphemeris, * 1013.25, // standard pressure in millibars * 15 // temperature in Celsius * ); */ export declare function calculateRiseTransitSet(startJulianDay: number, body: CelestialBody, eventType: number, longitude: number, latitude: number, altitude: number, flags?: CalculationFlagInput, atmosphericPressure?: number, atmosphericTemperature?: number): RiseTransitSet; /** * Close Swiss Ephemeris and free resources * * Call this function when you're done using Swiss Ephemeris to free * allocated resources. * * @example * // After all calculations are done * close(); */ export declare function close(): void; export * from '@swisseph/core'; //# sourceMappingURL=index.d.ts.map