Skip to content

Commit

Permalink
Merge branch 'release/v2.8.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
ygrenier committed Jul 2, 2019
2 parents 7c2ed71 + 6d937c0 commit 1930ecd
Show file tree
Hide file tree
Showing 20 changed files with 769 additions and 353 deletions.
430 changes: 344 additions & 86 deletions Programs/SweTest/Program.cs

Large diffs are not rendered by default.

68 changes: 54 additions & 14 deletions SwissEphNet/CPort/SweCL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ public saros_data(int s, double t) {
public int series_no; public double tstart;
};

// Saros cycle numbers of solar eclipses with date of initial
// eclipse. Table was derived from the table of the Nasa Eclipse Web Site:
// https://eclipse.gsfc.nasa.gov/SEsaros/SEsaros0-180.html
// Note, for eclipse dates =< 15 Feb -1604 and eclipse dates
// >= 2 Sep 2666, Saros cycle numbers cannot always be given.
const double SAROS_CYCLE = 6585.3213;
const int NSAROS_SOLAR = 181;
static saros_data[] saros_data_solar = new saros_data[NSAROS_SOLAR] {
Expand Down Expand Up @@ -320,6 +325,11 @@ public saros_data(int s, double t) {
new saros_data(180, 2729226.5), /* 08 Apr 2760 */
};

// Saros cycle numbers of lunar eclipses with date of initial
// eclipse. Table was derived from the table of the Nasa Eclipse Web Site:
// https://eclipse.gsfc.nasa.gov/LEsaros/LEsaroscat.html
// Note, for eclipse dates =< 29 April -1337 and eclipse dates
// >= 10 Aug 2892, Saros cycle numbers cannot always be given.
const int NSAROS_LUNAR = 180;
static saros_data[] saros_data_lunar = new saros_data[NSAROS_LUNAR]{
new saros_data(1, 782437.5), /* 14 Mar -2570 */
Expand Down Expand Up @@ -934,9 +944,11 @@ public Int32 swe_sol_eclipse_how(
double[] geopos,
double[] attr,
ref string serr) {
Int32 retflag, retflag2;
Int32 retflag, retflag2, i;
double[] dcore = new double[10], ls = new double[6], xaz = new double[6];
double[] geopos2 = new double[20];
for (i = 0; i <= 10; i++)
attr[i] = 0;
if (geopos[2] < Sweph.SEI_ECL_GEOALT_MIN || geopos[2] > Sweph.SEI_ECL_GEOALT_MAX)
{
if (serr != null)
Expand All @@ -961,6 +973,13 @@ public Int32 swe_sol_eclipse_how(
attr[6] = xaz[2];
if (xaz[2] <= 0)
retflag = 0;
if (retflag == 0)
{
for (i = 0; i <= 3; i++)
attr[i] = 0;
for (i = 8; i <= 10; i++)
attr[i] = 0;
}
return retflag;
}

Expand Down Expand Up @@ -1126,6 +1145,7 @@ Int32 eclipse_how(double tjd_ut, Int32 ipl, string starname, Int32 ifl,
/* saros series and member */
for (i = 0; i < NSAROS_SOLAR; i++) {
d = (tjd_ut - saros_data_solar[i].tstart) / SAROS_CYCLE;
if (d < 0 && d * SAROS_CYCLE > -2) d = 0.0000001;
if (d < 0) continue;
j = (int)d;
if ((d - j) * SAROS_CYCLE < 2) {
Expand Down Expand Up @@ -3058,6 +3078,15 @@ public void swe_set_lapse_rate(double lapse_rate) {
* * SE_TRUE_TO_APP
*
* function returns:
* function returns:
* double *dret; * array of 4 doubles; declare 20 doubles !
* - dret[0] true altitude, if possible; otherwise input value
* - dret[1] apparent altitude, if possible; otherwise input value
* - dret[2] refraction
* - dret[3] dip of the horizon
*
* The body is above the horizon if the dret[0] != dret[1]
*
* case 1, conversion from true altitude to apparent altitude
* - apparent altitude, if body appears above is observable above ideal horizon
* - true altitude (the input value), otherwise
Expand All @@ -3069,12 +3098,6 @@ public void swe_set_lapse_rate(double lapse_rate) {
* horizon
* - the input altitude otherwise
*
* in addition the array dret[] is given the following values
* - dret[0] true altitude, if possible; otherwise input value
* - dret[1] apparent altitude, if possible; otherwise input value
* - dret[2] refraction
* - dret[3] dip of the horizon
*
* The body is above the horizon if the dret[0] != dret[1]
*/
public double swe_refrac_extended(double inalt, double geoalt, double atpress, double attemp, double lapse_rate, Int32 calc_flag, double[] dret) {
Expand Down Expand Up @@ -3375,6 +3398,7 @@ Int32 lun_eclipse_how(
/* saros series and member */
for (i = 0; i < NSAROS_LUNAR; i++) {
d = (tjd_ut - saros_data_lunar[i].tstart) / SAROS_CYCLE;
if (d < 0 && d * SAROS_CYCLE > -2) d = 0.0000001;
if (d < 0) continue;
j = (int)d;
if ((d - j) * SAROS_CYCLE < 2) {
Expand Down Expand Up @@ -3840,7 +3864,7 @@ public Int32 swe_pheno(double tjd, Int32 ipl, Int32 iflag, double[] attr, ref st
double fac;
double T, inx, om, sinB, u1, u2, du;
double ph1, ph2; double[] me = new double[2];
Int32 iflagp, epheflag;
Int32 iflagp, epheflag, retflag, epheflag2;
string serr2 = string.Empty;
iflag &= ~(SwissEph.SEFLG_JPLHOR | SwissEph.SEFLG_JPLHOR_APPROX);
/* function calls for Pluto with asteroid number 134340
Expand Down Expand Up @@ -3869,16 +3893,28 @@ public Int32 swe_pheno(double tjd, Int32 ipl, Int32 iflag, double[] attr, ref st
/*
* geocentric planet
*/
if (SE.swe_calc(tjd, (int)ipl, iflag | SwissEph.SEFLG_XYZ, xx, ref serr) == SwissEph.ERR)
if ((retflag = SE.swe_calc(tjd, (int)ipl, iflag | SwissEph.SEFLG_XYZ, xx, ref serr)) == SwissEph.ERR)
/* int cast can be removed when swe_calc() gets int32 ipl definition */
return SwissEph.ERR;
// check epheflag and adjust iflag
epheflag2 = retflag & SEFLG_EPHMASK;
if (epheflag != epheflag2)
{
iflag &= ~epheflag;
iflagp &= ~epheflag;
iflag |= epheflag2;
iflagp |= epheflag2;
epheflag = epheflag2;
}
if (SE.swe_calc(tjd, (int)ipl, iflag, lbr, ref serr) == SwissEph.ERR)
/* int cast can be removed when swe_calc() gets int32 ipl definition */
return SwissEph.ERR;
/* if moon, we need sun as well, for magnitude */
if (ipl == SwissEph.SE_MOON)
{
if (SE.swe_calc(tjd, SwissEph.SE_SUN, iflag | SwissEph.SEFLG_XYZ, xxs, ref serr) == SwissEph.ERR)
return SwissEph.ERR;
}
if (ipl != SwissEph.SE_SUN && ipl != SwissEph.SE_EARTH &&
ipl != SwissEph.SE_MEAN_NODE && ipl != SwissEph.SE_TRUE_NODE &&
ipl != SwissEph.SE_MEAN_APOG && ipl != SwissEph.SE_OSCU_APOG) {
Expand Down Expand Up @@ -3931,7 +3967,8 @@ public Int32 swe_pheno(double tjd, Int32 ipl, Int32 iflag, double[] attr, ref st
} else if (ipl == SwissEph.SE_MOON) {
/* formula according to Allen, C.W., 1976, Astrophysical Quantities */
/*attr[4] = -21.62 + 5 * log10(384410497.8 / EARTH_RADIUS) / log10(10) + 0.026 * Math.Abs(attr[0]) + 0.000000004 * pow(attr[0], 4);*/
attr[4] = -21.62 + 5 * Math.Log10(lbr[2] * Sweph.AUNIT / Sweph.EARTH_RADIUS) / Math.Log10(10) + 0.026 * Math.Abs(attr[0]) + 0.000000004 * Math.Pow(attr[0], 4);
//attr[4] = -21.62 + 5 * Math.Log10(lbr[2] * Sweph.AUNIT / Sweph.EARTH_RADIUS) / Math.Log10(10) + 0.026 * Math.Abs(attr[0]) + 0.000000004 * Math.Pow(attr[0], 4);
attr[4] = -21.62 + 5 * Math.Log10(lbr[2] * Sweph.AUNIT / Sweph.EARTH_RADIUS) + 0.026 * Math.Abs(attr[0]) + 0.000000004 * Math.Pow(attr[0], 4);
//#if 0
// /* ratio apparent diameter : average diameter */
// fac = attr[3] / (asin(pla_diam[SE_MOON] / 2.0 / 384400000.0) * 2 * SwissEph.RADTODEG);
Expand All @@ -3946,7 +3983,8 @@ public Int32 swe_pheno(double tjd, Int32 ipl, Int32 iflag, double[] attr, ref st
// attr[4] = mag_elem[ipl,0] - 2.5 * log10(fac);
//#endif
/*printf("1 = %f, 2 = %f\n", mag, mag2);*/
} else if (ipl == SwissEph.SE_SATURN) {
}
else if (ipl == SwissEph.SE_SATURN) {
/* rings are considered according to Meeus, p. 301ff. (German version 329ff.) */
T = (tjd - dt - Sweph.J2000) / 36525.0;
inx = (28.075216 - 0.012998 * T + 0.000004 * T * T) * SwissEph.DEGTORAD;
Expand Down Expand Up @@ -4075,7 +4113,7 @@ public Int32 swe_pheno(double tjd, Int32 ipl, Int32 iflag, double[] attr, ref st
}
if (!string.IsNullOrEmpty(serr2))
serr = serr2;
return SwissEph.OK;
return iflag;
}

public Int32 swe_pheno_ut(double tjd_ut, Int32 ipl, Int32 iflag, double[] attr, ref string serr) {
Expand Down Expand Up @@ -5084,8 +5122,9 @@ public Int32 swe_nod_aps(double tjd_et, Int32 ipl, Int32 iflag,
if (ipl == SwissEph.SE_MEAN_NODE || ipl == SwissEph.SE_TRUE_NODE ||
ipl == SwissEph.SE_MEAN_APOG || ipl == SwissEph.SE_OSCU_APOG ||
ipl < 0 ||
(ipl >= SwissEph.SE_NPLANETS && ipl <= SwissEph.SE_AST_OFFSET)) {
/*(ipl >= SE_FICT_OFFSET && ipl - SE_FICT_OFFSET < SE_NFICT_ELEM)) */
(ipl >= SwissEph.SE_NPLANETS && ipl <= SwissEph.SE_AST_OFFSET))
// (ipl >= SE_FICT_OFFSET && ipl - SE_FICT_OFFSET < SE_NFICT_ELEM))
{
serr = C.sprintf("nodes/apsides for planet %5.0f are not implemented", (double)ipl);
if (xnasc != null)
for (i = 0; i <= 5; i++)
Expand Down Expand Up @@ -5419,6 +5458,7 @@ public Int32 swe_nod_aps(double tjd_et, Int32 ipl, Int32 iflag,
SE.SwephLib.swi_precess(xp, tjd_et, iflag, Sweph.J_TO_J2000);
if ((iflag & SwissEph.SEFLG_SPEED) != 0)
SE.Sweph.swi_precess_speed(xp, tjd_et, iflag, Sweph.J_TO_J2000);
// fprintf(stderr, "%.17f, %.17f, %.17f, %.17f, %.17f, %.17f\n", xp[0], xp[1], xp[2], xp[3], xp[4], xp[5]);
/*********************
* to barycenter
*********************/
Expand Down
7 changes: 2 additions & 5 deletions SwissEphNet/CPort/SweDate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public SweDate(SwissEph se)

/*
swe_date_conversion():
This function converts some date+time input {d,m,y,uttime}
This function converts some date+time input {y,m,d,uttime}
into the Julian day number tjd.
The function checks that the input is a legal combination
of dates; for illegal dates like 32 January 1993 it returns ERR
Expand Down Expand Up @@ -136,7 +136,7 @@ public int swe_date_conversion(int y,
} else {
return SwissEph.ERR;
}
} /* end date_conversion */
}

/*************** swe_julday ********************************************
* This function returns the absolute Julian day number (JD)
Expand Down Expand Up @@ -174,9 +174,6 @@ Year 0 (astronomical) = 1 BC
Original author: Marc Pottenger, Los Angeles.
with bug fix for year < -4711 15-aug-88 by Alois Treindl
(The parameter sequence m,d,y still indicates the US origin,
be careful because the similar function date_conversion() uses
other parameter sequence and also Astrodienst relative juldate.)
References: Oliver Montenbruck, Grundlagen der Ephemeridenrechnung,
Verlag Sterne und Weltraum (1987), p.49 ff
Expand Down
31 changes: 23 additions & 8 deletions SwissEphNet/CPort/SweHel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ double OpticFactor(double Bback, double kX, double[] dobs, double JDNDaysUT, str
double OpticDia = dobs[4];
double OpticTrans = dobs[5];
bool is_scotopic = false;
//JDNDaysUT = JDNDaysUT; /* currently not used, statement prevents compiler warning */
JDNDaysUT += 0.0; /* currently not used, statement prevents compiler warning */
SNi = SN;
if (SNi <= 0.00000001) SNi = 0.00000001;
/* 23 jaar as standard from Garstang*/
Expand Down Expand Up @@ -560,7 +560,7 @@ Int32 RiseSet(double JDNDaysUT, double[] dgeo, double[] datm, string ObjectName,
double SunRA(double JDNDaysUT, Int32 helflag, ref string serr) {
int imon = 0, iday = 0, iyar = 0, calflag = SwissEph.SE_GREG_CAL;
double dut = 0;
//helflag = helflag; /* statement prevents compiler warning */
helflag += 0; /* statement prevents compiler warning */
serr = null;
if (JDNDaysUT == SunRA_tjdlast)
return SunRA_ralast;
Expand Down Expand Up @@ -1245,7 +1245,7 @@ double Bday(double AltO, double AziO, double AltS, double AziS, double sunra, do
*/
double Bcity(double Value, double Press) {
double Bcity = Value;
//Press = Press; /* unused; statement prevents compiler warning */
Press += 0.0; /* unused; statement prevents compiler warning */
Bcity = mymax(Bcity, 0);
return Bcity;
}
Expand Down Expand Up @@ -1425,6 +1425,8 @@ static string tolower_string_star(ref string str)
}

/* Limiting magnitude in dark skies
* for information about input parameters, see function swe_heliacal_ut().
*
* function returns:
* -1 Error
* -2 Object is below horizon
Expand Down Expand Up @@ -1572,6 +1574,7 @@ public Int32 swe_topo_arcus_visionis(double tjdut, double[] dgeo, double[] datm,
sunra = SunRA(tjdut, helflag, ref serr);
if (!String.IsNullOrEmpty(serr))
return SwissEph.ERR;
default_heliacal_parameters(datm, dgeo, dobs, helflag);
return TopoArcVisionis(mag, dobs, alt_obj, azi_obj, alt_moon, azi_moon, tjdut, azi_sun, sunra, dgeo[1], dgeo[2], datm, helflag, ref dret, ref serr);
}

Expand Down Expand Up @@ -1664,6 +1667,7 @@ public Int32 swe_heliacal_angle(double tjdut, double[] dgeo, double[] datm, doub
return SwissEph.ERR;
}
SE.SwephLib.swi_set_tid_acc(tjdut, helflag, 0, ref serr);
default_heliacal_parameters(datm, dgeo, dobs, helflag);
return HeliacalAngle(mag, dobs, azi_obj, alt_moon, azi_moon, tjdut, azi_sun, dgeo, datm, helflag, dret, ref serr);
}

Expand Down Expand Up @@ -1788,7 +1792,9 @@ void strcpy_VBsafe(out string sout, string sin)

/*###################################################################
' JDNDaysUT [JDN]
' HPheno
' for information about input parameters, see function swe_heliacal_ut().
'
' output values:
'0=AltO [deg] topocentric altitude of object (unrefracted)
'1=AppAltO [deg] apparent altitude of object (refracted)
'2=GeoAltO [deg] geocentric altitude of object
Expand Down Expand Up @@ -3213,7 +3219,7 @@ Int32 moon_event_vis_lim(double tjdstart, double[] dgeo, double[] datm, double[]
Int32 epheflag = helflag & (SwissEph.SEFLG_JPLEPH | SwissEph.SEFLG_SWIEPH | SwissEph.SEFLG_MOSEPH);
dret[0] = tjdstart; /* will be returned in error case */
if (TypeEvent == 1 || TypeEvent == 2) {
serr = "error: the moon has no morning first or evening last";
serr_ret = "error: the moon has no morning first or evening last";
return SwissEph.ERR;
}
ObjectName = "moon";
Expand Down Expand Up @@ -3316,11 +3322,21 @@ Int32 heliacal_ut(double JDNDaysUTStart, double[] dgeo, double[] datm, double[]
' a good default would be 0.25
' VR=-1: the ktot is calculated from the other atmospheric
' constants.
' age [Year] default 36, experienced sky observer in ancient times
'
' dobs[6] observer parameters
' - age [Year] default 36, experienced sky observer in ancient times
' optimum age is 23
' SN Snellen factor of the visual aquity of the observer
' - SN Snellen factor of the visual aquity of the observer
' default 1
' see: http://www.i-see.org/eyecharts.html#make-your-own
' The following parameters of dobs[] are only relevant if the flag
' SE_HELFLAG_OPTICAL_PARAMS is set:
' - is_binocular 0 = monocular, 1 = binocular (actually a boolean)
' - OpticMagn telescope magnification:
' 0 = default to naked eye (binocular), 1 = naked eye
' - OpticDia optical aperture (telescope diameter) in mm
' - OpticTrans optical transmission
'
' TypeEvent 1 morning first
' 2 evening last
' 3 evening first
Expand All @@ -3347,7 +3363,6 @@ public Int32 swe_heliacal_ut(double JDNDaysUTStart, double[] dgeo, double[] datm
MaxCountSynodicPeriod = MAX_COUNT_SYNPER_MAX;
/* if (helflag & SE_HELFLAG_SEARCH_1_PERIOD)
MaxCountSynodicPeriod = 1; */
serr = String.Empty;
serr_ret = String.Empty;
/* note, the fixed stars functions rewrite the star name. The input string
may be too short, so we have to make sure we have enough space */
Expand Down
Loading

0 comments on commit 1930ecd

Please sign in to comment.