Module: Swisseph

Defined in:
lib/swisseph.rb,
lib/swisseph.rb,
ext/swisseph/swisseph.c

Constant Summary collapse

LOCK =

The Swiss Ephemeris C library (libswe) keeps process-global state and a shared file descriptor for its data files, so it is NOT thread-safe: two threads executing inside it at once can segfault the process. Every native call is serialized through one global re-entrant lock so concurrent threads -- e.g. a multi-threaded Puma app plus in-process background workers -- can never be inside libswe simultaneously. A single-threaded caller never contends for the lock; concurrent callers are serialized (a brief wait, not a segfault).

Monitor.new
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_CUPIDO =
INT2FIX(SE_CUPIDO)
SE_HADES =
INT2FIX(SE_HADES)
SE_ZEUS =
INT2FIX(SE_ZEUS)
SE_KRONOS =
INT2FIX(SE_KRONOS)
SE_APOLLON =
INT2FIX(SE_APOLLON)
SE_ADMETOS =
INT2FIX(SE_ADMETOS)
SE_VULKANUS =
INT2FIX(SE_VULKANUS)
SE_POSEIDON =
INT2FIX(SE_POSEIDON)
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 =
INT2FIX(SEFLG_NOABERR)
SEFLG_EQUATORIAL =
INT2FIX(SEFLG_EQUATORIAL)
SEFLG_XYZ =
INT2FIX(SEFLG_XYZ)
SEFLG_RADIANS =
INT2FIX(SEFLG_RADIANS)
SEFLG_BARYCTR =
INT2FIX(SEFLG_BARYCTR)
SEFLG_TOPOCTR =
INT2FIX(SEFLG_TOPOCTR)
SEFLG_SIDEREAL =
INT2FIX(SEFLG_SIDEREAL)
SEFLG_ICRS =
INT2FIX(SEFLG_ICRS)
SE_SIDM_FAGAN_BRADLEY =

0

INT2FIX(SE_SIDM_FAGAN_BRADLEY)
SE_SIDM_LAHIRI =

0

