/* set directory path of ephemeris files */ static PyObject* astrology_swe_set_ephe_path(PyObject *self, PyObject *args) { char* path; if (!PyArg_ParseTuple(args, "s", &path)) return NULL; swe_set_ephe_path(path); Py_INCREF(Py_None); return Py_None; }
char *placalc_set_ephepath(char *path) { static char *epath; if (path == NULL) return epath; if (epath != NULL) free((void *) epath); epath = malloc(strlen(path) + 1); if (epath != NULL) { strcpy(epath, path); swe_set_ephe_path(epath); } return epath; }
SweWrapper::SweWrapper(const std::string& path) { swe_set_ephe_path((char *)path.c_str()); }
int main() { swe_set_ephe_path("./SWEP/"); char snam[40], serr[AS_MAXCH]; int jday = 07, jmon = 11, jyear = 1964; int ora = 23; int min = 3; double jut = ora + min / 60; static double geopos[3], armc; /* Alessandra 44°54′48″N 8°37′12″E 95m */ top_long = 44.916; top_lat = 8.616; top_elev = 95; /* Milano 45°27′50.98″N 9°11′25.21″E 122m */ /* top_long = 45.464; top_lat = 9.19; top_elev = 122;a */ geopos[0] = top_long; geopos[1] = top_lat; geopos[2] = top_elev; swe_set_topo(top_long, top_lat, top_elev); double tjd, te, x2[6]; int32 iflag, iflgret; int p; iflag = SEFLG_SPEED; /* * we have day, month and year and convert to Julian day number */ tjd = swe_julday(jyear,jmon,jday,jut,SE_GREG_CAL); /* * compute Ephemeris time from Universal time by adding delta_t */ te = tjd + swe_deltat(tjd); printf("date: %02d.%02d.%d at %02d:%02d Universal time\n", jday, jmon, jyear, ora, min); printf("planet \tlongitude\tlatitude\tdistance\tspeed long.\n"); /* * a loop over all planets */ for (p = SE_SUN; p <= SE_SATURN; p++) { if (p == SE_EARTH) continue; /* * do the coordinate calculation for this planet p */ iflgret = swe_calc(te, p, iflag, x2, serr); /* * if there is a problem, a negative value is returned and an * errpr message is in serr. */ if (iflgret < 0) printf("error: %s\n", serr); else if (iflgret != iflag) printf("warning: iflgret != iflag. %s\n", serr); /* * get the name of the planet p */ swe_get_planet_name(p, snam); /* * print the coordinates */ printf("%10s\t%11.7f\t%10.7f\t%10.7f\t%10.7f\n", snam, x2[0], x2[1], x2[2], x2[3]); } /* iflag = SEFLG_SWIEPH | SEFLG_SPEED | SEFLG_EQUATORIAL; */ iflag = SEFLG_SPEED | SEFLG_EQUATORIAL; printf("planet \tasc retta \tdeclinazione\n"); /* * a loop over all planets */ for (p = SE_SUN; p <= SE_SATURN; p++) { if (p == SE_EARTH) continue; /* * do the coordinate calculation for this planet p */ iflgret = swe_calc(te, p, iflag, x2, serr); /* * if there is a problem, a negative value is returned and an * errpr message is in serr. */ if (iflgret < 0) printf("error: %s\n", serr); else if (iflgret != iflag) printf("warning: iflgret != iflag. %s\n", serr); /* * get the name of the planet p */ swe_get_planet_name(p, snam); /* * print the coordinates */ printf("%10s\t%11.3f\t%10.3f\n", snam, x2[0], x2[1]); } return OK; }
/* * Set directory path of ephemeris files * http://www.astro.com/swisseph/swephprg.htm#_Toc283735481 * int swe_set_ephe_path(char *path); */ static VALUE t_swe_set_ephe_path(VALUE self, VALUE path) { swe_set_ephe_path(StringValuePtr(path)); return Qnil; }