/swe/pyswisseph.c

https://github.com/astrolet/precious · C · 4153 lines · 3634 code · 327 blank · 192 comment · 471 complexity · f9ffdb67741ba2bd9f326deecdaf2b7b MD5 · raw file

  1. /*
  2. This file is part of Pyswisseph.
  3. Copyright (c) 2007-2011 Stanislas Marquis <smarquis@chaosorigin.com>
  4. Pyswisseph is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. Pyswisseph is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with Pyswisseph. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. /** Python extension to the Swiss Ephemeris
  16. Author/maintainer: Stanislas Marquis <smarquis@chaosorigin.com>
  17. Homepage: http://pyswisseph.chaosorigin.com/
  18. Swisseph authors: Alois Treindl, Dieter Koch.
  19. Swisseph homepage: http://www.astro.com/swisseph
  20. Swisseph version: 1.77.00
  21. Last revision: 08.09.2011
  22. */
  23. #define PYSWISSEPH_VERSION 20110908
  24. /* Set the default argument for set_ephe_path function */
  25. #ifndef PYSWE_DEFAULT_EPHE_PATH
  26. #ifdef WIN32
  27. #define PYSWE_DEFAULT_EPHE_PATH "C:\\swisseph"
  28. #else
  29. #define PYSWE_DEFAULT_EPHE_PATH "/usr/share/swisseph:/usr/local/share/swisseph"
  30. #endif
  31. #endif /* PYSWE_DEFAULT_EPHE_PATH */
  32. /* Wether to automaticly set ephemeris path on module import */
  33. #ifndef PYSWE_AUTO_SET_EPHE_PATH
  34. #define PYSWE_AUTO_SET_EPHE_PATH 1
  35. #endif
  36. /* Wether to build swephelp functions */
  37. #ifndef PYSWE_USE_SWEPHELP
  38. #define PYSWE_USE_SWEPHELP 1
  39. #endif
  40. /* Dont modify below */
  41. #include <Python.h>
  42. #include <swephexp.h>
  43. #if PYSWE_USE_SWEPHELP
  44. #include <swephelp.h>
  45. #endif
  46. /* Needed for compilation with Python < 2.4 */
  47. #if PY_MAJOR_VERSION < 2 || (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION <= 3)
  48. #define Py_RETURN_NONE Py_INCREF(Py_None); return Py_None;
  49. #define Py_RETURN_TRUE Py_INCREF(Py_True); return Py_True;
  50. #define Py_RETURN_FALSE Py_INCREF(Py_False); return Py_False;
  51. #endif
  52. #define FUNCARGS_SELF (PyObject *self)
  53. #define FUNCARGS_KEYWDS (PyObject *self, PyObject *args, PyObject *keywds)
  54. /* swisseph.Error */
  55. static PyObject * pyswe_Error; /* Module exception type */
  56. /* swisseph.set_ephe_path */
  57. static char pyswe_set_ephe_path__doc__[] =
  58. "Set ephemeris files path.\n\n"
  59. "Args: str path=\"" PYSWE_DEFAULT_EPHE_PATH "\"\n"
  60. "Return: None";
  61. static PyObject * pyswe_set_ephe_path FUNCARGS_KEYWDS
  62. {
  63. char *path = PYSWE_DEFAULT_EPHE_PATH;
  64. static char *kwlist[] = {"path", NULL};
  65. if (!PyArg_ParseTupleAndKeywords(args, keywds, "|s", kwlist, &path))
  66. return NULL;
  67. swe_set_ephe_path(path);
  68. Py_RETURN_NONE;
  69. }
  70. /* swisseph.set_jpl_file */
  71. static char pyswe_set_jpl_file__doc__[] =
  72. "Set JPL file path.\n\n"
  73. "Args: str path\n"
  74. "Return: None";
  75. static PyObject * pyswe_set_jpl_file FUNCARGS_KEYWDS
  76. {
  77. char *path;
  78. static char *kwlist[] = {"path", NULL};
  79. if (!PyArg_ParseTupleAndKeywords(args, keywds, "s", kwlist, &path))
  80. return NULL;
  81. swe_set_jpl_file(path);
  82. Py_RETURN_NONE;
  83. }
  84. /* swisseph.set_topo */
  85. static char pyswe_set_topo__doc__[] =
  86. "Set topocentric parameters.\n\n"
  87. "Args: float lon, float lat, float alt=0.0\n"
  88. "Return: None";
  89. static PyObject * pyswe_set_topo FUNCARGS_KEYWDS
  90. {
  91. double lon, lat, alt = 0.0;
  92. static char *kwlist[] = {"lon", "lat", "alt", NULL};
  93. if (!PyArg_ParseTupleAndKeywords(args, keywds, "dd|d", kwlist,
  94. &lon, &lat, &alt))
  95. return NULL;
  96. swe_set_topo(lon, lat, alt);
  97. Py_RETURN_NONE;
  98. }
  99. /* swisseph.set_sid_mode */
  100. static char pyswe_set_sid_mode__doc__[] =
  101. "Set sidereal mode.\n\n"
  102. "Args: int mode, float t0=0.0, float ayan_t0=0.0\n"
  103. "Return: None";
  104. static PyObject * pyswe_set_sid_mode FUNCARGS_KEYWDS
  105. {
  106. int mode;
  107. double t0 = 0.0, ayan_t0 = 0.0;
  108. static char *kwlist[] = {"mode", "t0", "ayan_t0", NULL};
  109. if (!PyArg_ParseTupleAndKeywords(args, keywds, "i|dd", kwlist,
  110. &mode, &t0, &ayan_t0))
  111. return NULL;
  112. swe_set_sid_mode(mode, t0, ayan_t0);
  113. Py_RETURN_NONE;
  114. }
  115. /* swisseph.get_ayanamsa */
  116. static char pyswe_get_ayanamsa__doc__[] =
  117. "Calculate ayanamsa (ET).\n\n"
  118. "Args: float julday\n"
  119. "Return: float";
  120. static PyObject * pyswe_get_ayanamsa FUNCARGS_KEYWDS
  121. {
  122. double jd, ret;
  123. static char *kwlist[] = {"julday", NULL};
  124. if (!PyArg_ParseTupleAndKeywords(args, keywds, "d", kwlist, &jd))
  125. return NULL;
  126. ret = swe_get_ayanamsa(jd);
  127. return Py_BuildValue("f", ret);
  128. }
  129. /* swisseph.get_ayanamsa_ut */
  130. static char pyswe_get_ayanamsa_ut__doc__[] =
  131. "Calculate ayanamsa (UT).\n\n"
  132. "Args: float julday\n"
  133. "Return: float";
  134. static PyObject * pyswe_get_ayanamsa_ut FUNCARGS_KEYWDS
  135. {
  136. double jd, ret;
  137. static char *kwlist[] = {"julday", NULL};
  138. if (!PyArg_ParseTupleAndKeywords(args, keywds, "d", kwlist, &jd))
  139. return NULL;
  140. ret = swe_get_ayanamsa_ut(jd);
  141. return Py_BuildValue("f", ret);
  142. }
  143. /* swisseph.get_ayanamsa_name */
  144. static char pyswe_get_ayanamsa_name__doc__[] =
  145. "Get ayanamsa name from sidereal mode constant.\n\n"
  146. "Args: int sidmode\n"
  147. "Return: str";
  148. static PyObject * pyswe_get_ayanamsa_name FUNCARGS_KEYWDS
  149. {
  150. int mode;
  151. char *name;
  152. static char *kwlist[] = {"sidmode", NULL};
  153. if (!PyArg_ParseTupleAndKeywords(args, keywds, "i", kwlist, &mode))
  154. return NULL;
  155. name = swe_get_ayanamsa_name(mode);
  156. return Py_BuildValue("s", name);
  157. }
  158. /* swisseph.close */
  159. static char pyswe_close__doc__[] =
  160. "Close swiss ephemeris.\n\n"
  161. "Args: -\n"
  162. "Return: None";
  163. static PyObject * pyswe_close FUNCARGS_SELF
  164. {
  165. swe_close();
  166. Py_RETURN_NONE;
  167. }
  168. /* swisseph.get_planet_name */
  169. static char pyswe_get_planet_name__doc__[] =
  170. "Get planet name.\n\n"
  171. "Args: int planet\n"
  172. "Return: str";
  173. static PyObject * pyswe_get_planet_name FUNCARGS_KEYWDS
  174. {
  175. int ipl;
  176. char name[256];
  177. static char *kwlist[] = {"planet", NULL};
  178. if (!PyArg_ParseTupleAndKeywords(args, keywds, "i", kwlist, &ipl))
  179. return NULL;
  180. swe_get_planet_name(ipl, name);
  181. return Py_BuildValue("s", name);
  182. }
  183. /* swisseph.calc */
  184. static char pyswe_calc__doc__[] =
  185. "Calculate body positions (ET).\n\n"
  186. "Args: float julday, int planet, int flag=FLG_SWIEPH+FLG_SPEED\n"
  187. "Return: tuple of 6 float";
  188. static PyObject * pyswe_calc FUNCARGS_KEYWDS
  189. {
  190. double jd, val[6];
  191. int ret, ipl, flag = SEFLG_SWIEPH + SEFLG_SPEED;
  192. char err[256];
  193. static char *kwlist[] = {"julday", "planet", "flag", NULL};
  194. if (!PyArg_ParseTupleAndKeywords(args, keywds, "di|i", kwlist,
  195. &jd, &ipl, &flag))
  196. return NULL;
  197. ret = swe_calc(jd, ipl, flag, val, err);
  198. if (ret < 0)
  199. {
  200. PyErr_SetString(pyswe_Error, err);
  201. return NULL;
  202. }
  203. return Py_BuildValue("(ffffff)", val[0], val[1], val[2], val[3], val[4],
  204. val[5]);
  205. }
  206. /* swisseph.calc_ut */
  207. static char pyswe_calc_ut__doc__[] =
  208. "Calculate body positions (UT).\n\n"
  209. "Args: float julday, int planet, int flag=FLG_SWIEPH+FLG_SPEED\n"
  210. "Return: tuple of 6 float";
  211. static PyObject * pyswe_calc_ut FUNCARGS_KEYWDS
  212. {
  213. double jd, val[6];
  214. int ret, ipl, flag = SEFLG_SWIEPH + SEFLG_SPEED;
  215. char err[256];
  216. static char *kwlist[] = {"julday", "planet", "flag", NULL};
  217. if (!PyArg_ParseTupleAndKeywords(args, keywds, "di|i", kwlist,
  218. &jd, &ipl, &flag))
  219. return NULL;
  220. ret = swe_calc_ut(jd, ipl, flag, val, err);
  221. if (ret < 0)
  222. {
  223. PyErr_SetString(pyswe_Error, err);
  224. return NULL;
  225. }
  226. return Py_BuildValue("(ffffff)", val[0], val[1], val[2], val[3], val[4],
  227. val[5]);
  228. }
  229. /* swisseph.fixstar */
  230. static char pyswe_fixstar__doc__[] =
  231. "Calculate fixed star positions (ET).\n\n"
  232. "Args: str star, float julday, int flag=FLG_SWIEPH\n"
  233. "Return: tuple of 6 float";
  234. static PyObject * pyswe_fixstar FUNCARGS_KEYWDS
  235. {
  236. char *star, st[41], err[256];
  237. double jd, val[6];
  238. int ret, flag = SEFLG_SWIEPH;
  239. static char *kwlist[] = {"star", "julday", "flag", NULL};
  240. if (!PyArg_ParseTupleAndKeywords(args, keywds, "sd|i", kwlist,
  241. &star, &jd, &flag))
  242. return NULL;
  243. strcpy(st, star);
  244. ret = swe_fixstar(st, jd, flag, val, err);
  245. if (ret < 0)
  246. {
  247. PyErr_SetString(pyswe_Error, err);
  248. return NULL;
  249. }
  250. return Py_BuildValue("(ffffff)", val[0], val[1], val[2], val[3], val[4],
  251. val[5]);
  252. }
  253. /* swisseph.fixstar_ut */
  254. static char pyswe_fixstar_ut__doc__[] =
  255. "Calculate fixed star positions (UT).\n\n"
  256. "Args: str star, float julday, int flag=FLG_SWIEPH\n"
  257. "Return: tuple of 6 float";
  258. static PyObject * pyswe_fixstar_ut FUNCARGS_KEYWDS
  259. {
  260. char *star, st[41], err[256];
  261. double jd, val[6];
  262. int ret, flag = SEFLG_SWIEPH;
  263. static char *kwlist[] = {"star", "julday", "flag", NULL};
  264. if (!PyArg_ParseTupleAndKeywords(args, keywds, "sd|i", kwlist,
  265. &star, &jd, &flag))
  266. return NULL;
  267. strcpy(st, star);
  268. ret = swe_fixstar_ut(st, jd, flag, val, err);
  269. if (ret < 0)
  270. {
  271. PyErr_SetString(pyswe_Error, err);
  272. return NULL;
  273. }
  274. return Py_BuildValue("(ffffff)", val[0], val[1], val[2], val[3], val[4],
  275. val[5]);
  276. }
  277. /* swisseph.nod_aps */
  278. static char pyswe_nod_aps__doc__[] =
  279. "Calculate planetary nodes and apsides (ET).\n\n"
  280. "Args: float julday, int planet, int method=NODBIT_MEAN, int flag=FLG_SWIEPH+FLG_SPEED\n"
  281. "Return: 4 tuples of 6 float (asc, des, per, aph)";
  282. static PyObject * pyswe_nod_aps FUNCARGS_KEYWDS
  283. {
  284. char err[256];
  285. double jd, xasc[6], xdsc[6], xper[6], xaph[6];
  286. int ret, planet, method = SE_NODBIT_MEAN, flag = SEFLG_SWIEPH + SEFLG_SPEED;
  287. static char *kwlist[] = {"julday", "planet", "method", "flag", NULL};
  288. if (!PyArg_ParseTupleAndKeywords(args, keywds, "di|ii", kwlist,
  289. &jd, &planet, &method, &flag))
  290. return NULL;
  291. ret = swe_nod_aps(jd, planet, flag, method, xasc, xdsc, xper, xaph, err);
  292. if (ret < 0)
  293. {
  294. PyErr_SetString(pyswe_Error, err);
  295. return NULL;
  296. }
  297. return Py_BuildValue("(ffffff)(ffffff)(ffffff)(ffffff)", xasc[0],xasc[1],
  298. xasc[2],xasc[3],xasc[4],xasc[5],xdsc[0],xdsc[1],xdsc[2],xdsc[3],xdsc[4],
  299. xdsc[5],xper[0],xper[1],xper[2],xper[3],xper[4],xper[5],xaph[0],xaph[1],
  300. xaph[2],xaph[3],xaph[4],xaph[5]);
  301. }
  302. /* swisseph.nod_aps_ut */
  303. static char pyswe_nod_aps_ut__doc__[] =
  304. "Calculate planetary nodes and apsides (UT).\n\n"
  305. "Args: float julday, int planet, int method=NODBIT_MEAN, int flag=FLG_SWIEPH+FLG_SPEED\n"
  306. "Return: 4 tuples of 6 float (asc, des, per, aph)";
  307. static PyObject * pyswe_nod_aps_ut FUNCARGS_KEYWDS
  308. {
  309. char err[256];
  310. double jd, xasc[6], xdsc[6], xper[6], xaph[6];
  311. int ret, planet, method = SE_NODBIT_MEAN, flag = SEFLG_SWIEPH + SEFLG_SPEED;
  312. static char *kwlist[] = {"julday", "planet", "method", "flag", NULL};
  313. if (!PyArg_ParseTupleAndKeywords(args, keywds, "di|ii", kwlist,
  314. &jd, &planet, &method, &flag))
  315. return NULL;
  316. ret = swe_nod_aps_ut(jd, planet, flag, method, xasc, xdsc, xper, xaph, err);
  317. if (ret < 0)
  318. {
  319. PyErr_SetString(pyswe_Error, err);
  320. return NULL;
  321. }
  322. return Py_BuildValue("(ffffff)(ffffff)(ffffff)(ffffff)", xasc[0],xasc[1],
  323. xasc[2],xasc[3],xasc[4],xasc[5],xdsc[0],xdsc[1],xdsc[2],xdsc[3],xdsc[4],
  324. xdsc[5],xper[0],xper[1],xper[2],xper[3],xper[4],xper[5],xaph[0],xaph[1],
  325. xaph[2],xaph[3],xaph[4],xaph[5]);
  326. }
  327. /* swisseph.sidtime */
  328. static char pyswe_sidtime__doc__[] =
  329. "Calculate sidereal time (UT).\n\n"
  330. "Args: float julday\n"
  331. "Return: float";
  332. static PyObject * pyswe_sidtime FUNCARGS_KEYWDS
  333. {
  334. double jd, ret;
  335. static char *kwlist[] = {"julday", NULL};
  336. if (!PyArg_ParseTupleAndKeywords(args, keywds, "d", kwlist, &jd))
  337. return NULL;
  338. ret = swe_sidtime(jd);
  339. return Py_BuildValue("f", ret);
  340. }
  341. /* swisseph.sidtime0 */
  342. static char pyswe_sidtime0__doc__[] =
  343. "Calculate sidereal time, given obliquity and nutation (UT).\n\n"
  344. "Args: float julday, float obliquity, float nutation\n"
  345. "Return: float";
  346. static PyObject * pyswe_sidtime0 FUNCARGS_KEYWDS
  347. {
  348. double jd, ret, obliquity, nutation;
  349. static char *kwlist[] = {"julday", "obliquity", "nutation", NULL};
  350. if (!PyArg_ParseTupleAndKeywords(args, keywds, "ddd", kwlist,
  351. &jd, &obliquity, &nutation))
  352. return NULL;
  353. ret = swe_sidtime0(jd, obliquity, nutation);
  354. return Py_BuildValue("f", ret);
  355. }
  356. /* swisseph.houses */
  357. static char pyswe_houses__doc__[] =
  358. "Calculate houses cusps (UT).\n\n"
  359. "Args: float julday, float lat, float lon, char hsys='P'\n"
  360. "Return: 2 tuples of 12 and 8 float (cusps, ascmc) (except Gauquelin)";
  361. static PyObject * pyswe_houses FUNCARGS_KEYWDS
  362. {
  363. double jd, lat, lon, cusps[37], ascmc[10];
  364. int ret, hsys = 'P';
  365. static char *kwlist[] = {"julday", "lat", "lon", "hsys", NULL};
  366. if (!PyArg_ParseTupleAndKeywords(args, keywds, "ddd|c", kwlist,
  367. &jd, &lat, &lon, &hsys))
  368. return NULL;
  369. ret = swe_houses(jd, lat, lon, hsys, cusps, ascmc);
  370. if (ret < 0)
  371. {
  372. PyErr_SetString(pyswe_Error, "swisseph.houses: error while computing");
  373. return NULL;
  374. }
  375. if (hsys == 71) /* Gauquelin houses */
  376. {
  377. return Py_BuildValue("(ffffffffffffffffffffffffffffffffffff)(ffffffff)",
  378. cusps[1],cusps[2],cusps[3],cusps[4],cusps[5],cusps[6],cusps[7],cusps[8],
  379. cusps[9],cusps[10],cusps[11],cusps[12],cusps[13],cusps[14],cusps[15],
  380. cusps[16],cusps[17],cusps[18],cusps[19],cusps[20],cusps[21],cusps[22],
  381. cusps[23],cusps[24],cusps[25],cusps[26],cusps[27],cusps[28],cusps[29],
  382. cusps[30],cusps[31],cusps[32],cusps[33],cusps[34],cusps[35],cusps[36],
  383. ascmc[0],ascmc[1],ascmc[2],ascmc[3],ascmc[4],ascmc[5],ascmc[6],ascmc[7]);
  384. }
  385. else
  386. {
  387. return Py_BuildValue("(ffffffffffff)(ffffffff)", cusps[1],cusps[2],
  388. cusps[3],cusps[4],cusps[5],cusps[6],cusps[7],cusps[8],cusps[9],cusps[10],
  389. cusps[11],cusps[12],ascmc[0],ascmc[1],ascmc[2],ascmc[3],ascmc[4],ascmc[5],
  390. ascmc[6],ascmc[7]);
  391. }
  392. }
  393. /* swisseph.houses_armc */
  394. static char pyswe_houses_armc__doc__[] =
  395. "Calculate houses cusps with ARMC.\n\n"
  396. "Args: float armc, float lat, float obliquity, char hsys='P'\n"
  397. "Return: 2 tuples of 12 and 8 float (cusps, ascmc) (except Gauquelin)";
  398. static PyObject * pyswe_houses_armc FUNCARGS_KEYWDS
  399. {
  400. double armc, lat, obl, cusps[37], ascmc[10];
  401. int ret, hsys = 'P';
  402. static char *kwlist[] = {"armc", "lat", "obliquity", "hsys", NULL};
  403. if (!PyArg_ParseTupleAndKeywords(args, keywds, "ddd|c", kwlist,
  404. &armc, &lat, &obl, &hsys))
  405. return NULL;
  406. ret = swe_houses_armc(armc, lat, obl, hsys, cusps, ascmc);
  407. if (ret < 0)
  408. {
  409. PyErr_SetString(pyswe_Error, "swisseph.houses_armc: error while computing");
  410. return NULL;
  411. }
  412. if (hsys == 71) /* Gauquelin houses */
  413. {
  414. return Py_BuildValue("(ffffffffffffffffffffffffffffffffffff)(ffffffff)",
  415. cusps[1],cusps[2],cusps[3],cusps[4],cusps[5],cusps[6],cusps[7],cusps[8],
  416. cusps[9],cusps[10],cusps[11],cusps[12],cusps[13],cusps[14],cusps[15],
  417. cusps[16],cusps[17],cusps[18],cusps[19],cusps[20],cusps[21],cusps[22],
  418. cusps[23],cusps[24],cusps[25],cusps[26],cusps[27],cusps[28],cusps[29],
  419. cusps[30],cusps[31],cusps[32],cusps[33],cusps[34],cusps[35],cusps[36],
  420. ascmc[0],ascmc[1],ascmc[2],ascmc[3],ascmc[4],ascmc[5],ascmc[6],ascmc[7]);
  421. }
  422. else
  423. {
  424. return Py_BuildValue("(ffffffffffff)(ffffffff)", cusps[1],cusps[2],
  425. cusps[3],cusps[4],cusps[5],cusps[6],cusps[7],cusps[8],cusps[9],
  426. cusps[10],cusps[11],cusps[12],ascmc[0],ascmc[1],ascmc[2],ascmc[3],
  427. ascmc[4],ascmc[5],ascmc[6],ascmc[7]);
  428. }
  429. }
  430. /* swisseph.houses_ex */
  431. static char pyswe_houses_ex__doc__[] =
  432. "Calculate houses cusps (extended) (UT).\n\n"
  433. "Args: float julday, float lat, float lon, char hsys='P', int flag=0\n"
  434. "Return: 2 tuples of 12 and 8 float (cusps, ascmc) (except Gauquelin)";
  435. static PyObject * pyswe_houses_ex FUNCARGS_KEYWDS
  436. {
  437. double jd, lat, lon, cusps[37], ascmc[10];
  438. int ret, hsys = 'P', flag = 0;
  439. static char *kwlist[] = {"julday", "lat", "lon", "hsys", "flag", NULL};
  440. if (!PyArg_ParseTupleAndKeywords(args, keywds, "ddd|ci", kwlist,
  441. &jd, &lat, &lon, &hsys, &flag))
  442. return NULL;
  443. ret = swe_houses_ex(jd, flag, lat, lon, hsys, cusps, ascmc);
  444. if (ret < 0)
  445. {
  446. PyErr_SetString(pyswe_Error, "swisseph.houses_ex: error while computing");
  447. return NULL;
  448. }
  449. if (hsys == 71) /* Gauquelin houses */
  450. {
  451. return Py_BuildValue("(ffffffffffffffffffffffffffffffffffff)(ffffffff)",
  452. cusps[1],cusps[2],cusps[3],cusps[4],cusps[5],cusps[6],cusps[7],cusps[8],
  453. cusps[9],cusps[10],cusps[11],cusps[12],cusps[13],cusps[14],cusps[15],
  454. cusps[16],cusps[17],cusps[18],cusps[19],cusps[20],cusps[21],cusps[22],
  455. cusps[23],cusps[24],cusps[25],cusps[26],cusps[27],cusps[28],cusps[29],
  456. cusps[30],cusps[31],cusps[32],cusps[33],cusps[34],cusps[35],cusps[36],
  457. ascmc[0],ascmc[1],ascmc[2],ascmc[3],ascmc[4],ascmc[5],ascmc[6],ascmc[7]);
  458. }
  459. else
  460. {
  461. return Py_BuildValue("(ffffffffffff)(ffffffff)", cusps[1],cusps[2],
  462. cusps[3],cusps[4],cusps[5],cusps[6],cusps[7],cusps[8],cusps[9],
  463. cusps[10],cusps[11],cusps[12],ascmc[0],ascmc[1],ascmc[2],ascmc[3],
  464. ascmc[4],ascmc[5],ascmc[6],ascmc[7]);
  465. }
  466. }
  467. /* swisseph.house_pos */
  468. static char pyswe_house_pos__doc__[] =
  469. "Calculate house position of a body.\n\n"
  470. "Args: float armc, float geolat, float obliquity, float objlon,"
  471. " float objlat=0.0, char hsys='P'\n"
  472. "Return: float";
  473. static PyObject * pyswe_house_pos FUNCARGS_KEYWDS
  474. {
  475. double armc, lat, obl, res;
  476. double obj[] = {0.0, 0.0};
  477. int hsys = 'P';
  478. char err[256];
  479. static char *kwlist[] = {"armc", "geolat", "obliquity", "objlon", "objlat",
  480. "hsys", NULL};
  481. if (!PyArg_ParseTupleAndKeywords(args, keywds, "dddd|dc", kwlist,
  482. &armc, &lat, &obl, &obj[0], &obj[1], &hsys))
  483. return NULL;
  484. res = swe_house_pos(armc, lat, obl, hsys, obj, err);
  485. if (res < 0)
  486. {
  487. PyErr_SetString(pyswe_Error, err);
  488. return NULL;
  489. }
  490. return Py_BuildValue("f", res);
  491. }
  492. /* swisseph.gauquelin_sector */
  493. static char pyswe_gauquelin_sector__doc__[] =
  494. "Calculate Gauquelin sector position of a body (UT).\n\n"
  495. "Args: float julday, int or str body, float lon, float lat, float alt,"
  496. " float press=0, float temp=0, int method=0, int flag=FLG_SWIEPH\n"
  497. "Return: float";
  498. static PyObject * pyswe_gauquelin_sector FUNCARGS_KEYWDS
  499. {
  500. double jd, geopos[3], res, ret, press = 0.0, temp = 0.0;
  501. int plt, flag = SEFLG_SWIEPH, method = 0;
  502. char *star = "", err[256];
  503. PyObject *body;
  504. static char *kwlist[] = {"julday", "body", "lon", "lat", "alt", "press",
  505. "temp", "method", "flag", NULL};
  506. if (!PyArg_ParseTupleAndKeywords(args, keywds, "dOddd|ddii", kwlist,
  507. &jd, &body, &geopos[0], &geopos[1], &geopos[2], &press, &temp, &method,
  508. &flag))
  509. return NULL;
  510. if (PyLong_CheckExact(body)) /* long -> planet */
  511. {
  512. plt = (int) PyLong_AsLong(body);
  513. }
  514. #if PY_MAJOR_VERSION >= 3
  515. else if (PyUnicode_CheckExact(body)) /* unicode -> fixed star */
  516. {
  517. plt = 0;
  518. star = (char*) PyUnicode_AS_DATA(body);
  519. }
  520. #elif PY_MAJOR_VERSION < 3
  521. else if (PyInt_CheckExact(body)) /* int -> planet */
  522. {
  523. plt = (int) PyInt_AsLong(body);
  524. }
  525. else if (PyString_CheckExact(body)) /* str -> fixed star */
  526. {
  527. plt = 0;
  528. star = PyString_AsString(body);
  529. }
  530. #endif
  531. else
  532. {
  533. PyErr_SetString(pyswe_Error,
  534. "swisseph.gauquelin_sector: Invalid body type");
  535. return NULL;
  536. }
  537. res = swe_gauquelin_sector(jd, plt, star, flag, method, geopos, press,
  538. temp, &ret, err);
  539. if (res < 0)
  540. {
  541. PyErr_SetString(pyswe_Error, err);
  542. return NULL;
  543. }
  544. return Py_BuildValue("f", ret);
  545. }
  546. /* swisseph.julday */
  547. static char pyswe_julday__doc__[] =
  548. "Calculate Julian day number.\n\n"
  549. "Args: int year, int month, int day, float hour=12.0, int cal=GREG_CAL\n"
  550. "Return: float";
  551. static PyObject * pyswe_julday FUNCARGS_KEYWDS
  552. {
  553. int year, month, day;
  554. double ret, hour = 12.0;
  555. int cal = SE_GREG_CAL;
  556. static char *kwlist[] = {"year", "month", "day", "hour", "cal", NULL};
  557. if (!PyArg_ParseTupleAndKeywords(args, keywds, "iii|di", kwlist,
  558. &year, &month, &day, &hour, &cal))
  559. return NULL;
  560. ret = swe_julday(year, month, day, hour, cal);
  561. return Py_BuildValue("f", ret);
  562. }
  563. /* swisseph.date_conversion */
  564. static char pyswe_date_conversion__doc__[] =
  565. "Calculate Julian day number with check wether date is correct.\n\n"
  566. "Args: int year, int month, int day, float hour=12.0, char cal='g'\n"
  567. "Return: tuple (int result, float jd)";
  568. static PyObject * pyswe_date_conversion FUNCARGS_KEYWDS
  569. {
  570. int year, month, day, ret;
  571. double jd, hour = 12.0;
  572. char cal = 'g';
  573. static char *kwlist[] = {"year", "month", "day", "hour", "cal", NULL};
  574. if (!PyArg_ParseTupleAndKeywords(args, keywds, "iii|dc", kwlist,
  575. &year, &month, &day, &hour, &cal))
  576. return NULL;
  577. if (cal != 'g' && cal != 'j')
  578. {
  579. PyErr_SetString(pyswe_Error,
  580. "swisseph.date_conversion: Invalid calendar (g/j)");
  581. return NULL;
  582. }
  583. ret = swe_date_conversion(year, month, day, hour, cal, &jd);
  584. return Py_BuildValue("if", ret, jd);
  585. }
  586. /* swisseph.revjul */
  587. static char pyswe_revjul__doc__[] =
  588. "Calculate year, month, day, hour from Julian day number.\n\n"
  589. "Args: float julday, int cal=GREG_CAL\n"
  590. "Return: tuple of 3 int and 1 float";
  591. static PyObject * pyswe_revjul FUNCARGS_KEYWDS
  592. {
  593. int year, month, day, cal = SE_GREG_CAL;
  594. double hour, jd;
  595. static char *kwlist[] = {"julday", "cal", NULL};
  596. if (!PyArg_ParseTupleAndKeywords(args, keywds, "d|i", kwlist,
  597. &jd, &cal))
  598. return NULL;
  599. swe_revjul(jd, cal, &year, &month, &day, &hour);
  600. return Py_BuildValue("(iiif)", year, month, day, hour);
  601. }
  602. /* swisseph.utc_to_jd */
  603. static char pyswe_utc_to_jd__doc__ [] =
  604. "Convert UTC to julian day.\n\n"
  605. "Args: int year, int month, int day, int hour, int minutes, float seconds, int flag\n"
  606. "Return: tuple (float et, float ut)";
  607. static PyObject * pyswe_utc_to_jd FUNCARGS_KEYWDS
  608. {
  609. int i, y, m, d, h, mi, flg;
  610. double s, dret[2];
  611. char serr[255];
  612. static char *kwlist[] = {"year", "month", "day", "hour", "minutes",
  613. "seconds", "flag", NULL};
  614. if (!PyArg_ParseTupleAndKeywords(args, keywds, "iiiiidi", kwlist,
  615. &y, &m, &d, &h, &mi, &s, &flg))
  616. return NULL;
  617. i = swe_utc_to_jd(y, m, d, h, mi, s, flg, dret, serr);
  618. if (i < 0)
  619. {
  620. PyErr_SetString(pyswe_Error, serr);
  621. return NULL;
  622. }
  623. return Py_BuildValue("dd", dret[0], dret[1]);
  624. }
  625. /* swisseph.jdet_to_utc */
  626. static char pyswe_jdet_to_utc__doc__ [] =
  627. "Convert ET julian day number to UTC.\n\n"
  628. "Args: float et, int flag\n"
  629. "Return: tuple (int year, int month, int day, int hour, int minutes, float seconds)";
  630. static PyObject * pyswe_jdet_to_utc FUNCARGS_KEYWDS
  631. {
  632. int y, m, d, h, mi, flg;
  633. double s, et;
  634. static char *kwlist[] = {"et", "flag", NULL};
  635. if (!PyArg_ParseTupleAndKeywords(args, keywds, "di", kwlist, &et, &flg))
  636. return NULL;
  637. swe_jdet_to_utc(et, flg, &y, &m, &d, &h, &mi, &s);
  638. return Py_BuildValue("iiiiid", y, m, d, h, mi, s);
  639. }
  640. /* swisseph.jdut1_to_utc */
  641. static char pyswe_jdut1_to_utc__doc__ [] =
  642. "Convert UT julian day number to UTC.\n\n"
  643. "Args: float ut, int flag\n"
  644. "Return: tuple (int year, int month, int day, int hour, int minutes, float seconds)";
  645. static PyObject * pyswe_jdut1_to_utc FUNCARGS_KEYWDS
  646. {
  647. int y, m, d, h, mi, flg;
  648. double s, ut;
  649. static char *kwlist[] = {"ut", "flag", NULL};
  650. if (!PyArg_ParseTupleAndKeywords(args, keywds, "di", kwlist, &ut, &flg))
  651. return NULL;
  652. swe_jdut1_to_utc(ut, flg, &y, &m, &d, &h, &mi, &s);
  653. return Py_BuildValue("iiiiid", y, m, d, h, mi, s);
  654. }
  655. /* swisseph.deltat */
  656. static char pyswe_deltat__doc__[] =
  657. "Calculate value of delta T.\n\n"
  658. "Args: float julday\n"
  659. "Return: float";
  660. static PyObject * pyswe_deltat FUNCARGS_KEYWDS
  661. {
  662. double jd;
  663. static char *kwlist[] = {"julday", NULL};
  664. if (!PyArg_ParseTupleAndKeywords(args, keywds, "d", kwlist, &jd))
  665. return NULL;
  666. return Py_BuildValue("f", swe_deltat(jd));
  667. }
  668. /* swisseph.time_equ */
  669. static char pyswe_time_equ__doc__[] =
  670. "Calculate equation of time (ET).\n\n"
  671. "Args: float julday\n"
  672. "Return: float";
  673. static PyObject * pyswe_time_equ FUNCARGS_KEYWDS
  674. {
  675. double jd, ret, res;
  676. char err[256];
  677. static char *kwlist[] = {"julday", NULL};
  678. if (!PyArg_ParseTupleAndKeywords(args, keywds, "d", kwlist, &jd))
  679. return NULL;
  680. res = swe_time_equ(jd, &ret, err);
  681. if (res < 0)
  682. {
  683. PyErr_SetString(pyswe_Error, err);
  684. return NULL;
  685. }
  686. return Py_BuildValue("f", ret);
  687. }
  688. /* swisseph.get_tid_acc */
  689. static char pyswe_get_tid_acc__doc__[] =
  690. "Get tidal acceleration.\n\n"
  691. "Args: -\n"
  692. "Return: float";
  693. static PyObject * pyswe_get_tid_acc FUNCARGS_SELF
  694. {
  695. return Py_BuildValue("f", swe_get_tid_acc());
  696. }
  697. /* swisseph.set_tid_acc */
  698. static char pyswe_set_tid_acc__doc__[] =
  699. "Set tidal acceleration.\n\n"
  700. "Args: float acc\n"
  701. "Return: None";
  702. static PyObject * pyswe_set_tid_acc FUNCARGS_KEYWDS
  703. {
  704. double acc;
  705. static char *kwlist[] = {"acc", NULL};
  706. if (!PyArg_ParseTupleAndKeywords(args, keywds, "d", kwlist, &acc))
  707. return NULL;
  708. swe_set_tid_acc(acc);
  709. Py_RETURN_NONE;
  710. }
  711. /* swisseph.sol_eclipse_when_loc */
  712. static char pyswe_sol_eclipse_when_loc__doc__[] =
  713. "Find the next solar eclipse for a given geographic position (UTC).\n\n"
  714. "Args: float julday, float lon, float lat, float alt=0.0, bool backward=False,"
  715. " int flag=FLG_SWIEPH\n"
  716. "Return: tuple of results";
  717. static PyObject * pyswe_sol_eclipse_when_loc FUNCARGS_KEYWDS
  718. {
  719. double jd, tret[10], attr[20], geopos[3] = {0.0, 0.0, 0.0};
  720. int res, backward = 0, flag = SEFLG_SWIEPH;
  721. char err[256];
  722. static char *kwlist[] = {"julday", "lon", "lat", "alt", "backward", "flag", NULL};
  723. if (!PyArg_ParseTupleAndKeywords(args, keywds, "ddd|dii", kwlist,
  724. &jd, &geopos[0], &geopos[1], &geopos[2], &backward, &flag))
  725. return NULL;
  726. res = swe_sol_eclipse_when_loc(jd, flag, geopos, tret, attr, backward, err);
  727. if (res < 0)
  728. {
  729. PyErr_SetString(pyswe_Error, err);
  730. return NULL;
  731. }
  732. return Py_BuildValue("(i)(fffffff)(ffffffff)", res,tret[0],tret[1],
  733. tret[2],tret[3],tret[4],tret[5],tret[6],attr[0],attr[1],attr[2],
  734. attr[3],attr[4],attr[5],attr[6],attr[7]);
  735. }
  736. /* swisseph.lun_occult_when_loc */
  737. static char pyswe_lun_occult_when_loc__doc__[] =
  738. "Find next occultation of a body by the moon for a given geographic position (UTC).\n\n"
  739. "Args: float julday, int or str body, float lon, float lat, float alt=0.0,"
  740. " bool backward=False, int flag=FLG_SWIEPH\n"
  741. "Return: tuple of results";
  742. static PyObject * pyswe_lun_occult_when_loc FUNCARGS_KEYWDS
  743. {
  744. double jd, tret[10], attr[20], geopos[3] = {0.0, 0.0, 0.0};
  745. int res, plt, backward = 0, flag = SEFLG_SWIEPH;
  746. char *star = "", err[256];
  747. PyObject *body;
  748. static char *kwlist[] = {"julday", "body", "lon", "lat", "alt", "backward", "flag", NULL};
  749. if (!PyArg_ParseTupleAndKeywords(args, keywds, "dOdd|dii", kwlist,
  750. &jd, &body, &geopos[0], &geopos[1], &geopos[2], &backward, &flag))
  751. return NULL;
  752. if (PyLong_CheckExact(body)) /* long -> planet */
  753. {
  754. plt = (int) PyLong_AsLong(body);
  755. }
  756. #if PY_MAJOR_VERSION >= 3
  757. else if (PyUnicode_CheckExact(body)) /* unicode -> fixed star */
  758. {
  759. plt = 0;
  760. star = (char*) PyUnicode_AS_DATA(body);
  761. }
  762. #elif PY_MAJOR_VERSION < 3
  763. else if (PyInt_CheckExact(body)) /* int -> planet */
  764. {
  765. plt = (int) PyInt_AsLong(body);
  766. }
  767. else if (PyString_CheckExact(body)) /* str -> fixed star */
  768. {
  769. plt = 0;
  770. star = PyString_AsString(body);
  771. }
  772. #endif
  773. else
  774. {
  775. PyErr_SetString(pyswe_Error, "swisseph.lun_occult_when_loc: Invalid body type");
  776. return NULL;
  777. }
  778. res = swe_lun_occult_when_loc(jd, plt, star, flag, geopos, tret, attr, backward, err);
  779. if (res < 0)
  780. {
  781. PyErr_SetString(pyswe_Error, err);
  782. return NULL;
  783. }
  784. return Py_BuildValue("(i)(fffffff)(ffffffff)", res,tret[0],tret[1],
  785. tret[2],tret[3],tret[4],tret[5],tret[6],attr[0],attr[1],attr[2],
  786. attr[3],attr[4],attr[5],attr[6],attr[7]);
  787. }
  788. /* swisseph.sol_eclipse_when_glob */
  789. static char pyswe_sol_eclipse_when_glob__doc__[] =
  790. "Find the next solar eclipse globally (UTC).\n\n"
  791. "Args: float jd_start, ecl_type=0, bool backward=False, int flag=FLG_SWIEPH\n"
  792. "Return: tuple of results";
  793. static PyObject * pyswe_sol_eclipse_when_glob FUNCARGS_KEYWDS
  794. {
  795. double jd, tret[10];
  796. int res, ecltype = 0, backward = 0, flag = SEFLG_SWIEPH;
  797. char err[256];
  798. static char *kwlist[] = {"jd_start", "ecl_type", "backward", "flag", NULL};
  799. if (!PyArg_ParseTupleAndKeywords(args, keywds, "d|iii", kwlist,
  800. &jd, &ecltype, &backward, &flag))
  801. return NULL;
  802. res = swe_sol_eclipse_when_glob(jd, flag, ecltype, tret, backward, err);
  803. if (res < 0)
  804. {
  805. PyErr_SetString(pyswe_Error, err);
  806. return NULL;
  807. }
  808. return Py_BuildValue("(i)(ffffffff)", res,tret[0],tret[1],tret[2],tret[3],
  809. tret[4],tret[5],tret[6],tret[7]);
  810. }
  811. /* swisseph.lun_occult_when_glob */
  812. static char pyswe_lun_occult_when_glob__doc__[] =
  813. "Find the next occultation of a planet or star by the moon globally (UTC).\n\n"
  814. "Args: float jd_start, int or str body, int ecl_type=0, bool backward=False,"
  815. " int flag=FLG_SWIEPH\n"
  816. "Return: tuple of results";
  817. static PyObject * pyswe_lun_occult_when_glob FUNCARGS_KEYWDS
  818. {
  819. double jd, tret[10];
  820. int res, plt, ecltype = 0, backward = 0, flag = SEFLG_SWIEPH;
  821. char *star = "", err[256];
  822. PyObject *body;
  823. static char *kwlist[] = {"jd_start", "body", "ecl_type", "backward", "flag", NULL};
  824. if (!PyArg_ParseTupleAndKeywords(args, keywds, "dO|iii", kwlist,
  825. &jd, &body, &ecltype, &backward, &flag))
  826. return NULL;
  827. if (PyLong_CheckExact(body)) /* long -> planet */
  828. {
  829. plt = (int) PyLong_AsLong(body);
  830. }
  831. #if PY_MAJOR_VERSION >= 3
  832. else if (PyUnicode_CheckExact(body)) /* unicode -> fixed star */
  833. {
  834. plt = 0;
  835. star = (char*) PyUnicode_AS_DATA(body);
  836. }
  837. #elif PY_MAJOR_VERSION < 3
  838. else if (PyInt_CheckExact(body)) /* int -> planet */
  839. {
  840. plt = (int) PyInt_AsLong(body);
  841. }
  842. else if (PyString_CheckExact(body)) /* str -> fixed star */
  843. {
  844. plt = 0;
  845. star = PyString_AsString(body);
  846. }
  847. #endif
  848. else
  849. {
  850. PyErr_SetString(pyswe_Error, "swisseph.lun_occult_when_glob: Invalid body type");
  851. return NULL;
  852. }
  853. res = swe_lun_occult_when_glob(jd, plt, star, flag, ecltype, tret, backward, err);
  854. if (res < 0)
  855. {
  856. PyErr_SetString(pyswe_Error, err);
  857. return NULL;
  858. }
  859. return Py_BuildValue("(i)(ffffffffff)", res,tret[0],tret[1],tret[2],
  860. tret[3],tret[4],tret[5],tret[6],tret[7],tret[8],tret[9]);
  861. }
  862. /* swisseph.sol_eclipse_how */
  863. static char pyswe_sol_eclipse_how__doc__[] =
  864. "Calculate attributes of a solar eclipse.\n\n"
  865. "Args: float julday, float lon, float lat, float alt=0.0, int flag=FLG_SWIEPH\n"
  866. "Return: tuple of results";
  867. static PyObject * pyswe_sol_eclipse_how FUNCARGS_KEYWDS
  868. {
  869. double jd, attr[20], geopos[3] = {0.0, 0.0, 0.0};
  870. int res, flag = SEFLG_SWIEPH;
  871. char err[256];
  872. static char *kwlist[] = {"julday", "lon", "lat", "alt", "flag", NULL};
  873. if (!PyArg_ParseTupleAndKeywords(args, keywds, "ddd|di", kwlist,
  874. &jd, &geopos[0], &geopos[1], &geopos[2], &flag))
  875. return NULL;
  876. res = swe_sol_eclipse_how(jd, flag, geopos, attr, err);
  877. if (res < 0)
  878. {
  879. PyErr_SetString(pyswe_Error, err);
  880. return NULL;
  881. }
  882. return Py_BuildValue("(i)(ffffffff)", res,attr[0],attr[1],attr[2],attr[3],
  883. attr[4],attr[5],attr[6],attr[7]);
  884. }
  885. /* swisseph.sol_eclipse_where */
  886. static char pyswe_sol_eclipse_where__doc__[] =
  887. "Find where a solar eclipse is central or maximal (UTC).\n\n"
  888. "Args: float julday, int flag=FLG_SWIEPH\n"
  889. "Return: tuple of results (retval)(geopos)(attr)";
  890. static PyObject * pyswe_sol_eclipse_where FUNCARGS_KEYWDS
  891. {
  892. double jd, geopos[2], attr[20];
  893. int res, flag = SEFLG_SWIEPH;
  894. char err[256];
  895. static char *kwlist[] = {"julday", "flag", NULL};
  896. if (!PyArg_ParseTupleAndKeywords(args, keywds, "d|i", kwlist, &jd, &flag))
  897. return NULL;
  898. res = swe_sol_eclipse_where(jd, flag, geopos, attr, err);
  899. if (res < 0)
  900. {
  901. PyErr_SetString(pyswe_Error, err);
  902. return NULL;
  903. }
  904. return Py_BuildValue("(i)(ffffffffff)(ffffffff)", res,geopos[0],geopos[1],
  905. geopos[2],geopos[3],geopos[4],geopos[5],geopos[6],geopos[7],geopos[8],
  906. geopos[9],attr[0],attr[1],attr[2],attr[3],attr[4],attr[5],attr[6],attr[7]);
  907. }
  908. /* swisseph.lun_occult_where */
  909. static char pyswe_lun_occult_where__doc__[] =
  910. "Find where a lunar occultation is central or maximal (UTC).\n\n"
  911. "Args: float julday, int or str body, int flag=FLG_SWIEPH\n"
  912. "Return: tuple of results";
  913. static PyObject * pyswe_lun_occult_where FUNCARGS_KEYWDS
  914. {
  915. double jd, geopos[2], attr[20];
  916. int res, plt, flag = SEFLG_SWIEPH;
  917. char *star = "", err[256];
  918. PyObject *body;
  919. static char *kwlist[] = {"julday", "body", "flag", NULL};
  920. if (!PyArg_ParseTupleAndKeywords(args, keywds, "dO|i", kwlist,
  921. &jd, &body, &flag))
  922. return NULL;
  923. if (PyLong_CheckExact(body)) /* long -> planet */
  924. {
  925. plt = (int) PyLong_AsLong(body);
  926. }
  927. #if PY_MAJOR_VERSION >= 3
  928. else if (PyUnicode_CheckExact(body)) /* unicode -> fixed star */
  929. {
  930. plt = 0;
  931. star = (char*) PyUnicode_AS_DATA(body);
  932. }
  933. #elif PY_MAJOR_VERSION < 3
  934. else if (PyInt_CheckExact(body)) /* int -> planet */
  935. {
  936. plt = (int) PyInt_AsLong(body);
  937. }
  938. else if (PyString_CheckExact(body)) /* str -> fixed star */
  939. {
  940. plt = 0;
  941. star = PyString_AsString(body);
  942. }
  943. #endif
  944. else
  945. {
  946. PyErr_SetString(pyswe_Error, "swisseph.lun_occult_where: Invalid body type");
  947. return NULL;
  948. }
  949. res = swe_lun_occult_where(jd, plt, star, flag, geopos, attr, err);
  950. if (res < 0)
  951. {
  952. PyErr_SetString(pyswe_Error, err);
  953. return NULL;
  954. }
  955. return Py_BuildValue("(i)(ffffffffff)(ffffffff)", res,geopos[0],geopos[1],
  956. geopos[2],geopos[3],geopos[4],geopos[5],geopos[6],geopos[7],geopos[8],
  957. geopos[9],attr[0],attr[1],attr[2],attr[3],attr[4],attr[5],attr[6],attr[7]);
  958. }
  959. /* swisseph.lun_eclipse_how */
  960. static char pyswe_lun_eclipse_how__doc__[] =
  961. "Calculate attributes of a lunar eclipse (UTC).\n\n"
  962. "Args: float julday, float lon, float lat, float alt=0.0, int flag=FLG_SWIEPH\n"
  963. "Return: tuple of results";
  964. static PyObject * pyswe_lun_eclipse_how FUNCARGS_KEYWDS
  965. {
  966. double jd, attr[20], geopos[3] = {0.0, 0.0, 0.0};
  967. int res, flag = SEFLG_SWIEPH;
  968. char err[256];
  969. static char *kwlist[] = {"julday", "lon", "lat", "alt", "flag", NULL};
  970. if (!PyArg_ParseTupleAndKeywords(args, keywds, "ddd|di", kwlist,
  971. &jd, &geopos[0], &geopos[1], &geopos[2], &flag))
  972. return NULL;
  973. res = swe_lun_eclipse_how(jd, flag, geopos, attr, err);
  974. if (res < 0)
  975. {
  976. PyErr_SetString(pyswe_Error, err);
  977. return NULL;
  978. }
  979. return Py_BuildValue("(i)(ffffff)", res,attr[0],attr[1],attr[4],attr[5],
  980. attr[6],attr[7]);
  981. }
  982. /* swisseph.lun_eclipse_when */
  983. static char pyswe_lun_eclipse_when__doc__[] =
  984. "Find the next lunar eclipse (UTC).\n\n"
  985. "Args: float jd_start, int ecl_type=0, bool backward=False, int flag=FLG_SWIEPH\n"
  986. "Return: tuple of results";
  987. static PyObject * pyswe_lun_eclipse_when FUNCARGS_KEYWDS
  988. {
  989. double jd, tret[10];
  990. int res, ecltype = 0, backward = 0, flag = SEFLG_SWIEPH;
  991. char err[256];
  992. static char *kwlist[] = {"jd_start", "ecl_type", "backward", "flag", NULL};
  993. if (!PyArg_ParseTupleAndKeywords(args, keywds, "d|iii", kwlist,
  994. &jd, &ecltype, &backward, &flag))
  995. return NULL;
  996. res = swe_lun_eclipse_when(jd, flag, ecltype, tret, backward, err);
  997. if (res < 0)
  998. {
  999. PyErr_SetString(pyswe_Error, err);
  1000. return NULL;
  1001. }
  1002. return Py_BuildValue("(i)(ffffffff)", res,tret[0],tret[1],tret[2],tret[3],tret[4],
  1003. tret[5],tret[6],tret[7]);
  1004. }
  1005. /* swisseph.rise_trans */
  1006. static char pyswe_rise_trans__doc__[] =
  1007. "Calculate times of rising, setting and meridian transits.\n\n"
  1008. "Args: float jd_start, int or str body, float lon, float lat, float alt=0.0,"
  1009. " float press=0.0, float temp=0.0, int rsmi=0, int flag=FLG_SWIEPH\n"
  1010. "Return: tuple of results";
  1011. static PyObject * pyswe_rise_trans FUNCARGS_KEYWDS
  1012. {
  1013. double jd, tret[10], press = 0.0, temp = 0.0, geopos[3] = {0.0, 0.0, 0.0};
  1014. int res, plt, rsmi = 0, flag = SEFLG_SWIEPH;
  1015. char *star = "", err[256];
  1016. PyObject *body;
  1017. static char *kwlist[] = {"jd_start", "body", "lon", "lat", "alt", "press",
  1018. "temp", "rsmi", "flag", NULL};
  1019. if (!PyArg_ParseTupleAndKeywords(args, keywds, "dOdd|dddii", kwlist,
  1020. &jd, &body, &geopos[0], &geopos[1], &geopos[2], &press, &temp, &rsmi, &flag))
  1021. return NULL;
  1022. if (PyLong_CheckExact(body)) /* long -> planet */
  1023. {
  1024. plt = (int) PyLong_AsLong(body);
  1025. }
  1026. #if PY_MAJOR_VERSION >= 3
  1027. else if (PyUnicode_CheckExact(body)) /* unicode -> fixed star */
  1028. {
  1029. plt = 0;
  1030. star = (char*) PyUnicode_AS_DATA(body);
  1031. }
  1032. #elif PY_MAJOR_VERSION < 3
  1033. else if (PyInt_CheckExact(body)) /* int -> planet */
  1034. {
  1035. plt = (int) PyInt_AsLong(body);
  1036. }
  1037. else if (PyString_CheckExact(body)) /* str -> fixed star */
  1038. {
  1039. plt = 0;
  1040. star = PyString_AsString(body);
  1041. }
  1042. #endif
  1043. else
  1044. {
  1045. PyErr_SetString(pyswe_Error, "swisseph.rise_trans: Invalid body type");
  1046. return NULL;
  1047. }
  1048. res = swe_rise_trans(jd, plt, star, flag, rsmi, geopos, press, temp, tret, err);
  1049. if (res == -1)
  1050. {
  1051. PyErr_SetString(pyswe_Error, err);
  1052. return NULL;
  1053. }
  1054. return Py_BuildValue("(i)(ffffffffff)", res,tret[0],tret[1],tret[2],
  1055. tret[3],tret[4],tret[5],tret[6],tret[7],tret[8],tret[9]);
  1056. }
  1057. /* swisseph.pheno */
  1058. static char pyswe_pheno__doc__[] =
  1059. "Calculate planetary phenomena (ET).\n\n"
  1060. "Args: float julday, int planet, int flag=FLG_SWIEPH\n"
  1061. "Return: tuple of results";
  1062. static PyObject * pyswe_pheno FUNCARGS_KEYWDS
  1063. {
  1064. double jd, attr[20];
  1065. int res, plt, flag = SEFLG_SWIEPH;
  1066. char err[256];
  1067. static char *kwlist[] = {"julday", "planet", "flag", NULL};
  1068. if (!PyArg_ParseTupleAndKeywords(args, keywds, "di|i", kwlist,
  1069. &jd, &plt, &flag))
  1070. return NULL;
  1071. res = swe_pheno(jd, plt, flag, attr, err);
  1072. if (res < 0)
  1073. {
  1074. PyErr_SetString(pyswe_Error, err);
  1075. return NULL;
  1076. }
  1077. return Py_BuildValue("(fffff)", attr[0],attr[1],attr[2],attr[3],attr[4]);
  1078. }
  1079. /* swisseph.pheno_ut */
  1080. static char pyswe_pheno_ut__doc__[] =
  1081. "Calculate planetary phenomena (UTC).\n\n"
  1082. "Args: float julday, int planet, int flag=FLG_SWIEPH\n"
  1083. "Return: tuple of results";
  1084. static PyObject * pyswe_pheno_ut FUNCARGS_KEYWDS
  1085. {
  1086. double jd, attr[20];
  1087. int res, plt, flag = SEFLG_SWIEPH;
  1088. char err[256];
  1089. static char *kwlist[] = {"julday", "planet", "flag", NULL};
  1090. if (!PyArg_ParseTupleAndKeywords(args, keywds, "di|i", kwlist,
  1091. &jd, &plt, &flag))
  1092. return NULL;
  1093. res = swe_pheno(jd, plt, flag, attr, err);
  1094. if (res < 0)
  1095. {
  1096. PyErr_SetString(pyswe_Error, err);
  1097. return NULL;
  1098. }
  1099. return Py_BuildValue("(fffff)", attr[0],attr[1],attr[2],attr[3],attr[4]);
  1100. }
  1101. /* swisseph.refrac */
  1102. static char pyswe_refrac__doc__[] =
  1103. "Calculate either true altitude from apparent altitude, or apparent altitude"
  1104. " from true altitude.\n\n"
  1105. "Args: float alt, float press=0.0, float temp=0.0, int flag=TRUE_TO_APP\n"
  1106. "Return: float";
  1107. static PyObject * pyswe_refrac FUNCARGS_KEYWDS
  1108. {
  1109. double alt, press = 0.0, temp = 0.0;
  1110. int flag = SE_TRUE_TO_APP;
  1111. static char *kwlist[] = {"alt", "press", "temp", "flag", NULL};
  1112. if (!PyArg_ParseTupleAndKeywords(args, keywds, "d|ddi", kwlist,
  1113. &alt, &press, &temp, &flag))
  1114. return NULL;
  1115. return Py_BuildValue("f", swe_refrac(alt, press, temp, flag));
  1116. }
  1117. /* swisseph.refrac_extended */
  1118. static char pyswe_refrac_extended__doc__[] =
  1119. "Calculate either true altitude from apparent altitude, or apparent altitude"
  1120. " from true altitude, for geographical altitudes above sea level.\n\n"
  1121. "Args: float alt, float geoalt, float lrate, float press=0.0, float temp=0.0,"
  1122. " int flag=TRUE_TO_APP\n"
  1123. "Return: 2 tuples of 1 and 4 float";
  1124. static PyObject * pyswe_refrac_extended FUNCARGS_KEYWDS
  1125. {
  1126. double alt, geoalt, lapserate, ret, dret[4], press = 0.0, temp = 0.0;
  1127. int flag = SE_TRUE_TO_APP;
  1128. static char *kwlist[] = {"alt", "geoalt", "lrate", "press",
  1129. "temp", "flag", NULL};
  1130. if (!PyArg_ParseTupleAndKeywords(args, keywds, "ddd|ddi", kwlist,
  1131. &alt, &geoalt, &lapserate, &press, &temp, &flag))
  1132. return NULL;
  1133. ret = swe_refrac_extended(alt, geoalt, press, temp, lapserate, flag, dret);
  1134. return Py_BuildValue("(f)(ffff)", ret, dret[0], dret[1], dret[2], dret[3]);
  1135. }
  1136. /* swisseph.set_lapse_rate */
  1137. static char pyswe_set_lapse_rate__doc__[] =
  1138. "Set lapse rate.\n\nArgs: float lrate\nReturn: None";
  1139. static PyObject * pyswe_set_lapse_rate FUNCARGS_KEYWDS
  1140. {
  1141. double lapserate;
  1142. static char *kwlist[] = {"lrate", NULL};
  1143. if (!PyArg_ParseTupleAndKeywords(args, keywds, "d", kwlist,
  1144. &lapserate))
  1145. return NULL;
  1146. swe_set_lapse_rate(lapserate);
  1147. Py_RETURN_NONE;
  1148. }
  1149. /* swisseph.azalt */
  1150. static char pyswe_azalt__doc__[] =
  1151. "Calculate horizontal coordinates (azimuth and altitude) of a planet or a star"
  1152. " from either ecliptical or equatorial coordinates (UTC).\n\n"
  1153. "Args: float julday, float lon, float lat, float hei, float x, float y,"
  1154. " float z=0.0, float press=0.0, float temp=0.0, int flag=ECL2HOR\n"
  1155. "Return: tuple of 3 float (azimuth, true altitude, apparent altitude)";
  1156. static PyObject * pyswe_azalt FUNCARGS_KEYWDS
  1157. {
  1158. double jd, geo[3], xin[3], press = 0.0, temp = 0.0, xaz[3];
  1159. int flag = SE_ECL2HOR;
  1160. static char *kwlist[] = {"julday", "lon", "lat", "hei",
  1161. "x", "y", "z", "press", "temp", "flag", NULL};
  1162. xin[2] = 0.0;
  1163. if (!PyArg_ParseTupleAndKeywords(args, keywds, "dddddd|dddi", kwlist,
  1164. &jd, &geo[0], &geo[1], &geo[2], &xin[0], &xin[1], &xin[2], &press,
  1165. &temp, &flag))
  1166. return NULL;
  1167. swe_azalt(jd, flag, geo, press, temp, xin, xaz);
  1168. return Py_BuildValue("(fff)", xaz[0], xaz[1], xaz[2]);
  1169. };
  1170. /* swisseph.azalt_rev */
  1171. static char pyswe_azalt_rev__doc__[] =
  1172. "Calculate either ecliptical or equatorial coordinates from azimuth and true"
  1173. " altitude.\n\n"
  1174. "Args: float julday, float lon, float lat, float hei, double azim, double alt,"
  1175. " int flag=HOR2ECL\n"
  1176. "Return: tuple of 2 float";
  1177. static PyObject * pyswe_azalt_rev FUNCARGS_KEYWDS
  1178. {
  1179. double jd, geo[3], xin[2], xout[2];
  1180. int flag = SE_HOR2ECL;
  1181. static char *kwlist[] = {"julday", "lon", "lat", "hei",
  1182. "azim", "alt", "flag", NULL};
  1183. if (!PyArg_ParseTupleAndKeywords(args, keywds, "dddddd|i", kwlist,
  1184. &jd, &geo[0], &geo[1], &geo[2], &xin[0], &xin[1], &flag))
  1185. return NULL;
  1186. swe_azalt_rev(jd, flag, geo, xin, xout);
  1187. return Py_BuildValue("(ff)", xout[0], xout[1]);
  1188. }
  1189. /* *** Auxiliary functions *** */
  1190. /* swisseph.cotrans */
  1191. static char pyswe_cotrans__doc__[] =
  1192. "Coordinate transformation from ecliptic to equator or vice-versa.\n\n"
  1193. "Args: float lon, float lat, float dist, float obliquity\n"
  1194. "Return: tuple of 3 float (longitude, latitude, distance)";
  1195. static PyObject * pyswe_cotrans FUNCARGS_KEYWDS
  1196. {
  1197. double xpo[3], xpn[3], eps;
  1198. static char *kwlist[] = {"lon", "lat", "dist", "obliquity", NULL};
  1199. if (!PyArg_ParseTupleAndKeywords(args, keywds, "dddd", kwlist,
  1200. &xpo[0], &xpo[1], &xpo[2], &eps))
  1201. return NULL;
  1202. swe_cotrans(xpo, xpn, eps);
  1203. return Py_BuildValue("(fff)", xpn[0], xpn[1], xpn[2]);
  1204. }
  1205. /* swisseph.cotrans_sp */
  1206. static char pyswe_cotrans_sp__doc__[] =
  1207. "Coordinate transformation of position and speed, from ecliptic to equator"
  1208. " or vice-versa.\n\n"
  1209. "Args: float lon, float lat, float dist, float lonspeed, float latspeed,"
  1210. " float distspeed, float obliquity\n"
  1211. "Return: tuple of 6 float";
  1212. static PyObject * pyswe_cotrans_sp FUNCARGS_KEYWDS
  1213. {
  1214. double xpo[6], xpn[6], eps;
  1215. static char *kwlist[] = {"lon", "lat", "dist", "lonspeed",
  1216. "latspeed", "distspeed", "obliquity", NULL};
  1217. if (!PyArg_ParseTupleAndKeywords(args, keywds, "ddddddd", kwlist,
  1218. &xpo[0], &xpo[1], &xpo[2], &xpo[3], &xpo[4], &xpo[5], &eps))
  1219. return NULL;
  1220. swe_cotrans(xpo, xpn, eps);
  1221. return Py_BuildValue("(ffffff)", xpn[0], xpn[1], xpn[2], xpn[3],
  1222. xpn[4], xpn[5]);
  1223. }
  1224. /* swisseph.degnorm */
  1225. static char pyswe_degnorm__doc__[] =
  1226. "Normalization of any degree number to the range [0;360].\n\n"
  1227. "Args: float x\n"
  1228. "Return: float";
  1229. static PyObject * pyswe_degnorm FUNCARGS_KEYWDS
  1230. {
  1231. double x;
  1232. static char *kwlist[] = {"x", NULL};
  1233. if (!PyArg_ParseTupleAndKeywords(args, keywds, "d", kwlist, &x))
  1234. return NULL;
  1235. return Py_BuildValue("f", swe_degnorm(x));
  1236. }
  1237. /* swisseph.csnorm */
  1238. static char pyswe_csnorm__doc__[] =
  1239. "Normalization of any centisecond number to the range [0;360].\n\n"
  1240. "Args: int x\n"
  1241. "Return: int";
  1242. static PyObject * pyswe_csnorm FUNCARGS_KEYWDS
  1243. {
  1244. int x;
  1245. static char *kwlist[] = {"x", NULL};
  1246. if (!PyArg_ParseTupleAndKeywords(args, keywds, "i", kwlist, &x))
  1247. return NULL;
  1248. return Py_BuildValue("i", swe_csnorm(x));
  1249. }
  1250. /* swisseph.radnorm */
  1251. static char pyswe_radnorm__doc__[] =
  1252. "Normalization of any radian number to the range [0;2*pi].\n\n"
  1253. "Args: float x\n"
  1254. "Return: float";
  1255. static PyObject * pyswe_radnorm FUNCARGS_KEYWDS
  1256. {
  1257. double x;
  1258. static char *kwlist[] = {"x", NULL};
  1259. if (!PyArg_ParseTupleAndKeywords(args, keywds, "d", kwlist, &x))
  1260. return NULL;
  1261. return Py_BuildValue("f", swe_radnorm(x));
  1262. }
  1263. /* swisseph.rad_midp */
  1264. static char pyswe_rad_midp__doc__[] =
  1265. "Calculate midpoint (in radians).\n\n"
  1266. "Args: float x, float y\n"
  1267. "Return: float";
  1268. static PyObject * pyswe_rad_midp FUNCARGS_KEYWDS
  1269. {
  1270. double x, y;
  1271. static char *kwlist[] = {"x", "y", NULL};
  1272. if (!PyArg_ParseTupleAndKeywords(args, keywds, "dd", kwlist, &x, &y))
  1273. return NULL;
  1274. return Py_BuildValue("f", swe_rad_midp(x, y));
  1275. }
  1276. /* swisseph.deg_midp */
  1277. static char pyswe_deg_midp__doc__[] =
  1278. "Calculate midpoint (in degrees).\n\n"
  1279. "Args: float x, float y\n"
  1280. "Return: float";
  1281. static PyObject * pyswe_deg_midp FUNCARGS_KEYWDS
  1282. {
  1283. double x, y;
  1284. static char *kwlist[] = {"x", "y", NULL};
  1285. if (!PyArg_ParseTupleAndKeywords(args, keywds, "dd", kwlist, &x, &y))
  1286. return NULL;
  1287. return Py_BuildValue("f", swe_deg_midp(x, y));
  1288. }
  1289. /* swisseph.split_deg */
  1290. static char pyswe_split_deg__doc__[] =
  1291. "Split centiseconds in degrees, minutes, seconds, fraction of seconds, zodiac sign number.\n\n"
  1292. "Args: float ddeg, int roundflag\n"
  1293. "Return: tuple";
  1294. static PyObject * pyswe_split_deg FUNCARGS_KEYWDS
  1295. {
  1296. double ddeg, secfr;
  1297. int deg, min, sec, sign, flag;
  1298. static char *kwlist[] = {"ddeg", "roundflag", NULL};
  1299. if (!PyArg_ParseTupleAndKeywords(args, keywds, "di", kwlist, &ddeg, &flag))
  1300. return NULL;
  1301. swe_split_deg(ddeg, flag, &deg, &min, &sec, &secfr, &sign);
  1302. return Py_BuildValue("(iiidi)", deg, min, sec, secfr, sign);
  1303. }
  1304. /* swisseph.difcsn */
  1305. static char pyswe_difcsn__doc__[] =
  1306. "Calculate distance in centisecs p1 - p2.\n\n"
  1307. "Args: int p1, int p2\n"
  1308. "Return: int";
  1309. static PyObject * pyswe_difcsn FUNCARGS_KEYWDS
  1310. {
  1311. int p1, p2;
  1312. static char *kwlist[] = {"p1", "p2", NULL};
  1313. if (!PyArg_ParseTupleAndKeywords(args, keywds, "ii", kwlist, &p1, &p2))
  1314. return NULL;
  1315. return Py_BuildValue("i", swe_difcsn(p1, p2));
  1316. }
  1317. /* swisseph.difdegn */
  1318. static char pyswe_difdegn__doc__[] =
  1319. "Calculate distance in degrees p1 - p2.\n\n"
  1320. "Args: float p1, float p2\n"
  1321. "Return: float";
  1322. static PyObject * pyswe_difdegn FUNCARGS_KEYWDS
  1323. {
  1324. double p1, p2;
  1325. static char *kwlist[] = {"p1", "p2", NULL};
  1326. if (!PyArg_ParseTupleAndKeywords(args, keywds, "dd", kwlist, &p1, &p2))
  1327. return NULL;
  1328. return Py_BuildValue("f", swe_difdegn(p1, p2));
  1329. }
  1330. /* swisseph.difcs2n */
  1331. static char pyswe_difcs2n__doc__[] =
  1332. "Calculate distance in centisecs p1 - p2 normalized to [-180;180].\n\n"
  1333. "Args: int p1, int p2\n"
  1334. "Return: int";
  1335. static PyObject * pyswe_difcs2n FUNCARGS_KEYWDS
  1336. {
  1337. int p1, p2;
  1338. static char *kwlist[] = {"p1", "p2", NULL};
  1339. if (!PyArg_ParseTupleAndKeywords(args, keywds, "ii", kwlist, &p1, &p2))
  1340. return NULL;
  1341. return Py_BuildValue("i", swe_difcs2n(p1, p2));
  1342. }
  1343. /* swisseph.difdeg2n */
  1344. static char pyswe_difdeg2n__doc__[] =
  1345. "Calculate distance in degrees p1 - p2 normalized to [-180;180].\n\n"
  1346. "Args: float p1, float p2\n"
  1347. "Return: float";
  1348. static PyObject * pyswe_difdeg2n FUNCARGS_KEYWDS
  1349. {
  1350. double p1, p2;
  1351. static char *kwlist[] = {"p1", "p2", NULL};
  1352. if (!PyArg_ParseTupleAndKeywords(args, keywds, "dd", kwlist, &p1, &p2))
  1353. return NULL;
  1354. return Py_BuildValue("f", swe_difdeg2n(p1, p2));
  1355. }
  1356. /* swisseph.difrad2n */
  1357. static char pyswe_difrad2n__doc__[] =
  1358. "Calculate distance in radians p1 - p2 normalized to [-180;180].\n\n"
  1359. "Args: float p1, float p2\n"
  1360. "Return: float";
  1361. static PyObject * pyswe_difrad2n FUNCARGS_KEYWDS
  1362. {
  1363. double p1, p2;
  1364. static char *kwlist[] = {"p1", "p2", NULL};
  1365. if (!PyArg_ParseTupleAndKeywords(args, keywds, "dd", kwlist, &p1, &p2))
  1366. return NULL;
  1367. return Py_BuildValue("f", swe_difrad2n(p1, p2));
  1368. }
  1369. /* swisseph.csroundsec */
  1370. static char pyswe_csroundsec__doc__[] =
  1371. "Round centiseconds, but at 29.5959 always down.\n\n"
  1372. "Args: int x\n"
  1373. "Return: int";
  1374. static PyObject * pyswe_csroundsec FUNCARGS_KEYWDS
  1375. {
  1376. int x;
  1377. static char *kwlist[] = {"x", NULL};
  1378. if (!PyArg_ParseTupleAndKeywords(args, keywds, "i", kwlist, &x))
  1379. return NULL;
  1380. return Py_BuildValue("i", swe_csroundsec(x));
  1381. }
  1382. /* swisseph.d2l */
  1383. static char pyswe_d2l__doc__[] =
  1384. "Double to integer with rounding, no overflow check.\n\n"
  1385. "Args: float x\n"
  1386. "Return: int";
  1387. static PyObject * pyswe_d2l FUNCARGS_KEYWDS
  1388. {
  1389. double x;
  1390. static char *kwlist[] = {"x", NULL};
  1391. if (!PyArg_ParseTupleAndKeywords(args, keywds, "d", kwlist, &x))
  1392. return NULL;
  1393. return Py_BuildValue("i", swe_d2l(x));
  1394. }
  1395. /* swisseph.day_of_week */
  1396. static char pyswe_day_of_week__doc__[] =
  1397. "Calculate day of week number [0;6] from julian day number.\n\n"
  1398. "Args: float julday\n"
  1399. "Return: int";
  1400. static PyObject * pyswe_day_of_week FUNCARGS_KEYWDS
  1401. {
  1402. double jd;
  1403. static char *kwlist[] = {"julday", NULL};
  1404. if (!PyArg_ParseTupleAndKeywords(args, keywds, "d", kwlist, &jd))
  1405. return NULL;
  1406. return Py_BuildValue("i", swe_day_of_week(jd));
  1407. }
  1408. /* swisseph.cs2timestr */
  1409. static char pyswe_cs2timestr__doc__[] =
  1410. "Get time string from centiseconds.\n\n"
  1411. "Args: int cs, char sep, bool suppresszero=True\n"
  1412. "Return: str";
  1413. static PyObject * pyswe_cs2timestr FUNCARGS_KEYWDS
  1414. {
  1415. int cs, sep, suppresszero = 1;
  1416. char ret[9];
  1417. static char *kwlist[] = {"cs", "sep", "suppresszero", NULL};
  1418. if (!PyArg_ParseTupleAndKeywords(args, keywds, "ic|i", kwlist,
  1419. &cs, &sep, &suppresszero))
  1420. return NULL;
  1421. swe_cs2timestr(cs, sep, suppresszero, ret);
  1422. return Py_BuildValue("s", ret);
  1423. }
  1424. /* swisseph.cs2lonlatstr */
  1425. static char pyswe_cs2lonlatstr__doc__[] =
  1426. "Get longitude or latitude string from centiseconds.\n\n"
  1427. "Args: int cs, char plus, char minus\n"
  1428. "Return: str";
  1429. static PyObject * pyswe_cs2lonlatstr FUNCARGS_KEYWDS
  1430. {
  1431. int cs;
  1432. char ret[10], p, m;
  1433. static char *kwlist[] = {"cs", "plus", "minus", NULL};
  1434. if (!PyArg_ParseTupleAndKeywords(args, keywds, "icc", kwlist,
  1435. &cs, &p, &m))
  1436. return NULL;
  1437. swe_cs2lonlatstr(cs, p, m, ret);
  1438. return Py_BuildValue("s", ret);
  1439. }
  1440. /* swisseph.cs2degstr */
  1441. static char pyswe_cs2degstr__doc__[] =
  1442. "Get degrees string from centiseconds.\n\n"
  1443. "Args: int cs\n"
  1444. "Return: str";
  1445. static PyObject * pyswe_cs2degstr FUNCARGS_KEYWDS
  1446. {
  1447. int cs;
  1448. char ret[9];
  1449. static char *kwlist[] = {"cs", NULL};
  1450. if (!PyArg_ParseTupleAndKeywords(args, keywds, "i", kwlist, &cs))
  1451. return NULL;
  1452. swe_cs2degstr(cs, ret);
  1453. return Py_BuildValue("s", ret);
  1454. }
  1455. /* swisseph.fixstar_mag */
  1456. static char pyswe_fixstar_mag__doc__ [] =
  1457. "Get fixed star magnitude.\n\n"
  1458. "Args: str star\n"
  1459. "Return: float";
  1460. static PyObject * pyswe_fixstar_mag FUNCARGS_KEYWDS
  1461. {
  1462. char *star, err[256];
  1463. int ret;
  1464. double mag;
  1465. static char *kwlist[] = {"star", NULL};
  1466. if (!PyArg_ParseTupleAndKeywords(args, keywds, "s", kwlist, &star))
  1467. return NULL;
  1468. ret = swe_fixstar_mag(star, &mag, err);
  1469. if (ret < 0)
  1470. {
  1471. PyErr_SetString(pyswe_Error, err);
  1472. return NULL;
  1473. }
  1474. return Py_BuildValue("f", mag);
  1475. }
  1476. /* swisseph.heliacal_ut */
  1477. static char pyswe_heliacal_ut__doc__ [] =
  1478. "Find the Julian day of the next heliacal phenomenon after a given start date.\n"
  1479. "It works between geographic latitudes 60s - 60n.\n\n"
  1480. "Args: float jdstart, seq geopos, seq atmo, seq observer, str object, int enventtype, int helflag\n"
  1481. "Return: tuple with 3 julian days";
  1482. static PyObject * pyswe_heliacal_ut FUNCARGS_KEYWDS
  1483. {
  1484. double jdstart, geopos[3], atmo[4], observ[6], dret[3];
  1485. char serr[255], *obj = 0; /* dummy assign */
  1486. int i, evnt, flg;
  1487. PyObject *o1=0, *o2=0, *o3=0, *o4, *o5, *o6, *o7, *o8, *o9;
  1488. static char *kwlist[] = {"jdstart", "geopos", "atmo", "observer", "object",
  1489. "eventtype", "helflag", NULL};
  1490. if (!PyArg_ParseTupleAndKeywords(args, keywds, "dOOOsii", kwlist,
  1491. &jdstart, o1, o2, o3, obj, &evnt, &flg))
  1492. return NULL;
  1493. if (!PySequence_Check(o1) || PySequence_Length(o1) != 3)
  1494. {
  1495. PyErr_SetString(pyswe_Error, "Invalid geopos sequence");
  1496. return NULL;
  1497. }
  1498. else
  1499. {
  1500. o4 = PySequence_ITEM(o1, 0);
  1501. o5 = PySequence_ITEM(o1, 1);
  1502. o6 = PySequence_ITEM(o1, 2);
  1503. if (!PyNumber_Check(o4) || !PyNumber_Check(o5) || !PyNumber_Check(o6))
  1504. {
  1505. PyErr_SetString(pyswe_Error, "Invalid geopos value type");
  1506. Py_DECREF(o4); Py_DECREF(o5); Py_DECREF(o6);
  1507. return NULL;
  1508. }
  1509. /* checking longitude */
  1510. if (PyFloat_Check(o4))
  1511. {
  1512. geopos[0] = PyFloat_AsDouble(o4);
  1513. }
  1514. #if PY_MAJOR_VERSION < 3
  1515. else if (PyInt_Check(o5))
  1516. {
  1517. geopos[0] = (double) PyInt_AsLong(o4);
  1518. }
  1519. #endif
  1520. else if (PyLong_Check(o4))
  1521. {
  1522. geopos[0] = (double) PyLong_AsLong(o4);
  1523. }
  1524. else
  1525. {
  1526. PyErr_SetString(pyswe_Error, "Invalid longitude type");
  1527. Py_DECREF(o4); Py_DECREF(o5); Py_DECREF(o6);
  1528. return NULL;
  1529. }
  1530. /* checking latitude */
  1531. if (PyFloat_Check(o5))
  1532. {
  1533. geopos[1] = PyFloat_AsDouble(o5);
  1534. }
  1535. #if PY_MAJOR_VERSION < 3
  1536. else if (PyInt_Check(o5))
  1537. {
  1538. geopos[1] = (double) PyInt_AsLong(o5);
  1539. }
  1540. #endif
  1541. else if (PyLong_Check(o5))
  1542. {
  1543. geopos[1] = (double) PyLong_AsLong(o5);
  1544. }
  1545. else
  1546. {
  1547. PyErr_SetString(pyswe_Error, "Invalid latitude type");
  1548. Py_DECREF(o4); Py_DECREF(o5); Py_DECREF(o6);
  1549. return NULL;
  1550. }
  1551. /* checking altitude */
  1552. if (PyFloat_Check(o6))
  1553. {
  1554. geopos[2] = PyFloat_AsDouble(o6);
  1555. }
  1556. #if PY_MAJOR_VERSION < 3
  1557. else if (PyInt_Check(o5))
  1558. {
  1559. geopos[2] = (double) PyInt_AsLong(o6);
  1560. }
  1561. #endif
  1562. else if (PyLong_Check(o6))
  1563. {
  1564. geopos[2] = (double) PyLong_AsLong(o6);
  1565. }
  1566. else
  1567. {
  1568. PyErr_SetString(pyswe_Error, "Invalid altitude type");
  1569. Py_DECREF(o4); Py_DECREF(o5); Py_DECREF(o6);
  1570. return NULL;
  1571. }
  1572. Py_DECREF(o4); Py_DECREF(o5); Py_DECREF(o6);
  1573. }
  1574. if (!PySequence_Check(o2) || PySequence_Length(o2) != 4)
  1575. {
  1576. PyErr_SetString(pyswe_Error, "Invalid atmospheric sequence");
  1577. return NULL;
  1578. }
  1579. else
  1580. {
  1581. o4 = PySequence_ITEM(o2, 0);
  1582. o5 = PySequence_ITEM(o2, 1);
  1583. o6 = PySequence_ITEM(o2, 2);
  1584. o7 = PySequence_ITEM(o2, 3);
  1585. if (!PyNumber_Check(o4) || !PyNumber_Check(o5) || !PyNumber_Check(o6)
  1586. || !PyNumber_Check(o7))
  1587. {
  1588. PyErr_SetString(pyswe_Error, "Invalid atmospheric value type");
  1589. Py_DECREF(o4); Py_DECREF(o5); Py_DECREF(o6); Py_DECREF(o7);
  1590. return NULL;
  1591. }
  1592. /* atmospheric pressure */
  1593. if (PyFloat_Check(o4))
  1594. {
  1595. atmo[0] = PyFloat_AsDouble(o4);
  1596. }
  1597. #if PY_MAJOR_VERSION < 3
  1598. else if (PyInt_Check(o4))
  1599. {
  1600. atmo[0] = (double) PyInt_AsLong(o4);
  1601. }
  1602. #endif
  1603. else if (PyLong_Check(o4))
  1604. {
  1605. atmo[0] = (double) PyLong_AsLong(o4);
  1606. }
  1607. else
  1608. {
  1609. PyErr_SetString(pyswe_Error, "Invalid atmospheric pressure");
  1610. Py_DECREF(o4); Py_DECREF(o5); Py_DECREF(o6); Py_DECREF(o7);
  1611. return NULL;
  1612. }
  1613. /* atmospheric temperature */
  1614. if (PyFloat_Check(o5))
  1615. {
  1616. atmo[1] = PyFloat_AsDouble(o5);
  1617. }
  1618. #if PY_MAJOR_VERSION < 3
  1619. else if (PyInt_Check(o5))
  1620. {
  1621. atmo[1] = (double) PyInt_AsLong(o5);
  1622. }
  1623. #endif
  1624. else if (PyLong_Check(o5))
  1625. {
  1626. atmo[1] = (double) PyLong_AsLong(o5);
  1627. }
  1628. else
  1629. {
  1630. PyErr_SetString(pyswe_Error, "Invalid atmospheric temperature");
  1631. Py_DECREF(o4); Py_DECREF(o5); Py_DECREF(o6); Py_DECREF(o7);
  1632. return NULL;
  1633. }
  1634. /* humidity */
  1635. if (PyFloat_Check(o6))
  1636. {
  1637. atmo[2] = PyFloat_AsDouble(o6);
  1638. }
  1639. #if PY_MAJOR_VERSION < 3
  1640. else if (PyInt_Check(o6))
  1641. {
  1642. atmo[2] = (double) PyInt_AsLong(o6);
  1643. }
  1644. #endif
  1645. else if (PyLong_Check(o6))
  1646. {
  1647. atmo[2] = (double) PyLong_AsLong(o6);
  1648. }
  1649. else
  1650. {
  1651. PyErr_SetString(pyswe_Error, "Invalid humidity");
  1652. Py_DECREF(o4); Py_DECREF(o5); Py_DECREF(o6); Py_DECREF(o7);
  1653. return NULL;
  1654. }
  1655. /* meteorological range */
  1656. if (PyFloat_Check(o7))
  1657. {
  1658. atmo[3] = PyFloat_AsDouble(o7);
  1659. }
  1660. #if PY_MAJOR_VERSION < 3
  1661. else if (PyInt_Check(o7))
  1662. {
  1663. atmo[3] = (double) PyInt_AsLong(o7);
  1664. }
  1665. #endif
  1666. else if (PyLong_Check(o7))
  1667. {
  1668. atmo[3] = (double) PyLong_AsLong(o7);
  1669. }
  1670. else
  1671. {
  1672. PyErr_SetString(pyswe_Error, "Invalid meteorological range");
  1673. Py_DECREF(o4); Py_DECREF(o5); Py_DECREF(o6); Py_DECREF(o7);
  1674. return NULL;
  1675. }
  1676. Py_DECREF(o4); Py_DECREF(o5); Py_DECREF(o6); Py_DECREF(o7);
  1677. }
  1678. if (!PySequence_Check(o3) || PySequence_Length(o3) != 6)
  1679. {
  1680. PyErr_SetString(pyswe_Error, "Invalid observer sequence");
  1681. return NULL;
  1682. }
  1683. else
  1684. {
  1685. o4 = PySequence_ITEM(o3, 0);
  1686. o5 = PySequence_ITEM(o3, 1);
  1687. o6 = PySequence_ITEM(o3, 2);
  1688. o7 = PySequence_ITEM(o3, 3);
  1689. o8 = PySequence_ITEM(o3, 4);
  1690. o9 = PySequence_ITEM(o3, 5);
  1691. if (!PyNumber_Check(o4) || !PyNumber_Check(o5) || !PyNumber_Check(o6)
  1692. || !PyNumber_Check(o7) || !PyNumber_Check(o8) || !PyNumber_Check(o9))
  1693. {
  1694. PyErr_SetString(pyswe_Error, "Invalid observer value type");
  1695. Py_DECREF(o4); Py_DECREF(o5); Py_DECREF(o6); Py_DECREF(o7);
  1696. Py_DECREF(o8); Py_DECREF(o9);
  1697. return NULL;
  1698. }
  1699. /* observer age */
  1700. if (PyFloat_Check(o4))
  1701. {
  1702. observ[0] = PyFloat_AsDouble(o4);
  1703. }
  1704. #if PY_MAJOR_VERSION < 3
  1705. else if (PyInt_Check(o4))
  1706. {
  1707. observ[0] = (double) PyInt_AsLong(o4);
  1708. }
  1709. #endif
  1710. else if (PyLong_Check(o4))
  1711. {
  1712. observ[0] = (double) PyLong_AsLong(o4);
  1713. }
  1714. else
  1715. {
  1716. PyErr_SetString(pyswe_Error, "Invalid observer age");
  1717. Py_DECREF(o4); Py_DECREF(o5); Py_DECREF(o6); Py_DECREF(o7);
  1718. Py_DECREF(o8); Py_DECREF(o9);
  1719. return NULL;
  1720. }
  1721. /* snellen ratio */
  1722. if (PyFloat_Check(o5))
  1723. {
  1724. observ[1] = PyFloat_AsDouble(o5);
  1725. }
  1726. #if PY_MAJOR_VERSION < 3
  1727. else if (PyInt_Check(o5))
  1728. {
  1729. observ[1] = (double) PyInt_AsLong(o5);
  1730. }
  1731. #endif
  1732. else if (PyLong_Check(o5))
  1733. {
  1734. observ[1] = (double) PyLong_AsLong(o5);
  1735. }
  1736. else
  1737. {
  1738. PyErr_SetString(pyswe_Error, "Invalid snellen ratio");
  1739. Py_DECREF(o4); Py_DECREF(o5); Py_DECREF(o6); Py_DECREF(o7);
  1740. Py_DECREF(o8); Py_DECREF(o9);
  1741. return NULL;
  1742. }
  1743. /* mono/binocular */
  1744. if (PyFloat_Check(o6))
  1745. {
  1746. observ[2] = PyFloat_AsDouble(o6);
  1747. }
  1748. #if PY_MAJOR_VERSION < 3
  1749. else if (PyInt_Check(o6))
  1750. {
  1751. observ[2] = (double) PyInt_AsLong(o6);
  1752. }
  1753. #endif
  1754. else if (PyLong_Check(o6))
  1755. {
  1756. observ[2] = (double) PyLong_AsLong(o6);
  1757. }
  1758. else
  1759. {
  1760. PyErr_SetString(pyswe_Error, "Invalid telescope");
  1761. Py_DECREF(o4); Py_DECREF(o5); Py_DECREF(o6); Py_DECREF(o7);
  1762. Py_DECREF(o8); Py_DECREF(o9);
  1763. return NULL;
  1764. }
  1765. /* telescope magnification */
  1766. if (PyFloat_Check(o7))
  1767. {
  1768. observ[3] = PyFloat_AsDouble(o7);
  1769. }
  1770. #if PY_MAJOR_VERSION < 3
  1771. else if (PyInt_Check(o7))
  1772. {
  1773. observ[3] = (double) PyInt_AsLong(o7);
  1774. }
  1775. #endif
  1776. else if (PyLong_Check(o7))
  1777. {
  1778. observ[3] = (double) PyLong_AsLong(o7);
  1779. }
  1780. else
  1781. {
  1782. PyErr_SetString(pyswe_Error, "Invalid telescope magnification");
  1783. Py_DECREF(o4); Py_DECREF(o5); Py_DECREF(o6); Py_DECREF(o7);
  1784. Py_DECREF(o8); Py_DECREF(o9);
  1785. return NULL;
  1786. }
  1787. /* optical aperture */
  1788. if (PyFloat_Check(o8))
  1789. {
  1790. observ[4] = PyFloat_AsDouble(o8);
  1791. }
  1792. #if PY_MAJOR_VERSION < 3
  1793. else if (PyInt_Check(o8))
  1794. {
  1795. observ[4] = (double) PyInt_AsLong(o8);
  1796. }
  1797. #endif
  1798. else if (PyLong_Check(o8))
  1799. {
  1800. observ[4] = (double) PyLong_AsLong(o8);
  1801. }
  1802. else
  1803. {
  1804. PyErr_SetString(pyswe_Error, "Invalid telescope aperture");
  1805. Py_DECREF(o4); Py_DECREF(o5); Py_DECREF(o6); Py_DECREF(o7);
  1806. Py_DECREF(o8); Py_DECREF(o9);
  1807. return NULL;
  1808. }
  1809. /* optical transmission */
  1810. if (PyFloat_Check(o9))
  1811. {
  1812. observ[5] = PyFloat_AsDouble(o9);
  1813. }
  1814. #if PY_MAJOR_VERSION < 3
  1815. else if (PyInt_Check(o9))
  1816. {
  1817. observ[5] = (double) PyInt_AsLong(o9);
  1818. }
  1819. #endif
  1820. else if (PyLong_Check(o9))
  1821. {
  1822. observ[5] = (double) PyLong_AsLong(o9);
  1823. }
  1824. else
  1825. {
  1826. PyErr_SetString(pyswe_Error, "Invalid telescope aperture");
  1827. Py_DECREF(o4); Py_DECREF(o5); Py_DECREF(o6); Py_DECREF(o7);
  1828. Py_DECREF(o8); Py_DECREF(o9);
  1829. return NULL;
  1830. }
  1831. Py_DECREF(o4); Py_DECREF(o5); Py_DECREF(o6); Py_DECREF(o7);
  1832. Py_DECREF(o8); Py_DECREF(o9);
  1833. }
  1834. i = swe_heliacal_ut(jdstart, geopos, atmo, observ, obj, evnt, flg, dret, serr);
  1835. if (i == 0)
  1836. {
  1837. return Py_BuildValue("ddd", dret[0], dret[1], dret[2]);
  1838. }
  1839. else
  1840. {
  1841. PyErr_SetString(pyswe_Error, serr);
  1842. return NULL;
  1843. }
  1844. }
  1845. /* swisseph.vis_limit_mag */
  1846. static char pyswe_vis_limit_mag__doc__ [] =
  1847. "Find the limiting visual magnitude in dark skies.\n\n"
  1848. "Args: float jd, seq geopos, seq atmo, seq observer, str object, int helflag\n"
  1849. "Return: tuple (float res, float magnitude)";
  1850. static PyObject * pyswe_vis_limit_mag FUNCARGS_KEYWDS
  1851. {
  1852. double jd, geopos[3], atmo[4], observ[6], dres, dret;
  1853. char serr[255], *obj = 0;
  1854. int flg;
  1855. PyObject *o1=0, *o2=0, *o3=0, *o4, *o5, *o6, *o7, *o8, *o9;
  1856. static char *kwlist[] = {"jd", "geopos", "atmo", "observer", "object",
  1857. "helflag", NULL};
  1858. if (!PyArg_ParseTupleAndKeywords(args, keywds, "dOOOsi", kwlist,
  1859. &jd, o1, o2, o3, obj, &flg))
  1860. return NULL;
  1861. if (!PySequence_Check(o1) || PySequence_Length(o1) != 3)
  1862. {
  1863. PyErr_SetString(pyswe_Error, "Invalid geopos sequence");
  1864. return NULL;
  1865. }
  1866. else
  1867. {
  1868. o4 = PySequence_ITEM(o1, 0);
  1869. o5 = PySequence_ITEM(o1, 1);
  1870. o6 = PySequence_ITEM(o1, 2);
  1871. if (!PyNumber_Check(o4) || !PyNumber_Check(o5) || !PyNumber_Check(o6))
  1872. {
  1873. PyErr_SetString(pyswe_Error, "Invalid geopos value type");
  1874. Py_DECREF(o4); Py_DECREF(o5); Py_DECREF(o6);
  1875. return NULL;
  1876. }
  1877. /* checking longitude */
  1878. if (PyFloat_Check(o4))
  1879. {
  1880. geopos[0] = PyFloat_AsDouble(o4);
  1881. }
  1882. #if PY_MAJOR_VERSION < 3
  1883. else if (PyInt_Check(o5))
  1884. {
  1885. geopos[0] = (double) PyInt_AsLong(o4);
  1886. }
  1887. #endif
  1888. else if (PyLong_Check(o4))
  1889. {
  1890. geopos[0] = (double) PyLong_AsLong(o4);
  1891. }
  1892. else
  1893. {
  1894. PyErr_SetString(pyswe_Error, "Invalid longitude type");
  1895. Py_DECREF(o4); Py_DECREF(o5); Py_DECREF(o6);
  1896. return NULL;
  1897. }
  1898. /* checking latitude */
  1899. if (PyFloat_Check(o5))
  1900. {
  1901. geopos[1] = PyFloat_AsDouble(o5);
  1902. }
  1903. #if PY_MAJOR_VERSION < 3
  1904. else if (PyInt_Check(o5))
  1905. {
  1906. geopos[1] = (double) PyInt_AsLong(o5);
  1907. }
  1908. #endif
  1909. else if (PyLong_Check(o5))
  1910. {
  1911. geopos[1] = (double) PyLong_AsLong(o5);
  1912. }
  1913. else
  1914. {
  1915. PyErr_SetString(pyswe_Error, "Invalid latitude type");
  1916. Py_DECREF(o4); Py_DECREF(o5); Py_DECREF(o6);
  1917. return NULL;
  1918. }
  1919. /* checking altitude */
  1920. if (PyFloat_Check(o6))
  1921. {
  1922. geopos[2] = PyFloat_AsDouble(o6);
  1923. }
  1924. #if PY_MAJOR_VERSION < 3
  1925. else if (PyInt_Check(o5))
  1926. {
  1927. geopos[2] = (double) PyInt_AsLong(o6);
  1928. }
  1929. #endif
  1930. else if (PyLong_Check(o6))
  1931. {
  1932. geopos[2] = (double) PyLong_AsLong(o6);
  1933. }
  1934. else
  1935. {
  1936. PyErr_SetString(pyswe_Error, "Invalid altitude type");
  1937. Py_DECREF(o4); Py_DECREF(o5); Py_DECREF(o6);
  1938. return NULL;
  1939. }
  1940. Py_DECREF(o4); Py_DECREF(o5); Py_DECREF(o6);
  1941. }
  1942. if (!PySequence_Check(o2) || PySequence_Length(o2) != 4)
  1943. {
  1944. PyErr_SetString(pyswe_Error, "Invalid atmospheric sequence");
  1945. return NULL;
  1946. }
  1947. else
  1948. {
  1949. o4 = PySequence_ITEM(o2, 0);
  1950. o5 = PySequence_ITEM(o2, 1);
  1951. o6 = PySequence_ITEM(o2, 2);
  1952. o7 = PySequence_ITEM(o2, 3);
  1953. if (!PyNumber_Check(o4) || !PyNumber_Check(o5) || !PyNumber_Check(o6)
  1954. || !PyNumber_Check(o7))
  1955. {
  1956. PyErr_SetString(pyswe_Error, "Invalid atmospheric value type");
  1957. Py_DECREF(o4); Py_DECREF(o5); Py_DECREF(o6); Py_DECREF(o7);
  1958. return NULL;
  1959. }
  1960. /* atmospheric pressure */
  1961. if (PyFloat_Check(o4))
  1962. {
  1963. atmo[0] = PyFloat_AsDouble(o4);
  1964. }
  1965. #if PY_MAJOR_VERSION < 3
  1966. else if (PyInt_Check(o4))
  1967. {
  1968. atmo[0] = (double) PyInt_AsLong(o4);
  1969. }
  1970. #endif
  1971. else if (PyLong_Check(o4))
  1972. {
  1973. atmo[0] = (double) PyLong_AsLong(o4);
  1974. }
  1975. else
  1976. {
  1977. PyErr_SetString(pyswe_Error, "Invalid atmospheric pressure");
  1978. Py_DECREF(o4); Py_DECREF(o5); Py_DECREF(o6); Py_DECREF(o7);
  1979. return NULL;
  1980. }
  1981. /* atmospheric temperature */
  1982. if (PyFloat_Check(o5))
  1983. {
  1984. atmo[1] = PyFloat_AsDouble(o5);
  1985. }
  1986. #if PY_MAJOR_VERSION < 3
  1987. else if (PyInt_Check(o5))
  1988. {
  1989. atmo[1] = (double) PyInt_AsLong(o5);
  1990. }
  1991. #endif
  1992. else if (PyLong_Check(o5))
  1993. {
  1994. atmo[1] = (double) PyLong_AsLong(o5);
  1995. }
  1996. else
  1997. {
  1998. PyErr_SetString(pyswe_Error, "Invalid atmospheric temperature");
  1999. Py_DECREF(o4); Py_DECREF(o5); Py_DECREF(o6); Py_DECREF(o7);
  2000. return NULL;
  2001. }
  2002. /* humidity */
  2003. if (PyFloat_Check(o6))
  2004. {
  2005. atmo[2] = PyFloat_AsDouble(o6);
  2006. }
  2007. #if PY_MAJOR_VERSION < 3
  2008. else if (PyInt_Check(o6))
  2009. {
  2010. atmo[2] = (double) PyInt_AsLong(o6);
  2011. }
  2012. #endif
  2013. else if (PyLong_Check(o6))
  2014. {
  2015. atmo[2] = (double) PyLong_AsLong(o6);
  2016. }
  2017. else
  2018. {
  2019. PyErr_SetString(pyswe_Error, "Invalid humidity");
  2020. Py_DECREF(o4); Py_DECREF(o5); Py_DECREF(o6); Py_DECREF(o7);
  2021. return NULL;
  2022. }
  2023. /* meteorological range */
  2024. if (PyFloat_Check(o7))
  2025. {
  2026. atmo[3] = PyFloat_AsDouble(o7);
  2027. }
  2028. #if PY_MAJOR_VERSION < 3
  2029. else if (PyInt_Check(o7))
  2030. {
  2031. atmo[3] = (double) PyInt_AsLong(o7);
  2032. }
  2033. #endif
  2034. else if (PyLong_Check(o7))
  2035. {
  2036. atmo[3] = (double) PyLong_AsLong(o7);
  2037. }
  2038. else
  2039. {
  2040. PyErr_SetString(pyswe_Error, "Invalid meteorological range");
  2041. Py_DECREF(o4); Py_DECREF(o5); Py_DECREF(o6); Py_DECREF(o7);
  2042. return NULL;
  2043. }
  2044. Py_DECREF(o4); Py_DECREF(o5); Py_DECREF(o6); Py_DECREF(o7);
  2045. }
  2046. if (!PySequence_Check(o3) || PySequence_Length(o3) != 6)
  2047. {
  2048. PyErr_SetString(pyswe_Error, "Invalid observer sequence");
  2049. return NULL;
  2050. }
  2051. else
  2052. {
  2053. o4 = PySequence_ITEM(o3, 0);
  2054. o5 = PySequence_ITEM(o3, 1);
  2055. o6 = PySequence_ITEM(o3, 2);
  2056. o7 = PySequence_ITEM(o3, 3);
  2057. o8 = PySequence_ITEM(o3, 4);
  2058. o9 = PySequence_ITEM(o3, 5);
  2059. if (!PyNumber_Check(o4) || !PyNumber_Check(o5) || !PyNumber_Check(o6)
  2060. || !PyNumber_Check(o7) || !PyNumber_Check(o8) || !PyNumber_Check(o9))
  2061. {
  2062. PyErr_SetString(pyswe_Error, "Invalid observer value type");
  2063. Py_DECREF(o4); Py_DECREF(o5); Py_DECREF(o6); Py_DECREF(o7);
  2064. Py_DECREF(o8); Py_DECREF(o9);
  2065. return NULL;
  2066. }
  2067. /* observer age */
  2068. if (PyFloat_Check(o4))
  2069. {
  2070. observ[0] = PyFloat_AsDouble(o4);
  2071. }
  2072. #if PY_MAJOR_VERSION < 3
  2073. else if (PyInt_Check(o4))
  2074. {
  2075. observ[0] = (double) PyInt_AsLong(o4);
  2076. }
  2077. #endif
  2078. else if (PyLong_Check(o4))
  2079. {
  2080. observ[0] = (double) PyLong_AsLong(o4);
  2081. }
  2082. else
  2083. {
  2084. PyErr_SetString(pyswe_Error, "Invalid observer age");
  2085. Py_DECREF(o4); Py_DECREF(o5); Py_DECREF(o6); Py_DECREF(o7);
  2086. Py_DECREF(o8); Py_DECREF(o9);
  2087. return NULL;
  2088. }
  2089. /* snellen ratio */
  2090. if (PyFloat_Check(o5))
  2091. {
  2092. observ[1] = PyFloat_AsDouble(o5);
  2093. }
  2094. #if PY_MAJOR_VERSION < 3
  2095. else if (PyInt_Check(o5))
  2096. {
  2097. observ[1] = (double) PyInt_AsLong(o5);
  2098. }
  2099. #endif
  2100. else if (PyLong_Check(o5))
  2101. {
  2102. observ[1] = (double) PyLong_AsLong(o5);
  2103. }
  2104. else
  2105. {
  2106. PyErr_SetString(pyswe_Error, "Invalid snellen ratio");
  2107. Py_DECREF(o4); Py_DECREF(o5); Py_DECREF(o6); Py_DECREF(o7);
  2108. Py_DECREF(o8); Py_DECREF(o9);
  2109. return NULL;
  2110. }
  2111. /* mono/binocular */
  2112. if (PyFloat_Check(o6))
  2113. {
  2114. observ[2] = PyFloat_AsDouble(o6);
  2115. }
  2116. #if PY_MAJOR_VERSION < 3
  2117. else if (PyInt_Check(o6))
  2118. {
  2119. observ[2] = (double) PyInt_AsLong(o6);
  2120. }
  2121. #endif
  2122. else if (PyLong_Check(o6))
  2123. {
  2124. observ[2] = (double) PyLong_AsLong(o6);
  2125. }
  2126. else
  2127. {
  2128. PyErr_SetString(pyswe_Error, "Invalid telescope");
  2129. Py_DECREF(o4); Py_DECREF(o5); Py_DECREF(o6); Py_DECREF(o7);
  2130. Py_DECREF(o8); Py_DECREF(o9);
  2131. return NULL;
  2132. }
  2133. /* telescope magnification */
  2134. if (PyFloat_Check(o7))
  2135. {
  2136. observ[3] = PyFloat_AsDouble(o7);
  2137. }
  2138. #if PY_MAJOR_VERSION < 3
  2139. else if (PyInt_Check(o7))
  2140. {
  2141. observ[3] = (double) PyInt_AsLong(o7);
  2142. }
  2143. #endif
  2144. else if (PyLong_Check(o7))
  2145. {
  2146. observ[3] = (double) PyLong_AsLong(o7);
  2147. }
  2148. else
  2149. {
  2150. PyErr_SetString(pyswe_Error, "Invalid telescope magnification");
  2151. Py_DECREF(o4); Py_DECREF(o5); Py_DECREF(o6); Py_DECREF(o7);
  2152. Py_DECREF(o8); Py_DECREF(o9);
  2153. return NULL;
  2154. }
  2155. /* optical aperture */
  2156. if (PyFloat_Check(o8))
  2157. {
  2158. observ[4] = PyFloat_AsDouble(o8);
  2159. }
  2160. #if PY_MAJOR_VERSION < 3
  2161. else if (PyInt_Check(o8))
  2162. {
  2163. observ[4] = (double) PyInt_AsLong(o8);
  2164. }
  2165. #endif
  2166. else if (PyLong_Check(o8))
  2167. {
  2168. observ[4] = (double) PyLong_AsLong(o8);
  2169. }
  2170. else
  2171. {
  2172. PyErr_SetString(pyswe_Error, "Invalid telescope aperture");
  2173. Py_DECREF(o4); Py_DECREF(o5); Py_DECREF(o6); Py_DECREF(o7);
  2174. Py_DECREF(o8); Py_DECREF(o9);
  2175. return NULL;
  2176. }
  2177. /* optical transmission */
  2178. if (PyFloat_Check(o9))
  2179. {
  2180. observ[5] = PyFloat_AsDouble(o9);
  2181. }
  2182. #if PY_MAJOR_VERSION < 3
  2183. else if (PyInt_Check(o9))
  2184. {
  2185. observ[5] = (double) PyInt_AsLong(o9);
  2186. }
  2187. #endif
  2188. else if (PyLong_Check(o9))
  2189. {
  2190. observ[5] = (double) PyLong_AsLong(o9);
  2191. }
  2192. else
  2193. {
  2194. PyErr_SetString(pyswe_Error, "Invalid telescope aperture");
  2195. Py_DECREF(o4); Py_DECREF(o5); Py_DECREF(o6); Py_DECREF(o7);
  2196. Py_DECREF(o8); Py_DECREF(o9);
  2197. return NULL;
  2198. }
  2199. Py_DECREF(o4); Py_DECREF(o5); Py_DECREF(o6); Py_DECREF(o7);
  2200. Py_DECREF(o8); Py_DECREF(o9);
  2201. }
  2202. dres = swe_vis_limit_mag(jd, geopos, atmo, observ, obj, flg, &dret, serr);
  2203. if (dres != -1)
  2204. {
  2205. return Py_BuildValue("dd", dres, dret);
  2206. }
  2207. else
  2208. {
  2209. PyErr_SetString(pyswe_Error, serr);
  2210. return NULL;
  2211. }
  2212. }
  2213. #if PYSWE_USE_SWEPHELP
  2214. /* *** Specific pyswisseph functions. ***
  2215. All names begin with an underscore. They are not part of the original swisseph,
  2216. but provided here as helpers for the programmer.
  2217. There is no guarantee that these functions are accurate. Use at your own risks.
  2218. */
  2219. /* swisseph._jdnow */
  2220. static char pyswe__jdnow__doc__[] =
  2221. "Get current Julian day number (Gregorian calendar, UTC).\n\n"
  2222. "Args: -\n"
  2223. "Return: float";
  2224. static PyObject * pyswe__jdnow FUNCARGS_SELF
  2225. {
  2226. return Py_BuildValue("f", swh_jdnow());
  2227. }
  2228. /* swisseph._julday */
  2229. static char pyswe__julday__doc__[] =
  2230. "Get Julian day number (UTC), without having to calculate hour in decimal.\n\n"
  2231. "Args: int year, int month, int day, int hour=12, int minutes=0, int seconds=0,"
  2232. " int flag=GREG_FLAG\n"
  2233. "Return: float";
  2234. static PyObject * pyswe__julday FUNCARGS_KEYWDS
  2235. {
  2236. int year, mon, day, hour=12, min=0, sec=0, flag=SE_GREG_CAL;
  2237. static char *kwlist[] = {"year", "month", "day", "hour", "minutes",
  2238. "seconds", "flag", NULL};
  2239. if (!PyArg_ParseTupleAndKeywords(args, keywds, "iii|iiii", kwlist,
  2240. &year, &mon, &day, &hour, &min, &sec, &flag))
  2241. return NULL;
  2242. return Py_BuildValue("f", swh_julday(year, mon, day, hour,
  2243. min, sec, flag));
  2244. }
  2245. /* swisseph._revjul */
  2246. static char pyswe__revjul__doc__[] =
  2247. "Reverse Julian day to date & time (UTC).\n\n"
  2248. "Args: double julday, int flag=GREG_CAL\n"
  2249. "Return: tuple of 6 int";
  2250. static PyObject * pyswe__revjul FUNCARGS_KEYWDS
  2251. {
  2252. int dt[6], flag=SE_GREG_CAL;
  2253. double jd;
  2254. static char *kwlist[] = {"julday", "flag", NULL};
  2255. if (!PyArg_ParseTupleAndKeywords(args, keywds, "d|i", kwlist,
  2256. &jd, &flag))
  2257. return NULL;
  2258. swh_revjul(jd, flag, dt);
  2259. return Py_BuildValue("(iiiiii)", dt[0], dt[1], dt[2], dt[3], dt[4], dt[5]);
  2260. }
  2261. /* swisseph._degsplit */
  2262. static char pyswe__degsplit__doc__[] =
  2263. "Get degrees, sign number [0;11], minutes, seconds, from a longitude position in [0;360[.\n\n"
  2264. "Args: double pos\n"
  2265. "Return: tuple of 4 int (deg, sign, min, sec)";
  2266. static PyObject * pyswe__degsplit FUNCARGS_KEYWDS
  2267. {
  2268. int ret[6];
  2269. double pos;
  2270. static char *kwlist[] = {"pos", NULL};
  2271. if (!PyArg_ParseTupleAndKeywords(args, keywds, "d", kwlist, &pos))
  2272. return NULL;
  2273. swh_degsplit(pos, ret);
  2274. return Py_BuildValue("(iiii)", ret[0], ret[1], ret[2], ret[3]);
  2275. }
  2276. /* swisseph._signtostr */
  2277. static char pyswe__signtostr__doc__[] =
  2278. "Get a 3-letters string representing the sign number [0;11].\n\n"
  2279. "Args: int sign\n"
  2280. "Return: str";
  2281. static PyObject * pyswe__signtostr FUNCARGS_KEYWDS
  2282. {
  2283. int res, sign;
  2284. char str[4];
  2285. static char *kwlist[] = {"sign", NULL};
  2286. if (!PyArg_ParseTupleAndKeywords(args, keywds, "i", kwlist, &sign))
  2287. return NULL;
  2288. res = swh_signtostr(sign, str);
  2289. if (res < 0)
  2290. {
  2291. PyErr_SetString(pyswe_Error, "swisseph._signtostr: invalid sign number");
  2292. return NULL;
  2293. }
  2294. return Py_BuildValue("s", str);
  2295. }
  2296. /* swisseph._house_system_name */
  2297. static char pyswe__house_system_name__doc__[] =
  2298. "Get house system name.\n\n"
  2299. "Args: char hsys\n"
  2300. "Return: str";
  2301. static PyObject * pyswe__house_system_name FUNCARGS_KEYWDS
  2302. {
  2303. int res;
  2304. char hsys, str[25];
  2305. static char *kwlist[] = {"hsys", NULL};
  2306. if (!PyArg_ParseTupleAndKeywords(args, keywds, "c", kwlist, &hsys))
  2307. return NULL;
  2308. res = swh_house_system_name(hsys, str);
  2309. if (res < 0)
  2310. {
  2311. PyErr_SetString(pyswe_Error, "swisseph._house_system_name: invalid house system");
  2312. return NULL;
  2313. }
  2314. return Py_BuildValue("s", str);
  2315. }
  2316. /* swisseph._min_retro_time */
  2317. static char pyswe__min_retro_time__doc__[] =
  2318. "Get approximate minimum retrogradation time of a planet, in days.\n\n"
  2319. "Args: int planet\n"
  2320. "Return: int";
  2321. static PyObject * pyswe__min_retro_time FUNCARGS_KEYWDS
  2322. {
  2323. int plnt, res;
  2324. char err[64];
  2325. static char *kwlist[] = {"planet", NULL};
  2326. if (!PyArg_ParseTupleAndKeywords(args, keywds, "i", kwlist, &plnt))
  2327. return NULL;
  2328. res = swh_min_retro_time(plnt, err);
  2329. if (res < 0)
  2330. {
  2331. PyErr_SetString(pyswe_Error, err);
  2332. return NULL;
  2333. }
  2334. return Py_BuildValue("i", res);
  2335. }
  2336. /* swisseph._max_retro_time */
  2337. static char pyswe__max_retro_time__doc__[] =
  2338. "Get approximate maximum retrogradation time of a planet, in days.\n\n"
  2339. "Args: int planet\n"
  2340. "Return: int";
  2341. static PyObject * pyswe__max_retro_time FUNCARGS_KEYWDS
  2342. {
  2343. int plnt, res;
  2344. char err[64];
  2345. static char *kwlist[] = {"planet", NULL};
  2346. if (!PyArg_ParseTupleAndKeywords(args, keywds, "i", kwlist, &plnt))
  2347. return NULL;
  2348. res = swh_max_retro_time(plnt, err);
  2349. if (res < 0)
  2350. {
  2351. PyErr_SetString(pyswe_Error, err);
  2352. return NULL;
  2353. }
  2354. return Py_BuildValue("i", res);
  2355. }
  2356. /* swisseph._next_retro */
  2357. static char pyswe__next_retro__doc__[] =
  2358. "Find next direction changing of object.\n\n"
  2359. "If daystep=0, use predefined step.\n"
  2360. "Flag should include FLG_SPEED, and FLG_NOGDEFL to avoid bad surprises;"
  2361. " alternatively use true positions.\n"
  2362. "If dayspan != 0, can return None if limit has been reached.\n\n"
  2363. "Args: int planet, float jdstart, float daystep=0, bool backwards=False,"
  2364. " float dayspan=0, int flag=FLG_SWIEPH+FLG_SPEED+FLG_NOGDEFL\n"
  2365. "Return: 2 tuples Julian day, positions (or None if time limit has been reached)";
  2366. static PyObject * pyswe__next_retro FUNCARGS_KEYWDS
  2367. {
  2368. int res, plnt, backw=0, flag=SEFLG_SWIEPH+SEFLG_SPEED+SEFLG_NOGDEFL;
  2369. double jd, step=0.0, trange=0, jdret, posret[6];
  2370. char err[256];
  2371. static char *kwlist[] = {"planet", "jdstart", "daystep", "backwards",
  2372. "dayspan", "flag", NULL};
  2373. if (!PyArg_ParseTupleAndKeywords(args, keywds, "id|didi", kwlist,
  2374. &plnt, &jd, &step, &backw, &trange, &flag))
  2375. return NULL;
  2376. res = swh_next_retro(plnt, jd, step, backw, trange, flag,
  2377. &jdret, posret, err);
  2378. if (res < 0)
  2379. {
  2380. PyErr_SetString(pyswe_Error, err);
  2381. return NULL;
  2382. }
  2383. else if (res > 0) /* time limit reached */
  2384. {
  2385. return Py_BuildValue("(O)(OOOOOO)", Py_None, Py_None, Py_None, Py_None,
  2386. Py_None, Py_None, Py_None);
  2387. }
  2388. else
  2389. {
  2390. return Py_BuildValue("(f)(ffffff)", jdret, posret[0], posret[1],
  2391. posret[2], posret[3], posret[4], posret[5]);
  2392. }
  2393. }
  2394. /* swisseph._go_past */
  2395. static char pyswe__go_past__doc__[] =
  2396. "Get Julian day number and positions when a celestial object has gone past a"
  2397. " fixed point expressed in longitude degrees.\n\n"
  2398. "If daystep=0, use a predefined step.\n"
  2399. "Same warning as in swe._next_retro.\n\n"
  2400. "Args: int planet, float fixedpt, float jdstart, float daystep=0, bool backwards=False, int flag=FLG_SWIEPH+FLG_SPEED+FLG_NOGDEFL\n"
  2401. "Return: 2 tuples Julian day, positions";
  2402. static PyObject * pyswe__go_past FUNCARGS_KEYWDS
  2403. {
  2404. int plnt, backw=0, flag=SEFLG_SWIEPH+SEFLG_SPEED+SEFLG_NOGDEFL;
  2405. double fix, jd, step=0, res, jdret, posret[6];
  2406. char err[256];
  2407. static char *kwlist[] = {"planet", "fixedpt", "jdstart", "daystep",
  2408. "backwards", "flag", NULL};
  2409. if (!PyArg_ParseTupleAndKeywords(args, keywds, "idd|dii", kwlist,
  2410. &plnt, &fix, &jd, &step, &backw, &flag))
  2411. return NULL;
  2412. res = swh_go_past(plnt, fix, jd, step, backw, flag, &jdret, posret, err);
  2413. if (res < 0)
  2414. {
  2415. PyErr_SetString(pyswe_Error, err);
  2416. return NULL;
  2417. }
  2418. return Py_BuildValue("(f)(ffffff)", jdret, posret[0], posret[1], posret[2],
  2419. posret[3], posret[4], posret[5]);
  2420. }
  2421. /* swisseph._next_aspect */
  2422. static char pyswe__next_aspect__doc__[] =
  2423. "Get Julian day number and positions when celestial object makes longitudinal"
  2424. " aspect to a fixed point expressed in longitude degrees.\n\n"
  2425. "Aspect in the range [0;360[.\n"
  2426. "If daystep=0, use a predefined step.\n"
  2427. "If dayspan != 0, can return None if limit has been reached.\n\n"
  2428. "Args: int planet, float aspect, float fixedpt, float jdstart, float daystep=0,"
  2429. " bool backwards=False, float dayspan=0, int flag=FLG_SWIEPH+FLG_SPEED+FLG_NOGDEFL\n"
  2430. "Return: 2 tuples Julian day, positions (or None if limit has been reached)";
  2431. static PyObject * pyswe__next_aspect FUNCARGS_KEYWDS
  2432. {
  2433. int plnt, backw=0, flag=SEFLG_SWIEPH+SEFLG_SPEED+SEFLG_NOGDEFL;
  2434. double asp, fix, jd, step=0, trange=0, res, jdret, posret[6];
  2435. char err[256];
  2436. static char *kwlist[] = {"planet", "aspect", "fixedpt", "jdstart",
  2437. "daystep", "backwards", "dayspan", "flag", NULL};
  2438. if (!PyArg_ParseTupleAndKeywords(args, keywds, "iddd|didi", kwlist,
  2439. &plnt, &asp, &fix, &jd, &step, &backw, &trange, &flag))
  2440. return NULL;
  2441. res = swh_next_aspect(plnt, asp, fix, jd, step, backw, trange, flag,
  2442. &jdret, posret, err);
  2443. if (res < 0)
  2444. {
  2445. PyErr_SetString(pyswe_Error, err);
  2446. return NULL;
  2447. }
  2448. else if (res > 0) /* time limit reached */
  2449. {
  2450. return Py_BuildValue("(O)(OOOOOO)", Py_None, Py_None, Py_None, Py_None,
  2451. Py_None, Py_None, Py_None);
  2452. }
  2453. else
  2454. {
  2455. return Py_BuildValue("(f)(ffffff)", jdret, posret[0], posret[1],
  2456. posret[2], posret[3], posret[4], posret[5]);
  2457. }
  2458. }
  2459. /* swisseph._next_aspect2 */
  2460. static char pyswe__next_aspect2__doc__[] =
  2461. "Same as _next_aspect, but with aspect in range [0;180].\n\n"
  2462. "If aspect is not 0 or 180, it will try the two aspects in [0;360[, and return"
  2463. " the nearest from jdstart. It may then be faster to use _next_aspect several"
  2464. " times, especially when scanning long periods of time.\n\n"
  2465. "Args: int planet, float aspect, float fixedpt, float jdstart, float daystep=0,"
  2466. " bool backwards=False, float dayspan=0, int flag=FLG_SWIEPH+FLG_SPEED+FLG_NOGDEFL\n"
  2467. "Return: 2 tuples Julian day, positions (or None if limit has been reached)";
  2468. static PyObject * pyswe__next_aspect2 FUNCARGS_KEYWDS
  2469. {
  2470. int plnt, backw=0, flag=SEFLG_SWIEPH+SEFLG_SPEED+SEFLG_NOGDEFL;
  2471. double asp, fix, jd, step=0, trange=0, res, jdret, posret[6];
  2472. char err[256];
  2473. static char *kwlist[] = {"planet", "aspect", "fixedpt", "jdstart",
  2474. "daystep", "backwards", "dayspan", "flag", NULL};
  2475. if (!PyArg_ParseTupleAndKeywords(args, keywds, "iddd|didi", kwlist,
  2476. &plnt, &asp, &fix, &jd, &step, &backw, &trange, &flag))
  2477. return NULL;
  2478. res = swh_next_aspect2(plnt, asp, fix, jd, step, backw, trange, flag,
  2479. &jdret, posret, err);
  2480. if (res < 0)
  2481. {
  2482. PyErr_SetString(pyswe_Error, err);
  2483. return NULL;
  2484. }
  2485. else if (res > 0) /* time limit reached */
  2486. {
  2487. return Py_BuildValue("(O)(OOOOOO)", Py_None, Py_None, Py_None, Py_None,
  2488. Py_None, Py_None, Py_None);
  2489. }
  2490. else
  2491. {
  2492. return Py_BuildValue("(f)(ffffff)", jdret, posret[0], posret[1],
  2493. posret[2], posret[3], posret[4], posret[5]);
  2494. }
  2495. }
  2496. /* swisseph._next_aspect_with */
  2497. static char pyswe__next_aspect_with__doc__[] =
  2498. "Get Julian day number and positions when celestial object makes longitudinal"
  2499. " aspect to another moving object.\n\n"
  2500. "Aspect in the range [0;360[.\n"
  2501. "Other object can be a fixed star.\n"
  2502. "If dayspan != 0, can return None if limit has been reached.\n\n"
  2503. "Args: int planet, float aspect, int or str other, float jdstart,"
  2504. " float daystep=10, bool backwards=False, float dayspan=0, int flag=FLG_SWIEPH+FLG_SPEED\n"
  2505. "Return: 3 tuples Julian day, planet positions, other positions (or None if limit has been reached)";
  2506. static PyObject * pyswe__next_aspect_with FUNCARGS_KEYWDS
  2507. {
  2508. int res, plnt, other, backw=0, flag=SEFLG_SWIEPH+SEFLG_SPEED;
  2509. double asp, jd, step=10, trange=0, jdret, posret0[6], posret1[6];
  2510. char err[256], *star="";
  2511. PyObject *body;
  2512. static char *kwlist[] = {"planet", "aspect", "other", "jdstart",
  2513. "daystep", "backwards", "dayspan", "flag", NULL};
  2514. if (!PyArg_ParseTupleAndKeywords(args, keywds, "idOd|didi", kwlist,
  2515. &plnt, &asp, &body, &jd, &step, &backw, &trange, &flag))
  2516. return NULL;
  2517. if (PyLong_CheckExact(body)) /* long -> planet */
  2518. {
  2519. other = (int) PyLong_AsLong(body);
  2520. }
  2521. #if PY_MAJOR_VERSION >= 3
  2522. else if (PyUnicode_CheckExact(body)) /* unicode -> fixed star */
  2523. {
  2524. other = 0;
  2525. star = (char*) PyUnicode_AS_DATA(body);
  2526. }
  2527. #elif PY_MAJOR_VERSION < 3
  2528. else if (PyInt_CheckExact(body)) /* int -> planet */
  2529. {
  2530. other = (int) PyInt_AsLong(body);
  2531. }
  2532. else if (PyString_CheckExact(body)) /* str -> fixed star */
  2533. {
  2534. other = 0;
  2535. star = PyString_AsString(body);
  2536. }
  2537. #endif
  2538. else
  2539. {
  2540. PyErr_SetString(pyswe_Error,
  2541. "swisseph._next_aspect_with: Invalid body type");
  2542. return NULL;
  2543. }
  2544. res = swh_next_aspect_with(plnt, asp, other, star, jd, step, backw, trange,
  2545. flag, &jdret, posret0, posret1, err);
  2546. if (res < 0)
  2547. {
  2548. PyErr_SetString(pyswe_Error, err);
  2549. return NULL;
  2550. }
  2551. else if (res > 0) /* time limit reached */
  2552. {
  2553. return Py_BuildValue("(O)(OOOOOO)(OOOOOO)", Py_None, Py_None, Py_None,
  2554. Py_None, Py_None, Py_None, Py_None, Py_None, Py_None, Py_None, Py_None,
  2555. Py_None, Py_None);
  2556. }
  2557. else
  2558. {
  2559. return Py_BuildValue("(f)(ffffff)(ffffff)", jdret, posret0[0],
  2560. posret0[1], posret0[2], posret0[3], posret0[4], posret0[5], posret1[0],
  2561. posret1[1], posret1[2], posret1[3], posret1[4], posret1[5]);
  2562. }
  2563. }
  2564. /* swisseph._next_aspect_with2 */
  2565. static char pyswe__next_aspect_with2__doc__[] =
  2566. "Same as _next_aspect_with, but aspect in range [0;180].\n\n"
  2567. "If aspect is not 0 or 180, it will try the two aspects in [0;360[, and return"
  2568. " the nearest from jdstart. It may then be faster to use _next_aspect_with"
  2569. " several times, especially when scanning long periods of time.\n\n"
  2570. "Args: int planet, float aspect, int or str other, float jdstart,"
  2571. " float daystep=10, bool backwards=False, float dayspan=0, int flag=FLG_SWIEPH+FLG_SPEED\n"
  2572. "Return: 3 tuples Julian day, planet positions, other positions (or None if limit has been reached)";
  2573. static PyObject * pyswe__next_aspect_with2 FUNCARGS_KEYWDS
  2574. {
  2575. int res, plnt, other, backw=0, flag=SEFLG_SWIEPH+SEFLG_SPEED;
  2576. double asp, jd, step=10, trange=0, jdret, posret0[6], posret1[6];
  2577. char err[256], *star="";
  2578. PyObject *body;
  2579. static char *kwlist[] = {"planet", "aspect", "other", "jdstart",
  2580. "daystep", "backwards", "dayspan", "flag", NULL};
  2581. if (!PyArg_ParseTupleAndKeywords(args, keywds, "idOd|didi", kwlist,
  2582. &plnt, &asp, &body, &jd, &step, &backw, &trange, &flag))
  2583. return NULL;
  2584. if (PyLong_CheckExact(body)) /* long -> planet */
  2585. {
  2586. other = (int) PyLong_AsLong(body);
  2587. }
  2588. #if PY_MAJOR_VERSION >= 3
  2589. else if (PyUnicode_CheckExact(body)) /* unicode -> fixed star */
  2590. {
  2591. other = 0;
  2592. star = (char*) PyUnicode_AS_DATA(body);
  2593. }
  2594. #elif PY_MAJOR_VERSION < 3
  2595. else if (PyInt_CheckExact(body)) /* int -> planet */
  2596. {
  2597. other = (int) PyInt_AsLong(body);
  2598. }
  2599. else if (PyString_CheckExact(body)) /* str -> fixed star */
  2600. {
  2601. other = 0;
  2602. star = PyString_AsString(body);
  2603. }
  2604. #endif
  2605. else
  2606. {
  2607. PyErr_SetString(pyswe_Error,
  2608. "swisseph._next_aspect_with2: Invalid body type");
  2609. return NULL;
  2610. }
  2611. res = swh_next_aspect_with2(plnt, asp, other, star, jd, step, backw, trange,
  2612. flag, &jdret, posret0, posret1, err);
  2613. if (res < 0)
  2614. {
  2615. PyErr_SetString(pyswe_Error, err);
  2616. return NULL;
  2617. }
  2618. else if (res > 0) /* time limit reached */
  2619. {
  2620. return Py_BuildValue("(O)(OOOOOO)(OOOOOO)", Py_None, Py_None, Py_None,
  2621. Py_None, Py_None, Py_None, Py_None, Py_None, Py_None, Py_None, Py_None,
  2622. Py_None, Py_None);
  2623. }
  2624. else
  2625. {
  2626. return Py_BuildValue("(f)(ffffff)(ffffff)", jdret, posret0[0],
  2627. posret0[1], posret0[2], posret0[3], posret0[4], posret0[5], posret1[0],
  2628. posret1[1], posret1[2], posret1[3], posret1[4], posret1[5]);
  2629. }
  2630. }
  2631. /* swisseph._next_aspect_cusp */
  2632. static char pyswe__next_aspect_cusp__doc__[] =
  2633. "Get Julian day number and positions, and houses cusps and ascmc, when celestial"
  2634. " object makes longitudinal aspect to a house cusp.\n\n"
  2635. "House cusp expressed as an integer in [1;12] or [1;36] for Gauquelin.\n"
  2636. "Aspect in the range [0;360[.\n"
  2637. "Body can be a fixed star.\n"
  2638. "For risings, settings, meridian transits, see rise_trans.\n\n"
  2639. "Args: int or str body, float aspect, int cusp, double jdstart, double lat,"
  2640. " double lon, char hsys='P', bool backwards=False, int flag=FLG_SWIEPH+FLG_SPEED\n"
  2641. "Return: 4 tuples Julian day, body positions, cusps, ascmc";
  2642. static PyObject * pyswe__next_aspect_cusp FUNCARGS_KEYWDS
  2643. {
  2644. int res, plnt, cusp, hsys='P', backw=0, flag=SEFLG_SWIEPH+SEFLG_SPEED;
  2645. double asp, jd, lat, lon, step=0.2, jdret, posret[6], cusps[37], ascmc[10];
  2646. char err[256], *star="";
  2647. PyObject *body;
  2648. static char *kwlist[] = {"body", "aspect", "cusp", "jdstart", "lat", "lon",
  2649. "hsys", "backwards", "flag", NULL};
  2650. if (!PyArg_ParseTupleAndKeywords(args, keywds, "Odiddd|cii", kwlist,
  2651. &body, &asp, &cusp, &jd, &lat, &lon, &hsys, &backw, &flag))
  2652. return NULL;
  2653. if (PyLong_CheckExact(body)) /* long -> planet */
  2654. {
  2655. plnt = (int) PyLong_AsLong(body);
  2656. }
  2657. #if PY_MAJOR_VERSION >= 3
  2658. else if (PyUnicode_CheckExact(body)) /* unicode -> fixed star */
  2659. {
  2660. plnt = 0;
  2661. star = (char*) PyUnicode_AS_DATA(body);
  2662. }
  2663. #elif PY_MAJOR_VERSION < 3
  2664. else if (PyInt_CheckExact(body)) /* int -> planet */
  2665. {
  2666. plnt = (int) PyInt_AsLong(body);
  2667. }
  2668. else if (PyString_CheckExact(body)) /* str -> fixed star */
  2669. {
  2670. plnt = 0;
  2671. star = PyString_AsString(body);
  2672. }
  2673. #endif
  2674. else
  2675. {
  2676. PyErr_SetString(pyswe_Error,
  2677. "swisseph._next_aspect_cusp: Invalid body type");
  2678. return NULL;
  2679. }
  2680. res = swh_next_aspect_cusp(plnt, star, asp, cusp, jd, lat, lon, hsys, step,
  2681. backw, flag, &jdret, posret, cusps, ascmc, err);
  2682. if (res < 0)
  2683. {
  2684. PyErr_SetString(pyswe_Error, err);
  2685. return NULL;
  2686. }
  2687. if (hsys == 71) /* Gauquelin sectors */
  2688. {
  2689. return Py_BuildValue("(f)(ffffff)(ffffffffffffffffffffffffffffffffffff)(ffffffff)",
  2690. jdret,
  2691. posret[0], posret[1], posret[2], posret[3], posret[4], posret[5],
  2692. cusps[1], cusps[2], cusps[3], cusps[4], cusps[5], cusps[6], cusps[7],
  2693. cusps[8], cusps[9], cusps[10], cusps[11], cusps[12], cusps[13],
  2694. cusps[14], cusps[15], cusps[16], cusps[17], cusps[18], cusps[19],
  2695. cusps[20], cusps[21], cusps[22], cusps[23], cusps[24], cusps[25],
  2696. cusps[26], cusps[27], cusps[28], cusps[29], cusps[30], cusps[31],
  2697. cusps[32], cusps[33], cusps[34], cusps[35], cusps[36],
  2698. ascmc[0], ascmc[1], ascmc[2], ascmc[3], ascmc[4], ascmc[5], ascmc[6],
  2699. ascmc[7]);
  2700. }
  2701. else
  2702. {
  2703. return Py_BuildValue("(f)(ffffff)(ffffffffffff)(ffffffff)", jdret,
  2704. posret[0], posret[1], posret[2], posret[3], posret[4], posret[5],
  2705. cusps[1], cusps[2], cusps[3], cusps[4], cusps[5], cusps[6], cusps[7],
  2706. cusps[8], cusps[9], cusps[10], cusps[11], cusps[12],
  2707. ascmc[0], ascmc[1], ascmc[2], ascmc[3], ascmc[4], ascmc[5], ascmc[6],
  2708. ascmc[7]);
  2709. }
  2710. }
  2711. /* swisseph._next_aspect_cusp2 */
  2712. static char pyswe__next_aspect_cusp2__doc__[] =
  2713. "Same as _next_aspect_cusp, but aspect in range[0;180].\n\n"
  2714. "If aspect is not 0 or 180, it will try the two aspects in [0;360[, and return"
  2715. " the nearest from jdstart. It may then be faster to use _next_aspect_cusp"
  2716. " several times, especially when scanning long periods of time.\n\n"
  2717. "Args: int or str body, float aspect, int cusp, double jdstart, double lat,"
  2718. " double lon, char hsys='P', bool backwards=False, int flag=FLG_SWIEPH+FLG_SPEED\n"
  2719. "Return: 4 tuples Julian day, body positions, cusps, ascmc";
  2720. static PyObject * pyswe__next_aspect_cusp2 FUNCARGS_KEYWDS
  2721. {
  2722. int res, plnt, cusp, hsys='P', backw=0, flag=SEFLG_SWIEPH+SEFLG_SPEED;
  2723. double asp, jd, lat, lon, step=0.2, jdret, posret[6], cusps[37], ascmc[10];
  2724. char err[256], *star="";
  2725. PyObject *body;
  2726. static char *kwlist[] = {"body", "aspect", "cusp", "jdstart", "lat", "lon",
  2727. "hsys", "backwards", "flag", NULL};
  2728. if (!PyArg_ParseTupleAndKeywords(args, keywds, "Odiddd|cii", kwlist,
  2729. &body, &asp, &cusp, &jd, &lat, &lon, &hsys, &backw, &flag))
  2730. return NULL;
  2731. if (PyLong_CheckExact(body)) /* long -> planet */
  2732. {
  2733. plnt = (int) PyLong_AsLong(body);
  2734. }
  2735. #if PY_MAJOR_VERSION >= 3
  2736. else if (PyUnicode_CheckExact(body)) /* unicode -> fixed star */
  2737. {
  2738. plnt = 0;
  2739. star = (char*) PyUnicode_AS_DATA(body);
  2740. }
  2741. #elif PY_MAJOR_VERSION < 3
  2742. else if (PyInt_CheckExact(body)) /* int -> planet */
  2743. {
  2744. plnt = (int) PyInt_AsLong(body);
  2745. }
  2746. else if (PyString_CheckExact(body)) /* str -> fixed star */
  2747. {
  2748. plnt = 0;
  2749. star = PyString_AsString(body);
  2750. }
  2751. #endif
  2752. else
  2753. {
  2754. PyErr_SetString(pyswe_Error,
  2755. "swisseph._next_aspect_cusp2: Invalid body type");
  2756. return NULL;
  2757. }
  2758. res = swh_next_aspect_cusp2(plnt, star, asp, cusp, jd, lat, lon, hsys, step,
  2759. backw, flag, &jdret, posret, cusps, ascmc, err);
  2760. if (res < 0)
  2761. {
  2762. PyErr_SetString(pyswe_Error, err);
  2763. return NULL;
  2764. }
  2765. if (hsys == 71) /* Gauquelin sectors */
  2766. {
  2767. return Py_BuildValue("(f)(ffffff)(ffffffffffffffffffffffffffffffffffff)(ffffffff)",
  2768. jdret,
  2769. posret[0], posret[1], posret[2], posret[3], posret[4], posret[5],
  2770. cusps[1], cusps[2], cusps[3], cusps[4], cusps[5], cusps[6], cusps[7],
  2771. cusps[8], cusps[9], cusps[10], cusps[11], cusps[12], cusps[13],
  2772. cusps[14], cusps[15], cusps[16], cusps[17], cusps[18], cusps[19],
  2773. cusps[20], cusps[21], cusps[22], cusps[23], cusps[24], cusps[25],
  2774. cusps[26], cusps[27], cusps[28], cusps[29], cusps[30], cusps[31],
  2775. cusps[32], cusps[33], cusps[34], cusps[35], cusps[36],
  2776. ascmc[0], ascmc[1], ascmc[2], ascmc[3], ascmc[4], ascmc[5], ascmc[6],
  2777. ascmc[7]);
  2778. }
  2779. else
  2780. {
  2781. return Py_BuildValue("(f)(ffffff)(ffffffffffff)(ffffffff)", jdret,
  2782. posret[0], posret[1], posret[2], posret[3], posret[4], posret[5],
  2783. cusps[1], cusps[2], cusps[3], cusps[4], cusps[5], cusps[6], cusps[7],
  2784. cusps[8], cusps[9], cusps[10], cusps[11], cusps[12],
  2785. ascmc[0], ascmc[1], ascmc[2], ascmc[3], ascmc[4], ascmc[5], ascmc[6],
  2786. ascmc[7]);
  2787. }
  2788. }
  2789. /* swisseph._match_aspect */
  2790. static char pyswe__match_aspect__doc__[] =
  2791. "Check if the two given positions match the aspect within the given orb.\n\n"
  2792. "If so return a tuple with difference, a value for application (True),"
  2793. " separation (False) or equal speeds (None), and an aspect strength factor;"
  2794. " else return three None.\n"
  2795. "Aspect in range [0;360[.\n\n"
  2796. "Args: float pos1, float speed1, float pos2, float speed2, float aspect,"
  2797. " float orb\nReturn: tuple (difference, application, factor)";
  2798. static PyObject * pyswe__match_aspect FUNCARGS_KEYWDS
  2799. {
  2800. int applic;
  2801. double res, pos0, pos1, sp0, sp1, asp, orb, ret, ftor;
  2802. static char *kwlist[] = {"pos1", "speed1", "pos2", "speed2", "aspect",
  2803. "orb", NULL};
  2804. if (!PyArg_ParseTupleAndKeywords(args, keywds, "dddddd", kwlist,
  2805. &pos0, &sp0, &pos1, &sp1, &asp, &orb))
  2806. return NULL;
  2807. res = swh_match_aspect(pos0, sp0, pos1, sp1, asp, orb, &ret, &applic, &ftor);
  2808. if (res < 0)
  2809. return Py_BuildValue("(OOO)", Py_None, Py_None, Py_None);
  2810. else if (applic == 1)
  2811. return Py_BuildValue("(fOf)", ret, Py_False, ftor);
  2812. else if (applic == -1)
  2813. return Py_BuildValue("(fOf)", ret, Py_True, ftor);
  2814. else
  2815. return Py_BuildValue("(fOf)", ret, Py_None, ftor);
  2816. }
  2817. /* swisseph._match_aspect2 */
  2818. static char pyswe__match_aspect2__doc__[] =
  2819. "Same as _match_aspect, but with aspect in range [0;180].\n\n"
  2820. "Args: float pos1, float speed1, float pos2, float speed2, float aspect, float orb\n"
  2821. "Return: tuple (difference, application, factor)";
  2822. static PyObject * pyswe__match_aspect2 FUNCARGS_KEYWDS
  2823. {
  2824. int applic;
  2825. double res, pos0, pos1, sp0, sp1, asp, orb, ret, ftor;
  2826. static char *kwlist[] = {"pos1", "speed1", "pos2", "speed2", "aspect",
  2827. "orb", NULL};
  2828. if (!PyArg_ParseTupleAndKeywords(args, keywds, "dddddd", kwlist,
  2829. &pos0, &sp0, &pos1, &sp1, &asp, &orb))
  2830. return NULL;
  2831. res = swh_match_aspect2(pos0, sp0, pos1, sp1, asp, orb, &ret, &applic, &ftor);
  2832. if (res < 0)
  2833. return Py_BuildValue("(OOO)", Py_None, Py_None, Py_None);
  2834. else if (applic == 1)
  2835. return Py_BuildValue("(fOf)", ret, Py_False, ftor);
  2836. else if (applic == -1)
  2837. return Py_BuildValue("(fOf)", ret, Py_True, ftor);
  2838. else
  2839. return Py_BuildValue("(fOf)", ret, Py_None, ftor);
  2840. }
  2841. /* swisseph._match_aspect3 */
  2842. static char pyswe__match_aspect3__doc__[] =
  2843. "Same as _match_aspect, but with specific orbs for applying/separating/stable aspects.\n\n"
  2844. "Args: float pos1, float speed1, float pos2, float speed2, float aspect, "
  2845. "float app_orb, float sep_orb, float sta_orb\n"
  2846. "Return: tuple (delta, applying, factor)";
  2847. static PyObject * pyswe__match_aspect3 FUNCARGS_KEYWDS
  2848. {
  2849. int applic;
  2850. double res, pos0, pos1, sp0, sp1, asp, app_orb, sep_orb, sta_orb, ret, ftor;
  2851. static char *kwlist[] = {"pos1", "speed1", "pos2", "speed2", "aspect",
  2852. "app_orb", "sep_orb", "sta_orb", NULL};
  2853. if (!PyArg_ParseTupleAndKeywords(args, keywds, "dddddddd", kwlist,
  2854. &pos0, &sp0, &pos1, &sp1, &asp, &app_orb, &sep_orb, &sta_orb))
  2855. return NULL;
  2856. res = swh_match_aspect3(pos0, sp0, pos1, sp1, asp, app_orb, sep_orb, sta_orb,
  2857. &ret, &applic, &ftor);
  2858. if (res < 0)
  2859. return Py_BuildValue("(OOO)", Py_None, Py_None, Py_None);
  2860. else if (applic == 1)
  2861. return Py_BuildValue("(fOf)", ret, Py_False, ftor);
  2862. else if (applic == -1)
  2863. return Py_BuildValue("(fOf)", ret, Py_True, ftor);
  2864. else
  2865. return Py_BuildValue("(fOf)", ret, Py_None, ftor);
  2866. }
  2867. /* swisseph._match_aspect4 */
  2868. static char pyswe__match_aspect4__doc__[] =
  2869. "Same as _match_aspect2, but with specific orbs for applying/separating/stable aspects.\n\n"
  2870. "Args: float pos1, float speed1, float pos2, float speed2, float aspect, "
  2871. "float app_orb, float sep_orb, float sta_orb\n"
  2872. "Return: tuple (delta, applying, factor)";
  2873. static PyObject * pyswe__match_aspect4 FUNCARGS_KEYWDS
  2874. {
  2875. int applic;
  2876. double res, pos0, pos1, sp0, sp1, asp, app_orb, sep_orb, sta_orb, ret, ftor;
  2877. static char *kwlist[] = {"pos1", "speed1", "pos2", "speed2", "aspect",
  2878. "app_orb", "sep_orb", "sta_orb", NULL};
  2879. if (!PyArg_ParseTupleAndKeywords(args, keywds, "dddddddd", kwlist,
  2880. &pos0, &sp0, &pos1, &sp1, &asp, &app_orb, &sep_orb, &sta_orb))
  2881. return NULL;
  2882. res = swh_match_aspect4(pos0, sp0, pos1, sp1, asp, app_orb, sep_orb, sta_orb,
  2883. &ret, &applic, &ftor);
  2884. if (res < 0)
  2885. return Py_BuildValue("(OOO)", Py_None, Py_None, Py_None);
  2886. else if (applic == 1)
  2887. return Py_BuildValue("(fOf)", ret, Py_False, ftor);
  2888. else if (applic == -1)
  2889. return Py_BuildValue("(fOf)", ret, Py_True, ftor);
  2890. else
  2891. return Py_BuildValue("(fOf)", ret, Py_None, ftor);
  2892. }
  2893. /* swisseph._years_diff */
  2894. static char pyswe__years_diff__doc__[] =
  2895. "Get number of 'astrological' years between two Julian days.\n\n"
  2896. "Args: float jd1, float jd2, int flag=FLG_SWIEPH\n"
  2897. "Return: float";
  2898. static PyObject * pyswe__years_diff FUNCARGS_KEYWDS
  2899. {
  2900. double jd1, jd2, years;
  2901. int flag = SEFLG_SWIEPH, res;
  2902. char err[256];
  2903. static char *kwlist[] = {"jd1", "jd2", "flag", NULL};
  2904. if (!PyArg_ParseTupleAndKeywords(args, keywds, "dd|i", kwlist,
  2905. &jd1, &jd2, &flag))
  2906. return NULL;
  2907. res = swh_years_diff(jd1, jd2, flag, &years, err);
  2908. if (res < 0)
  2909. {
  2910. PyErr_SetString(pyswe_Error, err);
  2911. return NULL;
  2912. }
  2913. return Py_BuildValue("f", years);
  2914. }
  2915. /* swisseph._geoc2d */
  2916. static char pyswe__geoc2d__doc__[] =
  2917. "Get float from given string meant as a geographical coordinates, examples:"
  2918. " \"022:W:25\", \"46:N:02:0\", \"6:E:55:00\".\n\n"
  2919. "Args: str coord\n"
  2920. "Return: float";
  2921. static PyObject * pyswe__geoc2d FUNCARGS_KEYWDS
  2922. {
  2923. int res;
  2924. double ret;
  2925. char *coord;
  2926. static char *kwlist[] = {"coord", NULL};
  2927. if (!PyArg_ParseTupleAndKeywords(args, keywds, "s", kwlist, &coord))
  2928. return NULL;
  2929. res = swh_geoc2d(coord, &ret);
  2930. if (res == -1)
  2931. {
  2932. PyErr_SetString(pyswe_Error, "swisseph._geoc2d: Invalid coord string");
  2933. return NULL;
  2934. }
  2935. return Py_BuildValue("f", ret);
  2936. }
  2937. /* swisseph._geolat2c */
  2938. static char pyswe__geolat2c__doc__[] =
  2939. "Get formated string of given geographical latitude.\n\n"
  2940. "Args: float lat\n"
  2941. "Return: str";
  2942. static PyObject * pyswe__geolat2c FUNCARGS_KEYWDS
  2943. {
  2944. int res;
  2945. double lat;
  2946. char ret[11];
  2947. static char *kwlist[] = {"lat", NULL};
  2948. if (!PyArg_ParseTupleAndKeywords(args, keywds, "d", kwlist, &lat))
  2949. return NULL;
  2950. res = swh_geolat2c(lat, ret);
  2951. if (res == -1)
  2952. {
  2953. PyErr_SetString(pyswe_Error, "swisseph._geolat2c: Invalid latitude");
  2954. return NULL;
  2955. }
  2956. return Py_BuildValue("s", ret);
  2957. }
  2958. /* swisseph._geolon2c */
  2959. static char pyswe__geolon2c__doc__[] =
  2960. "Get formated string of given geographical longitude.\n\n"
  2961. "Args: float lon\n"
  2962. "Return: str";
  2963. static PyObject * pyswe__geolon2c FUNCARGS_KEYWDS
  2964. {
  2965. int res;
  2966. double lon;
  2967. char ret[12];
  2968. static char *kwlist[] = {"lon", NULL};
  2969. if (!PyArg_ParseTupleAndKeywords(args, keywds, "d", kwlist, &lon))
  2970. return NULL;
  2971. res = swh_geolon2c(lon, ret);
  2972. if (res == -1)
  2973. {
  2974. PyErr_SetString(pyswe_Error, "swisseph._geolon2c: Invalid longitude");
  2975. return NULL;
  2976. }
  2977. return Py_BuildValue("s", ret);
  2978. }
  2979. /* swisseph._raman_houses */
  2980. static char pyswe__raman_houses__doc__[] =
  2981. "Get Raman houses cusps (bhavamadhya the default, or arambhasandhi).\n\n"
  2982. "Args: float asc, float mc, bool sandhi=False\n"
  2983. "Return: tuple of 12 float";
  2984. static PyObject * pyswe__raman_houses FUNCARGS_KEYWDS
  2985. {
  2986. int sdi = 0;
  2987. double asc, mc, ret[12];
  2988. static char *kwlist[] = {"asc", "mc", "sandhi", NULL};
  2989. if (!PyArg_ParseTupleAndKeywords(args, keywds, "dd|b", kwlist, &asc, &mc, &sdi))
  2990. return NULL;
  2991. swh_raman_houses(asc, mc, ret, sdi);
  2992. return Py_BuildValue("ffffffffffff", ret[0],ret[1],ret[2],ret[3],ret[4],
  2993. ret[5],ret[6],ret[7],ret[8],ret[9],ret[10],ret[11]);
  2994. }
  2995. /* swisseph._lord */
  2996. static char pyswe__lord__doc__[] =
  2997. "Get sign lord.\n\n"
  2998. "Args: int sign [0:11]\n"
  2999. "Return: int planet number";
  3000. static PyObject * pyswe__lord FUNCARGS_KEYWDS
  3001. {
  3002. int sign, i;
  3003. static char *kwlist[] = {"sign", NULL};
  3004. if (!PyArg_ParseTupleAndKeywords(args, keywds, "i", kwlist, &sign))
  3005. return NULL;
  3006. i = swh_lord(sign);
  3007. if (i == -1)
  3008. {
  3009. PyErr_SetString(pyswe_Error, "swisseph._lord: Invalid sign number");
  3010. return NULL;
  3011. }
  3012. return Py_BuildValue("i", i);
  3013. }
  3014. /* swisseph._long2rasi */
  3015. static char pyswe__long2rasi__doc__[] =
  3016. "Get rasi number from ecliptical longitude.\n\n"
  3017. "Args: float lon\n"
  3018. "Return: int";
  3019. static PyObject * pyswe__long2rasi FUNCARGS_KEYWDS
  3020. {
  3021. double lon;
  3022. static char *kwlist[] = {"lon", NULL};
  3023. if (!PyArg_ParseTupleAndKeywords(args, keywds, "d", kwlist, &lon))
  3024. return NULL;
  3025. return Py_BuildValue("i", swh_long2rasi(lon));
  3026. }
  3027. /* swisseph._long2navamsa */
  3028. static char pyswe__long2navamsa__doc__[] =
  3029. "Get navamsa from ecliptical longitude.\n\n"
  3030. "Args: float lon\n"
  3031. "Return: int";
  3032. static PyObject * pyswe__long2navamsa FUNCARGS_KEYWDS
  3033. {
  3034. double lon;
  3035. static char *kwlist[] = {"lon", NULL};
  3036. if (!PyArg_ParseTupleAndKeywords(args, keywds, "d", kwlist, &lon))
  3037. return NULL;
  3038. return Py_BuildValue("i", swh_long2navamsa(lon));
  3039. }
  3040. /* swisseph._long2nakshatra */
  3041. static char pyswe__long2nakshatra__doc__[] =
  3042. "Get nakshatra and pada from ecliptical longitude.\n\n"
  3043. "Args: float lon\n"
  3044. "Return: 2 int";
  3045. static PyObject * pyswe__long2nakshatra FUNCARGS_KEYWDS
  3046. {
  3047. int ret[2];
  3048. double lon;
  3049. static char *kwlist[] = {"lon", NULL};
  3050. if (!PyArg_ParseTupleAndKeywords(args, keywds, "d", kwlist, &lon))
  3051. return NULL;
  3052. swh_long2nakshatra(lon, ret);
  3053. return Py_BuildValue("ii", ret[0], ret[1]);
  3054. }
  3055. /* swisseph._get_nakshatra_name */
  3056. static char pyswe__get_nakshatra_name__doc__[] =
  3057. "Get nakshatra name from nakshatra number [0:26].\n\n"
  3058. "Args: int nakshatra\n"
  3059. "Return: str";
  3060. static PyObject * pyswe__get_nakshatra_name FUNCARGS_KEYWDS
  3061. {
  3062. char ret[15];
  3063. int nak;
  3064. static char *kwlist[] = {"nakshatra", NULL};
  3065. if (!PyArg_ParseTupleAndKeywords(args, keywds, "i", kwlist, &nak))
  3066. return NULL;
  3067. if (swh_get_nakshatra_name(nak, ret) == -1)
  3068. {
  3069. PyErr_SetString(pyswe_Error, "swisseph._get_nakshatra_name: Invalid nakshatra number");
  3070. return NULL;
  3071. }
  3072. return Py_BuildValue("s", ret);
  3073. }
  3074. /* swisseph._rasinorm */
  3075. static char pyswe__rasinorm__doc__[] =
  3076. "Get a normalized rasi number between 0 and 11.\n\n"
  3077. "Args: int rasi\n"
  3078. "Return: int";
  3079. static PyObject * pyswe__rasinorm FUNCARGS_KEYWDS
  3080. {
  3081. int rasi;
  3082. static char *kwlist[] = {"rasi", NULL};
  3083. if (!PyArg_ParseTupleAndKeywords(args, keywds, "i", kwlist, &rasi))
  3084. return NULL;
  3085. return Py_BuildValue("i", swh_rasinorm(rasi));
  3086. }
  3087. /* swisseph._rasi_dif */
  3088. static char pyswe__rasi_dif__doc__[] =
  3089. "Get number of rasi between two rasis, from 0 to 11.\n\n"
  3090. "Args: int r1, int r2\n"
  3091. "Return: int";
  3092. static PyObject * pyswe__rasi_dif FUNCARGS_KEYWDS
  3093. {
  3094. int r1, r2;
  3095. static char *kwlist[] = {"r1", "r2", NULL};
  3096. if (!PyArg_ParseTupleAndKeywords(args, keywds, "ii", kwlist, &r1, &r2))
  3097. return NULL;
  3098. return Py_BuildValue("i", swh_rasi_dif(r1, r2));
  3099. }
  3100. /* swisseph._rasi_dif2 */
  3101. static char pyswe__rasi_dif2__doc__[] =
  3102. "Get number of rasi between two rasis, from -5 to 6.\n\n"
  3103. "Args: int r1, int r2\n"
  3104. "Return: int";
  3105. static PyObject * pyswe__rasi_dif2 FUNCARGS_KEYWDS
  3106. {
  3107. int r1, r2;
  3108. static char *kwlist[] = {"r1", "r2", NULL};
  3109. if (!PyArg_ParseTupleAndKeywords(args, keywds, "ii", kwlist, &r1, &r2))
  3110. return NULL;
  3111. return Py_BuildValue("i", swh_rasi_dif2(r1, r2));
  3112. }
  3113. /* swisseph._tatkalika_relation */
  3114. static char pyswe__tatkalika_relation__doc__[] =
  3115. "Get the tatkalika relation between two planets, given their rasi numbers.\n\n"
  3116. "Args: int r1, int r2\n"
  3117. "Return: int 1 (Mitra) or -1 (Satru)";
  3118. static PyObject * pyswe__tatkalika_relation FUNCARGS_KEYWDS
  3119. {
  3120. int r1, r2;
  3121. static char *kwlist[] = {"r1", "r2", NULL};
  3122. if (!PyArg_ParseTupleAndKeywords(args, keywds, "ii", kwlist, &r1, &r2))
  3123. return NULL;
  3124. return Py_BuildValue("i", swh_tatkalika_relation(r1, r2));
  3125. }
  3126. /* swisseph._naisargika_relation */
  3127. static char pyswe__naisargika_relation__doc__[] =
  3128. "Get the naisargika relation between two planets.\n\n"
  3129. "Args: int gr1, int gr2\n"
  3130. "Return: int 1 (Mitra) 0 (Sama) or -1 (Satru)";
  3131. static PyObject * pyswe__naisargika_relation FUNCARGS_KEYWDS
  3132. {
  3133. int gr1, gr2, i, ret;
  3134. static char *kwlist[] = {"gr1", "gr2", NULL};
  3135. if (!PyArg_ParseTupleAndKeywords(args, keywds, "ii", kwlist, &gr1, &gr2))
  3136. return NULL;
  3137. i = swh_naisargika_relation(gr1, gr2, &ret);
  3138. if (i == -1)
  3139. {
  3140. PyErr_SetString(pyswe_Error, "swisseph._naisargika_relation: Invalid planet");
  3141. return NULL;
  3142. }
  3143. return Py_BuildValue("i", ret);
  3144. }
  3145. /* swisseph._residential_strength */
  3146. static char pyswe__residential_strength__doc__[] =
  3147. "Get the residential strength for a planet, given its longitude and bhavamadhya"
  3148. " longitudes in a 12 items sequence.\n\n"
  3149. "Args: int plon, seq bhavas\n"
  3150. "Return: float strength";
  3151. static PyObject * pyswe__residential_strength FUNCARGS_KEYWDS
  3152. {
  3153. int i;
  3154. double bh[12], ret, plon;
  3155. PyObject *seq, *p;
  3156. static char *kwlist[] = {"plon", "bhavas", NULL};
  3157. if (!PyArg_ParseTupleAndKeywords(args, keywds, "dO", kwlist, &plon, &seq))
  3158. return NULL;
  3159. if ((PySequence_Check(seq) != 1) || (PySequence_Length(seq) < 12))
  3160. {
  3161. PyErr_SetString(pyswe_Error, "swisseph._residential_strength: Invalid bhavas");
  3162. return NULL;
  3163. }
  3164. for (i = 0; i < 12; ++i) /* check sequence has 12 numbers */
  3165. {
  3166. p = PySequence_GetItem(seq, i);
  3167. if (PyFloat_CheckExact(p))
  3168. {
  3169. bh[i] = PyFloat_AS_DOUBLE(p);
  3170. }
  3171. else if (PyLong_CheckExact(p))
  3172. {
  3173. bh[i] = PyLong_AsDouble(p);
  3174. }
  3175. #if PY_MAJOR_VERSION < 3
  3176. else if (PyInt_CheckExact(p))
  3177. {
  3178. bh[i] = PyInt_AS_LONG(p);
  3179. }
  3180. #endif
  3181. else
  3182. {
  3183. PyErr_SetString(pyswe_Error, "swisseph._residential_strength: Invalid bhavas type");
  3184. return NULL;
  3185. }
  3186. }
  3187. i = swh_residential_strength(plon, bh, &ret);
  3188. if (i == -1) /* should not happen... */
  3189. {
  3190. PyErr_SetString(pyswe_Error, "swisseph._residential_strength: Invalid error");
  3191. return NULL;
  3192. }
  3193. return Py_BuildValue("f", ret);
  3194. }
  3195. /* swisseph._ochchabala */
  3196. static char pyswe__ochchabala__doc__[] =
  3197. "Get the ochchabala for a planet.\n\n"
  3198. "Args: int pl, float longitude\n"
  3199. "Return: float shashtiamsa";
  3200. static PyObject * pyswe__ochchabala FUNCARGS_KEYWDS
  3201. {
  3202. int ipl;
  3203. double lon, d;
  3204. static char *kwlist[] = {"pl", "longitude", NULL};
  3205. if (!PyArg_ParseTupleAndKeywords(args, keywds, "id", kwlist, &ipl, &lon))
  3206. return NULL;
  3207. d = swh_ochchabala(ipl, lon);
  3208. if (d == -1)
  3209. {
  3210. PyErr_SetString(pyswe_Error, "swisseph._ochchabala: Invalid planet");
  3211. return NULL;
  3212. }
  3213. return Py_BuildValue("f", d);
  3214. }
  3215. #if SWH_USE_THREADS
  3216. /* swisseph._lock */
  3217. static char pyswe__lock__doc__[] =
  3218. "Lock pyswisseph.\n\nArgs: -\nReturn: None";
  3219. static PyObject * pyswe__lock FUNCARGS_SELF
  3220. {
  3221. swh_lock();
  3222. Py_RETURN_NONE;
  3223. }
  3224. /* swisseph._unlock */
  3225. static char pyswe__unlock__doc__[] =
  3226. "Unlock pyswisseph.\n\nArgs: -\nReturn: None";
  3227. static PyObject * pyswe__unlock FUNCARGS_SELF
  3228. {
  3229. swh_unlock();
  3230. Py_RETURN_NONE;
  3231. }
  3232. /* swisseph._trylock */
  3233. static char pyswe__trylock__doc__[] =
  3234. "Try to lock pyswisseph.\n\nArgs: -\nReturn: bool";
  3235. static PyObject * pyswe__trylock FUNCARGS_SELF
  3236. {
  3237. if (swh_trylock() == 0)
  3238. {
  3239. Py_RETURN_TRUE;
  3240. }
  3241. else
  3242. {
  3243. Py_RETURN_FALSE;
  3244. }
  3245. }
  3246. #endif /* SWH_USE_THREADS */
  3247. #endif /* PYSWE_USE_SWEPHELP */
  3248. /* Methods */
  3249. static struct PyMethodDef pyswe_methods[] = {
  3250. {"set_ephe_path", (PyCFunction) pyswe_set_ephe_path,
  3251. METH_VARARGS|METH_KEYWORDS, pyswe_set_ephe_path__doc__},
  3252. {"set_jpl_file", (PyCFunction) pyswe_set_jpl_file,
  3253. METH_VARARGS|METH_KEYWORDS, pyswe_set_jpl_file__doc__},
  3254. {"set_topo", (PyCFunction) pyswe_set_topo,
  3255. METH_VARARGS|METH_KEYWORDS, pyswe_set_topo__doc__},
  3256. {"set_sid_mode", (PyCFunction) pyswe_set_sid_mode,
  3257. METH_VARARGS|METH_KEYWORDS, pyswe_set_sid_mode__doc__},
  3258. {"get_ayanamsa", (PyCFunction) pyswe_get_ayanamsa,
  3259. METH_VARARGS|METH_KEYWORDS, pyswe_get_ayanamsa__doc__},
  3260. {"get_ayanamsa_ut", (PyCFunction) pyswe_get_ayanamsa_ut,
  3261. METH_VARARGS|METH_KEYWORDS, pyswe_get_ayanamsa_ut__doc__},
  3262. {"get_ayanamsa_name", (PyCFunction) pyswe_get_ayanamsa_name,
  3263. METH_VARARGS|METH_KEYWORDS, pyswe_get_ayanamsa_name__doc__},
  3264. {"close", (PyCFunction) pyswe_close,
  3265. METH_NOARGS, pyswe_close__doc__},
  3266. {"get_planet_name", (PyCFunction) pyswe_get_planet_name,
  3267. METH_VARARGS|METH_KEYWORDS, pyswe_get_planet_name__doc__},
  3268. {"calc", (PyCFunction) pyswe_calc,
  3269. METH_VARARGS|METH_KEYWORDS, pyswe_calc__doc__},
  3270. {"calc_ut", (PyCFunction) pyswe_calc_ut,
  3271. METH_VARARGS|METH_KEYWORDS, pyswe_calc_ut__doc__},
  3272. {"fixstar", (PyCFunction) pyswe_fixstar,
  3273. METH_VARARGS|METH_KEYWORDS, pyswe_fixstar__doc__},
  3274. {"fixstar_ut", (PyCFunction) pyswe_fixstar_ut,
  3275. METH_VARARGS|METH_KEYWORDS, pyswe_fixstar_ut__doc__},
  3276. {"nod_aps", (PyCFunction) pyswe_nod_aps,
  3277. METH_VARARGS|METH_KEYWORDS, pyswe_nod_aps__doc__},
  3278. {"nod_aps_ut", (PyCFunction) pyswe_nod_aps_ut,
  3279. METH_VARARGS|METH_KEYWORDS, pyswe_nod_aps_ut__doc__},
  3280. {"sidtime", (PyCFunction) pyswe_sidtime,
  3281. METH_VARARGS|METH_KEYWORDS, pyswe_sidtime__doc__},
  3282. {"sidtime0", (PyCFunction) pyswe_sidtime0,
  3283. METH_VARARGS|METH_KEYWORDS, pyswe_sidtime0__doc__},
  3284. {"houses_armc", (PyCFunction) pyswe_houses_armc,
  3285. METH_VARARGS|METH_KEYWORDS, pyswe_houses_armc__doc__},
  3286. {"houses_ex", (PyCFunction) pyswe_houses_ex,
  3287. METH_VARARGS|METH_KEYWORDS, pyswe_houses_ex__doc__},
  3288. {"house_pos", (PyCFunction) pyswe_house_pos,
  3289. METH_VARARGS|METH_KEYWORDS, pyswe_house_pos__doc__},
  3290. {"gauquelin_sector", (PyCFunction) pyswe_gauquelin_sector,
  3291. METH_VARARGS|METH_KEYWORDS, pyswe_gauquelin_sector__doc__},
  3292. {"julday", (PyCFunction) pyswe_julday,
  3293. METH_VARARGS|METH_KEYWORDS, pyswe_julday__doc__},
  3294. {"date_conversion", (PyCFunction) pyswe_date_conversion,
  3295. METH_VARARGS|METH_KEYWORDS, pyswe_date_conversion__doc__},
  3296. {"revjul", (PyCFunction) pyswe_revjul,
  3297. METH_VARARGS|METH_KEYWORDS, pyswe_revjul__doc__},
  3298. {"utc_to_jd", (PyCFunction) pyswe_utc_to_jd,
  3299. METH_VARARGS|METH_KEYWORDS, pyswe_utc_to_jd__doc__},
  3300. {"jdet_to_utc", (PyCFunction) pyswe_jdet_to_utc,
  3301. METH_VARARGS|METH_KEYWORDS, pyswe_jdet_to_utc__doc__},
  3302. {"jdut1_to_utc", (PyCFunction) pyswe_jdut1_to_utc,
  3303. METH_VARARGS|METH_KEYWORDS, pyswe_jdut1_to_utc__doc__},
  3304. {"deltat", (PyCFunction) pyswe_deltat,
  3305. METH_VARARGS|METH_KEYWORDS, pyswe_deltat__doc__},
  3306. {"get_tid_acc", (PyCFunction) pyswe_get_tid_acc,
  3307. METH_NOARGS, pyswe_get_tid_acc__doc__},
  3308. {"set_tid_acc", (PyCFunction) pyswe_set_tid_acc,
  3309. METH_VARARGS|METH_KEYWORDS, pyswe_set_tid_acc__doc__},
  3310. {"houses", (PyCFunction) pyswe_houses,
  3311. METH_VARARGS|METH_KEYWORDS, pyswe_houses__doc__},
  3312. {"time_equ", (PyCFunction) pyswe_time_equ,
  3313. METH_VARARGS|METH_KEYWORDS, pyswe_time_equ__doc__},
  3314. {"sol_eclipse_when_loc", (PyCFunction) pyswe_sol_eclipse_when_loc,
  3315. METH_VARARGS|METH_KEYWORDS, pyswe_sol_eclipse_when_loc__doc__},
  3316. {"lun_occult_when_loc", (PyCFunction) pyswe_lun_occult_when_loc,
  3317. METH_VARARGS|METH_KEYWORDS, pyswe_lun_occult_when_loc__doc__},
  3318. {"sol_eclipse_when_glob", (PyCFunction) pyswe_sol_eclipse_when_glob,
  3319. METH_VARARGS|METH_KEYWORDS, pyswe_sol_eclipse_when_glob__doc__},
  3320. {"sol_eclipse_how", (PyCFunction) pyswe_sol_eclipse_how,
  3321. METH_VARARGS|METH_KEYWORDS, pyswe_sol_eclipse_how__doc__},
  3322. {"sol_eclipse_where", (PyCFunction) pyswe_sol_eclipse_where,
  3323. METH_VARARGS|METH_KEYWORDS, pyswe_sol_eclipse_where__doc__},
  3324. {"lun_occult_when_glob", (PyCFunction) pyswe_lun_occult_when_glob,
  3325. METH_VARARGS|METH_KEYWORDS, pyswe_lun_occult_when_glob__doc__},
  3326. {"lun_occult_where", (PyCFunction) pyswe_lun_occult_where,
  3327. METH_VARARGS|METH_KEYWORDS, pyswe_lun_occult_where__doc__},
  3328. {"lun_eclipse_when", (PyCFunction) pyswe_lun_eclipse_when,
  3329. METH_VARARGS|METH_KEYWORDS, pyswe_lun_eclipse_when__doc__},
  3330. {"lun_eclipse_how", (PyCFunction) pyswe_lun_eclipse_how,
  3331. METH_VARARGS|METH_KEYWORDS, pyswe_lun_eclipse_how__doc__},
  3332. {"rise_trans", (PyCFunction) pyswe_rise_trans,
  3333. METH_VARARGS|METH_KEYWORDS, pyswe_rise_trans__doc__},
  3334. {"pheno", (PyCFunction) pyswe_pheno,
  3335. METH_VARARGS|METH_KEYWORDS, pyswe_pheno__doc__},
  3336. {"pheno_ut", (PyCFunction) pyswe_pheno_ut,
  3337. METH_VARARGS|METH_KEYWORDS, pyswe_pheno_ut__doc__},
  3338. {"refrac", (PyCFunction) pyswe_refrac,
  3339. METH_VARARGS|METH_KEYWORDS, pyswe_refrac__doc__},
  3340. {"refrac_extended", (PyCFunction) pyswe_refrac_extended,
  3341. METH_VARARGS|METH_KEYWORDS, pyswe_refrac_extended__doc__},
  3342. {"set_lapse_rate", (PyCFunction) pyswe_set_lapse_rate,
  3343. METH_VARARGS|METH_KEYWORDS, pyswe_set_lapse_rate__doc__},
  3344. {"azalt", (PyCFunction) pyswe_azalt,
  3345. METH_VARARGS|METH_KEYWORDS, pyswe_azalt__doc__},
  3346. {"azalt_rev", (PyCFunction) pyswe_azalt_rev,
  3347. METH_VARARGS|METH_KEYWORDS, pyswe_azalt_rev__doc__},
  3348. {"cotrans", (PyCFunction) pyswe_cotrans,
  3349. METH_VARARGS|METH_KEYWORDS, pyswe_cotrans__doc__},
  3350. {"cotrans_sp", (PyCFunction) pyswe_cotrans_sp,
  3351. METH_VARARGS|METH_KEYWORDS, pyswe_cotrans_sp__doc__},
  3352. {"degnorm", (PyCFunction) pyswe_degnorm,
  3353. METH_VARARGS|METH_KEYWORDS, pyswe_degnorm__doc__},
  3354. {"csnorm", (PyCFunction) pyswe_csnorm,
  3355. METH_VARARGS|METH_KEYWORDS, pyswe_csnorm__doc__},
  3356. {"radnorm", (PyCFunction) pyswe_radnorm,
  3357. METH_VARARGS|METH_KEYWORDS, pyswe_radnorm__doc__},
  3358. {"rad_midp", (PyCFunction) pyswe_rad_midp,
  3359. METH_VARARGS|METH_KEYWORDS, pyswe_rad_midp__doc__},
  3360. {"deg_midp", (PyCFunction) pyswe_deg_midp,
  3361. METH_VARARGS|METH_KEYWORDS, pyswe_deg_midp__doc__},
  3362. {"split_deg", (PyCFunction) pyswe_split_deg,
  3363. METH_VARARGS|METH_KEYWORDS, pyswe_split_deg__doc__},
  3364. {"difcsn", (PyCFunction) pyswe_difcsn,
  3365. METH_VARARGS|METH_KEYWORDS, pyswe_difcsn__doc__},
  3366. {"difdegn", (PyCFunction) pyswe_difdegn,
  3367. METH_VARARGS|METH_KEYWORDS, pyswe_difdegn__doc__},
  3368. {"difcs2n", (PyCFunction) pyswe_difcs2n,
  3369. METH_VARARGS|METH_KEYWORDS, pyswe_difcs2n__doc__},
  3370. {"difdeg2n", (PyCFunction) pyswe_difdeg2n,
  3371. METH_VARARGS|METH_KEYWORDS, pyswe_difdeg2n__doc__},
  3372. {"difrad2n", (PyCFunction) pyswe_difrad2n,
  3373. METH_VARARGS|METH_KEYWORDS, pyswe_difrad2n__doc__},
  3374. {"csroundsec", (PyCFunction) pyswe_csroundsec,
  3375. METH_VARARGS|METH_KEYWORDS, pyswe_csroundsec__doc__},
  3376. {"d2l", (PyCFunction) pyswe_d2l,
  3377. METH_VARARGS|METH_KEYWORDS, pyswe_d2l__doc__},
  3378. {"day_of_week", (PyCFunction) pyswe_day_of_week,
  3379. METH_VARARGS|METH_KEYWORDS, pyswe_day_of_week__doc__},
  3380. {"cs2timestr", (PyCFunction) pyswe_cs2timestr,
  3381. METH_VARARGS|METH_KEYWORDS, pyswe_cs2timestr__doc__},
  3382. {"cs2lonlatstr", (PyCFunction) pyswe_cs2lonlatstr,
  3383. METH_VARARGS|METH_KEYWORDS, pyswe_cs2lonlatstr__doc__},
  3384. {"cs2degstr", (PyCFunction) pyswe_cs2degstr,
  3385. METH_VARARGS|METH_KEYWORDS, pyswe_cs2degstr__doc__},
  3386. {"fixstar_mag", (PyCFunction) pyswe_fixstar_mag,
  3387. METH_VARARGS|METH_KEYWORDS, pyswe_fixstar_mag__doc__},
  3388. {"heliacal_ut", (PyCFunction) pyswe_heliacal_ut,
  3389. METH_VARARGS|METH_KEYWORDS, pyswe_heliacal_ut__doc__},
  3390. {"vis_limit_mag", (PyCFunction) pyswe_vis_limit_mag,
  3391. METH_VARARGS|METH_KEYWORDS, pyswe_vis_limit_mag__doc__},
  3392. #if PYSWE_USE_SWEPHELP
  3393. /* pyswisseph/swephelp functions. */
  3394. {"_jdnow", (PyCFunction) pyswe__jdnow,
  3395. METH_NOARGS, pyswe__jdnow__doc__},
  3396. {"_julday", (PyCFunction) pyswe__julday,
  3397. METH_VARARGS|METH_KEYWORDS, pyswe__julday__doc__},
  3398. {"_revjul", (PyCFunction) pyswe__revjul,
  3399. METH_VARARGS|METH_KEYWORDS, pyswe__revjul__doc__},
  3400. {"_degsplit", (PyCFunction) pyswe__degsplit,
  3401. METH_VARARGS|METH_KEYWORDS, pyswe__degsplit__doc__},
  3402. {"_signtostr", (PyCFunction) pyswe__signtostr,
  3403. METH_VARARGS|METH_KEYWORDS, pyswe__signtostr__doc__},
  3404. {"_house_system_name", (PyCFunction) pyswe__house_system_name,
  3405. METH_VARARGS|METH_KEYWORDS, pyswe__house_system_name__doc__},
  3406. {"_min_retro_time", (PyCFunction) pyswe__min_retro_time,
  3407. METH_VARARGS|METH_KEYWORDS, pyswe__min_retro_time__doc__},
  3408. {"_max_retro_time", (PyCFunction) pyswe__max_retro_time,
  3409. METH_VARARGS|METH_KEYWORDS, pyswe__max_retro_time__doc__},
  3410. {"_next_retro", (PyCFunction) pyswe__next_retro,
  3411. METH_VARARGS|METH_KEYWORDS, pyswe__next_retro__doc__},
  3412. {"_go_past", (PyCFunction) pyswe__go_past,
  3413. METH_VARARGS|METH_KEYWORDS, pyswe__go_past__doc__},
  3414. {"_next_aspect", (PyCFunction) pyswe__next_aspect,
  3415. METH_VARARGS|METH_KEYWORDS, pyswe__next_aspect__doc__},
  3416. {"_next_aspect2", (PyCFunction) pyswe__next_aspect2,
  3417. METH_VARARGS|METH_KEYWORDS, pyswe__next_aspect2__doc__},
  3418. {"_next_aspect_with", (PyCFunction) pyswe__next_aspect_with,
  3419. METH_VARARGS|METH_KEYWORDS, pyswe__next_aspect_with__doc__},
  3420. {"_next_aspect_with2", (PyCFunction) pyswe__next_aspect_with2,
  3421. METH_VARARGS|METH_KEYWORDS, pyswe__next_aspect_with2__doc__},
  3422. {"_next_aspect_cusp", (PyCFunction) pyswe__next_aspect_cusp,
  3423. METH_VARARGS|METH_KEYWORDS, pyswe__next_aspect_cusp__doc__},
  3424. {"_next_aspect_cusp2", (PyCFunction) pyswe__next_aspect_cusp2,
  3425. METH_VARARGS|METH_KEYWORDS, pyswe__next_aspect_cusp2__doc__},
  3426. {"_match_aspect", (PyCFunction) pyswe__match_aspect,
  3427. METH_VARARGS|METH_KEYWORDS, pyswe__match_aspect__doc__},
  3428. {"_match_aspect2", (PyCFunction) pyswe__match_aspect2,
  3429. METH_VARARGS|METH_KEYWORDS, pyswe__match_aspect2__doc__},
  3430. {"_match_aspect3", (PyCFunction) pyswe__match_aspect3,
  3431. METH_VARARGS|METH_KEYWORDS, pyswe__match_aspect3__doc__},
  3432. {"_match_aspect4", (PyCFunction) pyswe__match_aspect4,
  3433. METH_VARARGS|METH_KEYWORDS, pyswe__match_aspect4__doc__},
  3434. {"_years_diff", (PyCFunction) pyswe__years_diff,
  3435. METH_VARARGS|METH_KEYWORDS, pyswe__years_diff__doc__},
  3436. {"_geoc2d", (PyCFunction) pyswe__geoc2d,
  3437. METH_VARARGS|METH_KEYWORDS, pyswe__geoc2d__doc__},
  3438. {"_geolat2c", (PyCFunction) pyswe__geolat2c,
  3439. METH_VARARGS|METH_KEYWORDS, pyswe__geolat2c__doc__},
  3440. {"_geolon2c", (PyCFunction) pyswe__geolon2c,
  3441. METH_VARARGS|METH_KEYWORDS, pyswe__geolon2c__doc__},
  3442. {"_raman_houses", (PyCFunction) pyswe__raman_houses,
  3443. METH_VARARGS|METH_KEYWORDS, pyswe__raman_houses__doc__},
  3444. {"_lord", (PyCFunction) pyswe__lord,
  3445. METH_VARARGS|METH_KEYWORDS, pyswe__lord__doc__},
  3446. {"_long2rasi", (PyCFunction) pyswe__long2rasi,
  3447. METH_VARARGS|METH_KEYWORDS, pyswe__long2rasi__doc__},
  3448. {"_long2navamsa", (PyCFunction) pyswe__long2navamsa,
  3449. METH_VARARGS|METH_KEYWORDS, pyswe__long2navamsa__doc__},
  3450. {"_long2nakshatra", (PyCFunction) pyswe__long2nakshatra,
  3451. METH_VARARGS|METH_KEYWORDS, pyswe__long2nakshatra__doc__},
  3452. {"_get_nakshatra_name", (PyCFunction) pyswe__get_nakshatra_name,
  3453. METH_VARARGS|METH_KEYWORDS, pyswe__get_nakshatra_name__doc__},
  3454. {"_rasinorm", (PyCFunction) pyswe__rasinorm,
  3455. METH_VARARGS|METH_KEYWORDS, pyswe__rasinorm__doc__},
  3456. {"_rasi_dif", (PyCFunction) pyswe__rasi_dif,
  3457. METH_VARARGS|METH_KEYWORDS, pyswe__rasi_dif__doc__},
  3458. {"_rasi_dif2", (PyCFunction) pyswe__rasi_dif2,
  3459. METH_VARARGS|METH_KEYWORDS, pyswe__rasi_dif2__doc__},
  3460. {"_tatkalika_relation", (PyCFunction) pyswe__tatkalika_relation,
  3461. METH_VARARGS|METH_KEYWORDS, pyswe__tatkalika_relation__doc__},
  3462. {"_naisargika_relation", (PyCFunction) pyswe__naisargika_relation,
  3463. METH_VARARGS|METH_KEYWORDS, pyswe__naisargika_relation__doc__},
  3464. {"_residential_strength", (PyCFunction) pyswe__residential_strength,
  3465. METH_VARARGS|METH_KEYWORDS, pyswe__residential_strength__doc__},
  3466. {"_ochchabala", (PyCFunction) pyswe__ochchabala,
  3467. METH_VARARGS|METH_KEYWORDS, pyswe__ochchabala__doc__},
  3468. #if SWH_USE_THREADS
  3469. {"_lock", (PyCFunction) pyswe__lock,
  3470. METH_VARARGS|METH_KEYWORDS, pyswe__lock__doc__},
  3471. {"_unlock", (PyCFunction) pyswe__unlock,
  3472. METH_VARARGS|METH_KEYWORDS, pyswe__unlock__doc__},
  3473. {"_trylock", (PyCFunction) pyswe__trylock,
  3474. METH_VARARGS|METH_KEYWORDS, pyswe__trylock__doc__},
  3475. #endif /* SWH_USE_THREADS */
  3476. #endif /* PYSWE_USE_SWEPHELP */
  3477. {NULL, (PyCFunction) NULL, 0, NULL}
  3478. };
  3479. static char pyswe_module_documentation[] =
  3480. "Python extension to AstroDienst Swiss Ephemeris library.\n"
  3481. #if PYSWE_AUTO_SET_EPHE_PATH
  3482. "Import of this extension module does automagicaly set the ephemeris path"
  3483. " to \"" PYSWE_DEFAULT_EPHE_PATH "\".\n"
  3484. #endif
  3485. "Extended documentation can be found on AstroDienst website.\n\n"
  3486. "Pyswisseph homepage: http://pyswisseph.chaosorigin.com/\n"
  3487. "AstroDienst: http://www.astro.com/swisseph/\n"
  3488. "PyPI: http://pypi.python.org/pypi/pyswisseph/";
  3489. #if PY_MAJOR_VERSION >= 3
  3490. struct PyModuleDef pyswe_module =
  3491. {
  3492. PyModuleDef_HEAD_INIT,
  3493. "swisseph", /* module name */
  3494. pyswe_module_documentation, /* module docstring */
  3495. -1, /* size of per-interpreter state of the module,
  3496. or -1 if the module keeps state in global variables. */
  3497. pyswe_methods
  3498. };
  3499. PyMODINIT_FUNC PyInit_swisseph(void)
  3500. #elif PY_MAJOR_VERSION < 3
  3501. PyMODINIT_FUNC initswisseph(void)
  3502. #endif
  3503. {
  3504. PyObject *m;
  3505. char buf[10];
  3506. #if PY_MAJOR_VERSION >= 3
  3507. m = PyModule_Create(&pyswe_module);
  3508. if (m == NULL)
  3509. Py_FatalError("Can't create module swisseph!");
  3510. #elif PY_MAJOR_VERSION < 3
  3511. m = Py_InitModule4("swisseph", pyswe_methods,
  3512. pyswe_module_documentation,
  3513. (PyObject*) NULL, PYTHON_API_VERSION);
  3514. #endif
  3515. pyswe_Error = PyErr_NewException("swisseph.Error", NULL, NULL);
  3516. Py_INCREF(pyswe_Error);
  3517. PyModule_AddObject(m, "Error", pyswe_Error);
  3518. /* Constants */
  3519. PyModule_AddIntConstant(m, "JUL_CAL", SE_JUL_CAL);
  3520. PyModule_AddIntConstant(m, "GREG_CAL", SE_GREG_CAL);
  3521. PyModule_AddIntConstant(m, "ECL_NUT", SE_ECL_NUT);
  3522. PyModule_AddIntConstant(m, "SUN", SE_SUN);
  3523. PyModule_AddIntConstant(m, "MOON", SE_MOON);
  3524. PyModule_AddIntConstant(m, "MERCURY", SE_MERCURY);
  3525. PyModule_AddIntConstant(m, "VENUS", SE_VENUS);
  3526. PyModule_AddIntConstant(m, "MARS", SE_MARS);
  3527. PyModule_AddIntConstant(m, "JUPITER", SE_JUPITER);
  3528. PyModule_AddIntConstant(m, "SATURN", SE_SATURN);
  3529. PyModule_AddIntConstant(m, "URANUS", SE_URANUS);
  3530. PyModule_AddIntConstant(m, "NEPTUNE", SE_NEPTUNE);
  3531. PyModule_AddIntConstant(m, "PLUTO", SE_PLUTO);
  3532. PyModule_AddIntConstant(m, "MEAN_NODE", SE_MEAN_NODE);
  3533. PyModule_AddIntConstant(m, "TRUE_NODE", SE_TRUE_NODE);
  3534. PyModule_AddIntConstant(m, "MEAN_APOG", SE_MEAN_APOG);
  3535. PyModule_AddIntConstant(m, "OSCU_APOG", SE_OSCU_APOG);
  3536. PyModule_AddIntConstant(m, "EARTH", SE_EARTH);
  3537. PyModule_AddIntConstant(m, "CHIRON", SE_CHIRON);
  3538. PyModule_AddIntConstant(m, "PHOLUS", SE_PHOLUS);
  3539. PyModule_AddIntConstant(m, "CERES", SE_CERES);
  3540. PyModule_AddIntConstant(m, "PALLAS", SE_PALLAS);
  3541. PyModule_AddIntConstant(m, "JUNO", SE_JUNO);
  3542. PyModule_AddIntConstant(m, "VESTA", SE_VESTA);
  3543. PyModule_AddIntConstant(m, "INTP_APOG", SE_INTP_APOG);
  3544. PyModule_AddIntConstant(m, "INTP_PERG", SE_INTP_PERG);
  3545. PyModule_AddIntConstant(m, "NPLANETS", SE_NPLANETS);
  3546. PyModule_AddIntConstant(m, "AST_OFFSET", SE_AST_OFFSET);
  3547. PyModule_AddIntConstant(m, "VARUNA", SE_VARUNA);
  3548. PyModule_AddIntConstant(m, "FICT_OFFSET", SE_FICT_OFFSET);
  3549. PyModule_AddIntConstant(m, "FICT_OFFSET_1", SE_FICT_OFFSET_1);
  3550. PyModule_AddIntConstant(m, "FICT_MAX", SE_FICT_MAX);
  3551. PyModule_AddIntConstant(m, "NFICT_ELEM", SE_NFICT_ELEM);
  3552. PyModule_AddIntConstant(m, "COMET_OFFSET", SE_COMET_OFFSET);
  3553. PyModule_AddIntConstant(m, "NALL_NAT_POINTS", SE_NALL_NAT_POINTS);
  3554. PyModule_AddIntConstant(m, "CUPIDO", SE_CUPIDO);
  3555. PyModule_AddIntConstant(m, "HADES", SE_HADES);
  3556. PyModule_AddIntConstant(m, "ZEUS", SE_ZEUS);
  3557. PyModule_AddIntConstant(m, "KRONOS", SE_KRONOS);
  3558. PyModule_AddIntConstant(m, "APOLLON", SE_APOLLON);
  3559. PyModule_AddIntConstant(m, "ADMETOS", SE_ADMETOS);
  3560. PyModule_AddIntConstant(m, "VULKANUS", SE_VULKANUS);
  3561. PyModule_AddIntConstant(m, "POSEIDON", SE_POSEIDON);
  3562. PyModule_AddIntConstant(m, "ISIS", SE_ISIS);
  3563. PyModule_AddIntConstant(m, "NIBIRU", SE_NIBIRU);
  3564. PyModule_AddIntConstant(m, "HARRINGTON", SE_HARRINGTON);
  3565. PyModule_AddIntConstant(m, "NEPTUNE_LEVERRIER", SE_NEPTUNE_LEVERRIER);
  3566. PyModule_AddIntConstant(m, "NEPTUNE_ADAMS", SE_NEPTUNE_ADAMS);
  3567. PyModule_AddIntConstant(m, "PLUTO_LOWELL", SE_PLUTO_LOWELL);
  3568. PyModule_AddIntConstant(m, "PLUTO_PICKERING", SE_PLUTO_PICKERING);
  3569. PyModule_AddIntConstant(m, "VULCAN", SE_VULCAN);
  3570. PyModule_AddIntConstant(m, "WHITE_MOON", SE_WHITE_MOON);
  3571. PyModule_AddIntConstant(m, "PROSERPINA", SE_PROSERPINA);
  3572. PyModule_AddIntConstant(m, "WALDEMATH", SE_WALDEMATH);
  3573. PyModule_AddIntConstant(m, "FIXSTAR", SE_FIXSTAR);
  3574. PyModule_AddIntConstant(m, "ASC", SE_ASC);
  3575. PyModule_AddIntConstant(m, "MC", SE_MC);
  3576. PyModule_AddIntConstant(m, "ARMC", SE_ARMC);
  3577. PyModule_AddIntConstant(m, "VERTEX", SE_VERTEX);
  3578. PyModule_AddIntConstant(m, "EQUASC", SE_EQUASC);
  3579. PyModule_AddIntConstant(m, "COASC1", SE_COASC1);
  3580. PyModule_AddIntConstant(m, "COASC2", SE_COASC2);
  3581. PyModule_AddIntConstant(m, "POLASC", SE_POLASC);
  3582. PyModule_AddIntConstant(m, "NASCMC", SE_NASCMC);
  3583. PyModule_AddIntConstant(m, "FLG_JPLEPH", SEFLG_JPLEPH);
  3584. PyModule_AddIntConstant(m, "FLG_SWIEPH", SEFLG_SWIEPH);
  3585. PyModule_AddIntConstant(m, "FLG_MOSEPH", SEFLG_MOSEPH);
  3586. PyModule_AddIntConstant(m, "FLG_HELCTR", SEFLG_HELCTR);
  3587. PyModule_AddIntConstant(m, "FLG_TRUEPOS", SEFLG_TRUEPOS);
  3588. PyModule_AddIntConstant(m, "FLG_J2000", SEFLG_J2000);
  3589. PyModule_AddIntConstant(m, "FLG_NONUT", SEFLG_NONUT);
  3590. PyModule_AddIntConstant(m, "FLG_SPEED3", SEFLG_SPEED3);
  3591. PyModule_AddIntConstant(m, "FLG_SPEED", SEFLG_SPEED);
  3592. PyModule_AddIntConstant(m, "FLG_NOGDEFL", SEFLG_NOGDEFL);
  3593. PyModule_AddIntConstant(m, "FLG_NOABERR", SEFLG_NOABERR);
  3594. PyModule_AddIntConstant(m, "FLG_EQUATORIAL", SEFLG_EQUATORIAL);
  3595. PyModule_AddIntConstant(m, "FLG_XYZ", SEFLG_XYZ);
  3596. PyModule_AddIntConstant(m, "FLG_RADIANS", SEFLG_RADIANS);
  3597. PyModule_AddIntConstant(m, "FLG_BARYCTR", SEFLG_BARYCTR);
  3598. PyModule_AddIntConstant(m, "FLG_TOPOCTR", SEFLG_TOPOCTR);
  3599. PyModule_AddIntConstant(m, "FLG_SIDEREAL", SEFLG_SIDEREAL);
  3600. PyModule_AddIntConstant(m, "FLG_ICRS", SEFLG_ICRS);
  3601. PyModule_AddIntConstant(m, "SIDBITS", SE_SIDBITS);
  3602. PyModule_AddIntConstant(m, "SIDBIT_ECL_T0", SE_SIDBIT_ECL_T0);
  3603. PyModule_AddIntConstant(m, "SIDBIT_SSY_PLANE", SE_SIDBIT_SSY_PLANE);
  3604. PyModule_AddIntConstant(m, "SIDM_FAGAN_BRADLEY", SE_SIDM_FAGAN_BRADLEY);
  3605. PyModule_AddIntConstant(m, "SIDM_LAHIRI", SE_SIDM_LAHIRI);
  3606. PyModule_AddIntConstant(m, "SIDM_DELUCE", SE_SIDM_DELUCE);
  3607. PyModule_AddIntConstant(m, "SIDM_RAMAN", SE_SIDM_RAMAN);
  3608. PyModule_AddIntConstant(m, "SIDM_USHASHASHI", SE_SIDM_USHASHASHI);
  3609. PyModule_AddIntConstant(m, "SIDM_KRISHNAMURTI", SE_SIDM_KRISHNAMURTI);
  3610. PyModule_AddIntConstant(m, "SIDM_DJWHAL_KHUL", SE_SIDM_DJWHAL_KHUL);
  3611. PyModule_AddIntConstant(m, "SIDM_YUKTESHWAR", SE_SIDM_YUKTESHWAR);
  3612. PyModule_AddIntConstant(m, "SIDM_JN_BHASIN", SE_SIDM_JN_BHASIN);
  3613. PyModule_AddIntConstant(m, "SIDM_BABYL_KUGLER1", SE_SIDM_BABYL_KUGLER1);
  3614. PyModule_AddIntConstant(m, "SIDM_BABYL_KUGLER2", SE_SIDM_BABYL_KUGLER2);
  3615. PyModule_AddIntConstant(m, "SIDM_BABYL_KUGLER3", SE_SIDM_BABYL_KUGLER3);
  3616. PyModule_AddIntConstant(m, "SIDM_BABYL_HUBER", SE_SIDM_BABYL_HUBER);
  3617. PyModule_AddIntConstant(m, "SIDM_BABYL_ETPSC", SE_SIDM_BABYL_ETPSC);
  3618. PyModule_AddIntConstant(m, "SIDM_ALDEBARAN_15TAU", SE_SIDM_ALDEBARAN_15TAU);
  3619. PyModule_AddIntConstant(m, "SIDM_HIPPARCHOS", SE_SIDM_HIPPARCHOS);
  3620. PyModule_AddIntConstant(m, "SIDM_SASSANIAN", SE_SIDM_SASSANIAN);
  3621. PyModule_AddIntConstant(m, "SIDM_GALCENT_0SAG", SE_SIDM_GALCENT_0SAG);
  3622. PyModule_AddIntConstant(m, "SIDM_J2000", SE_SIDM_J2000);
  3623. PyModule_AddIntConstant(m, "SIDM_J1900", SE_SIDM_J1900);
  3624. PyModule_AddIntConstant(m, "SIDM_B1950", SE_SIDM_B1950);
  3625. PyModule_AddIntConstant(m, "SIDM_USER", SE_SIDM_USER);
  3626. PyModule_AddIntConstant(m, "NSIDM_PREDEF", SE_NSIDM_PREDEF);
  3627. PyModule_AddIntConstant(m, "NODBIT_MEAN", SE_NODBIT_MEAN);
  3628. PyModule_AddIntConstant(m, "NODBIT_OSCU", SE_NODBIT_OSCU);
  3629. PyModule_AddIntConstant(m, "NODBIT_OSCU_BAR", SE_NODBIT_OSCU_BAR);
  3630. PyModule_AddIntConstant(m, "NODBIT_FOPOINT", SE_NODBIT_FOPOINT);
  3631. PyModule_AddIntConstant(m, "FLG_DEFAULTEPH", SEFLG_DEFAULTEPH);
  3632. PyModule_AddIntConstant(m, "MAX_STNAME", SE_MAX_STNAME);
  3633. PyModule_AddIntConstant(m, "ECL_CENTRAL", SE_ECL_CENTRAL);
  3634. PyModule_AddIntConstant(m, "ECL_NONCENTRAL", SE_ECL_NONCENTRAL);
  3635. PyModule_AddIntConstant(m, "ECL_TOTAL", SE_ECL_TOTAL);
  3636. PyModule_AddIntConstant(m, "ECL_ANNULAR", SE_ECL_ANNULAR);
  3637. PyModule_AddIntConstant(m, "ECL_PARTIAL", SE_ECL_PARTIAL);
  3638. PyModule_AddIntConstant(m, "ECL_ANNULAR_TOTAL", SE_ECL_ANNULAR_TOTAL);
  3639. PyModule_AddIntConstant(m, "ECL_PENUMBRAL", SE_ECL_PENUMBRAL);
  3640. PyModule_AddIntConstant(m, "ECL_VISIBLE", SE_ECL_VISIBLE);
  3641. PyModule_AddIntConstant(m, "ECL_MAX_VISIBLE", SE_ECL_MAX_VISIBLE);
  3642. PyModule_AddIntConstant(m, "ECL_1ST_VISIBLE", SE_ECL_1ST_VISIBLE);
  3643. PyModule_AddIntConstant(m, "ECL_2ND_VISIBLE", SE_ECL_2ND_VISIBLE);
  3644. PyModule_AddIntConstant(m, "ECL_3RD_VISIBLE", SE_ECL_3RD_VISIBLE);
  3645. PyModule_AddIntConstant(m, "ECL_4TH_VISIBLE", SE_ECL_4TH_VISIBLE);
  3646. PyModule_AddIntConstant(m, "ECL_ONE_TRY", SE_ECL_ONE_TRY);
  3647. PyModule_AddIntConstant(m, "CALC_RISE", SE_CALC_RISE);
  3648. PyModule_AddIntConstant(m, "CALC_SET", SE_CALC_SET);
  3649. PyModule_AddIntConstant(m, "CALC_MTRANSIT", SE_CALC_MTRANSIT);
  3650. PyModule_AddIntConstant(m, "CALC_ITRANSIT", SE_CALC_ITRANSIT);
  3651. PyModule_AddIntConstant(m, "BIT_DISC_CENTER", SE_BIT_DISC_CENTER);
  3652. PyModule_AddIntConstant(m, "BIT_NO_REFRACTION", SE_BIT_NO_REFRACTION);
  3653. PyModule_AddIntConstant(m, "BIT_CIVIL_TWILIGHT", SE_BIT_CIVIL_TWILIGHT);
  3654. PyModule_AddIntConstant(m, "BIT_NAUTIC_TWILIGHT", SE_BIT_NAUTIC_TWILIGHT);
  3655. PyModule_AddIntConstant(m, "BIT_ASTRO_TWILIGHT", SE_BIT_ASTRO_TWILIGHT);
  3656. PyModule_AddIntConstant(m, "ECL2HOR", SE_ECL2HOR);
  3657. PyModule_AddIntConstant(m, "EQU2HOR", SE_EQU2HOR);
  3658. PyModule_AddIntConstant(m, "HOR2ECL", SE_HOR2ECL);
  3659. PyModule_AddIntConstant(m, "HOR2EQU", SE_HOR2EQU);
  3660. PyModule_AddIntConstant(m, "TRUE_TO_APP", SE_TRUE_TO_APP);
  3661. PyModule_AddIntConstant(m, "APP_TO_TRUE", SE_APP_TO_TRUE);
  3662. PyModule_AddIntConstant(m, "DE_NUMBER", SE_DE_NUMBER);
  3663. PyModule_AddStringConstant(m, "FNAME_DE200", "de200.eph");
  3664. PyModule_AddStringConstant(m, "FNAME_DE403", "de403.eph");
  3665. PyModule_AddStringConstant(m, "FNAME_DE404", "de404.eph");
  3666. PyModule_AddStringConstant(m, "FNAME_DE405", "de405.eph");
  3667. PyModule_AddStringConstant(m, "FNAME_DE406", "de406.eph");
  3668. PyModule_AddStringConstant(m, "FNAME_DFT", "de406.eph");
  3669. PyModule_AddStringConstant(m, "STARFILE", "fixstars.cat");
  3670. PyModule_AddStringConstant(m, "ASTNAMFILE", "seasnam.txt");
  3671. PyModule_AddStringConstant(m, "FICTFILE", "seorbel.txt");
  3672. PyModule_AddStringConstant(m, "EPHE_PATH", SE_EPHE_PATH);
  3673. PyModule_AddIntConstant(m, "SPLIT_DEG_ROUND_SEC", SE_SPLIT_DEG_ROUND_SEC);
  3674. PyModule_AddIntConstant(m, "SPLIT_DEG_ROUND_MIN", SE_SPLIT_DEG_ROUND_MIN);
  3675. PyModule_AddIntConstant(m, "SPLIT_DEG_ROUND_DEG", SE_SPLIT_DEG_ROUND_DEG);
  3676. PyModule_AddIntConstant(m, "SPLIT_DEG_ZODIACAL", SE_SPLIT_DEG_ZODIACAL);
  3677. PyModule_AddIntConstant(m, "SPLIT_DEG_KEEP_SIGN", SE_SPLIT_DEG_KEEP_SIGN);
  3678. PyModule_AddIntConstant(m, "SPLIT_DEG_KEEP_DEG", SE_SPLIT_DEG_KEEP_DEG);
  3679. PyModule_AddIntConstant(m, "HELIACAL_RISING", SE_HELIACAL_RISING);
  3680. PyModule_AddIntConstant(m, "HELIACAL_SETTING", SE_HELIACAL_SETTING);
  3681. PyModule_AddIntConstant(m, "EVENING_FIRST", SE_EVENING_FIRST);
  3682. PyModule_AddIntConstant(m, "EVENING_LAST", SE_EVENING_LAST);
  3683. PyModule_AddIntConstant(m, "MORNING_LAST", SE_MORNING_LAST);
  3684. PyModule_AddIntConstant(m, "MORNING_FIRST", SE_MORNING_FIRST);
  3685. PyModule_AddIntConstant(m, "ACRONYCHAL_RISING", SE_ACRONYCHAL_RISING);
  3686. PyModule_AddIntConstant(m, "COSMICAL_SETTING", SE_COSMICAL_SETTING);
  3687. PyModule_AddIntConstant(m, "ACRONYCHAL_SETTING", SE_ACRONYCHAL_SETTING);
  3688. PyModule_AddIntConstant(m, "HELFLAG_LONG_SEARCH", SE_HELFLAG_LONG_SEARCH);
  3689. PyModule_AddIntConstant(m, "HELFLAG_HIGH_PRECISION", SE_HELFLAG_HIGH_PRECISION);
  3690. PyModule_AddIntConstant(m, "HELFLAG_OPTICAL_PARAMS", SE_HELFLAG_OPTICAL_PARAMS);
  3691. PyModule_AddIntConstant(m, "HELFLAG_NO_DETAILS", SE_HELFLAG_NO_DETAILS);
  3692. PyModule_AddIntConstant(m, "HELFLAG_AVKIND_VR", SE_HELFLAG_AVKIND_VR);
  3693. PyModule_AddIntConstant(m, "HELFLAG_AVKIND_PTO", SE_HELFLAG_AVKIND_PTO);
  3694. PyModule_AddIntConstant(m, "HELFLAG_AVKIND_MIN7", SE_HELFLAG_AVKIND_MIN7);
  3695. PyModule_AddIntConstant(m, "HELFLAG_AVKIND_MIN9", SE_HELFLAG_AVKIND_MIN9);
  3696. PyModule_AddIntConstant(m, "HELFLAG_AVKIND", SE_HELFLAG_AVKIND);
  3697. PyModule_AddObject(m, "TJD_INVALID", Py_BuildValue("f", TJD_INVALID));
  3698. PyModule_AddIntConstant(m, "SIMULATE_VICTORVB", SIMULATE_VICTORVB);
  3699. PyModule_AddIntConstant(m, "PHOTOPIC_FLAG", SE_PHOTOPIC_FLAG);
  3700. PyModule_AddIntConstant(m, "SCOTOPIC_FLAG", SE_SCOTOPIC_FLAG);
  3701. PyModule_AddIntConstant(m, "MIXEDOPIC_FLAG", SE_MIXEDOPIC_FLAG);
  3702. #if PYSWE_USE_SWEPHELP
  3703. /* *** Additional constants -- not swiss ephemeris ***/
  3704. /* Aspects */
  3705. PyModule_AddIntConstant(m, "CONJUNCTION", SWH_CONJUNCTION);
  3706. PyModule_AddIntConstant(m, "SQUISEXTILE", SWH_SQUISEXTILE);
  3707. PyModule_AddIntConstant(m, "SEMINOVILE", SWH_SEMINOVILE);
  3708. PyModule_AddObject(m, "SQUISQUARE", Py_BuildValue("f", SWH_SQUISQUARE));
  3709. PyModule_AddObject(m, "UNDECILE", Py_BuildValue("f", SWH_UNDECILE));
  3710. PyModule_AddIntConstant(m, "SEMISEXTILE", SWH_SEMISEXTILE);
  3711. PyModule_AddIntConstant(m, "SEMIQUINTILE", SWH_SEMIQUINTILE);
  3712. PyModule_AddIntConstant(m, "NOVILE", SWH_NOVILE);
  3713. PyModule_AddIntConstant(m, "SEMISQUARE", SWH_SEMISQUARE);
  3714. PyModule_AddObject(m, "SEPTILE", Py_BuildValue("f", SWH_SEPTILE));
  3715. PyModule_AddIntConstant(m, "SEXTILE", SWH_SEXTILE);
  3716. PyModule_AddObject(m, "BIUNDECILE", Py_BuildValue("f", SWH_BIUNDECILE));
  3717. PyModule_AddIntConstant(m, "QUINTILE", SWH_QUINTILE);
  3718. PyModule_AddIntConstant(m, "BINOVILE", SWH_BINOVILE);
  3719. PyModule_AddIntConstant(m, "SQUARE", SWH_SQUARE);
  3720. PyModule_AddObject(m, "TRIUNDECILE", Py_BuildValue("f", SWH_TRIUNDECILE));
  3721. PyModule_AddObject(m, "BISEPTILE", Py_BuildValue("f", SWH_BISEPTILE));
  3722. PyModule_AddIntConstant(m, "TRINE", SWH_TRINE);
  3723. PyModule_AddObject(m, "QUADUNDECILE", Py_BuildValue("f", SWH_QUADUNDECILE));
  3724. PyModule_AddIntConstant(m, "SESQUISQUARE", SWH_SESQUISQUARE);
  3725. PyModule_AddIntConstant(m, "BIQUINTILE", SWH_BIQUINTILE);
  3726. PyModule_AddIntConstant(m, "QUINCUNX", SWH_QUINCUNX);
  3727. PyModule_AddObject(m, "TRISEPTILE", Py_BuildValue("f", SWH_TRISEPTILE));
  3728. PyModule_AddIntConstant(m, "QUATRONOVILE", SWH_QUATRONOVILE);
  3729. PyModule_AddObject(m, "QUINUNDECILE", Py_BuildValue("f", SWH_QUINUNDECILE));
  3730. PyModule_AddIntConstant(m, "OPPOSITION", SWH_OPPOSITION);
  3731. /* Signs */
  3732. PyModule_AddIntConstant(m, "ARIES", SWH_ARIES);
  3733. PyModule_AddIntConstant(m, "TAURUS", SWH_TAURUS);
  3734. PyModule_AddIntConstant(m, "GEMINI", SWH_GEMINI);
  3735. PyModule_AddIntConstant(m, "CANCER", SWH_CANCER);
  3736. PyModule_AddIntConstant(m, "LEO", SWH_LEO);
  3737. PyModule_AddIntConstant(m, "VIRGO", SWH_VIRGO);
  3738. PyModule_AddIntConstant(m, "LIBRA", SWH_LIBRA);
  3739. PyModule_AddIntConstant(m, "SCORPIO", SWH_SCORPIO);
  3740. PyModule_AddIntConstant(m, "SAGITTARIUS", SWH_SAGITTARIUS);
  3741. PyModule_AddIntConstant(m, "CAPRICORN", SWH_CAPRICORN);
  3742. PyModule_AddIntConstant(m, "AQUARIUS", SWH_AQUARIUS);
  3743. PyModule_AddIntConstant(m, "PISCES", SWH_PISCES);
  3744. PyModule_AddIntConstant(m, "MESHA", SWH_MESHA);
  3745. PyModule_AddIntConstant(m, "VRISHABA", SWH_VRISHABA);
  3746. PyModule_AddIntConstant(m, "MITHUNA", SWH_MITHUNA);
  3747. PyModule_AddIntConstant(m, "KATAKA", SWH_KATAKA);
  3748. PyModule_AddIntConstant(m, "SIMHA", SWH_SIMHA);
  3749. PyModule_AddIntConstant(m, "KANYA", SWH_KANYA);
  3750. PyModule_AddIntConstant(m, "THULA", SWH_THULA);
  3751. PyModule_AddIntConstant(m, "VRISHIKA", SWH_VRISHIKA);
  3752. PyModule_AddIntConstant(m, "DHANUS", SWH_DHANUS);
  3753. PyModule_AddIntConstant(m, "MAKARA", SWH_MAKARA);
  3754. PyModule_AddIntConstant(m, "KUMBHA", SWH_KUMBHA);
  3755. PyModule_AddIntConstant(m, "MEENA", SWH_MEENA);
  3756. /* Planets */
  3757. PyModule_AddIntConstant(m, "RAVI", SWH_RAVI);
  3758. PyModule_AddIntConstant(m, "CHANDRA", SWH_CHANDRA);
  3759. PyModule_AddIntConstant(m, "BUDHA", SWH_BUDHA);
  3760. PyModule_AddIntConstant(m, "SUKRA", SWH_SUKRA);
  3761. PyModule_AddIntConstant(m, "KUJA", SWH_KUJA);
  3762. PyModule_AddIntConstant(m, "GURU", SWH_GURU);
  3763. PyModule_AddIntConstant(m, "SANI", SWH_SANI);
  3764. PyModule_AddIntConstant(m, "RAHU", SWH_RAHU);
  3765. PyModule_AddIntConstant(m, "KETU", SWH_KETU);
  3766. PyModule_AddIntConstant(m, "SURYA", SWH_SURYA);
  3767. PyModule_AddIntConstant(m, "SOMA", SWH_SOMA);
  3768. PyModule_AddIntConstant(m, "SOUMYA", SWH_SOUMYA);
  3769. PyModule_AddIntConstant(m, "BHARGAVA", SWH_BHARGAVA);
  3770. PyModule_AddIntConstant(m, "ANGARAKA", SWH_ANGARAKA);
  3771. PyModule_AddIntConstant(m, "BRIHASPATI", SWH_BRIHASPATI);
  3772. PyModule_AddIntConstant(m, "MANDA", SWH_MANDA);
  3773. PyModule_AddIntConstant(m, "THAMA", SWH_THAMA);
  3774. PyModule_AddIntConstant(m, "SIKHI", SWH_SIKHI);
  3775. /* Nakshatras */
  3776. PyModule_AddIntConstant(m, "ASWINI", SWH_ASWINI);
  3777. PyModule_AddIntConstant(m, "BHARANI", SWH_BHARANI);
  3778. PyModule_AddIntConstant(m, "KRITIKHA", SWH_KRITHIKA);
  3779. PyModule_AddIntConstant(m, "ROHINI", SWH_ROHINI);
  3780. PyModule_AddIntConstant(m, "MRIGASIRA", SWH_MRIGASIRA);
  3781. PyModule_AddIntConstant(m, "ARIDRA", SWH_ARIDRA);
  3782. PyModule_AddIntConstant(m, "PUNARVASU", SWH_PUNARVASU);
  3783. PyModule_AddIntConstant(m, "PUSHYAMI", SWH_PUSHYAMI);
  3784. PyModule_AddIntConstant(m, "ASLESHA", SWH_ASLESHA);
  3785. PyModule_AddIntConstant(m, "MAKHA", SWH_MAKHA);
  3786. PyModule_AddIntConstant(m, "PUBBA", SWH_PUBBA);
  3787. PyModule_AddIntConstant(m, "UTTARA", SWH_UTTARA);
  3788. PyModule_AddIntConstant(m, "HASTA", SWH_HASTA);
  3789. PyModule_AddIntConstant(m, "CHITTA", SWH_CHITTA);
  3790. PyModule_AddIntConstant(m, "SWATHI", SWH_SWATHI);
  3791. PyModule_AddIntConstant(m, "VISHAKA", SWH_VISHAKA);
  3792. PyModule_AddIntConstant(m, "ANURADHA", SWH_ANURADHA);
  3793. PyModule_AddIntConstant(m, "JYESTA", SWH_JYESTA);
  3794. PyModule_AddIntConstant(m, "MOOLA", SWH_MOOLA);
  3795. PyModule_AddIntConstant(m, "POORVASHADA", SWH_POORVASHADA);
  3796. PyModule_AddIntConstant(m, "UTTARASHADA", SWH_UTTARASHADA);
  3797. PyModule_AddIntConstant(m, "SRAVANA", SWH_SRAVANA);
  3798. PyModule_AddIntConstant(m, "DHANISHTA", SWH_DHANISHTA);
  3799. PyModule_AddIntConstant(m, "SATABISHA", SWH_SATABISHA);
  3800. PyModule_AddIntConstant(m, "POORVABHADRA", SWH_POORVABHADRA);
  3801. PyModule_AddIntConstant(m, "UTTARABHADRA", SWH_UTTARABHADRA);
  3802. PyModule_AddIntConstant(m, "REVATHI", SWH_REVATHI);
  3803. #endif /* PYSWE_USE_SWEPHELP */
  3804. PyModule_AddIntConstant(m, "__version__", PYSWISSEPH_VERSION);
  3805. PyModule_AddStringConstant(m, "version", swe_version(buf));
  3806. if (PyErr_Occurred())
  3807. Py_FatalError("Can't initialize module swisseph!");
  3808. #if PYSWE_AUTO_SET_EPHE_PATH
  3809. /* Automaticly set ephemeris path on module import */
  3810. swe_set_ephe_path(PYSWE_DEFAULT_EPHE_PATH);
  3811. #endif /* PYSWE_AUTO_SET_EPHE_PATH */
  3812. #if PY_MAJOR_VERSION >= 3
  3813. return m;
  3814. #endif
  3815. }
  3816. /* vi: set ai et sw=4 sts=4: */