Skip to content

Commit 4dec7b4

Browse files
Merge upstream develop into warn-irregular-drag-csv branch
PR RocketPy-Team#1232 landed on develop with the drag CSV docs note that this branch needs to update. Co-authored-by: Charles <CharlesXmf@users.noreply.github.com>
2 parents ae231d9 + b389b43 commit 4dec7b4

18 files changed

Lines changed: 1566 additions & 1651 deletions

‎docs/user/environment/1-atm-models/ensemble.rst‎

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,19 @@ is a two-column array: the first column is geometric height above sea level in
3030
meters, and the second column uses Pa for pressure, K for temperature and m/s
3131
for either wind component.
3232

33-
The pressure profiles determine a common isobaric grid. Temperature and wind
34-
are interpolated onto that grid, then written to a GEFS-compatible NetCDF file.
35-
Every pressure profile must overlap the others and decrease with height.
33+
The pressure profiles determine a common isobaric grid, and temperature and
34+
wind are interpolated onto that grid. Every pressure profile must overlap the
35+
others and decrease with height.
36+
37+
The profiles are not tied to a date. The Environment does not need one, and
38+
the ensemble stays the same if the launch date is changed later.
39+
40+
.. note::
41+
42+
Every profile is cut to the pressure range shared by all of them, and below
43+
that range the value at its bottom is used. Start all profiles at the same
44+
pressure, at or below the ground level of the launch site, so the values
45+
near the ground are the ones you gave.
3646

3747
.. code-block:: python
3848
@@ -41,15 +51,14 @@ Every pressure profile must overlap the others and decrease with height.
4151
from rocketpy import Environment
4252
4353
env = Environment(
44-
date=(2026, 9, 1, 12),
4554
latitude=32.990254,
4655
longitude=-106.974998,
4756
elevation=1400,
4857
)
4958
5059
pressure = np.array([85000, 70000, 50000]) # Pa
51-
height_0 = np.array([1500, 3000, 5500]) # m ASL
52-
height_1 = np.array([1550, 3100, 5650]) # m ASL
60+
height_0 = np.array([1400, 3000, 5500]) # m ASL
61+
height_1 = np.array([1400, 3100, 5650]) # m ASL
5362
5463
profiles = [
5564
{
@@ -66,21 +75,29 @@ Every pressure profile must overlap the others and decrease with height.
6675
},
6776
]
6877
69-
ensemble_file = env.create_ensemble(profiles, "my_ensemble.nc")
78+
env.create_ensemble(profiles)
7079
71-
The method activates member 0 after writing the file. Select another member
72-
with the same method used for forecast ensembles:
80+
The method activates member 0. Select another member with the same method used
81+
for forecast ensembles:
7382

7483
.. code-block:: python
7584
7685
env.select_ensemble_member(1)
7786
78-
Another Environment can load the returned file with the ``GEFS`` mapping:
87+
By default the ensemble is kept in memory and no file is written. To use it
88+
again later, give a file name. RocketPy then also saves the ensemble as a
89+
GEFS-compatible NetCDF file and returns its path:
90+
91+
.. code-block:: python
92+
93+
ensemble_file = env.create_ensemble(profiles, "my_ensemble.nc")
94+
95+
Another Environment, with any launch date or none, can load that file with the
96+
``GEFS`` mapping:
7997

