Module: Swe4r

Defined in:
ext/swe4r/swe4r.c

Constant Summary collapse

SE_SUN =

Constants

INT2FIX(SE_SUN)
SE_MOON =
INT2FIX(SE_MOON)
SE_MERCURY =
INT2FIX(SE_MERCURY)
SE_VENUS =
INT2FIX(SE_VENUS)
SE_MARS =
INT2FIX(SE_MARS)
SE_JUPITER =
INT2FIX(SE_JUPITER)
SE_SATURN =
INT2FIX(SE_SATURN)
SE_URANUS =
INT2FIX(SE_URANUS)
SE_NEPTUNE =
INT2FIX(SE_NEPTUNE)
SE_PLUTO =
INT2FIX(SE_PLUTO)
SE_MEAN_NODE =
INT2FIX(SE_MEAN_NODE)
SE_TRUE_NODE =
INT2FIX(SE_TRUE_NODE)
SE_MEAN_APOG =
INT2FIX(SE_MEAN_APOG)
SE_OSCU_APOG =
INT2FIX(SE_OSCU_APOG)
SE_EARTH =
INT2FIX(SE_EARTH)
SE_CHIRON =
INT2FIX(SE_CHIRON)
SE_PHOLUS =
INT2FIX(SE_PHOLUS)
SE_CERES =
INT2FIX(SE_CERES)
SE_PALLAS =
INT2FIX(SE_PALLAS)
SE_JUNO =
INT2FIX(SE_JUNO)
SE_VESTA =
INT2FIX(SE_VESTA)
SE_INTP_APOG =
INT2FIX(SE_INTP_APOG)
SE_INTP_PERG =
INT2FIX(SE_INTP_PERG)
SEFLG_JPLEPH =
INT2FIX(SEFLG_JPLEPH)
SEFLG_SWIEPH =
INT2FIX(SEFLG_SWIEPH)
SEFLG_MOSEPH =
INT2FIX(SEFLG_MOSEPH)
SEFLG_HELCTR =
INT2FIX(SEFLG_HELCTR)
SEFLG_TRUEPOS =
INT2FIX(SEFLG_TRUEPOS)
SEFLG_J2000 =
INT2FIX(SEFLG_J2000)
SEFLG_NONUT =
INT2FIX(SEFLG_NONUT)
SEFLG_SPEED3 =
INT2FIX(SEFLG_SPEED3)
SEFLG_SPEED =
INT2FIX(SEFLG_SPEED)
SEFLG_NOGDEFL =
INT2FIX(SEFLG_NOGDEFL)
SEFLG_NOABERR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M_SASSANIAN)
SE_SIDM_GALCENT_0SAG =
INT2FIX(SE_SIDM_GALCENT_0SAG)
SE_SIDM_J2000 =
INT2FIX(SE_SIDM_J2000)
SE_SIDM_J1900 =
INT2FIX(SE_SIDM_J1900)
SE_SIDM_B1950 =
INT2FIX(SE_SIDM_B1950)
SE_SIDM_USER =
INT2FIX(SE_SIDM_USER)

Class Method Summary collapse

Class Method Details

.swe_calc_ut(julian_ut, body, iflag) ⇒ Object

Calculation of planets, moon, asteroids, lunar nodes, apogees, fictitious bodies www.astro.com/swisseph/swephprg.htm#_Toc283735419 long swe_calc_ut( double tjd_ut, // Julian day number, Universal Time int ipl, // planet number long iflag, // flag bits double *xx, // target address for 6 position values: longitude, latitude, distance, long.speed, lat.speed, dist.speed char *serr // 256 bytes for error string );



161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'ext/swe4r/swe4r.c', line 161

static VALUE t_swe_calc_ut(VALUE self, VALUE julian_ut, VALUE body, VALUE iflag) {
	double results[6];
	char serr[AS_MAXCH];
	VALUE arr = rb_ary_new();
	int id_push = rb_intern("push");
	int i=0;
	
	if ( swe_calc_ut(NUM2DBL(julian_ut), NUM2INT(body), NUM2LONG(iflag), results,  serr) < 0 )
		rb_raise (rb_eRuntimeError, serr);
	
	for ( i = 0; i < 6; i++)
		rb_funcall(arr, id_push, 1, rb_float_new(results[i]));
	
	return arr;
}