INT2FIX(SE_SIDM_LAHIRI)
SE_SIDM_DELUCE =
INT2FIX(SE_SIDM_DELUCE)
SE_SIDM_RAMAN =
INT2FIX(SE_SIDM_RAMAN)
SE_SIDM_USHASHASHI =
INT2FIX(SE_SIDM_USHASHASHI)
SE_SIDM_KRISHNAMURTI =
INT2FIX(SE_SIDM_KRISHNAMURTI)
SE_SIDM_DJWHAL_KHUL =
INT2FIX(SE_SIDM_DJWHAL_KHUL)
SE_SIDM_YUKTESHWAR =
INT2FIX(SE_SIDM_YUKTESHWAR)
SE_SIDM_JN_BHASIN =
INT2FIX(SE_SIDM_JN_BHASIN)
SE_SIDM_BABYL_KUGLER1 =
INT2FIX(SE_SIDM_BABYL_KUGLER1)
SE_SIDM_BABYL_KUGLER2 =
INT2FIX(SE_SIDM_BABYL_KUGLER2)
SE_SIDM_BABYL_KUGLER3 =
INT2FIX(SE_SIDM_BABYL_KUGLER3)
SE_SIDM_BABYL_HUBER =
INT2FIX(SE_SIDM_BABYL_HUBER)
SE_SIDM_BABYL_ETPSC =
INT2FIX(SE_SIDM_BABYL_ETPSC)
SE_SIDM_ALDEBARAN_15TAU =
INT2FIX(SE_SIDM_ALDEBARAN_15TAU)
SE_SIDM_HIPPARCHOS =
INT2FIX(SE_SIDM_HIPPARCHOS)
SE_SIDM_SASSANIAN =
INT2FIX(SE_SIDM_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_SURYASIDDHANTA =
INT2FIX(SE_SIDM_SURYASIDDHANTA)
SE_SIDM_SURYASIDDHANTA_MSUN =
INT2FIX(SE_SIDM_SURYASIDDHANTA_MSUN)
SE_SIDM_ARYABHATA =
INT2FIX(SE_SIDM_ARYABHATA)
SE_SIDM_ARYABHATA_MSUN =
INT2FIX(SE_SIDM_ARYABHATA_MSUN)
SE_SIDM_SS_REVATI =
INT2FIX(SE_SIDM_SS_REVATI)
SE_SIDM_SS_CITRA =
INT2FIX(SE_SIDM_SS_CITRA)
SE_SIDM_TRUE_CITRA =
INT2FIX(SE_SIDM_TRUE_CITRA)
SE_SIDM_TRUE_REVATI =
INT2FIX(SE_SIDM_TRUE_REVATI)
SE_SIDM_TRUE_PUSHYA =
INT2FIX(SE_SIDM_TRUE_PUSHYA)
SE_SIDM_GALCENT_RGILBRAND =
INT2FIX(SE_SIDM_GALCENT_RGILBRAND)
SE_SIDM_GALEQU_IAU1958 =
INT2FIX(SE_SIDM_GALEQU_IAU1958)
SE_SIDM_GALEQU_TRUE =
INT2FIX(SE_SIDM_GALEQU_TRUE)
SE_SIDM_GALEQU_MULA =
INT2FIX(SE_SIDM_GALEQU_MULA)
SE_SIDM_GALALIGN_MARDYKS =
INT2FIX(SE_SIDM_GALALIGN_MARDYKS)
SE_SIDM_TRUE_MULA =
INT2FIX(SE_SIDM_TRUE_MULA)
SE_SIDM_GALCENT_MULA_WILHELM =
INT2FIX(SE_SIDM_GALCENT_MULA_WILHELM)
SE_SIDM_ARYABHATA_522 =
INT2FIX(SE_SIDM_ARYABHATA_522)
SE_SIDM_BABYL_BRITTON =
INT2FIX(SE_SIDM_BABYL_BRITTON)
SE_SIDM_TRUE_SHEORAN =
INT2FIX(SE_SIDM_TRUE_SHEORAN)
SE_SIDM_GALCENT_COCHRANE =
INT2FIX(SE_SIDM_GALCENT_COCHRANE)
SE_SIDM_GALEQU_FIORENZA =
INT2FIX(SE_SIDM_GALEQU_FIORENZA)
SE_SIDM_VALENS_MOON =
INT2FIX(SE_SIDM_VALENS_MOON)
SE_SIDM_LAHIRI_1940 =
INT2FIX(SE_SIDM_LAHIRI_1940)
SE_SIDM_LAHIRI_VP285 =
INT2FIX(SE_SIDM_LAHIRI_VP285)
SE_SIDM_KRISHNAMURTI_VP291 =
INT2FIX(SE_SIDM_KRISHNAMURTI_VP291)
SE_SIDM_LAHIRI_ICRC =

46

INT2FIX(SE_SIDM_LAHIRI_ICRC)
SE_SIDM_USER =

255

INT2FIX(SE_SIDM_USER)
SE_GREG_CAL =

255

INT2FIX(SE_GREG_CAL)
SE_JUL_CAL =
INT2FIX(SE_JUL_CAL)
SE_ECL2HOR =
INT2FIX(SE_ECL2HOR)
SE_EQU2HOR =
INT2FIX(SE_EQU2HOR)
SE_NODBIT_MEAN =
INT2FIX(SE_NODBIT_MEAN)
SE_NODBIT_OSCU =
INT2FIX(SE_NODBIT_OSCU)
SE_NODBIT_OSCU_BAR =
INT2FIX(SE_NODBIT_OSCU_BAR)
SE_NODBIT_FOPOINT =
INT2FIX(SE_NODBIT_FOPOINT)
SE_CALC_RISE =
INT2FIX(SE_CALC_RISE)
SE_CALC_SET =
INT2FIX(SE_CALC_SET)
SE_CALC_MTRANSIT =
INT2FIX(SE_CALC_MTRANSIT)
SE_CALC_ITRANSIT =
INT2FIX(SE_CALC_ITRANSIT)
SE_BIT_DISC_CENTER =
INT2FIX(SE_BIT_DISC_CENTER)
SE_BIT_DISC_BOTTOM =
INT2FIX(SE_BIT_DISC_BOTTOM)
SE_BIT_GEOCTR_NO_ECL_LAT =
INT2FIX(SE_BIT_GEOCTR_NO_ECL_LAT)
SE_BIT_NO_REFRACTION =
INT2FIX(SE_BIT_NO_REFRACTION)
SE_BIT_CIVIL_TWILIGHT =
INT2FIX(SE_BIT_CIVIL_TWILIGHT)
SE_BIT_NAUTIC_TWILIGHT =
INT2FIX(SE_BIT_NAUTIC_TWILIGHT)
SE_BIT_ASTRO_TWILIGHT =
INT2FIX(SE_BIT_ASTRO_TWILIGHT)
SE_BIT_FIXED_DISC_SIZE =
INT2FIX(SE_BIT_FIXED_DISC_SIZE)
SE_BIT_HINDU_RISING =
INT2FIX(SE_BIT_HINDU_RISING)
SE_HOR2ECL =

for swe_azalt_rev()

INT2FIX(SE_HOR2ECL)
SE_HOR2EQU =
INT2FIX(SE_HOR2EQU)
SE_TRUE_TO_APP =

for swe_refrac()

INT2FIX(SE_TRUE_TO_APP)
SE_APP_TO_TRUE =
INT2FIX(SE_APP_TO_TRUE)
SE_SPLIT_DEG_ROUND_SEC =

for swe_split_deg()

INT2FIX(SE_SPLIT_DEG_ROUND_SEC)
SE_SPLIT_DEG_ROUND_MIN =
INT2FIX(SE_SPLIT_DEG_ROUND_MIN)
SE_SPLIT_DEG_ROUND_DEG =
INT2FIX(SE_SPLIT_DEG_ROUND_DEG)
SE_SPLIT_DEG_ZODIACAL =
INT2FIX(SE_SPLIT_DEG_ZODIACAL)
SE_SPLIT_DEG_NAKSHATRA =
INT2FIX(SE_SPLIT_DEG_NAKSHATRA)
SE_SPLIT_DEG_KEEP_SIGN =
INT2FIX(SE_SPLIT_DEG_KEEP_SIGN)
SE_SPLIT_DEG_KEEP_DEG =
INT2FIX(SE_SPLIT_DEG_KEEP_DEG)
SE_ECL_CENTRAL =

for eclipse functions

INT2FIX(SE_ECL_CENTRAL)
SE_ECL_NONCENTRAL =
INT2FIX(SE_ECL_NONCENTRAL)
SE_ECL_TOTAL =
INT2FIX(SE_ECL_TOTAL)
SE_ECL_ANNULAR =
INT2FIX(SE_ECL_ANNULAR)
SE_ECL_PARTIAL =
INT2FIX(SE_ECL_PARTIAL)
SE_ECL_ANNULAR_TOTAL =
INT2FIX(SE_ECL_ANNULAR_TOTAL)
SE_ECL_HYBRID =
INT2FIX(SE_ECL_HYBRID)
SE_ECL_PENUMBRAL =
INT2FIX(SE_ECL_PENUMBRAL)
SE_ECL_ALLTYPES_SOLAR =
INT2FIX(SE_ECL_ALLTYPES_SOLAR)
SE_ECL_ALLTYPES_LUNAR =
INT2FIX(SE_ECL_ALLTYPES_LUNAR)
SE_ECL_VISIBLE =
INT2FIX(SE_ECL_VISIBLE)
SE_ECL_MAX_VISIBLE =
INT2FIX(SE_ECL_MAX_VISIBLE)
SE_ECL_1ST_VISIBLE =
INT2FIX(SE_ECL_1ST_VISIBLE)
SE_ECL_2ND_VISIBLE =
INT2FIX(SE_ECL_2ND_VISIBLE)
SE_ECL_3RD_VISIBLE =
INT2FIX(SE_ECL_3RD_VISIBLE)
SE_ECL_4TH_VISIBLE =
INT2FIX(SE_ECL_4TH_VISIBLE)
SE_ECL_ONE_TRY =
INT2FIX(SE_ECL_ONE_TRY)
SE_HELIACAL_RISING =

for heliacal functions

INT2FIX(SE_HELIACAL_RISING)
SE_HELIACAL_SETTING =
INT2FIX(SE_HELIACAL_SETTING)
SE_MORNING_FIRST =
INT2FIX(SE_MORNING_FIRST)
SE_EVENING_LAST =
INT2FIX(SE_EVENING_LAST)
SE_EVENING_FIRST =
INT2FIX(SE_EVENING_FIRST)
SE_MORNING_LAST =
INT2FIX(SE_MORNING_LAST)
SE_HELFLAG_LONG_SEARCH =
INT2FIX(SE_HELFLAG_LONG_SEARCH)
SE_HELFLAG_HIGH_PRECISION =
INT2FIX(SE_HELFLAG_HIGH_PRECISION)
SE_HELFLAG_OPTICAL_PARAMS =
INT2FIX(SE_HELFLAG_OPTICAL_PARAMS)
SE_HELFLAG_NO_DETAILS =
INT2FIX(SE_HELFLAG_NO_DETAILS)

Class Method Summary collapse

Class Method Details

.swe_azalt(julian_day, flag, lon, lat, height, pressure, temp, in0, in1, in2) ⇒ Object



687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
# File 'ext/swisseph/swisseph.c', line 687

static VALUE t_swe_azalt(VALUE self, VALUE julian_day, VALUE flag, VALUE lon, VALUE lat, VALUE height, VALUE pressure, VALUE temp, VALUE in0, VALUE in1, VALUE in2)
{
	double geopos[3];
	geopos[0] = NUM2DBL(lon);
	geopos[1] = NUM2DBL(lat);
	geopos[2] = NUM2DBL(height);

	double xin[3];
	xin[0] = NUM2DBL(in0);
	xin[1] = NUM2DBL(in1);
	xin[2] = NUM2DBL(in2);
	double xaz[3];

	swe_azalt(NUM2DBL(julian_day), NUM2INT(flag), geopos, NUM2DBL(pressure), NUM2DBL(temp), xin, xaz);

	VALUE output = rb_ary_new();
	rb_ary_push(output, rb_float_new(xaz[0]));
	rb_ary_push(output, rb_float_new(xaz[1]));
	rb_ary_push(output, rb_float_new(xaz[2]));
	return output;
}

.swe_azalt_rev(julian_day, flag, lon, lat, height, azimuth, altitude) ⇒ Object



716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
# File 'ext/swisseph/swisseph.c', line 716

static VALUE t_swe_azalt_rev(VALUE self, VALUE julian_day, VALUE flag, VALUE lon, VALUE lat, VALUE height, VALUE azimuth, VALUE altitude)
{
	double geopos[3];
	geopos[0] = NUM2DBL(lon);
	geopos[1] = NUM2DBL(lat);
	geopos[2] = NUM2DBL(height);

	double xin[2];
	xin[0] = NUM2DBL(azimuth);
	xin[1] = NUM2DBL(altitude);
	double xout[2];

	swe_azalt_rev(NUM2DBL(julian_day), NUM2INT(flag), geopos, xin, xout);

	VALUE output = rb_ary_new();
	rb_ary_push(output, rb_float_new(xout[0]));
	rb_ary_push(output, rb_float_new(xout[1]));
	return output;
}

.swe_calc(julian_et, body, iflag) ⇒ Object

Calculation of planets, moon, asteroids, etc. (ET/TT version) int32 swe_calc(double tjd_et, int ipl, int32 iflag, double *xx, char *serr);



265
266
267
268
269
270
271
272
273
274
275
276
277
278
# File 'ext/swisseph/swisseph.c', line 265

static VALUE t_swe_calc(VALUE self, VALUE julian_et, VALUE body, VALUE iflag)
{
	double results[6];
	char serr[AS_MAXCH];

	if (swe_calc(NUM2DBL(julian_et), NUM2INT(body), NUM2LONG(iflag), results, serr) < 0)
		rb_raise(rb_eRuntimeError, "%s", serr);

	VALUE output = rb_ary_new();
	for (int i = 0; i < 6; i++)
		rb_ary_push(output, rb_float_new(results[i]));

	return output;
}

.swe_calc_pctr(julian_et, body, center, iflag) ⇒ Object



1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
# File 'ext/swisseph/swisseph.c', line 1129

static VALUE t_swe_calc_pctr(VALUE self, VALUE julian_et, VALUE body, VALUE center, VALUE iflag)
{
	char serr[AS_MAXCH];
	double xxret[6];

	if (swe_calc_pctr(NUM2DBL(julian_et), NUM2INT(body), NUM2INT(center), NUM2INT(iflag), xxret, serr) < 0)
		rb_raise(rb_eRuntimeError, "%s", serr);

	VALUE output = rb_ary_new();
	for (int i = 0; i < 6; i++)
		rb_ary_push(output, rb_float_new(xxret[i]));

	return output;
}

.swe_calc_ut(julian_ut, body, iflag) ⇒ Object



246
247
248
249
250
251
252
253
254
255
256
257
258
259
# File 'ext/swisseph/swisseph.c', line 246

static VALUE t_swe_calc_ut(VALUE self, VALUE julian_ut, VALUE body, VALUE iflag)
{
	double results[6];
	char serr[AS_MAXCH];

	if (swe_calc_ut(NUM2DBL(julian_ut), NUM2INT(body), NUM2LONG(iflag), results, serr) < 0)
		rb_raise(rb_eRuntimeError, "%s", serr);

	VALUE output = rb_ary_new();
	for (int i = 0; i < 6; i++)
		rb_ary_push(output, rb_float_new(results[i]));

	return output;
}

.swe_closeObject



55
56
57
58
59
# File 'ext/swisseph/swisseph.c', line 55

static VALUE t_swe_close(VALUE self)
{
	swe_close();
	return Qnil;
}

.swe_cotrans(*args) ⇒ Object



827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
# File 'ext/swisseph/swisseph.c', line 827

static VALUE t_swe_cotrans(int argc, VALUE *argv, VALUE self)
{
	// VALUE self, VALUE VALUE lon, VALUE lat, VALUE distance
	if (argc < 3 || argc > 4)
	{ // there should only be 3 or 4 arguments
		rb_raise(rb_eArgError, "wrong number of arguments");
	}
	double eps = NUM2DBL(argv[0]);
	double xpo[3];
	xpo[0] = NUM2DBL(argv[1]); // NUM2DBL(lon);
	xpo[1] = NUM2DBL(argv[2]); // NUM2DBL(lat);
	xpo[2] = NUM2DBL((argc == 4) ? argv[3] : 1.0);

	double xpn[3];

	swe_cotrans(xpo, xpn, eps);

	VALUE output = rb_ary_new();
	rb_ary_push(output, rb_float_new(xpn[0]));
	rb_ary_push(output, rb_float_new(xpn[1]));
	if (argc == 4)
		rb_ary_push(output, rb_float_new(xpn[2]));
	return output;
}

.swe_cotrans_sp(eps, lon, lat, dist, lon_speed, lat_speed, dist_speed) ⇒ Object



858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
# File 'ext/swisseph/swisseph.c', line 858

static VALUE t_swe_cotrans_sp(VALUE self, VALUE eps, VALUE lon, VALUE lat, VALUE dist, VALUE lon_speed, VALUE lat_speed, VALUE dist_speed)
{
	double xpo[6];
	xpo[0] = NUM2DBL(lon);
	xpo[1] = NUM2DBL(lat);
	xpo[2] = NUM2DBL(dist);
	xpo[3] = NUM2DBL(lon_speed);
	xpo[4] = NUM2DBL(lat_speed);
	xpo[5] = NUM2DBL(dist_speed);

	double xpn[6];

	swe_cotrans_sp(xpo, xpn, NUM2DBL(eps));

	VALUE output = rb_ary_new();
	for (int i = 0; i < 6; i++)
		rb_ary_push(output, rb_float_new(xpn[i]));
	return output;
}

.swe_day_of_week(jd) ⇒ Object



214
215
216
217
# File 'ext/swisseph/swisseph.c', line 214

static VALUE t_swe_day_of_week(VALUE self, VALUE jd)
{
	return INT2NUM(swe_day_of_week(NUM2DBL(jd)));
}

.swe_degnorm(deg) ⇒ Object



300
301
302
303
# File 'ext/swisseph/swisseph.c', line 300

static VALUE t_swe_degnorm(VALUE self, VALUE deg)
{
	return rb_float_new(swe_degnorm(NUM2DBL(deg)));
}

.swe_deltat(julian_ut) ⇒ Object



1193
1194
1195
1196
1197
# File 'ext/swisseph/swisseph.c', line 1193

static VALUE t_swe_deltat(VALUE self, VALUE julian_ut)
{
	double delta_t = swe_deltat(NUM2DBL(julian_ut));
	return rb_float_new(delta_t);
}

.swe_deltat_ex(julian_ut, iflag) ⇒ Object



1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
# File 'ext/swisseph/swisseph.c', line 1204

static VALUE t_swe_deltat_ex(VALUE self, VALUE julian_ut, VALUE iflag)
{
	char serr[AS_MAXCH];
	double delta_t = swe_deltat_ex(NUM2DBL(julian_ut), NUM2INT(iflag), serr);

	// If there's an error message, return it along with the delta_t value
	if (serr[0] != '\0')
	{
		VALUE result = rb_ary_new();
		rb_ary_push(result, rb_float_new(delta_t));
		rb_ary_push(result, rb_str_new_cstr(serr));
		return result;
	}

	return rb_float_new(delta_t);
}

.swe_fixstar(star, julian_et, iflag) ⇒ Object



1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
# File 'ext/swisseph/swisseph.c', line 1221

static VALUE t_swe_fixstar(VALUE self, VALUE star, VALUE julian_et, VALUE iflag)
{
	char serr[AS_MAXCH];
	double results[6];

	if (swe_fixstar(StringValuePtr(star), NUM2DBL(julian_et), NUM2INT(iflag), results, serr) < 0)
		rb_raise(rb_eRuntimeError, "%s", serr);

	VALUE output = rb_ary_new();
	for (int i = 0; i < 6; i++)
		rb_ary_push(output, rb_float_new(results[i]));

	return output;
}

.swe_fixstar2(star, julian_et, iflag) ⇒ Object



1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
# File 'ext/swisseph/swisseph.c', line 1262

static VALUE t_swe_fixstar2(VALUE self, VALUE star, VALUE julian_et, VALUE iflag)
{
	char serr[AS_MAXCH];
	double results[6];

	if (swe_fixstar2(StringValuePtr(star), NUM2DBL(julian_et), NUM2INT(iflag), results, serr) < 0)
		rb_raise(rb_eRuntimeError, "%s", serr);

	VALUE output = rb_ary_new();
	for (int i = 0; i < 6; i++)
		rb_ary_push(output, rb_float_new(results[i]));

	return output;
}

.swe_fixstar2_mag(star) ⇒ Object



1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
# File 'ext/swisseph/swisseph.c', line 1292

static VALUE t_swe_fixstar2_mag(VALUE self, VALUE star)
{
	char serr[AS_MAXCH];
	double mag;

	if (swe_fixstar2_mag(StringValuePtr(star), &mag, serr) < 0)
		rb_raise(rb_eRuntimeError, "%s", serr);

	return rb_float_new(mag);
}

.swe_fixstar2_ut(star, julian_ut, iflag) ⇒ Object



1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
# File 'ext/swisseph/swisseph.c', line 1277

static VALUE t_swe_fixstar2_ut(VALUE self, VALUE star, VALUE julian_ut, VALUE iflag)
{
	char serr[AS_MAXCH];
	double results[6];

	if (swe_fixstar2_ut(StringValuePtr(star), NUM2DBL(julian_ut), NUM2INT(iflag), results, serr) < 0)
		rb_raise(rb_eRuntimeError, "%s", serr);

	VALUE output = rb_ary_new();
	for (int i = 0; i < 6; i++)
		rb_ary_push(output, rb_float_new(results[i]));

	return output;
}

.swe_fixstar_mag(star) ⇒ Object



1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
# File 'ext/swisseph/swisseph.c', line 1251

static VALUE t_swe_fixstar_mag(VALUE self, VALUE star)
{
	char serr[AS_MAXCH];
	double mag;

	if (swe_fixstar_mag(StringValuePtr(star), &mag, serr) < 0)
		rb_raise(rb_eRuntimeError, "%s", serr);

	return rb_float_new(mag);
}

.swe_fixstar_ut(star, julian_ut, iflag) ⇒ Object



1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
# File 'ext/swisseph/swisseph.c', line 1236

static VALUE t_swe_fixstar_ut(VALUE self, VALUE star, VALUE julian_ut, VALUE iflag)
{
	char serr[AS_MAXCH];
	double results[6];

	if (swe_fixstar_ut(StringValuePtr(star), NUM2DBL(julian_ut), NUM2INT(iflag), results, serr) < 0)
		rb_raise(rb_eRuntimeError, "%s", serr);

	VALUE output = rb_ary_new();
	for (int i = 0; i < 6; i++)
		rb_ary_push(output, rb_float_new(results[i]));

	return output;
}

.swe_gauquelin_sector(tjd_ut, body, iflag, imeth, lon, lat, height, atpress, attemp) ⇒ Object



1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
# File 'ext/swisseph/swisseph.c', line 1401

static VALUE t_swe_gauquelin_sector(VALUE self, VALUE tjd_ut, VALUE body, VALUE iflag, VALUE imeth, VALUE lon, VALUE lat, VALUE height, VALUE atpress, VALUE attemp)
{
	char serr[AS_MAXCH];
	double geopos[3];
	geopos[0] = NUM2DBL(lon);
	geopos[1] = NUM2DBL(lat);
	geopos[2] = NUM2DBL(height);
	double dgsect;
	int ipl;
	char *starname;

	if (TYPE(body) == T_STRING) {
		starname = StringValuePtr(body);
		ipl = 0;
	} else {
		ipl = NUM2INT(body);
		starname = NULL;
	}

	if (swe_gauquelin_sector(NUM2DBL(tjd_ut), ipl, starname, NUM2INT(iflag), NUM2INT(imeth), geopos, NUM2DBL(atpress), NUM2DBL(attemp), &dgsect, serr) < 0)
		rb_raise(rb_eRuntimeError, "%s", serr);

	return rb_float_new(dgsect);
}

.swe_get_ayanamsa(julian_et) ⇒ Object



369
370
371
372
373
# File 'ext/swisseph/swisseph.c', line 369

static VALUE t_swe_get_ayanamsa(VALUE self, VALUE julian_et)
{
	double ayanamsa = swe_get_ayanamsa(NUM2DBL(julian_et));
	return rb_float_new(ayanamsa);
}

.swe_get_ayanamsa_ex(julian_et, flag) ⇒ Object



402
403
404
405
406
407
408
409
410
411
# File 'ext/swisseph/swisseph.c', line 402

static VALUE t_swe_get_ayanamsa_ex(VALUE self, VALUE julian_et, VALUE flag)
{
	double ayanamsha;
	char serr[AS_MAXCH];

	if (swe_get_ayanamsa_ex(NUM2DBL(julian_et), NUM2INT(flag), &ayanamsha, serr) < 0)
		rb_raise(rb_eRuntimeError, "%s", serr);

	return rb_float_new(ayanamsha);
}

.swe_get_ayanamsa_ex_ut(julian_ut, flag) ⇒ Object



387
388
389
390
391
392
393
394
395
396
# File 'ext/swisseph/swisseph.c', line 387

static VALUE t_swe_get_ayanamsa_ex_ut(VALUE self, VALUE julian_ut, VALUE flag)
{
	double ayanamsha;
	char serr[AS_MAXCH];

	if (swe_get_ayanamsa_ex_ut(NUM2DBL(julian_ut), NUM2INT(flag), &ayanamsha, serr) < 0)
		rb_raise(rb_eRuntimeError, "%s", serr);

	return rb_float_new(ayanamsha);
}

.swe_get_ayanamsa_name(isidmode) ⇒ Object



87
88
89
90
91
92
93
# File 'ext/swisseph/swisseph.c', line 87

static VALUE t_swe_get_ayanamsa_name(VALUE self, VALUE isidmode)
{
	const char *name = swe_get_ayanamsa_name(NUM2INT(isidmode));
	if (name == NULL)
		return Qnil;
	return rb_str_new_cstr(name);
}

.swe_get_ayanamsa_ut(julian_ut) ⇒ Object



359
360
361
362
363
# File 'ext/swisseph/swisseph.c', line 359

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_get_orbital_elements(julian_et, body, iflag) ⇒ Object



1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
# File 'ext/swisseph/swisseph.c', line 1173

static VALUE t_swe_get_orbital_elements(VALUE self, VALUE julian_et, VALUE body, VALUE iflag)
{
	char serr[AS_MAXCH];
	double dret[17]; // Array to store the return values

	if (swe_get_orbital_elements(NUM2DBL(julian_et), NUM2INT(body), NUM2INT(iflag), dret, serr) < 0)
		rb_raise(rb_eRuntimeError, "%s", serr);

	VALUE output = rb_ary_new();
	for (int i = 0; i < 17; i++)
		rb_ary_push(output, rb_float_new(dret[i]));

	return output;
}

.swe_get_planet_name(ipl) ⇒ Object



76
77
78
79
80
81
# File 'ext/swisseph/swisseph.c', line 76

static VALUE t_swe_get_planet_name(VALUE self, VALUE ipl)
{
	char name[AS_MAXCH];
	swe_get_planet_name(NUM2INT(ipl), name);
	return rb_str_new_cstr(name);
}

.swe_heliacal_ut(*args) ⇒ Object



1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
# File 'ext/swisseph/swisseph.c', line 1312

static VALUE t_swe_heliacal_ut(int argc, VALUE *argv, VALUE self)
{
	if (argc != 9)
		rb_raise(rb_eArgError, "wrong number of arguments (9 required: tjd_ut, object_name, type_event, iflag, lon, lat, height, datm_array, dobs_array)");

	char serr[AS_MAXCH];
	double geopos[3];
	geopos[0] = NUM2DBL(argv[4]); // lon
	geopos[1] = NUM2DBL(argv[5]); // lat
	geopos[2] = NUM2DBL(argv[6]); // height

	// datm: atmospheric data array (4 doubles)
	VALUE datm_arr = argv[7];
	if (TYPE(datm_arr) != T_ARRAY || RARRAY_LEN(datm_arr) < 4)
		rb_raise(rb_eArgError, "datm must be array of 4 values [pressure, temp, humidity, extinction_coeff]");
	double datm[4];
	for (int i = 0; i < 4; i++)
		datm[i] = NUM2DBL(rb_ary_entry(datm_arr, i));

	// dobs: observer data array (6 doubles)
	VALUE dobs_arr = argv[8];
	if (TYPE(dobs_arr) != T_ARRAY || RARRAY_LEN(dobs_arr) < 6)
		rb_raise(rb_eArgError, "dobs must be array of 6 values [age, snellen_left, snellen_right, telescope_mag, telescope_diam, binoc_factor]");
	double dobs[6];
	for (int i = 0; i < 6; i++)
		dobs[i] = NUM2DBL(rb_ary_entry(dobs_arr, i));

	double dret[50];
	char *object_name = StringValuePtr(argv[1]);

	if (swe_heliacal_ut(NUM2DBL(argv[0]), geopos, datm, dobs, object_name, NUM2INT(argv[2]), NUM2INT(argv[3]), dret, serr) < 0)
		rb_raise(rb_eRuntimeError, "%s", serr);

	VALUE output = rb_ary_new();
	for (int i = 0; i < 50; i++)
		rb_ary_push(output, rb_float_new(dret[i]));
	return output;
}

.swe_helio_cross(body, x2cross, tjd_et, iflag, dir) ⇒ Object



1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
# File 'ext/swisseph/swisseph.c', line 1028

static VALUE t_swe_helio_cross(VALUE self, VALUE body, VALUE x2cross, VALUE tjd_et, VALUE iflag, VALUE dir)
{
	char serr[AS_MAXCH];
	serr[0] = '\0';
	double jx;
	int32 retval = swe_helio_cross(NUM2INT(body), NUM2DBL(x2cross), NUM2DBL(tjd_et), NUM2INT(iflag), NUM2INT(dir), &jx, serr);
	if (retval < 0)
		rb_raise(rb_eRuntimeError, "%s", serr);
	return rb_float_new(jx);
}

.swe_helio_cross_ut(body, x2cross, tjd_ut, iflag, dir) ⇒ Object



960
961
962
963
964
965
966
967
968
969
# File 'ext/swisseph/swisseph.c', line 960

static VALUE t_swe_helio_cross_ut(VALUE self, VALUE body, VALUE x2cross, VALUE tjd_ut, VALUE iflag, VALUE dir)
{
	char serr[AS_MAXCH];
	serr[0] = '\0';
	double jx;
	int32 retval = swe_helio_cross_ut(NUM2INT(body), NUM2DBL(x2cross), NUM2DBL(tjd_ut), NUM2INT(iflag), NUM2INT(dir), &jx, serr);
	if (retval < 0)
		rb_raise(rb_eRuntimeError, "%s", serr);
	return rb_float_new(jx);
}

.swe_house_name(hsys) ⇒ Object



582
583
584
585
# File 'ext/swisseph/swisseph.c', line 582

static VALUE t_swe_house_name(VALUE self, VALUE hsys)
{
	return rb_str_new_cstr(swe_house_name(NUM2CHR(hsys)));
}

.swe_house_pos(armc, geolat, eps, hsys, eclon, eclat) ⇒ Object



878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
# File 'ext/swisseph/swisseph.c', line 878

static VALUE t_swe_house_pos(VALUE self, VALUE armc, VALUE geolat, VALUE eps, VALUE hsys, VALUE eclon, VALUE eclat)
{
	// double armc,        /* ARMC */
	// double geolat,      /* geographic latitude, in degrees */
	// double eps,              /* ecliptic obliquity, in degrees */
	// int hsys,                /* house method, one of the letters PKRCAV */
	// double *xpin,       /* array of 2 doubles: ecl. longitude and latitude of the planet */
	// char *serr);             /* return area for error or warning message */

	double eclpos[2];
	eclpos[0] = NUM2DBL(eclon);
	eclpos[1] = NUM2DBL(eclat);
	char serr[AS_MAXCH];

	double retval = swe_house_pos(NUM2DBL(armc), NUM2DBL(geolat), NUM2DBL(eps), NUM2INT(hsys), eclpos, serr);
	if (retval < 0)
		rb_raise(rb_eRuntimeError, "%s", serr);

	VALUE output = rb_float_new(retval);
	return output;
}

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



442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
# File 'ext/swisseph/swisseph.c', line 442

static VALUE t_swe_houses(VALUE self, VALUE julian_day, VALUE latitude, VALUE longitude, VALUE house_system)
{
	double cusps[37];  // 37 for Gauquelin sectors, 13 for others
	double ascmc[10];
	char serr[AS_MAXCH];
	char hsys = NUM2CHR(house_system);
	int num_cusps = (hsys == 'G') ? 37 : 13;

	if (swe_houses(NUM2DBL(julian_day), NUM2DBL(latitude), NUM2DBL(longitude), hsys, cusps, ascmc) < 0)
		rb_raise(rb_eRuntimeError, "%s", serr);

	VALUE _cusps = rb_ary_new();
	for (int i = 0; i < num_cusps; i++)
		rb_ary_push(_cusps, rb_float_new(cusps[i]));

	VALUE _ascmc = rb_ary_new();
	for (int i = 0; i < 10; i++)
		rb_ary_push(_ascmc, rb_float_new(ascmc[i]));

	VALUE output = rb_ary_new();
	rb_ary_push(output, _cusps);
	rb_ary_push(output, _ascmc);
	return output;
}

.swe_houses_armc(armc, latitude, eps, house_system) ⇒ Object



500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
# File 'ext/swisseph/swisseph.c', line 500

static VALUE t_swe_houses_armc(VALUE self, VALUE armc, VALUE latitude, VALUE eps, VALUE house_system)
{
	double cusps[37];  // 37 for Gauquelin sectors, 13 for others
	double ascmc[10];
	char serr[AS_MAXCH];
	char hsys = NUM2CHR(house_system);
	int num_cusps = (hsys == 'G') ? 37 : 13;

	if (swe_houses_armc(NUM2DBL(armc), NUM2DBL(latitude), NUM2DBL(eps), hsys, cusps, ascmc) < 0)
		rb_raise(rb_eRuntimeError, "%s", serr);

	VALUE _cusps = rb_ary_new();
	for (int i = 0; i < num_cusps; i++)
		rb_ary_push(_cusps, rb_float_new(cusps[i]));

	VALUE _ascmc = rb_ary_new();
	for (int i = 0; i < 10; i++)
		rb_ary_push(_ascmc, rb_float_new(ascmc[i]));

	VALUE output = rb_ary_new();
	rb_ary_push(output, _cusps);
	rb_ary_push(output, _ascmc);
	return output;
}

.swe_houses_ex(julian_day, iflag, latitude, longitude, house_system) ⇒ Object



471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
# File 'ext/swisseph/swisseph.c', line 471

static VALUE t_swe_houses_ex(VALUE self, VALUE julian_day, VALUE iflag, VALUE latitude, VALUE longitude, VALUE house_system)
{
	double cusps[37];  // 37 for Gauquelin sectors, 13 for others
	double ascmc[10];
	char serr[AS_MAXCH];
	char hsys = NUM2CHR(house_system);
	int num_cusps = (hsys == 'G') ? 37 : 13;

	if (swe_houses_ex(NUM2DBL(julian_day), NUM2INT(iflag), NUM2DBL(latitude), NUM2DBL(longitude), hsys, cusps, ascmc) < 0)
		rb_raise(rb_eRuntimeError, "%s", serr);

	VALUE _cusps = rb_ary_new();
	for (int i = 0; i < num_cusps; i++)
		rb_ary_push(_cusps, rb_float_new(cusps[i]));

	VALUE _ascmc = rb_ary_new();
	for (int i = 0; i < 10; i++)
		rb_ary_push(_ascmc, rb_float_new(ascmc[i]));

	VALUE output = rb_ary_new();
	rb_ary_push(output, _cusps);
	rb_ary_push(output, _ascmc);
	return output;
}

.swe_houses_ex2(julian_day, flag, latitude, longitude, house_system) ⇒ Object



543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
# File 'ext/swisseph/swisseph.c', line 543

static VALUE t_swe_houses_ex2(VALUE self, VALUE julian_day, VALUE flag, VALUE latitude, VALUE longitude, VALUE house_system)
{
	double cusps[37];        // 37 for Gauquelin sectors, 13 for others
	double ascmc[10];
	double cusps_speed[37];  // 37 for Gauquelin sectors, 13 for others
	double ascmc_speed[10];
	char serr[AS_MAXCH];
	char hsys = NUM2CHR(house_system);
	int num_cusps = (hsys == 'G') ? 37 : 13;

	if (swe_houses_ex2(NUM2DBL(julian_day), NUM2INT(flag), NUM2DBL(latitude), NUM2DBL(longitude), hsys, cusps, ascmc, cusps_speed, ascmc_speed, serr) < 0)
		rb_raise(rb_eRuntimeError, "%s", serr);

	VALUE _cusps = rb_ary_new();
	for (int i = 0; i < num_cusps; i++)
		rb_ary_push(_cusps, rb_float_new(cusps[i]));

	VALUE _ascmc = rb_ary_new();
	for (int i = 0; i < 10; i++)
		rb_ary_push(_ascmc, rb_float_new(ascmc[i]));

	VALUE _cusps_speed = rb_ary_new();
	for (int i = 0; i < num_cusps; i++)
		rb_ary_push(_cusps_speed, rb_float_new(cusps_speed[i]));

	VALUE _ascmc_speed = rb_ary_new();
	for (int i = 0; i < 10; i++)
		rb_ary_push(_ascmc_speed, rb_float_new(ascmc_speed[i]));

	VALUE output = rb_ary_new();
	rb_ary_push(output, _cusps);
	rb_ary_push(output, _ascmc);
	rb_ary_push(output, _cusps_speed);
	rb_ary_push(output, _ascmc_speed);
	return output;
}

.swe_jdut1_to_utc(*args) ⇒ Object



188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# File 'ext/swisseph/swisseph.c', line 188

static VALUE t_swe_jdut1_to_utc(int argc, VALUE *argv, VALUE self)
{
	if (argc < 1 || argc > 2)
		rb_raise(rb_eArgError, "wrong number of arguments (1 or 2)");

	int32 gregflag = (argc == 2) ? NUM2INT(argv[1]) : SE_GREG_CAL;
	int32 year, month, day, hour, min;
	double sec;

	swe_jdut1_to_utc(NUM2DBL(argv[0]), gregflag, &year, &month, &day, &hour, &min, &sec);

	VALUE output = rb_ary_new();
	rb_ary_push(output, INT2NUM(year));
	rb_ary_push(output, INT2NUM(month));
	rb_ary_push(output, INT2NUM(day));
	rb_ary_push(output, INT2NUM(hour));
	rb_ary_push(output, INT2NUM(min));
	rb_ary_push(output, rb_float_new(sec));
	return output;
}

.swe_julday(*args) ⇒ Object



106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'ext/swisseph/swisseph.c', line 106

static VALUE t_swe_julday(int argc, VALUE *argv, VALUE self)
{
	VALUE greg_flag;

	if (argc > 5 || argc < 4)
	{ // there should only be 4 or 5 arguments
		rb_raise(rb_eArgError, "wrong number of arguments");
	}
	greg_flag = (argc == 5) ? NUM2INT(argv[4]) : SE_GREG_CAL;

	double julday = swe_julday(NUM2INT(argv[0]), NUM2INT(argv[1]), NUM2INT(argv[2]), NUM2DBL(argv[3]), greg_flag);
	return rb_float_new(julday);
}

.swe_lat_to_lmt(tjd_lat, geolon) ⇒ Object



808
809
810
811
812
813
814
815
816
817
# File 'ext/swisseph/swisseph.c', line 808

static VALUE t_swe_lat_to_lmt(VALUE self, VALUE tjd_lat, VALUE geolon)
{
	double tjd_lmt;
	char serr[AS_MAXCH];

	if (swe_lat_to_lmt(NUM2DBL(tjd_lat), NUM2DBL(geolon), &tjd_lmt, serr) < 0)
		rb_raise(rb_eRuntimeError, "%s", serr);

	return rb_float_new(tjd_lmt);
}

.swe_lmt_to_lat(tjd_lmt, geolon) ⇒ Object



793
794
795
796
797
798
799
800
801
802
# File 'ext/swisseph/swisseph.c', line 793

static VALUE t_swe_lmt_to_lat(VALUE self, VALUE tjd_lmt, VALUE geolon)
{
	double tjd_lat;
	char serr[AS_MAXCH];

	if (swe_lmt_to_lat(NUM2DBL(tjd_lmt), NUM2DBL(geolon), &tjd_lat, serr) < 0)
		rb_raise(rb_eRuntimeError, "%s", serr);

	return rb_float_new(tjd_lat);
}

.swe_lun_eclipse_how(tjd, ifl, lon, lat, height) ⇒ Object



1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
# File 'ext/swisseph/swisseph.c', line 1643

static VALUE t_swe_lun_eclipse_how(VALUE self, VALUE tjd, VALUE ifl, VALUE lon, VALUE lat, VALUE height)
{
	char serr[AS_MAXCH];
	double geopos[3];
	geopos[0] = NUM2DBL(lon);
	geopos[1] = NUM2DBL(lat);
	geopos[2] = NUM2DBL(height);
	double attr[20];

	int32 result = swe_lun_eclipse_how(NUM2DBL(tjd), NUM2INT(ifl), geopos, attr, serr);
	if (result < 0)
		rb_raise(rb_eRuntimeError, "%s", serr);

	VALUE output = rb_ary_new();
	rb_ary_push(output, INT2NUM(result)); // eclipse type flags
	for (int i = 0; i < 20; i++)
		rb_ary_push(output, rb_float_new(attr[i]));
	return output;
}

.swe_lun_eclipse_when(tjd_start, ifl, ifltype, backward) ⇒ Object



1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
# File 'ext/swisseph/swisseph.c', line 1575

static VALUE t_swe_lun_eclipse_when(VALUE self, VALUE tjd_start, VALUE ifl, VALUE ifltype, VALUE backward)
{
	char serr[AS_MAXCH];
	double tret[10];

	int32 result = swe_lun_eclipse_when(NUM2DBL(tjd_start), NUM2INT(ifl), NUM2INT(ifltype), tret, NUM2INT(backward), serr);
	if (result < 0)
		rb_raise(rb_eRuntimeError, "%s", serr);

	VALUE output = rb_ary_new();
	rb_ary_push(output, INT2NUM(result)); // eclipse type flags
	for (int i = 0; i < 10; i++)
		rb_ary_push(output, rb_float_new(tret[i]));
	return output;
}

.swe_lun_eclipse_when_loc(tjd_start, ifl, lon, lat, height, backward) ⇒ Object



1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
# File 'ext/swisseph/swisseph.c', line 1596

static VALUE t_swe_lun_eclipse_when_loc(VALUE self, VALUE tjd_start, VALUE ifl, VALUE lon, VALUE lat, VALUE height, VALUE backward)
{
	char serr[AS_MAXCH];
	double geopos[3];
	geopos[0] = NUM2DBL(lon);
	geopos[1] = NUM2DBL(lat);
	geopos[2] = NUM2DBL(height);
	double tret[10];
	double attr[20];

	int32 result = swe_lun_eclipse_when_loc(NUM2DBL(tjd_start), NUM2INT(ifl), geopos, tret, attr, NUM2INT(backward), serr);
	if (result < 0)
		rb_raise(rb_eRuntimeError, "%s", serr);

	VALUE output = rb_ary_new();
	rb_ary_push(output, INT2NUM(result)); // eclipse type flags

	VALUE _tret = rb_ary_new();
	for (int i = 0; i < 10; i++)
		rb_ary_push(_tret, rb_float_new(tret[i]));
	rb_ary_push(output, _tret);

	VALUE _attr = rb_ary_new();
	for (int i = 0; i < 20; i++)
		rb_ary_push(_attr, rb_float_new(attr[i]));
	rb_ary_push(output, _attr);

	return output;
}

.swe_mooncross(x2cross, tjd_et, iflag) ⇒ Object



991
992
993
994
995
996
997
998
999
1000
1001
# File 'ext/swisseph/swisseph.c', line 991

static VALUE t_swe_mooncross(VALUE self, VALUE x2cross, VALUE tjd_et, VALUE iflag)
{
	char serr[AS_MAXCH];
	serr[0] = '\0';
	double tjd = NUM2DBL(tjd_et);

	double retval = swe_mooncross(NUM2DBL(x2cross), tjd, NUM2INT(iflag), serr);
	if (retval < tjd)
		rb_raise(rb_eRuntimeError, "%s", serr);
	return rb_float_new(retval);
}

.swe_mooncross_node(tjd_et, iflag) ⇒ Object



1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
# File 'ext/swisseph/swisseph.c', line 1007

static VALUE t_swe_mooncross_node(VALUE self, VALUE tjd_et, VALUE iflag)
{
	char serr[AS_MAXCH];
	serr[0] = '\0';
	double tjd = NUM2DBL(tjd_et);
	double xlon, xlat;
	double retval = swe_mooncross_node(tjd, NUM2INT(iflag), &xlon, &xlat, serr);
	if (retval < tjd)
		rb_raise(rb_eRuntimeError, "%s", serr);
	VALUE output = rb_ary_new();
	rb_ary_push(output, rb_float_new(retval));
	rb_ary_push(output, rb_float_new(xlon));
	rb_ary_push(output, rb_float_new(xlat));

	return output;
}

.swe_mooncross_node_ut(tjd_ut, iflag) ⇒ Object



940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
# File 'ext/swisseph/swisseph.c', line 940

static VALUE t_swe_mooncross_node_ut(VALUE self, VALUE tjd_ut, VALUE iflag)
{
	char serr[AS_MAXCH];
	serr[0] = '\0';
	double tjd = NUM2DBL(tjd_ut);
	double xlon, xlat;
	double retval = swe_mooncross_node_ut(tjd, NUM2INT(iflag), &xlon, &xlat, serr);
	if (retval < tjd)
		rb_raise(rb_eRuntimeError, "%s", serr);
	VALUE output = rb_ary_new();
	rb_ary_push(output, rb_float_new(retval));
	rb_ary_push(output, rb_float_new(xlon));
	rb_ary_push(output, rb_float_new(xlat));

	return output;
}

.swe_mooncross_ut(x2cross, tjd_ut, iflag) ⇒ Object



920
921
922
923
924
925
926
927
928
929
930
# File 'ext/swisseph/swisseph.c', line 920

static VALUE t_swe_mooncross_ut(VALUE self, VALUE x2cross, VALUE tjd_ut, VALUE iflag)
{
	char serr[AS_MAXCH];
	serr[0] = '\0';
	double tjd = NUM2DBL(tjd_ut);

	double retval = swe_mooncross_ut(NUM2DBL(x2cross), tjd, NUM2INT(iflag), serr);
	if (retval < tjd)
		rb_raise(rb_eRuntimeError, "%s", serr);
	return rb_float_new(retval);
}

.swe_nod_aps(julian_et, body, iflag, method) ⇒ Object



1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
# File 'ext/swisseph/swisseph.c', line 1083

static VALUE t_swe_nod_aps(VALUE self, VALUE julian_et, VALUE body, VALUE iflag, VALUE method)
{
	char serr[AS_MAXCH];
	double xnasc[6];
	double xndsc[6];
	double xperi[6];
	double xaphe[6];

	if (swe_nod_aps(NUM2DBL(julian_et), NUM2INT(body), NUM2INT(iflag), NUM2INT(method), xnasc, xndsc, xperi, xaphe, serr) < 0)
		rb_raise(rb_eRuntimeError, "%s", serr);

	VALUE output = rb_ary_new();

	VALUE ascending = rb_ary_new();
	for (int i = 0; i < 6; i++)
		rb_ary_push(ascending, rb_float_new(xnasc[i]));
	rb_ary_push(output, ascending);

	VALUE descending = rb_ary_new();
	for (int i = 0; i < 6; i++)
		rb_ary_push(descending, rb_float_new(xndsc[i]));
	rb_ary_push(output, descending);

	VALUE perihelion = rb_ary_new();
	for (int i = 0; i < 6; i++)
		rb_ary_push(perihelion, rb_float_new(xperi[i]));
	rb_ary_push(output, perihelion);

	VALUE aphelion = rb_ary_new();
	for (int i = 0; i < 6; i++)
		rb_ary_push(aphelion, rb_float_new(xaphe[i]));
	rb_ary_push(output, aphelion);

	return output; // return array of arrays
}

.swe_nod_aps_ut(julian_ut, body, iflag, method) ⇒ Object



1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
# File 'ext/swisseph/swisseph.c', line 1043

static VALUE t_swe_nod_aps_ut(VALUE self, VALUE julian_ut, VALUE body, VALUE iflag, VALUE method)
{
	char serr[AS_MAXCH];
	double xnasc[6];
	double xndsc[6];
	double xperi[6];
	double xaphe[6];

	if (swe_nod_aps_ut(NUM2DBL(julian_ut), NUM2INT(body), NUM2INT(iflag), NUM2INT(method), xnasc, xndsc, xperi, xaphe, serr) < 0)
		rb_raise(rb_eRuntimeError, "%s", serr);

	VALUE output = rb_ary_new();

	VALUE ascending = rb_ary_new();
	for (int i = 0; i < 6; i++)
		rb_ary_push(ascending, rb_float_new(xnasc[i]));
	rb_ary_push(output, ascending);

	VALUE descending = rb_ary_new();
	for (int i = 0; i < 6; i++)
		rb_ary_push(descending, rb_float_new(xndsc[i]));
	rb_ary_push(output, descending);

	VALUE perihelion = rb_ary_new();
	for (int i = 0; i < 6; i++)
		rb_ary_push(perihelion, rb_float_new(xperi[i]));
	rb_ary_push(output, perihelion);

	VALUE aphelion = rb_ary_new();
	for (int i = 0; i < 6; i++)
		rb_ary_push(aphelion, rb_float_new(xaphe[i]));
	rb_ary_push(output, aphelion);

	return output; // return array of arrays
}

.swe_pheno_ut(julian_ut, ipl, iflag) ⇒ Object



759
760
761
762
763
764
765
766
767
768
769
770
771
# File 'ext/swisseph/swisseph.c', line 759

static VALUE t_swe_pheno_ut(VALUE self, VALUE julian_ut, VALUE ipl, VALUE iflag)
{
	double attr[20];
	char serr[AS_MAXCH];

	if (swe_pheno_ut(NUM2DBL(julian_ut), NUM2INT(ipl), NUM2INT(iflag), attr, serr) < 0)
		rb_raise(rb_eRuntimeError, "%s", serr);

	VALUE output = rb_ary_new();
	for (int i = 0; i < 7; i++)
		rb_ary_push(output, rb_float_new(attr[i]));
	return output;
}

.swe_radnorm(rad) ⇒ Object



309
310
311
312
# File 'ext/swisseph/swisseph.c', line 309

static VALUE t_swe_radnorm(VALUE self, VALUE rad)
{
	return rb_float_new(swe_radnorm(NUM2DBL(rad)));
}

.swe_refrac(inalt, atpress, attemp, calc_flag) ⇒ Object



741
742
743
744
745
# File 'ext/swisseph/swisseph.c', line 741

static VALUE t_swe_refrac(VALUE self, VALUE inalt, VALUE atpress, VALUE attemp, VALUE calc_flag)
{
	double result = swe_refrac(NUM2DBL(inalt), NUM2DBL(atpress), NUM2DBL(attemp), NUM2INT(calc_flag));
	return rb_float_new(result);
}

.swe_revjul(*args) ⇒ Object



131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'ext/swisseph/swisseph.c', line 131

static VALUE t_swe_revjul(int argc, VALUE *argv, VALUE self)
{
	if (argc > 2 || argc < 1)
	{ // there should only be 2 or 3 arguments
		rb_raise(rb_eArgError, "wrong number of arguments");
	}
	VALUE greg_flag = (argc == 2) ? NUM2INT(argv[1]) : SE_GREG_CAL;

	int year, month, day;
	double hour;

	swe_revjul(NUM2DBL(argv[0]), greg_flag, &year, &month, &day, &hour);

	VALUE output = rb_ary_new();
	rb_ary_push(output, rb_uint_new(year));
	rb_ary_push(output, rb_uint_new(month));
	rb_ary_push(output, rb_uint_new(day));
	rb_ary_push(output, rb_float_new(hour));
	return output;
}

.swe_rise_trans(julian_day, body, flag, rmsi, lon, lat, height, pressure, temp) ⇒ Object



600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
# File 'ext/swisseph/swisseph.c', line 600

static VALUE t_swe_rise_trans(VALUE self, VALUE julian_day, VALUE body, VALUE flag, VALUE rmsi, VALUE lon, VALUE lat, VALUE height, VALUE pressure, VALUE temp)
{
	double geopos[3];
	geopos[0] = NUM2DBL(lon);
	geopos[1] = NUM2DBL(lat);
	geopos[2] = NUM2DBL(height);
	int ipl;
	char *starname;
	if (TYPE(body) == T_STRING)
	{
		starname = StringValuePtr(body);
		ipl = 0;
	}
	else
	{
		ipl = NUM2INT(body);
		starname = NULL;
	}
	char serr[AS_MAXCH];
	double retval;

	if (swe_rise_trans(NUM2DBL(julian_day), ipl, starname, NUM2INT(flag), NUM2INT(rmsi), geopos, NUM2DBL(pressure), NUM2DBL(temp), &retval, serr) < 0)
		rb_raise(rb_eRuntimeError, "%s", serr);
	return rb_float_new(retval);
}

.swe_rise_trans_true_hor(julian_day, body, flag, rmsi, lon, lat, height, pressure, temp, hor_height) ⇒ Object



640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
# File 'ext/swisseph/swisseph.c', line 640

static VALUE t_swe_rise_trans_true_hor(VALUE self, VALUE julian_day, VALUE body, VALUE flag, VALUE rmsi, VALUE lon, VALUE lat, VALUE height, VALUE pressure, VALUE temp, VALUE hor_height)
{
	double geopos[3];
	geopos[0] = NUM2DBL(lon);
	geopos[1] = NUM2DBL(lat);
	geopos[2] = NUM2DBL(height);
	int ipl;
	char *starname;
	if (TYPE(body) == T_STRING)
	{
		starname = StringValuePtr(body);
		ipl = 0;
	}
	else
	{
		ipl = NUM2INT(body);
		starname = NULL;
	}
	char serr[AS_MAXCH];
	double retval;

	if (swe_rise_trans_true_hor(NUM2DBL(julian_day), ipl, starname, NUM2INT(flag), NUM2INT(rmsi), geopos, NUM2DBL(pressure), NUM2DBL(temp), NUM2DBL(hor_height), &retval, serr) < 0)
		rb_raise(rb_eRuntimeError, "%s", serr);
	return rb_float_new(retval);
}

.swe_set_ephe_path(path) ⇒ Object

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



34
35
36
37
38
# File 'ext/swisseph/swisseph.c', line 34

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

.swe_set_jpl_file(path) ⇒ Object



45
46
47
48
49
# File 'ext/swisseph/swisseph.c', line 45

static VALUE t_swe_set_jpl_file(VALUE self, VALUE path)
{
	swe_set_jpl_file(StringValuePtr(path));
	return Qnil;
}

.swe_set_sid_mode(mode, t0, ayan_t0) ⇒ Object



345
346
347
348
349
# File 'ext/swisseph/swisseph.c', line 345

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



229
230
231
232
233
# File 'ext/swisseph/swisseph.c', line 229

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;
}

