Coder Social home page Coder Social logo

sweph's Introduction

Hello there

I'm Tim, a Slovenian dude born in Germany, raised in Portugal and currently living in Brazil!

Im a JavaScript enthusiast and professional nerd who develops high quality open source libraries on NPM. I also run a successful Discord bot and a powerful astronomy API. In my free time i like helping other developers, especially beginner developers on Discord and elsewhere.

My main interest is researching, benchmarking and delivering custom high-performance JavaScript solutions to specific problems.

Oh yes, I also read Astrology and Human Design charts :)

PS: Most of my work is offered free of charge and licensed under MIT, however if you use my open source libraries in a commercial product or business, consider subscribing to the appropriate sponsorship level here and get priority support for your company.

sweph's People

Contributors

erwin1234777 avatar iki avatar martynasj avatar timotejroiko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sweph's Issues

Electronjs

Will this work with electronjs for mac apps?

Planet position different result from Astro.com birth chart

I tried to get a planet position but the result is different from Astro.com birth chart, why? Thanks.

NOTE: the commented line is bugged: flag is 2 instead of 0.

const sweph = require('sweph');
const luxon = require('luxon');

const { constants, utc_to_jd, houses, house_pos, calc, calc_ut, split_deg } = sweph;
const { DateTime } = luxon;

sweph.set_ephe_path('ephe');

const planet_name = 'Neptune'
const planet_id = constants.SE_NEPTUNE;

const params = {
    year: 1978,
    month: 4,
    day: 11,
    hours: 11,
    minutes: 59,
    zone:  'Europe/Rome',
    // Camposampiero, ITALY, 45n34 11e56
    lat:  45.566667,
    lon: 11.933333
}

const localDate = DateTime.local(params.year, params.month, params.day, params.hours, params.minutes, { zone: params.zone });
const utcDate = localDate.toUTC();

const JD = utc_to_jd(utcDate.year, utcDate.month, utcDate.day, utcDate.hour, utcDate.minute, utcDate.second, constants.SE_GREG_CAL);
if (JD.flag !== constants.OK) { throw new Error(JD.error); }
const [ JDET, JDUT ] = JD.data;

const HOUSES = houses(JDUT, Number(params.lat), Number(params.lon), 'P');
if (HOUSES.flag !== constants.OK) { throw new Error(HOUSES.flag); }
const armc = HOUSES.data.points[2];

const ECLIPTIC = calc_ut(JDUT, constants.SE_ECL_NUT, 0);
const eps = ECLIPTIC.data[0];

const calcs = calc_ut(JDUT, planet_id, constants.SEFLG_TROPICAL);
// if (calcs.flag !== constants.OK) { throw new Error(JSON.stringify(calcs)); }
const xpin = calcs.data.slice(0, 2);

const NEPTUNE_POS = house_pos(armc, params.lat, eps, 'P', xpin);
const houseNum = parseInt(NEPTUNE_POS.data);
const housePosPercent = NEPTUNE_POS.data - houseNum;
const cusps = HOUSES.data.houses;
const currCusp = cusps[houseNum - 1];
let nextCusp = (cusps[houseNum] !== undefined ? cusps[houseNum] : cusps[0]);
if (nextCusp < currCusp) nextCusp += 360;
const houseWidth = (nextCusp - currCusp);
const deg = currCusp + houseWidth * housePosPercent;

let retrograde;
switch (planet_id) {
    case constants.SE_SUN:
    case constants.SE_MOON:
        retrograde = "Not applicable";
        break;
    case constants.SE_TRUE_NODE:
        retrograde = "Always";
        break;
    default:
        retrograde = (planet_id > 12) ? "Not a planet" : (calcs[3] < 0);
        break;
}

const SPLITTED_POS = split_deg(deg, constants.SE_SPLIT_DEG_ROUND_SEC + constants.SE_SPLIT_DEG_ZODIACAL);
console.log(``);
console.log(`Planet: ${planet_name}`);
console.log(``);
console.log(`SCRIPT RESULT`);
console.log(`sweph.house_pos = ${NEPTUNE_POS.data}`); // 5.618979596337847
console.log(`sweph.split_deg = ${JSON.stringify(SPLITTED_POS)}`); // {"degree":18,"minute":42,"second":36,"fraction":0,"sign":8}
console.log(`Retrograde = ${retrograde}`); // false
console.log(``);
console.log(`ASTRO.COM BIRTCHART RESULT`);
console.log(`deg = {"degree":18,"minute":11,"second":38,"fraction":0,"sign":8}`);
console.log(`Retrograde = true`);
console.log(``);

