UNPKG

sweph-wasm

Version:

High-precision Swiss Ephemeris WebAssembly bindings for TypeScript — comprehensive astronomical calculations including planetary positions, house systems, eclipses, fixed stars, and astrological computations with modern JS/TS support.

1,247 lines (1,210 loc) 191 kB
import { type FixedLengthArray, toFixedLengthArray } from "fixed-len-array"; import { ArrayPointer, NumberPointer, StringPointer, TypeConverter, } from "wasp-lib"; import { EpheFileMetadata } from "./utils/ephe_file_metadata"; import { getBaseURLPath } from "./utils/get_base_url_path"; import { SWEerror } from "./utils/swe_error"; import Module, { type WASMModule } from "./wasm"; /** Wrapper class for Swiss Ephemeris WebAssembly bindings. */ export default class SwissEPH { public readonly TRUE = 1; public readonly FALSE = 0; public readonly OK = 0; public readonly ERR = -1; public readonly NOT_AVAILABLE = -2; public readonly BEYOND_EPH_LIMITS = -3; /** Degree as string, utf8 encoding */ public readonly ODEGREE_STRING = "°"; /** Biggest value for REAL8 */ public readonly HUGE = 1.7e308; /** 3.14159265358979323846 */ public readonly M_PI = Math.PI; /** * Forward static obsolete used for string declarations, allowing 255 * char+\0 */ public readonly AS_MAXCH = 256; public readonly RADTODEG = 180.0 / this.M_PI; public readonly DEGTORAD = this.M_PI / 180.0; /** Degree expressed in centiseconds */ public readonly DEG = 360000; /** 7.5 degrees */ public readonly DEG7_30 = 2700000; public readonly DEG15 = 15 * this.DEG; public readonly DEG24 = 24 * this.DEG; public readonly DEG30 = 30 * this.DEG; public readonly DEG60 = 60 * this.DEG; public readonly DEG90 = 90 * this.DEG; public readonly DEG120 = 120 * this.DEG; public readonly DEG150 = 150 * this.DEG; public readonly DEG180 = 180 * this.DEG; public readonly DEG270 = 270 * this.DEG; public readonly DEG360 = 360 * this.DEG; /** CSTORAD = 4.84813681109536E-08 centisec to rad: pi / 180 /3600/100 */ public readonly CSTORAD = this.DEGTORAD / 360000.0; /** RADTOCS = 2.06264806247096E+07 rad to centisec 180_3600_100/pi */ public readonly RADTOCS = this.RADTODEG * 360000.0; /** Centisec to degree */ public readonly CS2DEG = 1.0 / 360000.0; /** Open binary file for reading */ public readonly BFILE_R_ACCESS = "rb"; /** Open binary file for writing and reading */ public readonly BFILE_RW_ACCESS = "r+b"; /** Create/open binary file for write */ public readonly BFILE_W_CREATE = "wb"; /** Create/open binary file for append */ public readonly BFILE_A_ACCESS = "a+b"; /** Semicolon as PATH separator */ public readonly PATH_SEPARATOR = ";"; /** Default file creation mode */ public readonly OPEN_MODE = "0666"; /** Open text file for reading */ public readonly FILE_R_ACCESS = "rt"; /** Open text file for writing and reading */ public readonly FILE_RW_ACCESS = "r+t"; /** Create/open text file for write */ public readonly FILE_W_CREATE = "wt"; /** Create/open text file for append */ public readonly FILE_A_ACCESS = "a+t"; /** * Attention, all backslashes for msdos directry names must be written as * because it is the C escape character glue string for directory/file */ public readonly DIR_GLUE = "\\"; public readonly SE_AUNIT_TO_KM = 149597870.7; public readonly SE_AUNIT_TO_LIGHTYEAR = 1.0 / 63241.07708427; public readonly SE_AUNIT_TO_PARSEC = 1.0 / 206264.8062471; /** Values for gregflag in swe_julday() and swe_revjul() */ public readonly SE_JUL_CAL = 0; public readonly SE_GREG_CAL = 1; /** Planet numbers for the ipl parameter in swe_calc() */ public readonly SE_ECL_NUT = -1; public readonly SE_SUN = 0; public readonly SE_MOON = 1; public readonly SE_MERCURY = 2; public readonly SE_VENUS = 3; public readonly SE_MARS = 4; public readonly SE_JUPITER = 5; public readonly SE_SATURN = 6; public readonly SE_URANUS = 7; public readonly SE_NEPTUNE = 8; public readonly SE_PLUTO = 9; public readonly SE_MEAN_NODE = 10; public readonly SE_TRUE_NODE = 11; public readonly SE_MEAN_APOG = 12; public readonly SE_OSCU_APOG = 13; public readonly SE_EARTH = 14; public readonly SE_CHIRON = 15; public readonly SE_PHOLUS = 16; public readonly SE_CERES = 17; public readonly SE_PALLAS = 18; public readonly SE_JUNO = 19; public readonly SE_VESTA = 20; public readonly SE_INTP_APOG = 21; public readonly SE_INTP_PERG = 22; public readonly SE_NPLANETS = 23; public readonly SE_PLMOON_OFFSET = 9000; public readonly SE_AST_OFFSET = 10000; public readonly SE_VARUNA = this.SE_AST_OFFSET + 20000; public readonly SE_FICT_OFFSET = 40; public readonly SE_FICT_OFFSET_1 = 39; public readonly SE_FICT_MAX = 999; public readonly SE_NFICT_ELEM = 15; public readonly SE_COMET_OFFSET = 1000; public readonly SE_NALL_NAT_POINTS = this.SE_NPLANETS + this.SE_NFICT_ELEM; /** Hamburger or Uranian "planets" */ public readonly SE_CUPIDO = 40; public readonly SE_HADES = 41; public readonly SE_ZEUS = 42; public readonly SE_KRONOS = 43; public readonly SE_APOLLON = 44; public readonly SE_ADMETOS = 45; public readonly SE_VULKANUS = 46; public readonly SE_POSEIDON = 47; /** Other fictitious bodies */ public readonly SE_ISIS = 48; public readonly SE_NIBIRU = 49; public readonly SE_HARRINGTON = 50; public readonly SE_NEPTUNE_LEVERRIER = 51; public readonly SE_NEPTUNE_ADAMS = 52; public readonly SE_PLUTO_LOWELL = 53; public readonly SE_PLUTO_PICKERING = 54; public readonly SE_VULCAN = 55; public readonly SE_WHITE_MOON = 56; public readonly SE_PROSERPINA = 57; public readonly SE_WALDEMATH = 58; public readonly SE_FIXSTAR = -10; public readonly SE_ASC = 0; public readonly SE_MC = 1; public readonly SE_ARMC = 2; public readonly SE_VERTEX = 3; public readonly SE_EQUASC = 4; /** "equatorial ascendant" */ public readonly SE_COASC1 = 5; /** "co-ascendant" ( W. Koch) */ public readonly SE_COASC2 = 6; /** "co-ascendant" ( M. Munkasey) */ public readonly SE_POLASC = 7; /** "polar ascendant" ( M. Munkasey) */ public readonly SE_NASCMC = 8; /** * Flag bits for parameter iflag in swe_calc() The flag bits are defined in * such a way that iflag = 0 delivers what one usually wants: * * - The default ephemeris ( SWISS EPHEMERIS) is used, * - Apparent geocentric positions referring to the true equinox of date are * returned. If not only coordinates, but also speed values are required, * use flag = SEFLG_SPEED. The 'L' behind the number indicates that 32-bit * integers ( Long) are used. */ /** Use JPL ephemeris */ public readonly SEFLG_JPLEPH = 1; /** Use SWISSEPH ephemeris */ public readonly SEFLG_SWIEPH = 2; /** Use Moshier ephemeris */ public readonly SEFLG_MOSEPH = 4; /** Heliocentric position */ public readonly SEFLG_HELCTR = 8; /** True/geometric position, not apparent position */ public readonly SEFLG_TRUEPOS = 16; /** No precession, i.e. give J2000 equinox */ public readonly SEFLG_J2000 = 32; /** No nutation, i.e. mean equinox of date */ public readonly SEFLG_NONUT = 64; /** * Speed from 3 positions (do not use it, SEFLG_SPEED is faster and more * precise.) */ public readonly SEFLG_SPEED3 = 128; /** High precision speed */ public readonly SEFLG_SPEED = 256; /** Turn off gravitational deflection */ public readonly SEFLG_NOGDEFL = 512; /** Turn off 'annual' aberration of light */ public readonly SEFLG_NOABERR = 1024; /** * Astrometric position, i.e. with light - time, but without aberration and * light deflection */ public readonly SEFLG_ASTROMETRIC = this.SEFLG_NOABERR | this.SEFLG_NOGDEFL; /** Equatorial positions are wanted */ public readonly SEFLG_EQUATORIAL = 2 * 1024; /** Cartesian, not polar, coordinates */ public readonly SEFLG_XYZ = 4 * 1024; /** Coordinates in radians, not degrees */ public readonly SEFLG_RADIANS = 8 * 1024; /** Barycentric position */ public readonly SEFLG_BARYCTR = 16 * 1024; /** Topocentric position */ public readonly SEFLG_TOPOCTR = 32 * 1024; /** Used for Astronomical Almanac mode in calculation of Kepler elipses */ public readonly SEFLG_ORBEL_AA = this.SEFLG_TOPOCTR; /** Tropical position ( default) */ public readonly SEFLG_TROPICAL = 0; /** Sidereal position */ public readonly SEFLG_SIDEREAL = 64 * 1024; /** ICRS ( DE406 reference frame) */ public readonly SEFLG_ICRS = 128 * 1024; /** Reproduce JPL Horizons 1962 - today to 0.002 arcsec. */ public readonly SEFLG_DPSIDEPS_1980 = 256 * 1024; public readonly SEFLG_JPLHOR = this.SEFLG_DPSIDEPS_1980; /** Approximate JPL Horizons 1962 - today */ public readonly SEFLG_JPLHOR_APPROX = 512 * 1024; /** * Calculate position of center of body ( COB) of planet, not barycenter of * its system */ public readonly SEFLG_CENTER_BODY = 1024 * 1024; /** Test raw data in files sepm9* */ public readonly SEFLG_TEST_PLMOON = (2 * 1024 * 1024) | this.SEFLG_J2000 | this.SEFLG_ICRS | this.SEFLG_HELCTR | this.SEFLG_TRUEPOS; public readonly SE_SIDBITS = 256; /** For projection onto ecliptic of t0 */ public readonly SE_SIDBIT_ECL_T0 = 256; /** For projection onto solar system plane */ public readonly SE_SIDBIT_SSY_PLANE = 512; /** With user-defined ayanamsha, t0 is UT */ public readonly SE_SIDBIT_USER_UT = 1024; /** * Ayanamsha measured on ecliptic of date; see commentaries in sweph.c: * swi_get_ayanamsa_ex(). */ public readonly SE_SIDBIT_ECL_DATE = 2048; /** * Test feature: don't apply const ant offset to ayanamsha see commentary * above sweph.c: get_aya_correction() */ public readonly SE_SIDBIT_NO_PREC_OFFSET = 4096; /** Test feature: calculate ayanamsha using its original precession model */ public readonly SE_SIDBIT_PREC_ORIG = 8192; /** Sidereal modes ( ayanamsas) */ public readonly SE_SIDM_FAGAN_BRADLEY = 0; public readonly SE_SIDM_LAHIRI = 1; public readonly SE_SIDM_DELUCE = 2; public readonly SE_SIDM_RAMAN = 3; public readonly SE_SIDM_USHASHASHI = 4; public readonly SE_SIDM_KRISHNAMURTI = 5; public readonly SE_SIDM_DJWHAL_KHUL = 6; public readonly SE_SIDM_YUKTESHWAR = 7; public readonly SE_SIDM_JN_BHASIN = 8; public readonly SE_SIDM_BABYL_KUGLER1 = 9; public readonly SE_SIDM_BABYL_KUGLER2 = 10; public readonly SE_SIDM_BABYL_KUGLER3 = 11; public readonly SE_SIDM_BABYL_HUBER = 12; public readonly SE_SIDM_BABYL_ETPSC = 13; public readonly SE_SIDM_ALDEBARAN_15TAU = 14; public readonly SE_SIDM_HIPPARCHOS = 15; public readonly SE_SIDM_SASSANIAN = 16; public readonly SE_SIDM_GALCENT_0SAG = 17; public readonly SE_SIDM_J2000 = 18; public readonly SE_SIDM_J1900 = 19; public readonly SE_SIDM_B1950 = 20; public readonly SE_SIDM_SURYASIDDHANTA = 21; public readonly SE_SIDM_SURYASIDDHANTA_MSUN = 22; public readonly SE_SIDM_ARYABHATA = 23; public readonly SE_SIDM_ARYABHATA_MSUN = 24; public readonly SE_SIDM_SS_REVATI = 25; public readonly SE_SIDM_SS_CITRA = 26; public readonly SE_SIDM_TRUE_CITRA = 27; public readonly SE_SIDM_TRUE_REVATI = 28; public readonly SE_SIDM_TRUE_PUSHYA = 29; public readonly SE_SIDM_GALCENT_RGILBRAND = 30; public readonly SE_SIDM_GALEQU_IAU1958 = 31; public readonly SE_SIDM_GALEQU_TRUE = 32; public readonly SE_SIDM_GALEQU_MULA = 33; public readonly SE_SIDM_GALALIGN_MARDYKS = 34; public readonly SE_SIDM_TRUE_MULA = 35; public readonly SE_SIDM_GALCENT_MULA_WILHELM = 36; public readonly SE_SIDM_ARYABHATA_522 = 37; public readonly SE_SIDM_BABYL_BRITTON = 38; public readonly SE_SIDM_TRUE_SHEORAN = 39; public readonly SE_SIDM_GALCENT_COCHRANE = 40; public readonly SE_SIDM_GALEQU_FIORENZA = 41; public readonly SE_SIDM_VALENS_MOON = 42; public readonly SE_SIDM_LAHIRI_1940 = 43; public readonly SE_SIDM_LAHIRI_VP285 = 44; public readonly SE_SIDM_KRISHNAMURTI_VP291 = 45; public readonly SE_SIDM_LAHIRI_ICRC = 46; // public SE_SIDM_MANJULA = 43 /** User-defined ayanamsha, t0 is TT */ public readonly SE_SIDM_USER = 255; public readonly SE_NSIDM_PREDEF = 47; /** Used for swe_nod_aps(): */ /** Mean nodes/apsides */ public readonly SE_NODBIT_MEAN = 1; /** Osculating nodes/apsides */ public readonly SE_NODBIT_OSCU = 2; /** Same, but motion about solar system barycenter is considered */ public readonly SE_NODBIT_OSCU_BAR = 4; /** Focal point of orbit instead of aphelion */ public readonly SE_NODBIT_FOPOINT = 256; /** Default ephemeris used when no ephemeris flagbit is set */ public readonly SEFLG_DEFAULTEPH = this.SEFLG_SWIEPH; /** * Maximum size of fixstar name; the parameter star in swe_fixstar must * allow twice this space for the returned star name. */ public readonly SE_MAX_STNAME = 256; /** Defines for eclipse computations */ public readonly SE_ECL_CENTRAL = 1; public readonly SE_ECL_NONCENTRAL = 2; public readonly SE_ECL_TOTAL = 4; public readonly SE_ECL_ANNULAR = 8; public readonly SE_ECL_PARTIAL = 16; public readonly SE_ECL_ANNULAR_TOTAL = 32; /** = annular-total */ public readonly SE_ECL_HYBRID = 32; public readonly SE_ECL_PENUMBRAL = 64; public readonly SE_ECL_ALLTYPES_SOLAR = this.SE_ECL_CENTRAL | this.SE_ECL_NONCENTRAL | this.SE_ECL_TOTAL | this.SE_ECL_ANNULAR | this.SE_ECL_PARTIAL | this.SE_ECL_ANNULAR_TOTAL; public readonly SE_ECL_ALLTYPES_LUNAR = this.SE_ECL_TOTAL | this.SE_ECL_PARTIAL | this.SE_ECL_PENUMBRAL; public readonly SE_ECL_VISIBLE = 128; public readonly SE_ECL_MAX_VISIBLE = 256; /** Begin of partial eclipse */ public readonly SE_ECL_1ST_VISIBLE = 512; /** Begin of partial eclipse */ public readonly SE_ECL_PARTBEG_VISIBLE = 512; /** Begin of total eclipse */ public readonly SE_ECL_2ND_VISIBLE = 1024; /** Begin of total eclipse */ public readonly SE_ECL_TOTBEG_VISIBLE = 1024; /** End of total eclipse */ public readonly SE_ECL_3RD_VISIBLE = 2048; /** End of total eclipse */ public readonly SE_ECL_TOTEND_VISIBLE = 2048; /** End of partial eclipse */ public readonly SE_ECL_4TH_VISIBLE = 4096; /** End of partial eclipse */ public readonly SE_ECL_PARTEND_VISIBLE = 4096; /** Begin of penumbral eclipse */ public readonly SE_ECL_PENUMBBEG_VISIBLE = 8192; /** End of penumbral eclipse */ public readonly SE_ECL_PENUMBEND_VISIBLE = 16384; /** Occultation begins during the day */ public readonly SE_ECL_OCC_BEG_DAYLIGHT = 8192; /** Occultation ends during the day */ public readonly SE_ECL_OCC_END_DAYLIGHT = 16384; /** * Check if the next conjunction of the moon with a planet is an * occultation; don't search further */ public readonly SE_ECL_ONE_TRY = 32 * 1024; /** For swe_rise_transit() */ public readonly SE_CALC_RISE = 1; public readonly SE_CALC_SET = 2; public readonly SE_CALC_MTRANSIT = 4; public readonly SE_CALC_ITRANSIT = 8; /** * To be or'ed to SE_CALC_RISE/SET, if rise or set of disc center is * required */ public readonly SE_BIT_DISC_CENTER = 256; /** * To be or'ed to SE_CALC_RISE/SET, if rise or set of lower limb of disc is * requried */ public readonly SE_BIT_DISC_BOTTOM = 8192; /** * Use geocentric rather than topocentric position of object and ignore its * ecliptic latitude */ public readonly SE_BIT_GEOCTR_NO_ECL_LAT = 128; /** To be or'ed to SE_CALC_RISE/SET, if refraction is to be ignored */ public readonly SE_BIT_NO_REFRACTION = 512; /** To be or'ed to SE_CALC_RISE/SET */ public readonly SE_BIT_CIVIL_TWILIGHT = 1024; /** To be or'ed to SE_CALC_RISE/SET */ public readonly SE_BIT_NAUTIC_TWILIGHT = 2048; /** To be or'ed to SE_CALC_RISE/SET */ public readonly SE_BIT_ASTRO_TWILIGHT = 4096; /** Or'ed to SE_CALC_RISE/SET: neglect the effect of distance on disc size */ public readonly SE_BIT_FIXED_DISC_SIZE = 16384; /** * This is only an Astrodienst in-house test flag.It forces the usage of the * old, slow calculation of risings and settings. */ public readonly SE_BIT_FORCE_SLOW_METHOD = 32768; public readonly SE_BIT_HINDU_RISING = this.SE_BIT_DISC_CENTER | this.SE_BIT_NO_REFRACTION | this.SE_BIT_GEOCTR_NO_ECL_LAT; /** For swe_azalt() and swe_azalt_rev() */ public readonly SE_ECL2HOR = 0; public readonly SE_EQU2HOR = 1; public readonly SE_HOR2ECL = 0; public readonly SE_HOR2EQU = 1; /** For swe_refrac() */ public readonly SE_TRUE_TO_APP = 0; public readonly SE_APP_TO_TRUE = 1; /** * Only used for experimenting with various JPL ephemeris files which are * available at Astrodienst's internal network */ public readonly SE_DE_NUMBER = 431; public readonly SE_FNAME_DE200 = "de200.eph"; public readonly SE_FNAME_DE403 = "de403.eph"; public readonly SE_FNAME_DE404 = "de404.eph"; public readonly SE_FNAME_DE405 = "de405.eph"; public readonly SE_FNAME_DE406 = "de406.eph"; public readonly SE_FNAME_DE431 = "de431.eph"; public readonly SE_FNAME_DFT = this.SE_FNAME_DE431; public readonly SE_FNAME_DFT2 = this.SE_FNAME_DE406; public readonly SE_STARFILE_OLD = "fixstars.cat"; public readonly SE_STARFILE = "sefstars.txt"; public readonly SE_ASTNAMFILE = "seasnam.txt"; public readonly SE_FICTFILE = "seorbel.txt"; /** Defines for swe_split_deg() ( in swephlib.c) */ public readonly SE_SPLIT_DEG_ROUND_SEC = 1; public readonly SE_SPLIT_DEG_ROUND_MIN = 2; public readonly SE_SPLIT_DEG_ROUND_DEG = 4; public readonly SE_SPLIT_DEG_ZODIACAL = 8; public readonly SE_SPLIT_DEG_NAKSHATRA = 1024; /** * Don't round to next sign, e.g. 29.9999999 will be rounded to 29d59'59" ( * or 29d59' or 29d) */ public readonly SE_SPLIT_DEG_KEEP_SIGN = 16; /** * Don't round to next degree e.g. 13.9999999 will be rounded to 13d59'59" ( * or 13d59' or 13d) */ public readonly SE_SPLIT_DEG_KEEP_DEG = 32; /** For heliacal functions */ public readonly SE_HELIACAL_RISING = 1; public readonly SE_HELIACAL_SETTING = 2; public readonly SE_MORNING_FIRST = this.SE_HELIACAL_RISING; public readonly SE_EVENING_LAST = this.SE_HELIACAL_SETTING; public readonly SE_EVENING_FIRST = 3; public readonly SE_MORNING_LAST = 4; /** Still not implemented */ public readonly SE_ACRONYCHAL_RISING = 5; /** Still not implemented */ public readonly SE_ACRONYCHAL_SETTING = 6; public readonly SE_COSMICAL_SETTING = this.SE_ACRONYCHAL_SETTING; public readonly SE_HELFLAG_LONG_SEARCH = 128; public readonly SE_HELFLAG_HIGH_PRECISION = 256; public readonly SE_HELFLAG_OPTICAL_PARAMS = 512; public readonly SE_HELFLAG_NO_DETAILS = 1024; /** 2048 */ public readonly SE_HELFLAG_SEARCH_1_PERIOD = 1 << 11; /** 4096 */ public readonly SE_HELFLAG_VISLIM_DARK = 1 << 12; /** 8192 */ public readonly SE_HELFLAG_VISLIM_NOMOON = 1 << 13; /** The following undocumented defines are for test reasons only */ /** 16384 */ public readonly SE_HELFLAG_VISLIM_PHOTOPIC = 1 << 14; /** 32768 */ public readonly SE_HELFLAG_VISLIM_SCOTOPIC = 1 << 15; /** 65536 */ public readonly SE_HELFLAG_AV = 1 << 16; /** 65536 */ public readonly SE_HELFLAG_AVKIND_VR = 1 << 16; public readonly SE_HELFLAG_AVKIND_PTO = 1 << 17; public readonly SE_HELFLAG_AVKIND_MIN7 = 1 << 18; public readonly SE_HELFLAG_AVKIND_MIN9 = 1 << 19; public readonly SE_HELFLAG_AVKIND = this.SE_HELFLAG_AVKIND_VR | this.SE_HELFLAG_AVKIND_PTO | this.SE_HELFLAG_AVKIND_MIN7 | this.SE_HELFLAG_AVKIND_MIN9; public readonly TJD_INVALID = 99999999.0; public readonly SIMULATE_VICTORVB = 1; /** Unused and redundant */ public readonly SE_HELIACAL_LONG_SEARCH = 128; public readonly SE_HELIACAL_HIGH_PRECISION = 256; public readonly SE_HELIACAL_OPTICAL_PARAMS = 512; public readonly SE_HELIACAL_NO_DETAILS = 1024; /** 2048 */ public readonly SE_HELIACAL_SEARCH_1_PERIOD = 1 << 11; /** 4096 */ public readonly SE_HELIACAL_VISLIM_DARK = 1 << 12; /** 8192 */ public readonly SE_HELIACAL_VISLIM_NOMOON = 1 << 13; /** 16384 */ public readonly SE_HELIACAL_VISLIM_PHOTOPIC = 1 << 14; /** 32768 */ public readonly SE_HELIACAL_AVKIND_VR = 1 << 15; public readonly SE_HELIACAL_AVKIND_PTO = 1 << 16; public readonly SE_HELIACAL_AVKIND_MIN7 = 1 << 17; public readonly SE_HELIACAL_AVKIND_MIN9 = 1 << 18; public readonly SE_HELIACAL_AVKIND = this.SE_HELFLAG_AVKIND_VR | this.SE_HELFLAG_AVKIND_PTO | this.SE_HELFLAG_AVKIND_MIN7 | this.SE_HELFLAG_AVKIND_MIN9; public readonly SE_PHOTOPIC_FLAG = 0; public readonly SE_SCOTOPIC_FLAG = 1; public readonly SE_MIXEDOPIC_FLAG = 2; /** * For swe_set_tid_acc() and ephemeris-dependent delta t: intrinsic tidal * acceleration in the mean motion of the moon, not given in the parameters * list of the ephemeris files but computed by Chapront / Chapront - Touzé / * Francou A & A 387(2002), p. 705. */ public readonly SE_TIDAL_DE200 = -23.8946; /** Was ( -25.8) until V. 1.76.2 */ public readonly SE_TIDAL_DE403 = -25.58; /** Was ( -25.8) until V. 1.76.2 */ public readonly SE_TIDAL_DE404 = -25.58; /** Was ( -25.7376) until V. 1.76.2 */ public readonly SE_TIDAL_DE405 = -25.826; /** Was ( -25.7376) until V. 1.76.2 */ public readonly SE_TIDAL_DE406 = -25.826; /** JPL Interoffice Memorandum 14-mar-2008 on DE421 Lunar Orbit */ public readonly SE_TIDAL_DE421 = -25.85; /** JPL Interoffice Memorandum 14-mar-2008 on DE421 ( sic!) Lunar Orbit */ public readonly SE_TIDAL_DE422 = -25.85; /** JPL Interoffice Memorandum 9-jul-2013 on DE430 Lunar Orbit */ public readonly SE_TIDAL_DE430 = -25.82; /** * IPN Progress Report 42-196 • February 15, 2014, p. 15; was ( -25.82) in * V. 2.00.00 */ public readonly SE_TIDAL_DE431 = -25.8; /** Unpublished value, from email by Jon Giorgini to DK on 11 Apr 2021 */ public readonly SE_TIDAL_DE441 = -25.936; public readonly SE_TIDAL_26 = -26.0; public readonly SE_TIDAL_STEPHENSON_2016 = -25.85; public readonly SE_TIDAL_DEFAULT = this.SE_TIDAL_DE431; public readonly SE_TIDAL_AUTOMATIC = 999999; public readonly SE_TIDAL_MOSEPH = this.SE_TIDAL_DE404; public readonly SE_TIDAL_SWIEPH = this.SE_TIDAL_DEFAULT; public readonly SE_TIDAL_JPLEPH = this.SE_TIDAL_DEFAULT; /** For swe_set_delta_t_userdef() */ public readonly SE_DELTAT_AUTOMATIC = -1e-10; public readonly SE_MODEL_DELTAT = 0; public readonly SE_MODEL_PREC_LONGTERM = 1; public readonly SE_MODEL_PREC_SHORTTERM = 2; public readonly SE_MODEL_NUT = 3; public readonly SE_MODEL_BIAS = 4; public readonly SE_MODEL_JPLHOR_MODE = 5; public readonly SE_MODEL_JPLHORA_MODE = 6; public readonly SE_MODEL_SIDT = 7; public readonly NSE_MODELS = 8; /** Precession models */ public readonly SEMOD_NPREC = 11; public readonly SEMOD_PREC_IAU_1976 = 1; public readonly SEMOD_PREC_LASKAR_1986 = 2; public readonly SEMOD_PREC_WILL_EPS_LASK = 3; public readonly SEMOD_PREC_WILLIAMS_1994 = 4; public readonly SEMOD_PREC_SIMON_1994 = 5; public readonly SEMOD_PREC_IAU_2000 = 6; public readonly SEMOD_PREC_BRETAGNON_2003 = 7; public readonly SEMOD_PREC_IAU_2006 = 8; public readonly SEMOD_PREC_VONDRAK_2011 = 9; public readonly SEMOD_PREC_OWEN_1990 = 10; public readonly SEMOD_PREC_NEWCOMB = 11; public readonly SEMOD_PREC_DEFAULT = this.SEMOD_PREC_VONDRAK_2011; /** * SE versions before 1.70 used IAU 1976 precession for a limited time range * of 2 centuries in combination with the long - term precession Simon * 1994. */ public readonly SEMOD_PREC_DEFAULT_SHORT = this.SEMOD_PREC_VONDRAK_2011; /** Nutation models */ public readonly SEMOD_NNUT = 5; public readonly SEMOD_NUT_IAU_1980 = 1; /** * Herring's ( 1987) corrections to IAU 1980 nutation series.AA(1996) * neglects them. */ public readonly SEMOD_NUT_IAU_CORR_1987 = 2; /** Very time consuming ! */ public readonly SEMOD_NUT_IAU_2000A = 3; /** Fast, but precision of milli-arcsec */ public readonly SEMOD_NUT_IAU_2000B = 4; public readonly SEMOD_NUT_WOOLARD = 5; /** Fast, but precision of milli-arcsec */ public readonly SEMOD_NUT_DEFAULT = this.SEMOD_NUT_IAU_2000B; /** Methods for sidereal time */ public readonly SEMOD_NSIDT = 4; public readonly SEMOD_SIDT_IAU_1976 = 1; public readonly SEMOD_SIDT_IAU_2006 = 2; public readonly SEMOD_SIDT_IERS_CONV_2010 = 3; public readonly SEMOD_SIDT_LONGTERM = 4; public readonly SEMOD_SIDT_DEFAULT = this.SEMOD_SIDT_LONGTERM; // const SEMOD_SIDT_DEFAULT = SEMOD_SIDT_IERS_CONV_2010 /** Frame bias methods */ public readonly SEMOD_NBIAS = 3; /** Ignore frame bias */ public readonly SEMOD_BIAS_NONE = 1; /** Use frame bias matrix IAU 2000 */ public readonly SEMOD_BIAS_IAU2000 = 2; /** Use frame bias matrix IAU 2006 */ public readonly SEMOD_BIAS_IAU2006 = 3; public readonly SEMOD_BIAS_DEFAULT = this.SEMOD_BIAS_IAU2006; /** * Methods of JPL Horizons ( iflag & SEFLG_JPLHOR), using daily dpsi, deps; * see explanations below */ public readonly SEMOD_NJPLHOR = 2; /** Daily dpsi and deps from file are */ public readonly SEMOD_JPLHOR_LONG_AGREEMENT = 1; /** * Limited to 1962 - today.JPL uses the first and last value for all dates * beyond this time range. */ public readonly SEMOD_JPLHOR_DEFAULT = this.SEMOD_JPLHOR_LONG_AGREEMENT; /** * Note, currently this is the only option for SEMOD_JPLHOR.. * SEMOD_JPLHOR_LONG_AGREEMENT, if combined with SEFLG_JPLHOR provides good * agreement with JPL Horizons for 9998 BC(-9997) until 9999 CE. * * - After 20 - jan - 1962 until today, Horizons uses correct dpsi and deps. * - For dates before that, it uses dpsi and deps of 20 - jan - 1962, which * provides a continuous ephemeris, but does not make sense otherwise. * - Before 1.1.1799 and after 1.1.2202, the precession model Owen 1990 is * used, as in Horizons. An agreement with Horizons to a couple of milli * arc seconds is achieved for the whole time range of Horizons. (BC 9998 * * - Mar - 20 to AD 9999 - Dec - 31 TT.) methods of approximation of JPL * Horizons ( iflag & SEFLG_JPLHORA), without dpsi, deps; see * explanations below */ public readonly SEMOD_NJPLHORA = 3; public readonly SEMOD_JPLHORA_1 = 1; public readonly SEMOD_JPLHORA_2 = 2; public readonly SEMOD_JPLHORA_3 = 3; public readonly SEMOD_JPLHORA_DEFAULT = this.SEMOD_JPLHORA_3; /** * With SEMOD_JPLHORA_1, planetary positions are always calculated using a * recent precession / nutation model.Frame bias matrix is applied with some * correction to RA and another correction added to epsilon. this provides a * very good approximation of JPL Horizons positions. With SEMOD_JPLHORA_2, * frame bias as recommended by IERS Conventions 2003 and 2010 is not * applied.Instead, dpsi_bias and deps_bias are added to nutation.this * procedure is found in some older astronomical software. Equatorial * apparent positions will be close to JPL Horizons (within a few mas) * between 1962 and current years.Ecl.longitude will be good, latitude bad. * With SEMOD_JPLHORA_3 works like SEMOD_JPLHORA_3 after 1962, but like * SEFLG_JPLHOR before that.this allows EXTREMELY good agreement with JPL * Horizons over its whole time range. */ public readonly SEMOD_NDELTAT = 5; public readonly SEMOD_DELTAT_STEPHENSON_MORRISON_1984 = 1; public readonly SEMOD_DELTAT_STEPHENSON_1997 = 2; public readonly SEMOD_DELTAT_STEPHENSON_MORRISON_2004 = 3; public readonly SEMOD_DELTAT_ESPENAK_MEEUS_2006 = 4; public readonly SEMOD_DELTAT_STEPHENSON_ETC_2016 = 5; /** Public SEMOD_DELTAT_DEFAULT = SEMOD_DELTAT_ESPENAK_MEEUS_2006; */ public readonly SEMOD_DELTAT_DEFAULT = this.SEMOD_DELTAT_STEPHENSON_ETC_2016; /** The Swisseph Emscripten WebAssembly Module instance. */ public wasm: WASMModule; /** * Creates a new instance. * * @param wasm - Swisseph Emscripten WebAssembly Module instance */ constructor(wasm: WASMModule) { this.wasm = wasm; } /** * Static method for creating and initializing the Swisseph module. * * @returns {Promise<SwissEPH>} : Promise<SwissEPH> */ static async init(): Promise<SwissEPH> { /** Swisseph Emscripten Module instance */ const wasm = await Module(); return new SwissEPH(wasm); } /** * Converts horizontal coordinates (azimuth and altitude) to either ecliptic * or equatorial coordinates, based on the observer's geographical position * and desired coordinate system. * * @param tjd_ut - Julian day in Universal Time (UT). * @param calc_flag - Calculation mode flag: `SE_HOR2ECL` for ecliptic or * `SE_HOR2EQU` for equatorial conversion. * @param geopos - Observer's geographic position as a tuple: `[longitude, * latitude, elevation]` in degrees/meters. * @param xin - Horizontal coordinates as `[azimuth, true altitude]` in * degrees. * @returns {CelestialCoordinates2D} An Array of 2 numbers representing * celestial coordinates in either: * * - **Ecliptic coordinates**: (λ, β) when using `SE_HOR2ECL` * - **Equatorial coordinates**: (α, δ) when using `SE_HOR2EQU` * * Array format: * * - `[0]` → longitude / right ascension * - `[1]` → latitude / declination */ swe_azalt_rev( tjd_ut: number, calc_flag: number, geopos: [longitude: number, latitude: number, elevation: number], xin: [azimuth: number, true_altitude: number] ): CelestialCoordinates2D { const geoposPtr = ArrayPointer.from(this.wasm, "double", 3, geopos); const xinPtr = ArrayPointer.from(this.wasm, "double", 2, xin); const outPtr = ArrayPointer.alloc(this.wasm, "double", 2); this.wasm._swe_azalt_rev( tjd_ut, calc_flag, geoposPtr.ptr, xinPtr.ptr, outPtr.ptr ); xinPtr.free(); geoposPtr.free(); return outPtr.readAndFree(); } /** * Converts ecliptic or equatorial coordinates into horizontal coordinates * based on observer's geographic location and atmospheric conditions. * * @param {number} tjd_ut - Julian Day in Universal Time * @param {number} calc_flag - Calculation flag: `0 (SE_ECL2HOR)` for * ecliptic, `1 (SE_EQU2HOR)` for equatorial to horizontal * @param {[number, number, number]} geopos - Observer's geographic * coordinates as `[longitude, latitude, elevation]` * @param {number} atpress - Atmospheric pressure in mbar/hPa (0 to * auto-estimate) * @param {number} attemp - Atmospheric temperature in °C * @param {[number, number, number]} xin - Input coordinates: * `[longitude/right ascension, latitude/declination, distance * (optional)]` * @returns {HorizontalCoordinates} Array of 2 numbers representing * horizontal coordinates of a celestial object: * * Array format: * * - `[0]` → Azimuth in degrees (measured from the south point, increasing * westwards) * - `[1]` → True altitude above the horizon in degrees * - `[2]` → Apparent altitude in degrees (corrected for atmospheric * refraction) */ swe_azalt( tjd_ut: number, calc_flag: number, geopos: [number, number, number], atpress: number, attemp: number, xin: [number, number, number] ): HorizontalCoordinates { const geoposPtr = ArrayPointer.from(this.wasm, "double", 3, geopos); const xinPtr = ArrayPointer.from(this.wasm, "double", 3, xin); const outPtr = ArrayPointer.alloc(this.wasm, "double", 3); // Allocate space for 3 doubles: az, alt, ap this.wasm._swe_azalt( tjd_ut, calc_flag, geoposPtr.ptr, atpress, attemp, xinPtr.ptr, outPtr.ptr ); geoposPtr.free(); xinPtr.free(); return outPtr.readAndFree(); } /** * Computes the planetocentric apparent position of a target celestial body * as seen from another planet. Useful for generating ephemerides from the * perspective of a different planet — for example, Jupiter-centric * positions of other planets. * * @param {number} tjd_et - Julian day (ephemeris time, TT) * @param {number} ipl - Target body ID (e.g., SE_MARS) * @param {number} iplctr - Center body ID (e.g., SE_JUPITER) * @param {number} iflag - Computation flags (bitwise ORed SEFLG constants) * @returns {CelestialCoordinatesAdvance} Array of 6 numbers representing * celestial position: * * Array format: * * - `[0]` → Longitude (λ), Right Ascension (α), Cartesian X, or True * Obliquity (ε) depending on flags * - `[1]` → Latitude (β), Declination (δ), Cartesian Y, or Mean Obliquity (ε) * depending on flags * - `[2]` → Distance (AU), Cartesian Z, or Nutation in longitude (Δψ) * depending on flags * - `[3]` → Longitude daily speed (λs), Right Ascension daily speed (αs), * Cartesian X speed (xs), or Nutation in obliquity (Δε) * - `[4]` → Latitude daily speed (βs), Declination daily speed (δs), * Cartesian Y speed (ys) * - `[5]` → Distance daily speed (aus), Cartesian Z speed (zs) * * @throws {SWEerror} - SWEerror If fails. */ swe_calc_pctr( tjd_et: number, ipl: number, iplctr: number, iflag: number ): CelestialCoordinatesAdvance { const xxPtr = ArrayPointer.alloc(this.wasm, "double", 6); const serrPtr = StringPointer.alloc(this.wasm, this.AS_MAXCH); // Predefined buffer length for error strings const flag = this.wasm._swe_calc_pctr( tjd_et, ipl, iplctr, iflag, xxPtr.ptr, serrPtr.ptr ); const errorMsg = serrPtr.readAndFree(); if (flag < this.OK) throw new SWEerror(errorMsg, flag); return xxPtr.readAndFree(); } /** * Computes positions of planets, asteroids, lunar nodes, and apogees for a * given Julian date. * * @param {number} tjd_ut - Julian day in universal time. * @param {number} ipl - Target object ID (planet, asteroid, etc.). * @param {number} iflag - Calculation flags controlling precision and * output format. * @returns {CelestialCoordinatesAdvance} Array of 6 numbers representing * celestial position: * * Array format: * * - `[0]` → Longitude (λ), Right Ascension (α), Cartesian X, or True * Obliquity (ε) depending on flags * - `[1]` → Latitude (β), Declination (δ), Cartesian Y, or Mean Obliquity (ε) * depending on flags * - `[2]` → Distance (AU), Cartesian Z, or Nutation in longitude (Δψ) * depending on flags * - `[3]` → Longitude daily speed (λs), Right Ascension daily speed (αs), * Cartesian X speed (xs), or Nutation in obliquity (Δε) * - `[4]` → Latitude daily speed (βs), Declination daily speed (δs), * Cartesian Y speed (ys) * - `[5]` → Distance daily speed (aus), Cartesian Z speed (zs) * * @throws {SWEerror} - SWEerror If fails. */ swe_calc_ut( tjd_ut: number, ipl: number, iflag: number ): CelestialCoordinatesAdvance { const xxPtr = ArrayPointer.alloc(this.wasm, "double", 6); const serrPtr = StringPointer.alloc( this.wasm, this.AS_MAXCH ); /** Error buffer (char *) */ const flag = this.wasm._swe_calc_ut( tjd_ut, ipl, iflag, xxPtr.ptr, serrPtr.ptr ); if (flag < this.OK) throw new SWEerror(serrPtr.readAndFree(), flag); return xxPtr.readAndFree(); } /** * Compute positions of planets, asteroids, lunar nodes and apogees from * ephemeris time * * @param tjd_et - Julian day in terrestrial/ephemeris time. * @param ipl - Target object ID (planet, asteroid, etc.). * @param iflag - Calculation flags controlling precision and output format. * @returns {CelestialCoordinatesAdvance} Array of 6 numbers representing * celestial position: * * Array format: * * - `[0]` → Longitude (λ), Right Ascension (α), Cartesian X, or True * Obliquity (ε) depending on flags * - `[1]` → Latitude (β), Declination (δ), Cartesian Y, or Mean Obliquity (ε) * depending on flags * - `[2]` → Distance (AU), Cartesian Z, or Nutation in longitude (Δψ) * depending on flags * - `[3]` → Longitude daily speed (λs), Right Ascension daily speed (αs), * Cartesian X speed (xs), or Nutation in obliquity (Δε) * - `[4]` → Latitude daily speed (βs), Declination daily speed (δs), * Cartesian Y speed (ys) * - `[5]` → Distance daily speed (aus), Cartesian Z speed (zs) * * @throws {SWEerror} - SWEerror If fails. */ swe_calc( tjd_et: number, ipl: number, iflag: number ): CelestialCoordinatesAdvance { const xxPtr = ArrayPointer.alloc(this.wasm, "double", 6); const serrPtr = StringPointer.alloc(this.wasm, this.AS_MAXCH); const flag = this.wasm._swe_calc( tjd_et, ipl, iflag, xxPtr.ptr, serrPtr.ptr ); if (flag < this.OK) throw new SWEerror(serrPtr.readAndFree(), flag); return xxPtr.readAndFree(); } /** * Reset swisseph internals and cleanup file handles Not usually required as * Node cleans after itself */ swe_close(): void { this.wasm._swe_close(); } /** * Transform between ecliptic and equatorial coordinate systems including * motion speeds From equatorial to ecliptic, obliquity must be positive * From ecliptic to equatorial, obliquity must be negative Distances are not * affected and can be 0 * * @param {CelestialCoordinatesAdvance} xpo - Input coordinates in ecliptic * or equatorial coordinates [lon, lat, dist, lonSpd, latSpd, distSpd] * @param {number} eps - Positive or negative obliquity of the ecliptic * @returns {CelestialCoordinatesAdvance} Array of 6 numbers representing * celestial position: * * Array format: * * - `[0]` → Longitude (λ), Right Ascension (α), Cartesian X, or True * Obliquity (ε) depending on flags * - `[1]` → Latitude (β), Declination (δ), Cartesian Y, or Mean Obliquity (ε) * depending on flags * - `[2]` → Distance (AU), Cartesian Z, or Nutation in longitude (Δψ) * depending on flags * - `[3]` → Longitude daily speed (λs), Right Ascension daily speed (αs), * Cartesian X speed (xs), or Nutation in obliquity (Δε) * - `[4]` → Latitude daily speed (βs), Declination daily speed (δs), * Cartesian Y speed (ys) * - `[5]` → Distance daily speed (aus), Cartesian Z speed (zs) */ swe_cotrans_sp( xpo: CelestialCoordinatesAdvance, eps: number ): CelestialCoordinatesAdvance { const xpoPtr = ArrayPointer.from(this.wasm, "double", 6, xpo); const xpnPtr = ArrayPointer.alloc(this.wasm, "double", 6); this.wasm._swe_cotrans_sp(xpoPtr.ptr, xpnPtr.ptr, eps); xpoPtr.free(); return xpnPtr.readAndFree(); } /** * Transform between ecliptic and equatorial coordinate systems From * equatorial to ecliptic, obliquity must be positive From ecliptic to * equatorial, obliquity must be negative Distance is not affected and can * be 0 * * @param {CelestialCoordinates3D} xpo - Input coordinates in ecliptic or * equatorial coordinates [lon, lat, dist] * @param {number} eps - Positive or negative obliquity of the ecliptic * @returns {CelestialCoordinates3D} Array of 3 numbers representing * celestial position: * * Array format: * * - `[0]` → Longitude (λ), Right Ascension (α), Cartesian X, or True * Obliquity (ε) depending on flags * - `[1]` → Latitude (β), Declination (δ), Cartesian Y, or Mean Obliquity (ε) * depending on flags * - `[2]` → Distance (AU), Cartesian Z, or Nutation in longitude (Δψ) * depending on flags */ swe_cotrans( xpo: CelestialCoordinates3D, eps: number ): CelestialCoordinates3D { const xpoPtr = ArrayPointer.from(this.wasm, "double", 3, xpo); const xpnPtr = ArrayPointer.alloc(this.wasm, "double", 3); this.wasm._swe_cotrans(xpoPtr.ptr, xpnPtr.ptr, eps); xpoPtr.free(); return xpnPtr.readAndFree(); } /** * Convert centiseconds to degrees string * * @param csec - Centiseconds value * @returns String */ swe_cs2degstr(csec: number): string { const out = StringPointer.alloc(this.wasm, this.AS_MAXCH); this.wasm._swe_cs2degstr(csec, out.ptr); return out.readAndFree(); } /** * Convert centiseconds to longitude or latitude string with user defined * sign character * * @param csec - Centiseconds value * @param pchar - Sign character for positive values * @param mchar - Sign character for negative values * @returns String */ swe_cs2lonlatstr(csec: number, pchar: string, mchar: string): string { const out = StringPointer.alloc(this.wasm, this.AS_MAXCH); this.wasm._swe_cs2lonlatstr( csec, pchar.charCodeAt(0), mchar.charCodeAt(0), out.ptr ); return out.readAndFree(); } /** * Convert centiseconds to time string * * @param csec - Centiseconds value * @param sep - Separator character * @param suppresszero - Omit seconds if they are zero * @returns String */ swe_cs2timestr(csec: number, sep: string, suppresszero: boolean): string { const out = StringPointer.alloc(this.wasm, this.AS_MAXCH); this.wasm._swe_cs2lonlatstr( csec, sep.charCodeAt(0), TypeConverter.boolToC(suppresszero), out.ptr ); return out.readAndFree(); } /** * Normalize centiseconds to 360 degrees range * * @param csec - Centiseconds value * @returns Number */ swe_csnorm(csec: number): number { return this.wasm._swe_csnorm(csec); } /** * Round centiseconds to nearest second * * @param csec - Centiseconds value * @returns Number */ swe_csroundsec(csec: number): number { return this.wasm._swe_csroundsec(csec); } /** * Round double precision value to long integer * * @param x - Double value * @returns Number */ swe_d2l(csec: number): number { return this.wasm._swe_d2l(csec); } /** * Calculate julian day and check if the date is valid * * @param {number} year Full year * @param {number} month Month (1-12) * @param {number} day Day (1-31) * @param {number} uttime Universal time in decimal Hour fraction (0-23.999) * @param {char} calendar: Calendar system, 'g' for gregorian calendar, 'j' * for julian calendar calendar g[regorian]|j[ulian]|a[stro = greg] * @returns {Number} Julian day numeric value */ swe_date_conversion( year: number, month: number, day: number, uttime: number, calendar: "g" | "j" = "j" ): number { const tjd = NumberPointer.alloc(this.wasm, "double"); const flag = this.wasm._swe_date_conversion( year, month, day, uttime, TypeConverter.charToC(calendar), tjd.ptr ); if (flag < this.OK) throw new SWEerror("illegal date", flag); return tjd.readAndFree(); } /** * Find which day of the week a particular date is * * @param {number} jd Julian day value in universal time number // 0 = * monday, ... 6 = sunday; */ swe_day_of_week(jd: number): number { return this.wasm._swe_day_of_week(jd); } /** * Normalize degree value to 0-360 range * * @param {number} deg Degree value number // Normalized degree value; */ swe_degnorm(deg: number): number { return this.wasm._swe_degnorm(deg); } /** * Obtain the Delta T value for a date using a particular ephemeris system * * @param {number} tjd Julian day value in Universal Time * @param {number} iflag Ephemeris flag (SEFLG_SWIEPH, SEFLG_JPLEPH or * SEFLG_MOSEPH) * @returns {number} Delta T value * @throws {SWEerror} Warning message if any */ swe_deltat_ex(tjd: number, iflag: number): number { const serr = StringPointer.alloc(this.wasm, this.AS_MAXCH); const out = this.wasm._swe_deltat_ex(tjd, iflag, serr.ptr); const error = serr.readAndFree(); if (error.trim().length > 1) throw new SWEerror(error, this.ERR); return out; } /** * Obtain the Delta T value for a particular date * * @param {number} tjd Julian day value in Universal Time number // Delta T * value */ swe_deltat(tjd: number): number { return this.wasm._swe_deltat(tjd); } /** * Arc distance between two points in centiseconds * * @param {number} csecP1 First point in centiseconds * @param {number} csecP2 Second point in centiseconds number // Distance in * centiseconds from -64800000 to 64800000 (negative if second point is * ahead of the first) */ swe_difcs2n(csecP1: number, csecP2: number): number { return this.wasm._swe_difcs2n(csecP1, csecP2); } /** * Arc distance between two points in centiseconds in a single direction * * @param {number} csec1 First point in centiseconds * @param {number} csec2 Second point in centiseconds number // Distance in * centiseconds from 0 to 129600000 */ swe_difcsn(csecP1: number, csecP2: number): number { return this.wasm._swe_difcsn(csecP1, csecP2); } /** * Arc distance between two points in degrees * * @param {number} deg1 First point in degrees * @param {number} deg2 Second point in degrees number // Distance in * degrees from -180 to 180 (negative if second point is ahead of the * first) */ swe_difdeg2n(deg1: number, deg2: number): number { return this.wasm._swe_difdeg2n(deg1, deg2); } /** * Arc distance between two points in degrees in a single direction * * @param {number} deg1 First point in degrees * @param {number} deg2 Second point in degrees number // Distance in * degrees from 0 to 360 */ swe_difdegn(deg1: number, deg2: number): number { return this.wasm._swe_difdegn(deg1, deg2); } /** * Get the visual magnitude (brightness) of a fixed star * * @param star: Name of the star to search for in the sefstars.txt file * @returns Object { name: string, // The name of the matched star from the * sefstars.txt file data: number // The star's magnitude value } Star: * ${result.name} Magnitude: ${result.data} `) */ swe_fixstar_mag(star: string): { /** Star name The full star name as it appears in the sefstars.txt file */ star_name: string; /** Magnitude value */ mag: number; } { const mag = NumberPointer.alloc(this.wasm, "double"); const serr = StringPointer.alloc(this.wasm, this.AS_MAXCH); const starPtr = StringPointer.from(this.wasm, star.length, star); const flag = this.wasm._swe_fixstar_mag(starPtr.ptr, mag.ptr, serr.ptr); if (flag < this.OK) throw new SWEerror(serr.readAndFree(), flag); return { star_name: starPtr.readAndFree(), mag: mag.readAndFree(), }; } /** * Calculate the positions of a star from universal time * * @param star: Name of the star to search for in the sefstars.txt file * @param {number} tjd_ut Julian day in universal time * @param {number} iflag Calculation flags * @returns Object { name: string, // The name of the matched star from the * sefstars.txt file data: Array<number> [ lon, // Longitude, right * ascension or cartesian X lat, // Latitude