.swe_sidtime(julian_ut) ⇒ Object



280
281
282
283
284
# File 'ext/swisseph/swisseph.c', line 280

static VALUE t_swe_sidtime(VALUE self, VALUE julian_ut)
{
	double sidtime = swe_sidtime(NUM2DBL(julian_ut));
	return rb_float_new(sidtime);
}

.swe_sidtime0(julian_ut, eps, nut) ⇒ Object



290
291
292
293
294
# File 'ext/swisseph/swisseph.c', line 290

static VALUE t_swe_sidtime0(VALUE self, VALUE julian_ut, VALUE eps, VALUE nut)
{
	double sidtime = swe_sidtime0(NUM2DBL(julian_ut), NUM2DBL(eps), NUM2DBL(nut));
	return rb_float_new(sidtime);
}

.swe_sol_eclipse_how(tjd, ifl, lon, lat, height) ⇒ Object



1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
# File 'ext/swisseph/swisseph.c', line 1510

static VALUE t_swe_sol_eclipse_how(VALUE self, VALUE tjd, VALUE ifl, VALUE lon, VALUE lat, VALUE height)
{
	char serr[AS_MAXCH];
	double geopos[3];
	geopos[0] = NUM2DBL(lon);
	geopos[1] = NUM2DBL(lat);
	geopos[2] = NUM2DBL(height);
	double attr[20];

	int32 result = swe_sol_eclipse_how(NUM2DBL(tjd), NUM2INT(ifl), geopos, attr, serr);
	if (result < 0)
		rb_raise(rb_eRuntimeError, "%s", serr);

	VALUE output = rb_ary_new();
	rb_ary_push(output, INT2NUM(result)); // eclipse type flags
	for (int i = 0; i < 20; i++)
		rb_ary_push(output, rb_float_new(attr[i]));
	return output;
}

