ecoscope.analysis.astronomy#
Module Contents#
- ecoscope.analysis.astronomy.DEFAULT_IS_NIGHT_TIME_RESOLUTION#
- ecoscope.analysis.astronomy.to_EarthLocation(geometry)#
Location on Earth, initialized from geocentric coordinates.
- Parameters:
geometry (gpd.GeoSeries) – GeoDataFrame’s geometry column
- Return type:
astropy.coordinates.EarthLocation.
- ecoscope.analysis.astronomy.is_night(geometry, time, time_resolution=DEFAULT_IS_NIGHT_TIME_RESOLUTION)#
Classify each (geometry, time) pair as night vs day.
- Parameters:
geometry (aligned series of locations and timestamps.)
time (aligned series of locations and timestamps.)
time_resolution (sample spacing for astropy's ErfaAstromInterpolator. Smaller) – values give more accurate results near sunrise/sunset at the cost of execution speed; larger values are much faster, introducing sub-degree errors in sun altitude. Defaults to 1 hour.
- Return type:
pandas.Series
- ecoscope.analysis.astronomy.sun_time(date, geometry)#
Sunrise and sunset of the local solar day labelled by date at geometry. Returned timestamps are in UTC, representing the UTC time of the local sunrise/sunset.
The geometry provided is assumed to be in EPSG:4326 (WGS84 lon/lat)
- Parameters:
date (datetime.datetime)
geometry (shapely.geometry.base.BaseGeometry)
- Return type:
pandas.Series
- ecoscope.analysis.astronomy.calculate_day_night_distance(date, segment_start, segment_end, dist_meters, daily_summary)#
- Parameters:
date (datetime.datetime)
segment_start (datetime.datetime)
segment_end (datetime.datetime)
dist_meters (int)
daily_summary (pandas.DataFrame)
- Return type:
None
- ecoscope.analysis.astronomy.calculate_day_fraction(sunrise, sunset, segment_start, segment_end)#
Vectorized fraction of each [segment_start, segment_end] interval that falls in daylight, given the corresponding sunrise/sunset per row.
Handles both sunrise < sunset (normal) and sunrise >= sunset (inverted / high-latitude) day orderings. Boundary samples (segment touching sunrise or sunset exactly) are assigned to the same side as the adjacent open interval, so np.select never falls through to NaN for valid segment_start < segment_end.
- Parameters:
sunrise (pandas.Series)
sunset (pandas.Series)
segment_start (pandas.Series)
segment_end (pandas.Series)
- Return type:
numpy.ndarray
- ecoscope.analysis.astronomy.get_nightday_ratio(gdf)#
- Parameters:
gdf (geopandas.GeoDataFrame)
- Return type:
float