Skip to content

Commit

Permalink
link script for rover data; print model before training; smooth GPS a…
Browse files Browse the repository at this point in the history
…nd time before trying to merge
  • Loading branch information
misko committed Dec 19, 2024
1 parent 1d7d8ac commit 3bc20d0
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
15 changes: 15 additions & 0 deletions spf/dataset/v4_link.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

if [ $# -ne 2 ]; then
echo $0 target_link input
exit
fi

target=$1
input=$2
input_basename="${input%.*}"

for x in ${input_basename}.*; do
ext="${x##*.}"
ln -s $x ${target}.${ext}
done
23 changes: 19 additions & 4 deletions spf/dataset/v4_tx_rx_to_v5.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@ def lat_lon_to_xy(lat, lon, center_lat, center_lon):
return proj_centered(lon, lat)


def smooth_out_timestamps_and_gps(timestamps_and_gps):
for prop in ["times", "gps_lats", "gps_longs"]:
arr = getattr(timestamps_and_gps, prop)
for missing_idx in np.where(arr == 0)[0]:
neighbors = []
if missing_idx > 0 and arr[missing_idx - 1] != 0:
neighbors.append(arr[missing_idx - 1])
if missing_idx < len(arr) and arr[missing_idx + 1] != 0:
neighbors.append(arr[missing_idx + 1])
arr[missing_idx] = sum(neighbors) / len(neighbors)
return timestamps_and_gps


@dataclass
class TimestampAndGPS:
times: np.ndarray # Array to store timestamps
Expand Down Expand Up @@ -167,10 +180,12 @@ def merge_v4rx_v4tx_into_v5(tx_fn, rx_fn, zarr_out_fn, gps_center_long_lat, fix_
rx_zarr = zarr_open_from_lmdb_store(rx_fn, readahead=True, mode="r")

rx_time_and_gpses = {
rx_idx: TimestampAndGPS(
times=rx_zarr["receivers"][rx_idx]["gps_timestamp"][:],
gps_lats=rx_zarr["receivers"][rx_idx]["gps_lat"][:],
gps_longs=rx_zarr["receivers"][rx_idx]["gps_long"][:],
rx_idx: smooth_out_timestamps_and_gps(
TimestampAndGPS(
times=rx_zarr["receivers"][rx_idx]["gps_timestamp"][:],
gps_lats=rx_zarr["receivers"][rx_idx]["gps_lat"][:],
gps_longs=rx_zarr["receivers"][rx_idx]["gps_long"][:],
)
)
for rx_idx in ["r0", "r1"]
}
Expand Down
3 changes: 3 additions & 0 deletions spf/scripts/train_single_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -1009,6 +1009,9 @@ def train_single_point(args):

m = load_model(config["model"], config["global"]).to(config["optim"]["device"])

logging.info("MODEL:")
logging.info(m)

model_checksum("load_model:", m)
optimizer, scheduler = load_optimizer(config["optim"], m.parameters())

Expand Down

0 comments on commit 3bc20d0

Please sign in to comment.