.swe_sol_eclipse_when_glob(tjd_start, ifl, ifltype, backward) ⇒ Object



1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
# File 'ext/swisseph/swisseph.c', line 1443

static VALUE t_swe_sol_eclipse_when_glob(VALUE self, VALUE tjd_start, VALUE ifl, VALUE ifltype, VALUE backward)
{
	char serr[AS_MAXCH];
	double tret[10];

	int32 result = swe_sol_eclipse_when_glob(NUM2DBL(tjd_start), NUM2INT(ifl), NUM2INT(ifltype), tret, NUM2INT(backward), serr);
	if (result < 0)
		rb_raise(rb_eRuntimeError, "%s", serr);

	VALUE output = rb_ary_new();
	rb_ary_push(output, INT2NUM(result)); // eclipse type flags
	for (int i = 0; i < 10; i++)
		rb_ary_push(output, rb_float_new(tret[i]));
	return output;
}

.swe_sol_eclipse_when_loc(tjd_start, ifl, lon, lat, height, backward) ⇒ Object



1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
# File 'ext/swisseph/swisseph.c', line 1464

static VALUE t_swe_sol_eclipse_when_loc(VALUE self, VALUE tjd_start, VALUE ifl, VALUE lon, VALUE lat, VALUE height, VALUE backward)
{
	char serr[AS_MAXCH];
	double geopos[3];
	geopos[0] = NUM2DBL(lon);
	geopos[1] = NUM2DBL(lat);
	geopos[2] = NUM2DBL(height);
	double tret[10];
	double attr[20];

	int32 result = swe_sol_eclipse_when_loc(NUM2DBL(tjd_start), NUM2INT(ifl), geopos, tret, attr, NUM2INT(backward), serr);
	if (result < 0)
		rb_raise(rb_eRuntimeError, "%s", serr);

	VALUE output = rb_ary_new();
	rb_ary_push(output, INT2NUM(result)); // eclipse type flags

	VALUE _tret = rb_ary_new();
	for (int i = 0; i < 10; i++)
		rb_ary_push(_tret, rb_float_new(tret[i]));
	rb_ary_push(output, _tret);

	VALUE _attr = rb_ary_new();
	for (int i = 0; i < 20; i++)
		rb_ary_push(_attr, rb_float_new(attr[i]));
	rb_ary_push(output, _attr);

	return output;
}

