From 65ba8d8fb5ce314a5e9ba5f5b44b070423c9d24c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Drza=C5=82?= Date: Thu, 21 Oct 2021 02:28:20 +0200 Subject: [PATCH 1/5] Update vectorlib.py --- skyfield/vectorlib.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/skyfield/vectorlib.py b/skyfield/vectorlib.py index 57ee37a0b..9708a22c2 100644 --- a/skyfield/vectorlib.py +++ b/skyfield/vectorlib.py @@ -215,8 +215,12 @@ def _at(self, t): p2, v2, another_gcrs_position, message = vf._at(t) if gcrs_position is None: # TODO: so bootleg; rework whole idea gcrs_position = another_gcrs_position - p += p2 - v += v2 + if not isinstance(p, float) and len(p2.shape) > len(p.shape): + p = p2 + p[:,newaxis] + v = v2 + v[:,newaxis] + else: + p += p2 + v += v2 return p, v, gcrs_position, message def _correct_for_light_travel_time(observer, target): From 802465cbd6fc770953611c32766344f9818d691b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Drza=C5=82?= Date: Thu, 21 Oct 2021 02:30:03 +0200 Subject: [PATCH 2/5] Update keplerlib.py --- skyfield/keplerlib.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/skyfield/keplerlib.py b/skyfield/keplerlib.py index 9ec83b68c..56706c383 100644 --- a/skyfield/keplerlib.py +++ b/skyfield/keplerlib.py @@ -536,7 +536,10 @@ def kepler_1d(x, orb_inds): t0 = repeat(t0, position.shape[1]) # shape of 2 dimensional arrays from here on out should be (#orbits, len(t1)) - dt = t1 - t0[:, newaxis] + if t1.shape == t0.shape: + dt = t1[:, newaxis] - t0[:, newaxis] + else: + dt = t1 - t0[:, newaxis] x = dt/bq copyto(x, -bound, where=(x<-bound)) From 3585ac74c813f751e132620b0c3592bbf5a87a21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Drza=C5=82?= Date: Sun, 24 Oct 2021 00:20:30 +0200 Subject: [PATCH 3/5] Update vectorlib.py --- skyfield/vectorlib.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/skyfield/vectorlib.py b/skyfield/vectorlib.py index 9708a22c2..984dadf35 100644 --- a/skyfield/vectorlib.py +++ b/skyfield/vectorlib.py @@ -1,7 +1,7 @@ """Vector functions and their composition.""" from jplephem.names import target_names as _jpl_code_name_dict -from numpy import max +from numpy import max, newaxis from .constants import C_AUDAY from .descriptorlib import reify from .errors import DeprecationError @@ -243,7 +243,7 @@ def _correct_for_light_travel_time(observer, target): tposition, tvelocity, gcrs_position, message = target._at(t) - distance = length_of(tposition - cposition) + distance = length_of(tposition - cposition[:,newaxis]) light_time0 = 0.0 for i in range(10): light_time = distance / C_AUDAY @@ -257,11 +257,11 @@ def _correct_for_light_travel_time(observer, target): t2 = ts.tdb_jd(whole, tdb_fraction - light_time) tposition, tvelocity, gcrs_position, message = target._at(t2) - distance = length_of(tposition - cposition) + distance = length_of(tposition - cposition[:,newaxis]) light_time0 = light_time else: raise ValueError('light-travel time failed to converge') - return tposition - cposition, tvelocity - cvelocity, t, light_time + return tposition - cposition[:,newaxis], tvelocity - cvelocity[:,newaxis], t, light_time def _jpl_name(target): if not isinstance(target, int): From 6a490826f0d50170f94d7fad421b6e3744227fc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Drza=C5=82?= Date: Sun, 24 Oct 2021 00:20:49 +0200 Subject: [PATCH 4/5] Update keplerlib.py --- skyfield/keplerlib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skyfield/keplerlib.py b/skyfield/keplerlib.py index 56706c383..3faa9744d 100644 --- a/skyfield/keplerlib.py +++ b/skyfield/keplerlib.py @@ -5,7 +5,7 @@ from numpy import(abs, amax, amin, arange, arccos, arctan, array, atleast_1d, clip, copy, copyto, cos, cosh, exp, float64, full_like, log, ndarray, newaxis, pi, power, repeat, sin, sinh, squeeze, - sqrt, sum, tan, tanh, zeros_like) + sqrt, sum, tan, tanh, zeros_like, newaxis) from skyfield.constants import AU_KM, DAY_S, DEG2RAD from skyfield.functions import dots, length_of, mxv From 3d779f39454f4ef19bd78846d3d6bc952400e01a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Drza=C5=82?= Date: Mon, 25 Oct 2021 13:44:21 +0200 Subject: [PATCH 5/5] Update vectorlib.py To also pass other tests with observe at --- skyfield/vectorlib.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/skyfield/vectorlib.py b/skyfield/vectorlib.py index 984dadf35..9382a826e 100644 --- a/skyfield/vectorlib.py +++ b/skyfield/vectorlib.py @@ -242,8 +242,11 @@ def _correct_for_light_travel_time(observer, target): cvelocity = observer.velocity.au_per_d tposition, tvelocity, gcrs_position, message = target._at(t) - - distance = length_of(tposition - cposition[:,newaxis]) + if len(cposition.shape) != len(tposition.shape) and len(tposition.shape) == 2 and len(cposition.shape) == 1: + cposition = cposition[:,newaxis] + cvelocity = cvelocity[:,newaxis] + + distance = length_of(tposition - cposition) light_time0 = 0.0 for i in range(10): light_time = distance / C_AUDAY @@ -257,11 +260,11 @@ def _correct_for_light_travel_time(observer, target): t2 = ts.tdb_jd(whole, tdb_fraction - light_time) tposition, tvelocity, gcrs_position, message = target._at(t2) - distance = length_of(tposition - cposition[:,newaxis]) + distance = length_of(tposition - cposition) light_time0 = light_time else: raise ValueError('light-travel time failed to converge') - return tposition - cposition[:,newaxis], tvelocity - cvelocity[:,newaxis], t, light_time + return tposition - cposition, tvelocity - cvelocity, t, light_time def _jpl_name(target): if not isinstance(target, int):