64 lines
2.3 KiB
Markdown
64 lines
2.3 KiB
Markdown
|
# Where's the Sat?
|
||
|
**Category**: Space and Things
|
||
|
**Points (final)**: 43
|
||
|
**Solves**: 107
|
||
|
|
||
|
> Let's start with an easy one, I tell you where I'm looking at a satellite, you tell me where to look for it later.
|
||
|
|
||
|
**Given files**: `stations.zip`
|
||
|
|
||
|
## Write-up
|
||
|
by [erin (`barzamin`)](https://imer.in).
|
||
|
|
||
|
Like all 106 other teams probably did, we used Python and [Skyfield](https://rhodesmill.org/skyfield/), an astronomical computation library.
|
||
|
The challenge gives us questions like
|
||
|
```
|
||
|
Please use the following time to find the correct satellite:(2020, 3, 18, 11, 43, 3.0)
|
||
|
Please use the following Earth Centered Inertial reference frame coordinates to find the satellite:
|
||
|
[-305.58833718148855, 5030.717506174544, 4485.770450701875]
|
||
|
Current attempt:1
|
||
|
What is the X coordinate at the time of:(2020, 3, 18, 4, 24, 46.0)?
|
||
|
```
|
||
|
|
||
|
We can easily grab the time and ECI coordinates (which turned out to be International Terrestrial Reference Frame coordinates) with some expect-style goodness:
|
||
|
```{.python}
|
||
|
r.readuntil('find the correct satellite:')
|
||
|
t = ts.utc(*[float(x) for x in r.readuntil('\n').decode().strip()[1:-1].split(', ')])
|
||
|
|
||
|
r.readuntil('coordinates to find the satellite:')
|
||
|
eci_coords = np.array([float(x) for x in r.readuntil('\n').decode().strip()[1:-1].split(', ')])
|
||
|
```
|
||
|
|
||
|
We're given a list of candidate satellites (or space stations, rather) in two-line element form; find the closest one at the given time:
|
||
|
```{.python}
|
||
|
satellites = load.tle_file('./stations.txt')
|
||
|
|
||
|
match = satellites[np.argmin([np.linalg.norm(s.at(t).position.km-eci_coords) for s in satellites])]
|
||
|
```
|
||
|
|
||
|
The challenge then wants us to project ITRF coordinates for three times it gives us. Read the challenge timestamps and tell it where the satellite is:
|
||
|
```{.python}
|
||
|
for _ in range(3):
|
||
|
r.readuntil('X coordinate at the time of:')
|
||
|
new_t = ts.utc(*[float(x)
|
||
|
for x in r.readuntil('?\n', drop=True).decode().strip()[1:-1].split(', ')])
|
||
|
print(new_t.utc_jpl())
|
||
|
|
||
|
x,y,z = match.at(new_t).position.km
|
||
|
r.send(f'{x}\n')
|
||
|
r.send(f'{y}\n')
|
||
|
r.send(f'{z}\n')
|
||
|
|
||
|
r.interactive()
|
||
|
```
|
||
|
|
||
|
The key can easily be grabbed from the output.
|
||
|
|
||
|
### Full code
|
||
|
```{.python include=wheres.py}
|
||
|
```
|
||
|
|
||
|
## Resources and other writeups
|
||
|
- <https://rhodesmill.org/skyfield/>
|
||
|
- <https://en.wikipedia.org/wiki/Earth-centered_inertial>
|
||
|
- <https://en.wikipedia.org/wiki/International_Terrestrial_Reference_System_and_Frame>
|