.swe_sol_eclipse_where(tjd, ifl) ⇒ Object



1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
# File 'ext/swisseph/swisseph.c', line 1535

static VALUE t_swe_sol_eclipse_where(VALUE self, VALUE tjd, VALUE ifl)
{
	char serr[AS_MAXCH];
	double geopos[10];
	double attr[20];

	int32 result = swe_sol_eclipse_where(NUM2DBL(tjd), NUM2INT(ifl), geopos, attr, serr);
	if (result < 0)
		rb_raise(rb_eRuntimeError, "%s", serr);

	VALUE output = rb_ary_new();
	rb_ary_push(output, INT2NUM(result)); // eclipse type flags

	VALUE _geopos = rb_ary_new();
	rb_ary_push(_geopos, rb_float_new(geopos[0])); // longitude
	rb_ary_push(_geopos, rb_float_new(geopos[1])); // latitude
	rb_ary_push(output, _geopos);

	VALUE _attr = rb_ary_new();
	for (int i = 0; i < 20; i++)
		rb_ary_push(_attr, rb_float_new(attr[i]));
	rb_ary_push(output, _attr);

	return output;
}

.swe_solcross(x2cross, tjd_et, iflag) ⇒ Object



975
976
977
978
979
980
981
982
983
984
985
# File 'ext/swisseph/swisseph.c', line 975