.swe_fixstar_ut(star, julian_ut, iflag) ⇒ Object

Compute fixed stars www.astro.com/swisseph/swephprg.htm#_Toc354479413 long swe_fixstar_ut( char* star, // The traditional name, nomenclature name, or line number of star in fixstars.cat (see modes below for further details) double tjd_ut, // Julian day number, Universal Time long iflag, // flag bits double* xx, // target address for 6 position values: longitude, latitude, distance, long.speed, lat.speed, dist.speed char* serr // 256 bytes for error string );

The function has three modes to search for a star in the file fixstars.cat: · star contains a positive number ( in ASCII string format, e.g. “234”): The 234-th non-comment line in the file fixstars.cat is used. Comment lines begin with # and are ignored. · star contains a traditional name: the first star in the file fixstars.cat is used whose traditional name fits the given name. All names are mapped to lower case before comparison. If star has n characters, only the first n characters of the traditional name field are compared. If a comma appears after a non-zero-length traditional name, the traditional name is cut off at the comma before the search. This allows the reuse of the returned star name from a previous call in the next call. · starbegins with a comma, followed by a nomenclature name, e.g. “,alTau”: the star with this name in the nomenclature field ( the second field ) is returned. Letter case is observed in the comparison for nomenclature names.



193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# File 'ext/swe4r/swe4r.c', line 193

static VALUE t_swe_fixstar_ut(VALUE self, VALUE star, VALUE julian_ut, VALUE iflag) {
	double results[6];
	char serr[AS_MAXCH];
	VALUE arr = rb_ary_new();
	int id_push = rb_intern("push");
	int i=0;
	
	if ( swe_fixstar_ut(StringValuePtr(star), NUM2DBL(julian_ut), NUM2LONG(iflag), results,  serr) < 0 )
		rb_raise (rb_eRuntimeError, serr);
	
	for ( i = 0; i < 6; i++)
		rb_funcall(arr, id_push, 1, rb_float_new(results[i]));
	
	return arr;
	
}

.swe_get_ayanamsa_ut(julian_ut) ⇒ Object

This function computes the ayanamsha, the distance of the tropical vernal point from the sidereal zero point of the zodiac. The ayanamsha is used to compute sidereal planetary positions from tropical ones: pos_sid = pos_trop – ayanamsha Before calling swe_get_ayanamsha(), you have to set the sidereal mode with swe_set_sid_mode, unless you want the default sidereal mode, which is the Fagan/Bradley ayanamsha. www.astro.com/swisseph/swephprg.htm#_Toc283735479 double swe_get_ayanamsa_ut(double tjd_ut);



233
234
235
236
# File 'ext/swe4r/swe4r.c', line 233

static VALUE t_swe_get_ayanamsa_ut(VALUE self, VALUE julian_ut) {
	double ayanamsa = swe_get_ayanamsa_ut(NUM2DBL(julian_ut));
	return rb_float_new(ayanamsa);
}

.swe_houses(julian_day, latitude, longitude, house_system) ⇒ Object

This function computes house cusps, ascendant, midheaven, etc www.astro.com/swisseph/swephprg.htm#_Toc283735486 int swe_houses( double tjd_ut, // Julian day number, UT double geolat, // geographic latitude, in degrees double geolon, // geographic longitude, in degrees (eastern longitude is positive, western longitude is negative, northern latitude is positive, southern latitude is negative int hsys, // house method, ascii code of one of the letters PKORCAEVXHTBG double *cusps, // array for 13 doubles double *ascmc // array for 10 doubles ); House method codes… ‘P’ = Placidus ‘K’ = Koch ‘O’ = Porphyrius ‘R’ = Regiomontanus ‘C’ = Campanus ‘A’ or ‘E’ = Equal (cusp 1 is Ascendant) ‘V’ = Vehlow equal (Asc. in middle of house 1) ‘W’ = Whole sign ‘X’ = axial rotation system ‘H’ = azimuthal or horizontal system ‘T’ = Polich/Page (“topocentric” system) ‘B’ = Alcabitus ‘M’ = Morinus ‘U’ = Krusinski-Pisa ‘G’ = Gauquelin sectors



