Skip to content

Commit

Permalink
Reenable obstruction in tracking data
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherRabotin committed Dec 8, 2024
1 parent 37fcbb2 commit 9c22b15
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 56 deletions.
6 changes: 3 additions & 3 deletions examples/04_lro_od/dsn-network.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ DSS-65 Madrid:
white_noise:
mean: 0.0
sigma: 50.0e-6 # 5 cm/s
light_time_correction: false
light_time_correction: true
latitude_deg: 40.427222
longitude_deg: 4.250556
height_km: 0.834939
Expand Down Expand Up @@ -43,7 +43,7 @@ DSS-34 Canberra:
white_noise:
mean: 0.0
sigma: 50.0e-6 # 5 cm/s
light_time_correction: false
light_time_correction: true
measurement_types:
- range_km
- doppler_km_s
Expand All @@ -68,7 +68,7 @@ DSS-13 Goldstone:
white_noise:
mean: 0.0
sigma: 50.0e-6 # 5 cm/s
light_time_correction: false
light_time_correction: true
measurement_types:
- range_km
- doppler_km_s
2 changes: 1 addition & 1 deletion examples/04_lro_od/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ fn main() -> Result<(), Box<dyn Error>> {
// Increase the initial covariance to account for larger deviation.
initial_estimate,
// Until https://github.com/nyx-space/nyx/issues/351, we need to specify the SNC in the acceleration of the Moon J2000 frame.
SNC3::from_diagonal(10 * Unit::Minute, &[1e-11, 1e-11, 1e-11]),
SNC3::from_diagonal(10 * Unit::Minute, &[1e-12, 1e-12, 1e-12]),
);

// We'll set up the OD process to reject measurements whose residuals are mover than 4 sigmas away from what we expect.
Expand Down
66 changes: 15 additions & 51 deletions examples/04_lro_od/plot_od_rslt.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
import numpy as np
import plotly.graph_objects as go
import plotly.express as px
import click

if __name__ == "__main__":
df = pl.read_parquet("output_data/ekf_rng_dpl_az_el_odp.parquet")

@click.command
@click.option("-p", "--path", type=str, default="./04_lro_od_results.parquet")
def main(path: str):
df = pl.read_parquet(path)

df = (
df.with_columns(pl.col("Epoch (UTC)").str.to_datetime("%Y-%m-%dT%H:%M:%S%.f"))
Expand Down Expand Up @@ -49,68 +53,25 @@
# Add scatter points
fig_qq.add_trace(
go.Scatter(
x=qq[0][0],
y=qq[0][1],
mode='markers',
name='Sample Data',
marker=dict(color='blue')
x=qq[0][0], y=qq[0][1], mode="markers", name="Residuals ratios (QQ)", marker=dict(color="blue")
)
)

# Add the theoretical line
fig_qq.add_trace(
go.Scatter(
x=x_qq,
y=y_qq,
mode='lines',
name='Theoretical Normal',
line=dict(color='red')
)
go.Scatter(x=x_qq, y=y_qq, mode="lines", name="Theoretical Normal", line=dict(color="red"))
)

# Update layout
fig_qq.update_layout(
title='Normal Q-Q Plot',
xaxis_title='Theoretical Quantiles',
yaxis_title='Sample Quantiles',
title="Normal Q-Q Plot",
xaxis_title="Theoretical Quantiles",
yaxis_title="Sample Quantiles",
)

# Show QQ plot
fig_qq.show()

# Create histogram with normal distribution overlay
hist_fig = px.histogram(
df,
x="Residual ratio",
color="Tracker",
marginal="rug",
hover_data=df.columns,
)

# Calculate normal distribution parameters
mean = residual_ratio.mean()
std = residual_ratio.std()
x_range = np.linspace(residual_ratio.min(), residual_ratio.max(), 100)
y_normal = stats.norm.pdf(x_range, mean, std)

# Scale the normal distribution to match histogram height
max_hist_height = 100
scaling_factor = max_hist_height / max(y_normal)
y_normal_scaled = y_normal * scaling_factor

# Add normal distribution curve
hist_fig.add_trace(
go.Scatter(
x=x_range,
y=y_normal_scaled,
name='Normal Distribution',
line=dict(color='red', width=2),
)
)

# Show histogram with normal overlay
hist_fig.show()

px.histogram(
df,
x="Residual ratio",
Expand Down Expand Up @@ -163,7 +124,6 @@
y=["Sigma Vx (RIC) (km/s)", "Sigma Vy (RIC) (km/s)", "Sigma Vz (RIC) (km/s)"],
).show()

raise AssertionError("stop")
# Load the RIC diff.
for fname, errname in [
("04_lro_od_truth_error", "OD vs Flown"),
Expand Down Expand Up @@ -219,3 +179,7 @@
],
title=f"Velocity error with {errname} ({fname})",
).show()


if __name__ == "__main__":
main()
38 changes: 38 additions & 0 deletions examples/04_lro_od/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
asttokens==2.4.1
attrs==23.2.0
click==8.1.7
decorator==5.1.1
executing==2.0.1
iniconfig==2.0.0
ipython==8.25.0
jedi==0.19.1
matplotlib-inline==0.1.7
maturin==1.6.0
numpy==1.26.4
packaging==24.1
pandas==2.1.4
parso==0.8.4
pexpect==4.9.0
pip==24.0
plotly==5.16.1
pluggy==1.5.0
polars==0.20.31
prompt-toolkit==3.0.47
ptyprocess==0.7.0
pure-eval==0.2.2
pyarrow==13.0.0
pygments==2.18.0
pytest==7.2.2
python-dateutil==2.9.0.post0
python-slugify==8.0.4
pytz==2024.1
ruff==0.5.0
scipy==1.11.4
six==1.16.0
stack-data==0.6.3
tenacity==8.3.0
text-unidecode==1.3
traitlets==5.14.3
typing-extensions==4.12.2
tzdata==2024.1
wcwidth==0.2.13
10 changes: 9 additions & 1 deletion src/od/ground_station/trk_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ impl TrackingDevice<Spacecraft> for GroundStation {
self.name, self.elevation_mask_deg, aer_t0.elevation_deg, aer_t1.elevation_deg
);
return Ok(None);

Check warning on line 86 in src/od/ground_station/trk_device.rs

View check run for this annotation

Codecov / codecov/patch

src/od/ground_station/trk_device.rs#L86

Added line #L86 was not covered by tests
} else if aer_t0.is_obstructed() || aer_t1.is_obstructed() {
debug!(
"{} obstruction at t0={}, t1={} -- no measurement",
self.name,
aer_t0.is_obstructed(),
aer_t1.is_obstructed()

Check warning on line 92 in src/od/ground_station/trk_device.rs

View check run for this annotation

Codecov / codecov/patch

src/od/ground_station/trk_device.rs#L88-L92

Added lines #L88 - L92 were not covered by tests
);
return Ok(None);

Check warning on line 94 in src/od/ground_station/trk_device.rs

View check run for this annotation

Codecov / codecov/patch

src/od/ground_station/trk_device.rs#L94

Added line #L94 was not covered by tests
}

// Noises are computed at the midpoint of the integration time.
Expand Down Expand Up @@ -128,7 +136,7 @@ impl TrackingDevice<Spacecraft> for GroundStation {
action: "computing AER",
})?;

if aer.elevation_deg >= self.elevation_mask_deg {
if aer.elevation_deg >= self.elevation_mask_deg && !aer.is_obstructed() {
// Only update the noises if the measurement is valid.
let noises = self.noises(rx.orbit.epoch, rng)?;

Expand Down

0 comments on commit 9c22b15

Please sign in to comment.