static VALUE t_swe_solcross(VALUE self, VALUE x2cross, VALUE tjd_et, VALUE iflag)
{
	char serr[AS_MAXCH];
	serr[0] = '\0';
	double tjd = NUM2DBL(tjd_et);

	double retval = swe_solcross(NUM2DBL(x2cross), tjd, NUM2INT(iflag), serr);
	if (retval < tjd)
		rb_raise(rb_eRuntimeError, "%s", serr);
	return rb_float_new(retval);
}

.swe_solcross_ut(x2cross, tjd_ut, iflag) ⇒ Object



904
905
906
907
908
909
910
911
912
913
914
# File 'ext/swisseph/swisseph.c', line 904

static VALUE t_swe_solcross_ut(VALUE self, VALUE x2cross, VALUE tjd_ut, VALUE iflag)
{
	char serr[AS_MAXCH];
	serr[0] = '\0';
	double tjd = NUM2DBL(tjd_ut);

	double retval = swe_solcross_ut(NUM2DBL(x2cross), tjd, NUM2INT(iflag), serr);
	if (retval < tjd)
		rb_raise(rb_eRuntimeError, "%s", serr);
	return rb_float_new(retval);
}

.swe_split_deg(ddeg, roundflag) ⇒ Object



320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
# File 'ext/swisseph/swisseph.c', line 320

