Skip to content

Commit d7eea65

Browse files
authored
Merge pull request #1 from leocelente/map
Added latitude and longitude simulation with GFS forecast data
2 parents 818f8ad + 9c8a5dc commit d7eea65

24 files changed

+2707
-333
lines changed

.gitignore

100644100755
File mode changed.

Air.py

100644100755
File mode changed.

Balloon.py

100644100755
Lines changed: 247 additions & 174 deletions
Large diffs are not rendered by default.

Geolocation.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Path is integrated to meters in a flat plane.
2+
# which is equivalent to a ENU or Local Tangent Plane
3+
# it is defined through geodesic latitude and longitude
4+
# so to view it correctly on a map, its also necessary
5+
# to convert it to geocentric latitude.
6+
# METERS (ENU) -> LAT/LNG (GEODETIC) -> LAT/LNG (ECEF)

Instrument.py

100644100755
File mode changed.

Integrator.py

100644100755
Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
11
from typing import Callable
22
import numpy as np
3+
from numpy import ndarray
34

45
'''
56
This is from a previous project, I'm trying to reuse code
67
'''
78

8-
def RK4(model: Callable[[float, list[float]], list[float]], state_prev: list[float], t_now: float, t_step: float):
9+
10+
def RK4(model: Callable[[float, ndarray], ndarray], state_prev: ndarray, t_now: float, t_step: float):
911
'''
1012
Range-Kutta 4\nIntegra o estado `state_prev` pelo modelo `model`
1113
no passo `t_now` até o passo `t_now + t_step`
1214
'''
13-
len = 2
15+
len = 2 + 1 + 2
1416
state_prev = np.ravel(state_prev)
1517
state_prev = np.reshape(state_prev, (len, 1))
1618

17-
k1: list[float] = model(t_now, state_prev)
18-
k2: list[float] = model(t_now+t_step/2., state_prev + (k1 * t_step/2.))
19-
k3: list[float] = model(t_now+t_step/2., state_prev + (k2 * t_step/2.))
20-
k4: list[float] = model(t_now+t_step, state_prev + k3 * t_step)
21-
k: list[float] = (1/6)*(k1 + 2*k2 + 2*k3 + k4)
19+
k1: ndarray = model(t_now, state_prev)
20+
k2: ndarray = model(t_now+t_step/2., state_prev + (k1 * t_step/2.))
21+
k3: ndarray = model(t_now+t_step/2., state_prev + (k2 * t_step/2.))
22+
k4: ndarray = model(t_now+t_step, state_prev + k3 * t_step)
23+
k: ndarray = (1/6)*(k1 + 2*k2 + 2*k3 + k4)
2224

23-
delta_state: list[float] = (k * t_step)
24-
state_next: list[float] = state_prev + delta_state
25+
delta_state: ndarray = (k * t_step)
26+
state_next: ndarray = state_prev + delta_state
2527

2628
return state_next

Local.py

100644100755
File mode changed.

README.md

100644100755
Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,20 @@ Python Simulation of a High Altitude Balloon ascent and descent.
55
Create a tool to help experiments involving HABs. Currently focusing efforts on
66
the design of an Altitude Control System.
77

8-
## State
9-
**Working!**
10-
Seems to work, but a timestep >= 1s fails to converge.
11-
8+
## Screenshots
9+
![map](assets/map.png)
1210
![screenshot](assets/screenshot.png)
1311
![terminal](assets/terminal.png)
1412

15-
## Dependencies
16-
Just:
13+
## Dependencies
1714
- `numpy`
1815
- `matplotlib`
16+
- `plotly`
17+
- `pandas`
18+
- `grequests`
19+
- `scipy`
1920

20-
Even so, please, use a virtual environment
21+
Please, use a virtual environment.
2122

2223
## How to use
2324
```shell
@@ -37,6 +38,7 @@ $ source .venv/bin/activate
3738
- `Utils.py`: some conversion functions that don't have a good place yet
3839
- `Local.py`: Placeholder for variables that could be of use in a future state of the project
3940
- `Universe.py`: Mostly replaces `Utils.py` keeping purely mathematical formulas
41+
- `thirdparty/`: Contains code from the [Astra Simulator](https://github.com/sobester/astra_simulator/) that handles Global Forecasting System communication and latitude/longitude conversions
4042

4143
The `main.py` code then creates an object of the class Balloon, and passes its collection o models
4244
to the Simulator, that then does the integration step.

Simulator.py

100644100755
Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,31 @@
22
import numpy as np
33
from Integrator import RK4
44
from Local import *
5+
from numpy import ndarray
56

67
'''
78
This is from a previous project, I'm trying to reuse code
89
'''
910

10-
def s(progress:float):
11-
'''
12-
Change this parameter to print the progress
13-
'''
14-
pass
1511

12+
def s(progress: float):
13+
'''
14+
Change this parameter to print the progress
15+
'''
16+
pass
1617

17-
def Simulate(state: list[float], model, time_start:float=0, time_end: float=30, time_step:float=1, status=s):
18-
'''
19-
Run simulation of `model` from `time_start` to `time_end`
20-
'''
21-
print(f"Simulating from {time_start}s to {time_end}s with dt of {time_step}s")
22-
time = np.arange(time_start, time_end, time_step, dtype=float)
2318

24-
view_state = []
25-
for i in range(len(time)):
26-
status(i/len(time))
27-
state = RK4(model, state, time[i], time_step)
28-
view_state.append(state[:, 0])
29-
return view_state, time
19+
def Simulate(state: ndarray, model, time_start: float = 0, time_end: float = 30, time_step: float = 1, status=s):
20+
'''
21+
Run simulation of `model` from `time_start` to `time_end`
22+
'''
23+
print(
24+
f"Simulating from {time_start}s to {time_end}s with dt of {time_step}s")
25+
time = np.arange(time_start, time_end, time_step, dtype=float)
26+
27+
view_state = []
28+
for i in range(len(time)):
29+
status(i/len(time))
30+
state = RK4(model, state, time[i], time_step)
31+
view_state.append(state[:, 0])
32+
return view_state, time

Universe.py

100644100755
File mode changed.

0 commit comments

Comments
 (0)