Skip to content

Commit

Permalink
Merge pull request #301 from johnbdesanto/transponder_mismatch
Browse files Browse the repository at this point in the history
fix: Ignore pings without replies from every transponder
  • Loading branch information
johnbdesanto authored Aug 21, 2024
2 parents d028023 + ff6233f commit f1686e5
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
31 changes: 31 additions & 0 deletions src/gnatss/ops/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,37 @@ def get_data_inputs(all_observations: pd.DataFrame) -> NumbaList:
return data_inputs


def prefilter_replies(
all_observations: pd.DataFrame,
num_transponders: int,
) -> pd.DataFrame:
"""
Remove pings that do receive replies from each
transponder in the array.
Parameters
----------
all_observations : pd.DataFrame
The original observations that include every ping and reply
num_transponders : int
The number of transponders in the array
Returns
-------
pd.DataFrame
The observations where the number of replies equal the
number of transponders
"""
# Get value counts for transmit times
time_counts = all_observations[constants.DATA_SPEC.tx_time].value_counts()

return all_observations[
all_observations[constants.DATA_SPEC.tx_time].isin(
time_counts[time_counts == num_transponders].index
)
]


def clean_tt(
travel_times: pd.DataFrame,
transponder_ids: list[str],
Expand Down
12 changes: 8 additions & 4 deletions src/gnatss/solver/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from .. import constants
from ..configs.main import Configuration
from ..configs.solver import SolverTransponder
from ..ops.data import filter_tt, get_data_inputs
from ..ops.data import filter_tt, get_data_inputs, prefilter_replies
from ..ops.validate import check_solutions
from ..utilities.geo import _get_rotation_matrix
from ..utilities.time import AstroTime
Expand Down Expand Up @@ -387,15 +387,19 @@ def prepare_and_solve(
# Store original xyz
original_positions = transponders_xyz.copy()

# Store number of transponders
num_transponders = len(transponders)

typer.echo("Preparing data inputs...")
data_inputs = get_data_inputs(all_observations)
typer.echo(f"Pre-filtering data with fewer than {num_transponders} replies...")
reduced_observations = prefilter_replies(all_observations, num_transponders)
data_inputs = get_data_inputs(reduced_observations)

typer.echo("Perform solve...")
is_converged = False
n_iter = 0
num_transponders = len(transponders)
process_dict = {}
num_data = len(all_observations)
num_data = len(reduced_observations)
typer.echo(f"--- {len(data_inputs)} epochs, {num_data} measurements ---")
while not is_converged:
# Max converge attempt failure
Expand Down

0 comments on commit f1686e5

Please sign in to comment.