static VALUE t_swe_split_deg(VALUE self, VALUE ddeg, VALUE roundflag)
{
	int32 ideg, imin, isec, isgn;
	double dsecfr;

	swe_split_deg(NUM2DBL(ddeg), NUM2INT(roundflag), &ideg, &imin, &isec, &dsecfr, &isgn);

	VALUE output = rb_ary_new();
	rb_ary_push(output, INT2NUM(ideg));
	rb_ary_push(output, INT2NUM(imin));
	rb_ary_push(output, INT2NUM(isec));
	rb_ary_push(output, rb_float_new(dsecfr));
	rb_ary_push(output, INT2NUM(isgn));
	return output;
}

.swe_time_equ(tjd) ⇒ Object



778
779
780
781
782
783
784
785
786
787
# File 'ext/swisseph/swisseph.c', line 778

static VALUE t_swe_time_equ(VALUE self, VALUE tjd)
{
	double te;
	char serr[AS_MAXCH];

	if (swe_time_equ(NUM2DBL(tjd), &te, serr) < 0)
		rb_raise(rb_eRuntimeError, "%s", serr);

	return rb_float_new(te);
}

.swe_utc_to_jd(*args) ⇒ Object



159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'ext/swisseph/swisseph.c', line 159

static VALUE t_swe_utc_to_jd(int argc, VALUE *argv, VALUE self)
{
	if (argc < 6 || argc > 7)
		rb_raise(rb_eArgError, "wrong number of arguments (6 or 7)");

	int32 gregflag = (argc == 7) ? NUM2INT(argv[6]) : SE_GREG_CAL;
	double dret[2];
	char serr[AS_MAXCH];

	int32 result = swe_utc_to_jd(
		NUM2INT(argv[0]), NUM2INT(argv[1]), NUM2INT(argv[2]),
		NUM2INT(argv[3]), NUM2INT(argv[4]), NUM2DBL(argv[5]),
		gregflag, dret, serr);

	if (result < 0)
		rb_raise(rb_eRuntimeError, "%s", serr);

	VALUE output = rb_ary_new();
	rb_ary_push(output, rb_float_new(dret[0])); // JD ET
	rb_ary_push(output, rb_float_new(dret[1])); // JD UT
	return output;
}