sweph.rise_trans returns incorrect value

The method sweph.rise_trans returns incorrect value.

The below code for calculating Sunrise time for 07/07/21 for Hyderabad, IN returns 2459402.535475984 which seem to be incorrect (by almost 30 minutes) when compared to calculation done using other libraries (listed below).
sweph.rise_trans(2459402.2708333335, 0, null, SWEC.SEFLG_SWIEPH, 769, [78.45636, 17.38405, 0], 0, 0); // 2459402.535475984

Using a python library or another Node.js library with the same input values gives correct results. Have verified the correctness of results from these libraries with Sunrise time from few websites.

Using Python Library (https://github.com/astrorigin/pyswisseph)
swe.rise_trans(2459402.2708333335, 0, 78.45636, 17.38405, rsmi = 769) // 2459402.514695216

Using Node.js Library (https://github.com/mivion/swisseph)

swisseph.swe_rise_trans(
  2459402.2708333335, 
  0, // Planet,
  "", // Star (empty string for Planet),
  swisseph.SEFLG_SWIEPH, 
  769, // rsmi swisseph.SE_CALC_RISE,
  78.45636, // longitude,
  17.38405, // latitude,
  0, // altitude,
  0, // pressure,
  0, // temperature,
  function (result) {
    console.log("Result: ", result.transitTime); // 2459402.514695169
  });

What am I missing here?

react native compatibility

This probably isn't a bug as much as a feature request. I'm running into issues trying to use this package within an expo react native app. I think it's probably got something to do with it being a node binding, and react native doesn't necessarily work out of the box with node core modules.

I ran into this article and it looks like possibly there might be workarounds, but it's a little over my head to figure out. Is there any way to modify this package so that it could be imported into a react native app? https://gist.github.com/parshap/e3063d9bf6058041b34b26b7166fd6bd

Right now I'm stuck with running an external server to use the java swisseph package and the API calls are killing my performance, so I'd love to get the calculations local on the device. Thanks so much!

edit for more info:

this is the (at least initial) error I run into when trying to use the module

Unable to resolve module ./build/Release/sweph.node from D:\dev\repos\swisseph-test-app\node_modules\sweph\index.js: 

None of these files exist:
  * node_modules\sweph\build\Release\sweph.node(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json)
  * node_modules\sweph\build\Release\sweph.node\index(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json)
  1 | "use strict";
  2 |
> 3 | const sweph = require("./build/Release/sweph.node");
    |                        ^
  4 | sweph.constants = require("./constants.js");
  5 | sweph.sweph = sweph;
  6 | sweph.default = sweph;

unable to install on Windows 11

Hi, installed latest Node, Python and Build Tools for Visual Studio 2022 but npm install sweph doesn't work (tried with both Windows 10 SDK 11 and Windows 11 SDK). Here is the log. Thanks.

0 verbose cli C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js
1 info using [email protected]
2 info using [email protected]
3 timing npm:load:whichnode Completed in 2ms
4 timing config:load:defaults Completed in 1ms
5 timing config:load:file:C:\Users\jure\AppData\Roaming\nvm\v16.17.1\node_modules\npm\npmrc Completed in 3ms
6 timing config:load:builtin Completed in 4ms
7 timing config:load:cli Completed in 1ms
8 timing config:load:env Completed in 1ms
9 timing config:load:file:C:\storage\Dropbox\Dropbox\franci\birthchart\.npmrc Completed in 0ms
10 timing config:load:project Completed in 1ms
11 timing config:load:file:C:\Users\jure\.npmrc Completed in 1ms
12 timing config:load:user Completed in 1ms
13 timing config:load:file:C:\Program Files\nodejs\etc\npmrc Completed in 0ms
14 timing config:load:global Completed in 0ms
15 timing config:load:setEnvs Completed in 1ms
16 timing config:load Completed in 11ms
17 timing npm:load:configload Completed in 11ms
18 timing config:load:flatten Completed in 2ms
19 timing npm:load:mkdirpcache Completed in 0ms
20 timing npm:load:mkdirplogs Completed in 1ms
21 verbose title npm install sweph
22 verbose argv "install" "sweph"
23 timing npm:load:setTitle Completed in 1ms
24 timing npm:load:display Completed in 0ms
25 verbose logfile logs-max:10 dir:C:\Users\jure\AppData\Local\npm-cache\_logs\2024-02-15T13_21_42_109Z-
26 verbose logfile C:\Users\jure\AppData\Local\npm-cache\_logs\2024-02-15T13_21_42_109Z-debug-0.log
27 timing npm:load:logFile Completed in 9ms
28 timing npm:load:timers Completed in 0ms
29 timing npm:load:configScope Completed in 0ms
30 timing npm:load Completed in 53ms
31 timing config:load:flatten Completed in 0ms
32 timing arborist:ctor Completed in 1ms
33 timing arborist:ctor Completed in 1ms
34 silly logfile start cleaning logs, removing 2 files
35 timing idealTree:init Completed in 14ms
36 timing idealTree:userRequests Completed in 3ms
37 silly idealTree buildDeps
38 silly fetch manifest sweph@*
39 silly logfile done cleaning log files
40 http fetch GET 200 https://registry.npmjs.org/sweph 382ms (cache revalidated)
41 silly placeDep ROOT [email protected] REPLACE for:  want: *
42 timing idealTree:#root Completed in 388ms
43 timing idealTree:node_modules/sweph Completed in 0ms
44 timing idealTree:buildDeps Completed in 389ms
45 timing idealTree:fixDepFlags Completed in 0ms
46 timing idealTree Completed in 407ms
47 timing reify:loadTrees Completed in 407ms
48 timing reify:diffTrees Completed in 1ms
49 silly reify mark retired [
49 silly reify   'C:\\storage\\Dropbox\\Dropbox\\franci\\birthchart\\node_modules\\sweph'
49 silly reify ]
50 silly reify moves {
50 silly reify   'C:\\storage\\Dropbox\\Dropbox\\franci\\birthchart\\node_modules\\sweph': 'C:\\storage\\Dropbox\\Dropbox\\franci\\birthchart\\node_modules\\.sweph-Cm7fpgpu'
50 silly reify }
51 timing reify:retireShallow Completed in 4ms
52 timing reify:createSparse Completed in 1ms
53 timing reify:loadBundles Completed in 0ms
54 timing reifyNode:node_modules/sweph Completed in 190ms
55 timing reify:unpack Completed in 190ms
56 timing reify:unretire Completed in 0ms
57 timing build:queue Completed in 14ms
58 info run [email protected] preinstall node_modules/sweph node -e "const { readdirSync, readFileSync, writeFileSync } = require('fs'); const file = readdirSync('./src/functions').map((x,i) => readFileSync('./src/functions/' + x, 'utf8').replace(/args/g, 'args' + i).replace('#include <sweph.h>', '')).reduce((a,b) => a + b, '#include <sweph.h>'); writeFileSync('./src/functions.cpp', file, 'utf8');"
59 info run [email protected] preinstall { code: 0, signal: null }
60 timing build:run:preinstall:node_modules/sweph Completed in 902ms
61 timing build:run:preinstall Completed in 903ms
62 info run [email protected] install node_modules/sweph node-gyp rebuild && npm run test
63 info run [email protected] install { code: 1, signal: null }
64 warn cleanup Failed to remove some directories [
64 warn cleanup   [
64 warn cleanup     'C:\\storage\\Dropbox\\Dropbox\\franci\\birthchart\\node_modules\\sweph',
64 warn cleanup     [Error: EBUSY: resource busy or locked, rmdir 'C:\storage\Dropbox\Dropbox\franci\birthchart\node_modules\sweph'] {
64 warn cleanup       errno: -4082,
64 warn cleanup       code: 'EBUSY',
64 warn cleanup       syscall: 'rmdir',
64 warn cleanup       path: 'C:\\storage\\Dropbox\\Dropbox\\franci\\birthchart\\node_modules\\sweph'
64 warn cleanup     }
64 warn cleanup   ],
64 warn cleanup   [
64 warn cleanup     'C:\\storage\\Dropbox\\Dropbox\\franci\\birthchart\\node_modules\\sweph',
64 warn cleanup     [Error: EBUSY: resource busy or locked, rmdir 'C:\storage\Dropbox\Dropbox\franci\birthchart\node_modules\sweph'] {
64 warn cleanup       errno: -4082,
64 warn cleanup       code: 'EBUSY',
64 warn cleanup       syscall: 'rmdir',
64 warn cleanup       path: 'C:\\storage\\Dropbox\\Dropbox\\franci\\birthchart\\node_modules\\sweph'
64 warn cleanup     }
64 warn cleanup   ]
64 warn cleanup ]
65 timing reify:rollback:createSparse Completed in 30ms
66 timing reify:rollback:retireShallow Completed in 4ms
67 timing command:install Completed in 6731ms
68 verbose stack Error: command failed
68 verbose stack     at ChildProcess.<anonymous> (C:\Users\jure\AppData\Roaming\nvm\v16.17.1\node_modules\npm\node_modules\@npmcli\promise-spawn\lib\index.js:53:27)
68 verbose stack     at ChildProcess.emit (node:events:513:28)
68 verbose stack     at maybeClose (node:internal/child_process:1093:16)
68 verbose stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
69 verbose pkgid [email protected]
70 verbose cwd C:\storage\Dropbox\Dropbox\franci\birthchart
71 verbose Windows_NT 10.0.22631
72 verbose node v16.17.1
73 verbose npm  v9.7.1
74 error code 1
75 error path C:\storage\Dropbox\Dropbox\franci\birthchart\node_modules\sweph
76 error command failed
77 error command C:\WINDOWS\system32\cmd.exe /d /s /c node-gyp rebuild && npm run test
78 error gyp info it worked if it ends with ok
78 error gyp info using [email protected]
78 error gyp info using [email protected] | win32 | x64
78 error gyp info find Python using Python version 3.12.2 found at "C:\Users\jure\AppData\Local\Programs\Python\Python312\python.exe"
78 error gyp info find VS using VS2022 (17.9.34607.119) found at:
78 error gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools"
78 error gyp info find VS run with --verbose for detailed information
78 error gyp info spawn C:\Users\jure\AppData\Local\Programs\Python\Python312\python.exe
78 error gyp info spawn args [
78 error gyp info spawn args   'C:\\Users\\jure\\AppData\\Roaming\\nvm\\v16.17.1\\node_modules\\npm\\node_modules\\node-gyp\\gyp\\gyp_main.py',
78 error gyp info spawn args   'binding.gyp',
78 error gyp info spawn args   '-f',
78 error gyp info spawn args   'msvs',
78 error gyp info spawn args   '-I',
78 error gyp info spawn args   'C:\\storage\\Dropbox\\Dropbox\\franci\\birthchart\\node_modules\\sweph\\build\\config.gypi',
78 error gyp info spawn args   '-I',
78 error gyp info spawn args   'C:\\Users\\jure\\AppData\\Roaming\\nvm\\v16.17.1\\node_modules\\npm\\node_modules\\node-gyp\\addon.gypi',
78 error gyp info spawn args   '-I',
78 error gyp info spawn args   'C:\\Users\\jure\\AppData\\Local\\node-gyp\\Cache\\16.17.1\\include\\node\\common.gypi',
78 error gyp info spawn args   '-Dlibrary=shared_library',
78 error gyp info spawn args   '-Dvisibility=default',
78 error gyp info spawn args   '-Dnode_root_dir=C:\\Users\\jure\\AppData\\Local\\node-gyp\\Cache\\16.17.1',
78 error gyp info spawn args   '-Dnode_gyp_dir=C:\\Users\\jure\\AppData\\Roaming\\nvm\\v16.17.1\\node_modules\\npm\\node_modules\\node-gyp',
78 error gyp info spawn args   '-Dnode_lib_file=C:\\\\Users\\\\jure\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\16.17.1\\\\<(target_arch)\\\\node.lib',
78 error gyp info spawn args   '-Dmodule_root_dir=C:\\storage\\Dropbox\\Dropbox\\franci\\birthchart\\node_modules\\sweph',
78 error gyp info spawn args   '-Dnode_engine=v8',
78 error gyp info spawn args   '--depth=.',
78 error gyp info spawn args   '--no-parallel',
78 error gyp info spawn args   '--generator-output',
78 error gyp info spawn args   'C:\\storage\\Dropbox\\Dropbox\\franci\\birthchart\\node_modules\\sweph\\build',
78 error gyp info spawn args   '-Goutput_dir=.'
78 error gyp info spawn args ]
78 error Traceback (most recent call last):
78 error   File "C:\Users\jure\AppData\Roaming\nvm\v16.17.1\node_modules\npm\node_modules\node-gyp\gyp\gyp_main.py", line 42, in <module>
78 error     import gyp  # noqa: E402
78 error     ^^^^^^^^^^
78 error   File "C:\Users\jure\AppData\Roaming\nvm\v16.17.1\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 9, in <module>
78 error     import gyp.input
78 error   File "C:\Users\jure\AppData\Roaming\nvm\v16.17.1\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\input.py", line 19, in <module>
78 error     from distutils.version import StrictVersion
78 error ModuleNotFoundError: No module named 'distutils'
78 error gyp ERR! configure error 
78 error gyp ERR! stack Error: `gyp` failed with exit code: 1
78 error gyp ERR! stack     at ChildProcess.onCpExit (C:\Users\jure\AppData\Roaming\nvm\v16.17.1\node_modules\npm\node_modules\node-gyp\lib\configure.js:325:16)
78 error gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
78 error gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
78 error gyp ERR! System Windows_NT 10.0.22631
78 error gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\jure\\AppData\\Roaming\\nvm\\v16.17.1\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
78 error gyp ERR! cwd C:\storage\Dropbox\Dropbox\franci\birthchart\node_modules\sweph
78 error gyp ERR! node -v v16.17.1
78 error gyp ERR! node-gyp -v v9.3.1
78 error gyp ERR! not ok
79 verbose exit 1
80 timing npm Completed in 11105ms
81 verbose unfinished npm timer reify 1708003306457
82 verbose unfinished npm timer reify:build 1708003307064
83 verbose unfinished npm timer build 1708003307064
84 verbose unfinished npm timer build:deps 1708003307064
85 verbose unfinished npm timer build:run:install 1708003307983
86 verbose unfinished npm timer build:run:install:node_modules/sweph 1708003307983
87 verbose code 1
88 error A complete log of this run can be found in: C:\Users\jure\AppData\Local\npm-cache\_logs\2024-02-15T13_21_42_109Z-debug-0.log

Astrodienst Dropbox folder is too big to be downloaded

Hi, i'm workinog on Windows 11.

I'd like to download all the Swiss Ephemeris files, not main planets only, because I need asteroids' informations too. So I tried to download the Dropbox folder.

I own a free Dropbox account, but when I try to download I get a "too big" message and the download does not start.

I tried some browser extension and utilities like JDownloader without success.

Then I decided to download each sub folder manually but the web interface has some strange behaviours, the result is that the numeration in the folders' names appears to be messy. I tried different browsers but the problem remains.

Are there alternative ways to download all the files?

Thanks.

Wrong info in utc_time_zone()

In utc_time_zone() the typescript is saying that timezone values can only take positive numbers which is d_timezone: number // Timezone offset in decimal hours (0-23.99999)

But in official documentation it can be both negative and positive

Problem when using constants as array indices in TypeScript

Hello again. I started using your library and it looks nice, so let me first thank you for all the work you've put into it and making it available to us all.

While using the library in a TypeScript project I continually run into the following problem: Planets are defined via an enum (e.g. sweph.constants.SE_MARS), but whenever I try to use them as numbers for an array index I get a TSC error.

Element implicitly has an 'any' type because index expression is not of type 'number'. ts(7015)

Example:

const array = new Array<number>();
[
    sweph.constants.SE_SUN,
    sweph.constants.SE_MOON,
    sweph.constants.SE_MERCURY,
    sweph.constants.SE_VENUS,
    sweph.constants.SE_MARS,
    sweph.constants.SE_JUPITER,
    sweph.constants.SE_SATURN,
    sweph.constants.SE_URANUS,
    sweph.constants.SE_NEPTUNE,
    sweph.constants.SE_PLUTO,
].forEach((planetId) => {
    array[planetId] = 123456789; // <-- ERROR
});

I think the problem is that not all enum members are numbers. Would it be possible to type the constants as object properties instead of using an enum?

This should only affect the type definitions and not the rest of the library.

Unable to run on Windows

I have used sweph module in my project. Everything is working fine on Linux (ubuntu), but when I tried running the same code on Windows 11, I am getting an error while doing npm install command

I have installed Visual Studio 2022 with "Desktop development with C++"

Node Version: 18.15.0
NPM version: 9.5.0
Python: 3.6 and 2.7

The error is:

npm WARN deprecated @npmcli/[email protected]: This functionality has been moved to @npmcli/fs
npm WARN deprecated [email protected]: Please use @jridgewell/sourcemap-codec instead
npm ERR! code 1
npm ERR! path C:\Users\prati\Desktop\project\node_modules\sweph
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node-gyp rebuild
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | win32 | x64
npm ERR! gyp info find Python using Python version 3.11.2 found at "C:\Python311\python.exe"
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS msvs_version not set from command line or npm config
npm ERR! gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
npm ERR! gyp ERR! find VS checking VS2022 (17.5.33530.505) found at:
npm ERR! gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools"
npm ERR! gyp ERR! find VS - found "Visual Studio C++ core features"
npm ERR! gyp ERR! find VS - found VC++ toolset: v143
npm ERR! gyp ERR! find VS - missing any Windows SDK
npm ERR! gyp ERR! find VS checking VS2019 (16.11.33529.622) found at:
npm ERR! gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools"
npm ERR! gyp ERR! find VS - found "Visual Studio C++ core features"
npm ERR! gyp ERR! find VS - found VC++ toolset: v142
npm ERR! gyp ERR! find VS - missing any Windows SDK
npm ERR! gyp ERR! find VS could not find a version of Visual Studio 2017 or newer to use
npm ERR! gyp ERR! find VS looking for Visual Studio 2015
npm ERR! gyp ERR! find VS - not found
npm ERR! gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS **************************************************************
npm ERR! gyp ERR! find VS You need to install the latest version of Visual Studio
npm ERR! gyp ERR! find VS including the "Desktop development with C++" workload.
npm ERR! gyp ERR! find VS For more information consult the documentation at:
npm ERR! gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
npm ERR! gyp ERR! find VS **************************************************************
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Could not find any Visual Studio installation to use
npm ERR! gyp ERR! stack     at VisualStudioFinder.fail (C:\Users\prati\Desktop\project\node_modules\node-gyp\lib\find-visualstudio.js:122:47)
projectnpm ERR! gyp ERR! stack     at VisualStudioFinder.findVisualStudio2013 (C:\Users\prati\Desktop\project\node_modules\node-gyp\lib\find-visualstudio.js:363:14)
npm ERR! gyp ERR! stack     at C:\Users\prati\Desktop\project\node_modules\node-gyp\lib\find-visualstudio.js:71:14
npm ERR! gyp ERR! stack     at C:\Users\prati\Desktop\project\node_modules\node-gyp\lib\find-visualstudio.js:384:16
npm ERR! gyp ERR! stack     at C:\Users\prati\Desktop\project\node_modules\node-gyp\lib\util.js:54:7
npm ERR! gyp ERR! stack     at C:\Users\prati\Desktop\project\node_modules\node-gyp\lib\util.js:33:16
npm ERR! gyp ERR! stack     at ChildProcess.exithandler (node:child_process:427:5)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
npm ERR! gyp ERR! stack     at maybeClose (node:internal/child_process:1091:16)
npm ERR! gyp ERR! System Windows_NT 10.0.22621
npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\prati\\Desktop\\project\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd C:\Users\prati\Desktop\project\node_modules\sweph
npm ERR! gyp ERR! node -v v18.15.0
npm ERR! gyp ERR! node-gyp -v v8.4.1
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\prati\AppData\Local\npm-cache\_logs\2023-04-12T01_59_50_783Z-debug-0.log

new feature

please feel free to delete since its not an actual issue but do you think you can add solcross and mooncross to your code <3

double swe_solcross_ut(

     double x2cross,

double tjd_ut,

int32 iflag,

char *serr);

Error in house_name() method

Method: house_name() asks for a string as a parameter, but gives an error when passed as house_name('p').

When an integer is passed like house_name(1), it works. But gives the same output for all other integer values.

Need help with Angular integration

I'm building an Angular application but unable to integrate sweph library.

Error:
./node_modules/sweph/index.mjs:1:0-39 - Error: Module not found: Error: Can't resolve 'module' in 'C:\Users\admin\Workspace\github\sweph\sweph-ui\node_modules\sweph'

Here is the Git repo

It has 2 projects. (both are NodeJS frameworks)

sweph-ui = Angular application
sweph-api = NestJS application

NestJS, its working fine.

So want to know if there is a workaround for sweph + angular.

Wrong sunrise time for negative timezones

I am trying to get sunrise time of:

longitude: 112.06666667
latitude: 33.45000000
timezone: -7
elevation: 330
year: 2023
month: 10
date: 1
hour: 0
minute: 0
second: 0

I converted the above date time to UTC and then to julian date which came to: 2460218.7916674046

Then I used rise_trans function from sweph package. Here is the code

rise_trans(
      2460218.7916674046,
      0, // Planet sun
      null,
      2, // flag.SWIEPH,
      1, // For rising 
      [112.06666667, 33.45000000, 330],
      0,
      0,
    )

I am getting this result in Julian date: 2460218.928608603, when converted to UTC it becomes 2023-10-01 10:17:00 (which is wrong) because in local time the sunrise time becomes at 3:17 AM

Issue in Electron

I am creating my own package using this sweph package. I try to install my package in electron project using github link in package json. ie something like this
{ "dependencies": { "sweph-extend": "git+ssh://[email protected]:arjunghimire/sweph-extend.git" }, }

node -v v20.10.0
npm -v 10.2.3

While running npm install command I got following issue

npm WARN deprecated @types/[email protected]: This is a stub types definition. terser-webpack-plugin provides its own type definitions, so you do not need this installed.
npm WARN deprecated @npmcli/[email protected]: This functionality has been moved to @npmcli/fs
npm ERR! code 1
npm ERR! path /home/arjun/Projects/Self/merokundaliapp/node_modules/sweph
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild && npm run test
npm ERR! make: Entering directory '/home/arjun/Projects/Self/merokundaliapp/node_modules/sweph/build'
npm ERR! CC(target) Release/obj.target/swisseph/swisseph/swecl.o
npm ERR! CC(target) Release/obj.target/swisseph/swisseph/swedate.o
npm ERR! CC(target) Release/obj.target/swisseph/swisseph/swehel.o
npm ERR! CC(target) Release/obj.target/swisseph/swisseph/swehouse.o
npm ERR! CC(target) Release/obj.target/swisseph/swisseph/swejpl.o
npm ERR! CC(target) Release/obj.target/swisseph/swisseph/swemmoon.o
npm ERR! CC(target) Release/obj.target/swisseph/swisseph/swemplan.o
npm ERR! CC(target) Release/obj.target/swisseph/swisseph/sweph.o
npm ERR! CC(target) Release/obj.target/swisseph/swisseph/swephlib.o
npm ERR! rm -f Release/obj.target/swisseph.a Release/obj.target/swisseph.a.ar-file-list; mkdir -p dirname Release/obj.target/swisseph.a
npm ERR! ar crs Release/obj.target/swisseph.a @Release/obj.target/swisseph.a.ar-file-list
npm ERR! COPY Release/swisseph.a
npm ERR! CXX(target) Release/obj.target/sweph/src/sweph.o
npm ERR! make: Leaving directory '/home/arjun/Projects/Self/merokundaliapp/node_modules/sweph/build'
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | linux | x64
npm ERR! gyp info find Python using Python version 3.10.12 found at "/usr/bin/python3"
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/home/arjun/Projects/Self/merokundaliapp/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'make',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/home/arjun/Projects/Self/merokundaliapp/node_modules/sweph/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/home/arjun/Projects/Self/merokundaliapp/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/home/arjun/.cache/node-gyp/20.10.0/include/node/common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=/home/arjun/.cache/node-gyp/20.10.0',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/home/arjun/Projects/Self/merokundaliapp/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/home/arjun/.cache/node-gyp/20.10.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/home/arjun/Projects/Self/merokundaliapp/node_modules/sweph',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! ../swisseph/sweph.c:124:29: warning: missing initializer for field ‘do_interpolate_nut’ of ‘struct swe_data’ [-Wmissing-field-initializers]
npm ERR! 124 | };
npm ERR! | ^
npm ERR! In file included from ../swisseph/sweph.c:71:
npm ERR! ../swisseph/sweph.h:825:11: note: ‘do_interpolate_nut’ declared here
npm ERR! 825 | AS_BOOL do_interpolate_nut;
npm ERR! | ^~~~~~~~~~~~~~~~~~
npm ERR! ../swisseph/sweph.c: In function ‘jplplan’:
npm ERR! ../swisseph/sweph.c:1988:48: warning: parameter ‘iflag’ set but not used [-Wunused-but-set-parameter]
npm ERR! 1988 | static int jplplan(double tjd, int ipli, int32 iflag, AS_BOOL do_save,
npm ERR! | ~~~~~~^~~~~
npm ERR! ../swisseph/sweph.c: In function ‘search_star_in_list’:
npm ERR! ../swisseph/sweph.c:6705:20: warning: comparison of integer expressions of different signedness: ‘long int’ and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare]
npm ERR! 6705 | if (sp - sstar != strlen(sstar) - 1) {
npm ERR! | ^~
npm ERR! In file included from ../src/sweph.cpp:1:
npm ERR! ../src/sweph.h:5:10: fatal error: napi.h: No such file or directory
npm ERR! 5 | #include <napi.h>
npm ERR! | ^~~~~~~~
npm ERR! compilation terminated.
npm ERR! make: *** [sweph.target.mk:123: Release/obj.target/sweph/src/sweph.o] Error 1
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: make failed with exit code: 2
npm ERR! gyp ERR! stack at ChildProcess.onExit (/home/arjun/Projects/Self/merokundaliapp/node_modules/node-gyp/lib/build.js:203:23)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:514:28)
npm ERR! gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:294:12)
npm ERR! gyp ERR! System Linux 5.15.0-94-generic
npm ERR! gyp ERR! command "/home/arjun/.nvm/versions/node/v20.10.0/bin/node" "/home/arjun/Projects/Self/merokundaliapp/node_modules/.bin/node-gyp" "rebuild"
npm ERR! gyp ERR! cwd /home/arjun/Projects/Self/merokundaliapp/node_modules/sweph
npm ERR! gyp ERR! node -v v20.10.0
npm ERR! gyp ERR! node-gyp -v v9.3.1
npm ERR! gyp ERR! not ok
npm ERR! A complete log of this run can be found in: /home/arjun/.npm/_logs/2024-02-12T17_00_36_677Z-debug-0.log

