Skip to content

API reference

earthcarekit.overpass

Utilities for processing satellite overpasses relative to ground stations.

Notes

This module depends on other internal modules:


OverpassInfo dataclass

Class storing details about an overpass, including duration, distance, time, closest index, etc.

Attributes:

Name Type Description
site_name str

Name of the site flown over.

site_lat_deg_north float

Latitude of the site in degrees north.

site_lon_deg_east float

Longitude of the site in degrees north.

site_radius_km float

Radius in kilometers around the site the overpass took place.

start_index int

Index at the start of the overpass.

end_index int

Index at the end of the overpass.

start_time Timestamp

Time at the start of the overpass.

end_time Timestamp

Time at the end of the overpass.

start_lat_deg_north float

Latitude at the start of the overpass.

start_lon_deg_east float

Latitude at the end of the overpass.

end_lat_deg_north float

Longitude at the start of the overpass.

end_lon_deg_east float

Longitude at the end of the overpass.

closest_index int

Index of the data sample that is geographically closest to the site.

closest_lat_deg_north float

Latitude of the data sample that is geographically closest to the site.

closest_lon_deg_east float

Longitude of the data sample that is geographically closest to the site.

closest_time Timestamp

Timestamp of the data sample that is geographically closest to the site.

closest_distance_km float

Distance in kilometers of the data sample that is geographically closest to the site.

along_track_distance_km float

Distance in kilometers along the overpass track withing the set radius.

frame_crosses_pole bool

Whether the original track crosses a pole at any point (not necessarily within the radius).

samples int

Number of data sample within the radius.

site Site

Site object.

Source code in earthcarekit/overpass/_overpass_info.py
@dataclass
class OverpassInfo:
    """
    Class storing details about an overpass, including duration, distance, time, closest index, etc.

    Attributes:
        site_name (str): Name of the site flown over.
        site_lat_deg_north (float): Latitude of the site in degrees north.
        site_lon_deg_east (float): Longitude of the site in degrees north.
        site_radius_km (float): Radius in kilometers around the site the overpass took place.
        start_index (int): Index at the start of the overpass.
        end_index (int): Index at the end of the overpass.
        start_time (pd.Timestamp): Time at the start of the overpass.
        end_time (pd.Timestamp): Time at the end of the overpass.
        start_lat_deg_north (float): Latitude at the start of the overpass.
        start_lon_deg_east (float): Latitude at the end of the overpass.
        end_lat_deg_north (float): Longitude at the start of the overpass.
        end_lon_deg_east (float): Longitude at the end of the overpass.
        closest_index (int): Index of the data sample that is geographically closest to the site.
        closest_lat_deg_north (float): Latitude of the data sample that is geographically closest to the site.
        closest_lon_deg_east (float): Longitude of the data sample that is geographically closest to the site.
        closest_time (pd.Timestamp): Timestamp of the data sample that is geographically closest to the site.
        closest_distance_km (float): Distance in kilometers of the data sample that is geographically closest to the site.
        along_track_distance_km (float): Distance in kilometers along the overpass track withing the set radius.
        frame_crosses_pole (bool): Whether the original track crosses a pole at any point (not necessarily within the radius).
        samples (int): Number of data sample within the radius.
        site (Site): Site object.
    """

    site_name: str
    site_lat_deg_north: float
    site_lon_deg_east: float
    site_radius_km: float
    start_index: int
    end_index: int
    start_time: pd.Timestamp
    end_time: pd.Timestamp
    start_lat_deg_north: float
    start_lon_deg_east: float
    end_lat_deg_north: float
    end_lon_deg_east: float
    closest_index: int
    closest_lat_deg_north: float
    closest_lon_deg_east: float
    closest_time: pd.Timestamp
    closest_distance_km: float
    along_track_distance_km: float
    frame_crosses_pole: bool
    samples: int
    site: Site

    @property
    def site_coords(self) -> tuple[float, float]:
        """Returns lat/lon coordinates of the overpassed site or center."""
        return self.site_lat_deg_north, self.site_lon_deg_east

    @property
    def index_range(self) -> tuple[int, int]:
        """Returns start and end indecies of the overpass."""
        return self.start_index, self.end_index

    @property
    def time_range(self) -> tuple[pd.Timestamp, pd.Timestamp]:
        """Returns start and end times of the overpass."""
        return self.start_time, self.end_time

    @property
    def start_coords(self) -> tuple[float, float]:
        """Returns lat/lon coordinates of the satellite at the start of the overpass."""
        return self.start_lat_deg_north, self.start_lon_deg_east

    @property
    def end_coords(self) -> tuple[float, float]:
        """Returns lat/lon coordinates of the satellite at the end of the overpass."""
        return self.end_lat_deg_north, self.end_lon_deg_east

    @property
    def closest_coords(self) -> tuple[float, float]:
        """Returns lat/lon coordinates where the satellite is geographically closest to the site."""
        return self.closest_lat_deg_north, self.closest_lon_deg_east

    @property
    def duration(self) -> pd.Timedelta:
        """Returns the duration of the overpass."""
        return self.end_time - self.start_time

    def to_dict(self) -> dict:
        """Returns overpass info as a Python `dict`."""
        d = dict(
            site_name=self.site_name,
            site_lat_deg_north=self.site_lat_deg_north,
            site_lon_deg_east=self.site_lon_deg_east,
            site_radius_km=self.site_radius_km,
            start_index=self.start_index,
            end_index=self.end_index,
            start_time=self.start_time,
            end_time=self.end_time,
            start_lat_deg_north=self.start_lat_deg_north,
            start_lon_deg_east=self.start_lon_deg_east,
            end_lat_deg_north=self.end_lat_deg_north,
            end_lon_deg_east=self.end_lon_deg_east,
            closest_index=self.closest_index,
            closest_lat_deg_north=self.closest_lat_deg_north,
            closest_lon_deg_east=self.closest_lon_deg_east,
            closest_time=self.closest_time,
            closest_distance_km=self.closest_distance_km,
            along_track_distance_km=self.along_track_distance_km,
            frame_crosses_pole=self.frame_crosses_pole,
            samples=self.samples,
        )
        return d

    def to_dataframe(self) -> pd.DataFrame:
        """Returns overpass info as a `pandas.Dataframe`."""
        df = pd.DataFrame([self.to_dict()])
        df = df.astype(
            dict(
                site_name=str,
                site_lat_deg_north=float,
                site_lon_deg_east=float,
                site_radius_km=float,
                start_index=int,
                end_index=int,
                start_time=pd.Timestamp,
                end_time=pd.Timestamp,
                start_lat_deg_north=float,
                start_lon_deg_east=float,
                end_lat_deg_north=float,
                end_lon_deg_east=float,
                closest_index=int,
                closest_lat_deg_north=float,
                closest_lon_deg_east=float,
                closest_time=pd.Timestamp,
                closest_distance_km=float,
                along_track_distance_km=float,
                frame_crosses_pole=bool,
                samples=int,
            )
        )
        return df

