From 4be7b949f6f874afad847506fa68c203f7f75bd4 Mon Sep 17 00:00:00 2001 From: Don Cross Date: Sun, 30 Jun 2019 07:50:29 -0400 Subject: [PATCH] JS: renamed field from apsisType to kind. --- generate/lunar_apsis_test.js | 4 ++-- generate/template/astronomy.js | 14 +++++++------- generate/template/astronomy.py | 6 ------ source/js/README.md | 2 +- source/js/astronomy.js | 14 +++++++------- source/js/astronomy.min.js | 4 ++-- source/python/astronomy.py | 6 ------ 7 files changed, 19 insertions(+), 31 deletions(-) diff --git a/generate/lunar_apsis_test.js b/generate/lunar_apsis_test.js index 02c30625..5989b000 100644 --- a/generate/lunar_apsis_test.js +++ b/generate/lunar_apsis_test.js @@ -32,9 +32,9 @@ function Test() { let date = new Date(token[1]); let dist = parseInt(token[2]); - if (evt.apsisType !== kind) { + if (evt.kind !== kind) { console.log('line = ', line); - throw `${filename} line ${lnum}: Expected apsis type ${kind}, found ${evt.apsisType}`; + throw `${filename} line ${lnum}: Expected apsis type ${kind}, found ${evt.kind}`; } let diff_minutes = Math.abs(evt.time.date - date) / (1000 * 60); diff --git a/generate/template/astronomy.js b/generate/template/astronomy.js index ca9a6d82..e594dc2d 100644 --- a/generate/template/astronomy.js +++ b/generate/template/astronomy.js @@ -3245,9 +3245,9 @@ Astronomy.SearchPeakMagnitude = function(body, startDate) { * @property {Astronomy.AstroTime} time * The date and time of the apsis. * - * @property {number} apsisType - * For a closest approach (perigee or perihelion), apsisType is 0. - * For a farthest distance event (apogee or aphelion), apsisType is 1. + * @property {number} kind + * For a closest approach (perigee or perihelion), kind is 0. + * For a farthest distance event (apogee or aphelion), kind is 1. * * @property {number} dist_au * The distance between the centers of the two bodies in astronomical units (AU). @@ -3259,9 +3259,9 @@ Astronomy.SearchPeakMagnitude = function(body, startDate) { * @see {@link Astronomy.NextLunarApsis} */ class Apsis { - constructor(time, apsisType, dist_au) { + constructor(time, kind, dist_au) { this.time = time; - this.apsisType = apsisType; + this.kind = kind; this.dist_au = dist_au; this.dist_km = dist_au * KM_PER_AU; } @@ -3366,8 +3366,8 @@ Astronomy.SearchLunarApsis = function(startDate) { Astronomy.NextLunarApsis = function(apsis) { const skip = 11; // number of days to skip to start looking for next apsis event let next = Astronomy.SearchLunarApsis(apsis.time.AddDays(skip)); - if (next.apsisType + apsis.apsisType !== 1) { - throw `NextLunarApsis INTERNAL ERROR: did not find alternating apogee/perigee: prev=${apsis.apsisType} @ ${apsis.time.toString()}, next=${next.apsisType} @ ${next.time.toString()}`; + if (next.kind + apsis.kind !== 1) { + throw `NextLunarApsis INTERNAL ERROR: did not find alternating apogee/perigee: prev=${apsis.kind} @ ${apsis.time.toString()}, next=${next.kind} @ ${next.time.toString()}`; } return next; } diff --git a/generate/template/astronomy.py b/generate/template/astronomy.py index d32f271c..f093048f 100644 --- a/generate/template/astronomy.py +++ b/generate/template/astronomy.py @@ -1986,12 +1986,6 @@ def NextLunarApsis(apsis): # + _neg_elong_slope # + SearchRelativeLongitude # + Elongation -# + LongitudeFromSun -# + MoonPhase -# + SearchMoonPhase -# + _moon_offset -# + SearchMoonQuarter -# + NextMoonQuarter # + SearchHourAngle # + SearchRiseSet # + Illumination diff --git a/source/js/README.md b/source/js/README.md index 8753d479..33373033 100644 --- a/source/js/README.md +++ b/source/js/README.md @@ -407,7 +407,7 @@ For the Moon orbiting the Earth, this is a perigee or apogee, respectively. | Name | Type | Description | | --- | --- | --- | | time | [AstroTime](#Astronomy.AstroTime) | The date and time of the apsis. | -| apsisType | number | For a closest approach (perigee or perihelion), apsisType is 0. For a farthest distance event (apogee or aphelion), apsisType is 1. | +| kind | number | For a closest approach (perigee or perihelion), kind is 0. For a farthest distance event (apogee or aphelion), kind is 1. | | dist_au | number | The distance between the centers of the two bodies in astronomical units (AU). | | dist_km | number | The distance between the centers of the two bodies in kilometers. | diff --git a/source/js/astronomy.js b/source/js/astronomy.js index 213bec47..19fb5271 100644 --- a/source/js/astronomy.js +++ b/source/js/astronomy.js @@ -4083,9 +4083,9 @@ Astronomy.SearchPeakMagnitude = function(body, startDate) { * @property {Astronomy.AstroTime} time * The date and time of the apsis. * - * @property {number} apsisType - * For a closest approach (perigee or perihelion), apsisType is 0. - * For a farthest distance event (apogee or aphelion), apsisType is 1. + * @property {number} kind + * For a closest approach (perigee or perihelion), kind is 0. + * For a farthest distance event (apogee or aphelion), kind is 1. * * @property {number} dist_au * The distance between the centers of the two bodies in astronomical units (AU). @@ -4097,9 +4097,9 @@ Astronomy.SearchPeakMagnitude = function(body, startDate) { * @see {@link Astronomy.NextLunarApsis} */ class Apsis { - constructor(time, apsisType, dist_au) { + constructor(time, kind, dist_au) { this.time = time; - this.apsisType = apsisType; + this.kind = kind; this.dist_au = dist_au; this.dist_km = dist_au * KM_PER_AU; } @@ -4204,8 +4204,8 @@ Astronomy.SearchLunarApsis = function(startDate) { Astronomy.NextLunarApsis = function(apsis) { const skip = 11; // number of days to skip to start looking for next apsis event let next = Astronomy.SearchLunarApsis(apsis.time.AddDays(skip)); - if (next.apsisType + apsis.apsisType !== 1) { - throw `NextLunarApsis INTERNAL ERROR: did not find alternating apogee/perigee: prev=${apsis.apsisType} @ ${apsis.time.toString()}, next=${next.apsisType} @ ${next.time.toString()}`; + if (next.kind + apsis.kind !== 1) { + throw `NextLunarApsis INTERNAL ERROR: did not find alternating apogee/perigee: prev=${apsis.kind} @ ${apsis.time.toString()}, next=${next.kind} @ ${next.time.toString()}`; } return next; } diff --git a/source/js/astronomy.min.js b/source/js/astronomy.min.js index 4347098f..9419ebf6 100644 --- a/source/js/astronomy.min.js +++ b/source/js/astronomy.min.js @@ -137,6 +137,6 @@ function(a,b){b=e.MakeTime(b);var d=e.LongitudeFromSun(a,b);if(180=b.tt)return e.Elongation(a,k);b=h.AddDays(1)}throw"SearchMaxElongation: failed to find event after 2 tries.";};e.SearchPeakMagnitude=function(a,b){function d(b){var c=b.AddDays(-.005);b=b.AddDays(.005);c=e.Illumination(a,c).mag;return(e.Illumination(a,b).mag-c)/.01}if("Venus"!==a)throw"SearchPeakMagnitude currently works for Venus only.";b=e.MakeTime(b);for(var c=0;2>=++c;){var g=e.EclipticLongitude(a,b),l=e.EclipticLongitude("Earth",b);l=J(g- l);var k=g=void 0,h=k=g=void 0;-10<=l&&10>l?(h=0,g=10,k=30):30<=l||-30>l?(h=0,g=-30,k=-10):0<=l?(h=-G(a)/4,g=10,k=30):(h=-G(a)/4,g=-30,k=-10);l=b.AddDays(h);g=e.SearchRelativeLongitude(a,g,l);k=e.SearchRelativeLongitude(a,k,g);l=d(g);if(0<=l)throw"SearchPeakMagnitude: internal error: m1 = "+l;h=d(k);if(0>=h)throw"SearchPeakMagnitude: internal error: m2 = "+h;l=e.Search(d,g,k,{init_f1:l,init_f2:h,dt_tolerance_seconds:10});if(!l)throw"SearchPeakMagnitude: failed search iter "+c+" (t1="+g.toString()+ -", t2="+k.toString()+")";if(l.tt>=b.tt)return e.Illumination(a,l);b=k.AddDays(1)}throw"SearchPeakMagnitude: failed to find event after 2 tries.";};var ea=function(a,b,d){this.time=a;this.apsisType=b;this.dist_au=d;this.dist_km=1.4959787069098932E8*d};e.SearchLunarApsis=function(a){function b(a){var b=a.AddDays(-5E-4);a=a.AddDays(5E-4);b=E(b).distance_au;return(E(a).distance_au-b)/.001}function d(a){return-b(a)}a=e.MakeTime(a);var c=b(a);++I.lunar_apsis_calls;for(var g=0;59.061176>5*g;++g){++I.lunar_apsis_iter; +", t2="+k.toString()+")";if(l.tt>=b.tt)return e.Illumination(a,l);b=k.AddDays(1)}throw"SearchPeakMagnitude: failed to find event after 2 tries.";};var ea=function(a,b,d){this.time=a;this.kind=b;this.dist_au=d;this.dist_km=1.4959787069098932E8*d};e.SearchLunarApsis=function(a){function b(a){var b=a.AddDays(-5E-4);a=a.AddDays(5E-4);b=E(b).distance_au;return(E(a).distance_au-b)/.001}function d(a){return-b(a)}a=e.MakeTime(a);var c=b(a);++I.lunar_apsis_calls;for(var g=0;59.061176>5*g;++g){++I.lunar_apsis_iter; var l=a.AddDays(5),k=b(l);if(0>=c*k){if(0>c||0k){a=e.Search(d,a,l,{init_f1:-c,init_f2:-k});if(null==a)throw"SearchLunarApsis INTERNAL ERROR: apogee search failed!";c=E(a).distance_au;return new ea(a,1,c)}throw"SearchLunarApsis INTERNAL ERROR: cannot classify apsis event!";}a=l;c=k}throw"SearchLunarApsis INTERNAL ERROR: could not find apsis within 2 synodic months of start date."; -};e.NextLunarApsis=function(a){var b=e.SearchLunarApsis(a.time.AddDays(11));if(1!==b.apsisType+a.apsisType)throw"NextLunarApsis INTERNAL ERROR: did not find alternating apogee/perigee: prev="+a.apsisType+" @ "+a.time.toString()+", next="+b.apsisType+" @ "+b.time.toString();return b}})("undefined"===typeof exports?this.Astronomy={}:exports); +};e.NextLunarApsis=function(a){var b=e.SearchLunarApsis(a.time.AddDays(11));if(1!==b.kind+a.kind)throw"NextLunarApsis INTERNAL ERROR: did not find alternating apogee/perigee: prev="+a.kind+" @ "+a.time.toString()+", next="+b.kind+" @ "+b.time.toString();return b}})("undefined"===typeof exports?this.Astronomy={}:exports); diff --git a/source/python/astronomy.py b/source/python/astronomy.py index f4e7971f..9e61b647 100644 --- a/source/python/astronomy.py +++ b/source/python/astronomy.py @@ -2824,12 +2824,6 @@ def NextLunarApsis(apsis): # + _neg_elong_slope # + SearchRelativeLongitude # + Elongation -# + LongitudeFromSun -# + MoonPhase -# + SearchMoonPhase -# + _moon_offset -# + SearchMoonQuarter -# + NextMoonQuarter # + SearchHourAngle # + SearchRiseSet # + Illumination