Can anyone please help me to solve this ?

Please help me out with deployment issue?

Hi, I am trying to deploy the project on AWS lambda which is dependent on 'sweph' module.

It is working fine locally, but when I deploy it to Lambda and run it. I get the following error:

2022-08-31T09:07:25.867Z	undefined	ERROR	Uncaught Exception 	{
    "errorType": "Error",
    "errorMessage": "/lib64/libm.so.6: version `GLIBC_2.29' not found (required by /var/task/node_modules/sweph/build/Release/sweph.node)",
    "code": "ERR_DLOPEN_FAILED",
    "stack": [
        "Error: /lib64/libm.so.6: version `GLIBC_2.29' not found (required by /var/task/node_modules/sweph/build/Release/sweph.node)",
        "    at Object.Module._extensions..node (node:internal/modules/cjs/loader:1189:18)",
        "    at Module.load (node:internal/modules/cjs/loader:981:32)",
        "    at Function.Module._load (node:internal/modules/cjs/loader:822:12)",
        "    at Module.require (node:internal/modules/cjs/loader:1005:19)",
        "    at require (node:internal/modules/cjs/helpers:102:18)",
        "    at Object.<anonymous> (/var/task/node_modules/sweph/index.js:3:15)",
        "    at Module._compile (node:internal/modules/cjs/loader:1105:14)",
        "    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)",
        "    at Module.load (node:internal/modules/cjs/loader:981:32)",
        "    at Function.Module._load (node:internal/modules/cjs/loader:822:12)"
    ]
}

Can you please help me out with this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.