Skip to content

Commit 20f3f72

Browse files
committed
Simple docs
0 parents  commit 20f3f72

7 files changed

+551
-0
lines changed

docs/api.md

+134
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# API
2+
3+
## How to read API docs
4+
API docs or "Application Programming Interface Documentation" is a fancy name for a list of all the things a piece of software can do, and how to use them.
5+
6+
The docs list all of the **methods** and **attributes** available in `astro_pi_orbit`.
7+
8+
You will see a block of code like this:
9+
10+
```python
11+
coordinates() -> str
12+
```
13+
14+
This tells you:
15+
16+
- there is a function called `coordinates`
17+
- the function has no arguments (blank parentheses)
18+
- the type the function returns (`-> str`)
19+
20+
You may also see a block of code like this:
21+
```python
22+
de421: skyfield.jpllib.SpiceKernel
23+
```
24+
25+
This tells you:
26+
- there is an attribute called `de421` that is of type `skyfield.pkllib.SpiceKernel`.
27+
28+
29+
## API docs
30+
31+
The `astro_pi_orbit` library exports four names: `ISS`, `de421`, `de440s`, and `ephemeries`.
32+
33+
### ISS
34+
35+
A function that returns a `Skyfield` `EarthSatellite` object with an additional `coordinates` method, produced by reading the latest [two-line element set](https://en.wikipedia.org/wiki/Two-line_element_set) file available on the operating system.
36+
37+
More information on the `Skyfield` objects returned and used can be found [here](https://rhodesmill.org/skyfield/earth-satellites.html) and [here](https://rhodesmill.org/skyfield/api-satellites.html).
38+
39+
40+
```python
41+
ISS() -> skyfield.sgp4lib.EarthSatellite
42+
```
43+
44+
##### Example
45+
46+
The code below reads the latest TLE data into the `iss` variable, and prints the `iss` variable to the console:
47+
```python
48+
from astro_pi_orbit import ISS
49+
iss = ISS()
50+
print(iss)
51+
```
52+
53+
When executed, this code outputs the following:
54+
```txt
55+
<EarthSatellite ISS (ZARYA) catalog #25544 epoch 2024-03-12 05:03:40 UTC>
56+
```
57+
58+
#### coordinates
59+
60+
- Gets the current coordinates of the ISS.
61+
- **Returns** a `skyfield.toposlib.GeographicPosition`.
62+
```python
63+
coordinates() -> <class 'skyfield.toposlib.GeographicPosition'>
64+
```
65+
66+
##### Example
67+
68+
This function can be used to geotag photos using `picamzero`.
69+
70+
```python
71+
from picamzero import Camera
72+
from astro_pi_orbit import ISS
73+
74+
iss = ISS()
75+
camera = Camera()
76+
77+
def take_photo(image_name):
78+
"""
79+
Takes a photo and embeds the current coordinates of the ISS
80+
into the metadata.
81+
"""
82+
point = iss.coordinates()
83+
coordinates = (point.latitude.signed_dms(), point.longitude.signed_dms())
84+
cam.take_photo(image_name, gps_coordinates=get_gps_coordinates(iss))
85+
86+
take_photo("tagged-img.jpg")
87+
```
88+
89+
This will take a photo called `tagged-img.jpg`, and embed the ISS
90+
coordinates into the image metadata.
91+
92+
---
93+
94+
### de421
95+
96+
- Access the standard `de421.bsp` ephemeris file data via the `skyfield.jpllib.SpiceKernel` interface. For more information on how this is used, see [here](https://rhodesmill.org/skyfield/planets.html)
97+
98+
```python
99+
de421: skyfield.jpllib.SpiceKernel
100+
```
101+
102+
##### Example
103+
104+
This code gets the current position of Mars and prints it to the console:
105+
```python
106+
from astro_pi_orbit import de421
107+
from skyfield.api import load
108+
109+
ts = load.timescale()
110+
print(de421['Mars Barycenter'].at(ts.now()))
111+
```
112+
113+
---
114+
115+
### de440s
116+
- Access the standard `de440s.bsp` ephemeris file data via the `skyfield.jpllib.SpiceKernel` interface. For more information on how this is used, see [here](https://rhodesmill.org/skyfield/planets.html)
117+
118+
##### Example
119+
120+
This code gets the current position of Earth and prints it to the console:
121+
122+
```python
123+
from astro_pi_orbit import de440s
124+
from skyfield.api import load
125+
126+
ts = load.timescale()
127+
print(de421['earth'].at(ts.now()))
128+
```
129+
130+
---
131+
132+
### ephemeris
133+
134+
A synonym for the `de421` attribute described above.

0 commit comments

Comments
 (0)