Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Horizons Covariance sample has small residual error #136

Merged
merged 2 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Changed the return signature for `fov_static_check`, this now returns indices of
the inputs, instead of the original inputs themselves.

### Fixed

- Sampling of JPL Horizons orbit fits was slightly off, and appears to be fixed by
assuming that the epoch time of the covariance fits is in UTC. This assumption is
now included in the covariance matrix sampling. This is different than their other
data products.


## [v1.0.2]

Expand Down
20 changes: 7 additions & 13 deletions src/kete/horizons.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def _sample(self, n_samples):
The number of samples to take of the covariance.
"""
matrix = self.covariance.cov_matrix
epoch = self.covariance.epoch
epoch = Time(self.covariance.epoch, scaling="utc").jd
samples = generate_sample_from_cov(n_samples, matrix)

elem_keywords = [
Expand All @@ -318,21 +318,14 @@ def _sample(self, n_samples):
"peri_time",
]

labels = self.json["orbit"]["covariance"]["labels"]
dahlend marked this conversation as resolved.
Show resolved Hide resolved
mapped_label = [_PARAM_MAP[k.lower()] for k in labels]

best_params = _nongrav_params(self)
for prop in elem_keywords:
best_params[prop] = getattr(self, prop)
states = []
non_gravs = []
for sample in samples:
cur_params = {
label: best_params[label] + d for label, d in zip(mapped_label, sample)
}
elem_params = {x: cur_params.pop(x) for x in elem_keywords}
names, vals = zip(*self.covariance.params)
params = dict(zip(names, np.array(vals) + sample))
elem_params = {x: params.pop(x) for x in elem_keywords}
state = CometElements(self.desig, epoch, **elem_params).state
non_grav = NonGravModel.new_comet(**cur_params)
non_grav = NonGravModel.new_comet(**params)
states.append(state)
non_gravs.append(non_grav)

Expand Down Expand Up @@ -475,7 +468,8 @@ def fetch_known_orbit_data(update_cache=False):
"https://ssd-api.jpl.nasa.gov/sbdb_query.api?fields="
"pdes,spkid,orbit_id,rms,H,diameter,epoch,e,i,q,w,tp,om,A1,A2,A3,DT"
"&full-prec=1&sb-xfrag=1"
)
),
timeout=120,
)
res.raise_for_status()
with gzip.open(filename, "wb") as f:
Expand Down