closest_coords property

closest_coords: tuple[float, float]

Returns lat/lon coordinates where the satellite is geographically closest to the site.

duration property

duration: Timedelta

Returns the duration of the overpass.

end_coords property

end_coords: tuple[float, float]

Returns lat/lon coordinates of the satellite at the end of the overpass.

index_range property

index_range: tuple[int, int]

Returns start and end indecies of the overpass.

site_coords property

site_coords: tuple[float, float]

Returns lat/lon coordinates of the overpassed site or center.

start_coords property

start_coords: tuple[float, float]

Returns lat/lon coordinates of the satellite at the start of the overpass.

time_range property

time_range: tuple[Timestamp, Timestamp]

Returns start and end times of the overpass.

to_dataframe

to_dataframe() -> DataFrame

Returns overpass info as a pandas.Dataframe.

Source code in earthcarekit/overpass/_overpass_info.py
def to_dataframe(self) -> pd.DataFrame:
    """Returns overpass info as a `pandas.Dataframe`."""
    df = pd.DataFrame([self.to_dict()])
    df = df.astype(
        dict(
            site_name=str,
            site_lat_deg_north=float,
            site_lon_deg_east=float,
            site_radius_km=float,
            start_index=int,
            end_index=int,
            start_time=pd.Timestamp,
            end_time=pd.Timestamp,
            start_lat_deg_north=float,
            start_lon_deg_east=float,
            end_lat_deg_north=float,
            end_lon_deg_east=float,
            closest_index=int,
            closest_lat_deg_north=float,
            closest_lon_deg_east=float,
            closest_time=pd.Timestamp,
            closest_distance_km=float,
            along_track_distance_km=float,
            frame_crosses_pole=bool,
            samples=int,
        )
    )
    return df

to_dict

to_dict() -> dict

Returns overpass info as a Python dict.