8098
.. code-block:: python
8199
82100
saved_env = Environment(
83-
date=(2026, 9, 1, 12),
84101
latitude=32.990254,
85102
longitude=-106.974998,
86103
elevation=1400,

‎docs/user/environment/1-atm-models/forecast.rst‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,31 @@ Other generic forecasts can also be imported.
2323
the same kind of pressure-level forecast as plain JSON, see
2424
:ref:`open_meteo`.
2525

26+
.. note::
27+
28+
Within one Python session, RocketPy keeps in memory the forecasts it
29+
downloaded with the shortcuts on this page (``file="GFS"``, ``"NAM"`` and
30+
so on), so that asking again for the same forecast, as when a notebook
31+
cell is run again, takes a couple of seconds instead of a full download.
32+
When the same model, place and launch time are asked for again, it asks
33+
the server which model run is current and downloads the data again only
34+
if the server published something new. Each forecast takes about 50 kB of
35+
memory and the 100 most recent ones are kept.
36+
37+
To keep forecasts between sessions, pass ``cache=True``:
38+
39+
.. code-block:: python
40+
41+
env.set_atmospheric_model(type="Forecast", file="GFS", cache=True)
42+
43+
The forecast is then also saved on disk, in the cache folder of your
44+
system (``~/.cache/rocketpy`` on Linux), and a later session uses it while
45+
the server says its model run is still the latest one. If the server
46+
cannot be reached, the saved forecast is used anyway, with a warning that
47+
it may not be the latest. A warning tells you every time a saved forecast
48+
is used, and forecasts saved more than 7 days ago are deleted. Without
49+
``cache=True`` nothing is saved on disk.
50+
2651

2752
.. _global-forecast-system:
2853

‎docs/user/environment/1-atm-models/reanalysis.rst‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ One common reanalysis dataset is the ERA5.
2020
2021 onwards, :ref:`open_meteo` retrieves them straight from an API, with
2121
no file to download.
2222

23+
.. note::
24+
25+
A reanalysis can also be read from a web address (an OPeNDAP address)
26+
instead of a local file. Pass ``cache=True`` to
27+
:meth:`rocketpy.Environment.set_atmospheric_model` to save what RocketPy
28+
reads on disk, in the cache folder of your system (``~/.cache/rocketpy`` on
29+
Linux), and use it in later sessions without downloading it again.
30+
Reanalysis data does not change, so the saved copy is always used, and a
31+
warning says so each time.
32+
2333
ERA5
2434
----
2535

‎docs/user/installation.rst‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ The following packages are needed in order to run RocketPy:
103103
- requests
104104
- pytz
105105
- simplekml
106+
- platformdirs
106107

107108
All of these packages, are automatically installed when RocketPy is installed using either ``pip`` or ``conda``.
108109
However, in case the user wants to install these packages manually, they can do so by following the instructions bellow.
@@ -121,6 +122,7 @@ The packages needed can be installed via ``pip`` by running the following lines
121122
pip install requests
122123
pip install pytz
123124
pip install simplekml
125+
pip install platformdirs
124126
125127
Installing Required Packages Using ``conda``
126128
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

‎docs/user/rocket/rocket_usage.rst‎

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,40 @@ positional arguments, in order:
100100

101101
``alpha, beta, mach, reynolds, pitch_rate, yaw_rate, roll_rate``
102102

103-
``alpha`` and ``beta`` are the angle of attack and sideslip angle in radians.
104-
The angular rates are expressed in radians per second in the rocket body frame.
105-
For example, a model based on angle of attack and Mach number can ignore the
106-
other inputs:
103+
``alpha`` and ``beta`` are the partial angle of attack and the sideslip angle in
104+
radians, as defined in :ref:`genericsurfaces`. They are the same angles as
105+
:meth:`rocketpy.Flight.partial_angle_of_attack` and
106+
:meth:`rocketpy.Flight.angle_of_sideslip`, but the drag model receives them in
107+
radians, while those Flight attributes are in degrees. The total angle is
108+
:meth:`rocketpy.Flight.angle_of_attack`. The angular rates are expressed in
109+
radians per second in the rocket body frame.
110+
111+
.. note::
112+
113+
- ``alpha`` and ``beta`` are two separate signed angles, and neither is
114+
the total angle of attack. ``alpha`` is measured in the pitch plane (the
115+
rocket axis and the body y axis) and ``beta`` in the yaw plane (the
116+
rocket axis and the body x axis). Each goes from -pi to pi, and reaches
117+
pi when the rocket flies tail first. Drag that depends on the total
118+
angle of attack has to combine both, for example through
119+
``alpha**2 + beta**2``, which is the square of the total angle for the
120+
small angles of a normal flight. Both can be negative, and a table that
121+
stops at zero returns its edge value for them, so tabulate the negative
122+
angles too (a callable can use ``abs``).
123+
- ``reynolds`` uses the rocket **diameter** (twice the ``radius`` given to
124+
``Rocket``) as the reference length. Some tools use the rocket length
125+
instead, so check which one your drag data was built with.
126+
127+
For example, a model based on the total angle of attack and Mach number can
128+
ignore the other inputs. Its angle term is only meant for small angles: at
129+
``alpha = pi`` it adds about 5.9 to the drag coefficient.
107130

108131
.. code-block:: python
109132
110133
def drag_coefficient(
111-
alpha, _beta, mach, _reynolds, _pitch_rate, _yaw_rate, _roll_rate
134+
alpha, beta, mach, _reynolds, _pitch_rate, _yaw_rate, _roll_rate
112135
):
113-
return 0.38 + 0.08 * mach**2 + 0.6 * alpha**2
136+
return 0.38 + 0.08 * mach**2 + 0.6 * (alpha**2 + beta**2)
114137
115138
rocket = Rocket(
116139
radius=0.0635,
@@ -130,11 +153,22 @@ defines drag as a function of angle of attack and Mach number:
130153
.. code-block:: text
131154
132155
alpha,mach,cd
156+
-0.1,0.5,0.32
157+
-0.1,1.0,0.48
133158
0.0,0.5,0.30
134159
0.0,1.0,0.45
135160
0.1,0.5,0.32
136161
0.1,1.0,0.48
137162
163+
.. note::
164+
165+
Fill in every combination of the values in the table, and write each value
166+
the same way in every row. If a combination is missing, a row is repeated
167+
or a value differs in any digit (0.3 and 0.30000000000000004), the file
168+
still loads and no warning is given, but RocketPy interpolates between
169+
scattered points instead of along the grid, and the drag coefficient
170+
changes both between and outside the points.
171+
138172
For backward compatibility, ``rocket.power_off_drag`` and
139173
``rocket.power_on_drag`` expose the Mach-only slice of each model, with the
140174
other six inputs set to zero. Use ``rocket.power_off_drag_7d`` and

‎requirements.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ matplotlib>=3.9.0 # Released May 15th 2024
44
netCDF4>=1.6.4
55
requests
66
pytz
7+
platformdirs # system cache folder of Environment.set_atmospheric_model(cache=True)
78
simplekml
89
dill

0 commit comments

Comments
 (0)