Skip to content

data_gen

data.data_gen

filter_overlaps(targets, min_dist_km=2.0)

Removes targets that are geographically too close to each other.

Source code in ground_segment/data/data_gen.py
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
def filter_overlaps(targets, min_dist_km=2.0):
    """Removes targets that are geographically too close to each other."""
    unique_targets = []
    skipped = 0
    for t in targets:
        is_too_close = False
        for u in unique_targets:
            if haversine(t["lon"], t["lat"], u["lon"], u["lat"]) < min_dist_km:
                is_too_close = True
                break
        if not is_too_close:
            unique_targets.append(t)
        else:
            skipped += 1
    print(
        f" Proximity Filter: Kept {len(unique_targets)} targets, skipped {skipped} overlaps."
    )
    return unique_targets

haversine(lon1, lat1, lon2, lat2)

Calculates the distance in kilometers between two points.

Source code in ground_segment/data/data_gen.py
31
32
33
34
35
36
37
38
39
40
41
42
43
def haversine(lon1, lat1, lon2, lat2):
    """Calculates the distance in kilometers between two points."""
    R = 6371  # Earth radius in km
    dlat = math.radians(lat2 - lat1)
    dlon = math.radians(lon2 - lon1)
    a = (
        math.sin(dlat / 2) ** 2
        + math.cos(math.radians(lat1))
        * math.cos(math.radians(lat2))
        * math.sin(dlon / 2) ** 2
    )
    c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a))
    return R * c