266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
# File 'ext/swe4r/swe4r.c', line 266

static VALUE t_swe_houses(VALUE self, VALUE julian_day, VALUE latitude, VALUE longitude, VALUE house_system)
{
	double cusps[13];
	double ascmc[10];
	char serr[AS_MAXCH];
	VALUE arr = rb_ary_new();
	int id_push = rb_intern("push");
	int i =0;
	
	if ( swe_houses(NUM2DBL(julian_day), NUM2DBL(latitude), NUM2DBL(longitude), NUM2CHR(house_system), cusps, ascmc) < 0 )
		rb_raise (rb_eRuntimeError, serr);
	
	for ( i = 0; i < 13; i++)
		rb_funcall(arr, id_push, 1, rb_float_new(cusps[i]));
	
	for ( i = 0; i < 10; i++)
		rb_funcall(arr, id_push, 1, rb_float_new(ascmc[i]));
	
	return arr;
}

.swe_julday(year, month, day, hour) ⇒ Object

Get the Julian day number from year, month, day, hour www.astro.com/swisseph/swephprg.htm#_Toc283735468 double swe_julday( int year, int month, int day, double hour, int gregflag // Gregorian calendar: 1, Julian calendar: 0 );



129
130
131
132
133
# File 'ext/swe4r/swe4r.c', line 129

static VALUE t_swe_julday(VALUE self, VALUE year, VALUE month, VALUE day, VALUE hour)
{
	double julday = swe_julday( NUM2INT(year), NUM2INT(month), NUM2INT(day), NUM2DBL(hour), SE_GREG_CAL );
	return rb_float_new(julday);
}

.swe_set_ephe_path(path) ⇒ Object

Set directory path of ephemeris files www.astro.com/swisseph/swephprg.htm#_Toc283735481 int swe_set_ephe_path(char *path);



112
113
114
115
116
# File 'ext/swe4r/swe4r.c', line 112

static VALUE t_swe_set_ephe_path(VALUE self, VALUE path)
{
	swe_set_ephe_path(StringValuePtr(path));
	return Qnil;
}

.swe_set_sid_mode(mode, t0, ayan_t0) ⇒ Object

This function can be used to specify the mode for sidereal computations www.astro.com/swisseph/swephprg.htm#_Toc283735478 void swe_set_sid_mode ( int32 sid_mode, // Mode double t0, // Reference date double ayan_t0 // Initial value of the ayanamsha );



220
221
222
223
# File 'ext/swe4r/swe4r.c', line 220

static VALUE t_swe_set_sid_mode(VALUE self, VALUE mode, VALUE t0, VALUE ayan_t0) {
	swe_set_sid_mode(NUM2INT(mode), NUM2DBL(t0), NUM2DBL(ayan_t0));
	return Qnil;
}

.swe_set_topo(lon, lat, alt) ⇒ Object

Set the geographic location for topocentric planet computation The longitude and latitude must be in degrees, the altitude in meters. www.astro.com/swisseph/swephprg.htm#_Toc283735476 void swe_set_topo ( double geolon, // geographic longitude: eastern longitude is positive, western longitude is negative double geolat, // geographic latitude: northern latitude is positive, southern latitude is negative double altitude // altitude above sea );



145
146
147
148
# File 'ext/swe4r/swe4r.c', line 145

static VALUE t_swe_set_topo(VALUE self, VALUE lon, VALUE lat, VALUE alt) {
	swe_set_topo(NUM2DBL(lon),NUM2DBL(lat),NUM2DBL(alt));
	return Qnil;
}