Flight Sun
Flight Sun is a Python package designed to calculate the proportion of a flight that will be in sunlight.
The sunrise and sunset times of the origin and destination airports are easily obtainable, so for short flights, it can usually be assumed whether a flight is a day or night flight.
However, for long flights, especially those travelling longitudinally, this calculation can be more difficult. For example, a 17-hour flight from London to Perth, Australia can take off and land in daylight, but spend the majority of the flight in darkness.
This package breaks a flight path into segments of day and night, allowing the proportion of a flight that is in sunlight to be calculated.
Features
- GeoJSON rendering of flight path with feature properties for whether the segment is in sunlight
- Integrated IATA and ICAO airport lookups (using airportsdata package). This retrieves the coordinates and local time zones of airports.
Assumptions
- The flight path is a direct great circle route between the origin and destination airports
- The aircraft flies at a constant speed
- Flight altitude is not considered
Installation
Flight Sun can be installed using pip:
pip install flight_sun
Usage
from flight_sun.flight import Flight
from flight_sun.visualisation import generate_geojson
from datetime import datetime
import json
take_off_time = datetime.fromisoformat("2023-02-11 11:50:00")
landing_time = datetime.fromisoformat("2023-02-12 12:25:00")
flight = Flight.from_iata_codes("LHR", "PER", take_off_time, landing_time)
# Get sunlight proportion
print(f"Sunlight proportion: {flight.proportion_in_sunlight():.2%}")
# Get sunlight segments
print("Sunlight segments:")
for segment in flight.light_segments:
print(f"Sunlight: {segment.sun_up}, start: {segment.start}, end: {segment.end}")
# Render to GeoJSON
geojson = generate_geojson(flight.light_segments)
with open("flight.geojson", "w") as f:
json.dump(geojson, f)
Example output
Sunlight proportion: 45.23%
Sunlight segments:
Sunlight: True, start: 2023-02-11 11:50:00+00:00, end: 2023-02-11 14:58:00+00:00
Sunlight: False, start: 2023-02-11 14:58:00+00:00, end: 2023-02-12 00:03:00+00:00
Sunlight: True, start: 2023-02-12 00:03:00+00:00, end: 2023-02-12 04:25:00+00:00
Future ideas
- Add support for more complex flight paths (e.g. via waypoints)
- Use real-world flight data to create a better time-distance interpolation function
- Consider the position of the sun in relation to the aircraft i.e. which side of the aircraft is in sunlight
Metadata
Release files for flight-sun 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| flight_sun-0.1.0.tar.gz | 5.9 kB | Without provenance | Details for flight_sun-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| flight_sun-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for flight_sun-0.1.0-py3-none-any.whl |
Total release size: 13.3 kB
Release files / flight_sun-0.1.0.tar.gz
| Download URL | flight_sun-0.1.0.tar.gz |
|---|---|
| Size | 5.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
009427dcb564a727b9b801b435eca5a2d34ebde5f67ed9082697fbdd5c7fb3ba
|
|
BLAKE2b-256 checksum How to use checksums |
a04e6262f3741c0ef127483366babc5699feadb0863f87501bb8cc04928b7229
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.2
|
Release files / flight_sun-0.1.0-py3-none-any.whl
| Download URL | flight_sun-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1addb41c641b6c3cfffc3a70398e3a084238011bcb416f0489f56f2c4191eba8
|
|
BLAKE2b-256 checksum How to use checksums |
fd7d6f61364f6620c6d88ffa9ac2ccdd341a4aad3876f195c33829db32cef72a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.2
|
Security for flight-sun 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.