.swe_versionObject



65
66
67
68
69
70
# File 'ext/swisseph/swisseph.c', line 65

static VALUE t_swe_version(VALUE self)
{
	char version[AS_MAXCH];
	swe_version(version);
	return rb_str_new_cstr(version);
}

.swe_vis_limit_mag(*args) ⇒ Object



1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
# File 'ext/swisseph/swisseph.c', line 1356

static VALUE t_swe_vis_limit_mag(int argc, VALUE *argv, VALUE self)
{
	if (argc != 8)
		rb_raise(rb_eArgError, "wrong number of arguments (8 required: tjd_ut, object_name, helflag, lon, lat, height, datm_array, dobs_array)");

	char serr[AS_MAXCH];
	double geopos[3];
	geopos[0] = NUM2DBL(argv[3]); // lon
	geopos[1] = NUM2DBL(argv[4]); // lat
	geopos[2] = NUM2DBL(argv[5]); // height

	// datm: atmospheric data array (4 doubles)
	VALUE datm_arr = argv[6];
	if (TYPE(datm_arr) != T_ARRAY || RARRAY_LEN(datm_arr) < 4)
		rb_raise(rb_eArgError, "datm must be array of 4 values [pressure, temp, humidity, extinction_coeff]");
	double datm[4];
	for (int i = 0; i < 4; i++)
		datm[i] = NUM2DBL(rb_ary_entry(datm_arr, i));

	// dobs: observer data array (6 doubles)
	VALUE dobs_arr = argv[7];
	if (TYPE(dobs_arr) != T_ARRAY || RARRAY_LEN(dobs_arr) < 6)
		rb_raise(rb_eArgError, "dobs must be array of 6 values [age, snellen_left, snellen_right, telescope_mag, telescope_diam, binoc_factor]");
	double dobs[6];
	for (int i = 0; i < 6; i++)
		dobs[i] = NUM2DBL(rb_ary_entry(dobs_arr, i));

	double dret[50];
	char *object_name = StringValuePtr(argv[1]);

	if (swe_vis_limit_mag(NUM2DBL(argv[0]), geopos, datm, dobs, object_name, NUM2INT(argv[2]), dret, serr) < 0)
		rb_raise(rb_eRuntimeError, "%s", serr);

	VALUE output = rb_ary_new();
	for (int i = 0; i < 8; i++)
		rb_ary_push(output, rb_float_new(dret[i]));
	return output;
}