Source code in earthcarekit/overpass/_overpass_info.py
def to_dict(self) -> dict:
    """Returns overpass info as a Python `dict`."""
    d = dict(
        site_name=self.site_name,
        site_lat_deg_north=self.site_lat_deg_north,
        site_lon_deg_east=self.site_lon_deg_east,
        site_radius_km=self.site_radius_km,
        start_index=self.start_index,
        end_index=self.end_index,
        start_time=self.start_time,
        end_time=self.end_time,
        start_lat_deg_north=self.start_lat_deg_north,
        start_lon_deg_east=self.start_lon_deg_east,
        end_lat_deg_north=self.end_lat_deg_north,
        end_lon_deg_east=self.end_lon_deg_east,
        closest_index=self.closest_index,
        closest_lat_deg_north=self.closest_lat_deg_north,
        closest_lon_deg_east=self.closest_lon_deg_east,
        closest_time=self.closest_time,
        closest_distance_km=self.closest_distance_km,
        along_track_distance_km=self.along_track_distance_km,
        frame_crosses_pole=self.frame_crosses_pole,
        samples=self.samples,
    )
    return d

get_overpass_info

get_overpass_info(
    ds: str | Dataset,
    site: SiteLike,
    radius_km: float | int = 100.0,
    *,
    time_var: str = TIME_VAR,
    lat_var: str = TRACK_LAT_VAR,
    lon_var: str = TRACK_LON_VAR,
    along_track_dim: str = ALONG_TRACK_DIM
) -> OverpassInfo

Extract details about an overpass, including duration, distance, time, closest index, etc.

Parameters:

Name Type Description Default
ds str | Dataset

Path to or instance of a dataset containing along-track satellite data.

required
site SiteLike

Site name or object over which the satellite is passing.

required
radius_km float | int

Radius to look for an overpass in kilometers. Defaults to 100.

100.0
time_var str

Name of the dataset variable containing time data. Defaults to "time".

TIME_VAR
lat_var str

Name of the dataset variable containing latitude data. Defaults to "latitude".

TRACK_LAT_VAR
lon_var str

Name of the dataset variable containing longitude data. Defaults to "longitude".

TRACK_LON_VAR
along_track_dim str

Name of the along-track or temporal dataset dimension. Defaults to "along_track".

ALONG_TRACK_DIM

Raises:

Type Description
TypeError

If ds is not of type str (i.e., filepath) or xr.Dataset.

Returns:

Name Type Description
OverpassInfo OverpassInfo

description

Source code in earthcarekit/overpass/_overpass_info.py
def get_overpass_info(
    ds: str | xr.Dataset,
    site: SiteLike,
    radius_km: float | int = 100.0,
    *,
    time_var: str = TIME_VAR,
    lat_var: str = TRACK_LAT_VAR,
    lon_var: str = TRACK_LON_VAR,
    along_track_dim: str = ALONG_TRACK_DIM,
) -> OverpassInfo:
    """
    Extract details about an overpass, including duration, distance, time, closest index, etc.

    Args:
        ds (str | xr.Dataset): Path to or instance of a dataset containing along-track satellite data.
        site (SiteLike): Site name or object over which the satellite is passing.
        radius_km (float | int, optional): Radius to look for an overpass in kilometers. Defaults to 100.
        time_var (str, optional): Name of the dataset variable containing time data. Defaults to "time".
        lat_var (str, optional): Name of the dataset variable containing latitude data. Defaults to "latitude".
        lon_var (str, optional): Name of the dataset variable containing longitude data. Defaults to "longitude".
        along_track_dim (str, optional): Name of the along-track or temporal dataset dimension. Defaults to "along_track".

    Raises:
        TypeError: If `ds` is not of type `str` (i.e., filepath) or `xr.Dataset`.

    Returns:
        OverpassInfo: _description_
    """
    if isinstance(ds, str):
        with read_product(ds) as _ds:
            result = _get_overpass_info(
                _ds,
                radius_km=radius_km,
                site=site,
                time_var=time_var,
                lat_var=lat_var,
                lon_var=lon_var,
                along_track_dim=along_track_dim,
            )
    elif isinstance(ds, xr.Dataset):
        result = _get_overpass_info(
            ds,
            radius_km=radius_km,
            site=site,
            time_var=time_var,
            lat_var=lat_var,
            lon_var=lon_var,
            along_track_dim=along_track_dim,
        )
    else:
        raise TypeError(
            f"`ds` has invalid type '{type(ds).__name__}', expected 'str' (i.e. filepath) or 'xr.Dataset'"
        )

    return result