Skip to content

Commit beefdd7

Browse files
Merge branch 'develop' into enh/function-crop-clip-methods
2 parents 7f251c5 + 71e2b3a commit beefdd7

File tree

20 files changed

+184
-344
lines changed

20 files changed

+184
-344
lines changed

.github/workflows/test_pytest.yaml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,11 @@ jobs:
2929
uses: actions/setup-python@main
3030
with:
3131
python-version: ${{ matrix.python-version }}
32-
33-
- name: Cache Python dependencies
34-
uses: actions/cache@main
35-
with:
36-
path: ~/.cache/pip
37-
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements-tests.txt') }}
38-
restore-keys: |
39-
${{ runner.os }}-pip-
32+
cache: 'pip'
33+
cache-dependency-path: |
34+
requirements.txt
35+
requirements-tests.txt
36+
requirements-optional.txt
4037
4138
- name: Install rocketpy
4239
run: pip install .

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ Attention: The newest changes should be on top -->
3535

3636
### Changed
3737

38+
- ENH: Add the Coriolis Force to the Flight class [#799](https://github.com/RocketPy-Team/RocketPy/pull/799)
39+
- ENH: _MotorPrints inheritance - issue #460 [#828](https://github.com/RocketPy-Team/RocketPy/pull/828)
40+
- MNT: fix deprecations and warnings [#829](https://github.com/RocketPy-Team/RocketPy/pull/829)
3841

3942
### Fixed
4043

@@ -44,7 +47,7 @@ Attention: The newest changes should be on top -->
4447
### Added
4548
- ENH: Support for ND arithmetic in Function class. [#810] (https://github.com/RocketPy-Team/RocketPy/pull/810)
4649
- ENH: allow users to provide custom samplers [#803](https://github.com/RocketPy-Team/RocketPy/pull/803)
47-
- ENH: Implement Multivariate Rejection Sampling (MRS) [#738] (https://github.com/RocketPy-Team/RocketPy/pull/738)
50+
- ENH: Implement Multivariate Rejection Sampling (MRS) [#738] (https://github.com/RocketPy-Team/RocketPy/pull/738)
4851
- ENH: Create a rocketpy file to store flight simulations [#800](https://github.com/RocketPy-Team/RocketPy/pull/800)
4952
- ENH: Support for the RSE file format has been added to the library [#798](https://github.com/RocketPy-Team/RocketPy/pull/798)
5053
- ENH: Introduce Net Thrust with pressure corrections [#789](https://github.com/RocketPy-Team/RocketPy/pull/789)

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
numpy>=1.13
22
scipy>=1.0
3-
matplotlib>=3.0
3+
matplotlib>=3.9.0 # Released May 15th 2024
44
netCDF4>=1.6.4
55
requests
66
pytz

rocketpy/environment/environment.py

Lines changed: 23 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,14 @@
2727
find_latitude_index,
2828
find_longitude_index,
2929
find_time_index,
30+
geodesic_to_utm,
3031
get_elevation_data_from_dataset,
3132
get_final_date_from_time_array,
3233
get_initial_date_from_time_array,
3334
get_interval_date_from_time_array,
3435
get_pressure_levels_from_file,
3536
mask_and_clean_dataset,
3637
)
37-
from rocketpy.environment.tools import geodesic_to_utm as geodesic_to_utm_tools
38-
from rocketpy.environment.tools import utm_to_geodesic as utm_to_geodesic_tools
3938
from rocketpy.environment.weather_model_mapping import WeatherModelMapping
4039
from rocketpy.mathutils.function import NUMERICAL_TYPES, Function, funcify_method
4140
from rocketpy.plots.environment_plots import _EnvironmentPlots
@@ -248,6 +247,8 @@ class Environment:
248247
Number of ensemble members. Only defined when using Ensembles.
249248
Environment.ensemble_member : int
250249
Current selected ensemble member. Only defined when using Ensembles.
250+
Environment.earth_rotation_vector : list[float]
251+
Earth's angular velocity vector in the Flight Coordinate System.
251252
252253
Notes
253254
-----
@@ -353,6 +354,7 @@ def __init__(
353354
self.set_location(latitude, longitude)
354355
self.__initialize_earth_geometry(datum)
355356
self.__initialize_utm_coordinates()
357+
self.__set_earth_rotation_vector()
356358

357359
# Set the gravity model
358360
self.gravity = self.set_gravity_model(gravity)
@@ -451,7 +453,7 @@ def __initialize_utm_coordinates(self):
451453
self.initial_utm_letter,
452454
self.initial_hemisphere,
453455
self.initial_ew,
454-
) = self.geodesic_to_utm(
456+
) = geodesic_to_utm(
455457
lat=self.latitude,
456458
lon=self.longitude,
457459
flattening=self.ellipsoid.flattening,
@@ -584,6 +586,23 @@ def __reset_wind_direction_function(self):
584586
self.wind_direction.set_outputs("Wind Direction (Deg True)")
585587
self.wind_direction.set_title("Wind Direction Profile")
586588

589+
def __set_earth_rotation_vector(self):
590+
"""Calculates and stores the Earth's angular velocity vector in the Flight
591+
Coordinate System, which is essential for evaluating inertial forces.
592+
"""
593+
# Sidereal day
594+
T = 86164.1 # seconds
595+
596+
# Earth's angular velocity magnitude
597+
w_earth = 2 * np.pi / T
598+
599+
# Vector in the Flight Coordinate System
600+
lat = np.radians(self.latitude)
601+
w_local = [0, w_earth * np.cos(lat), w_earth * np.sin(lat)]
602+
603+
# Store the attribute
604+
self.earth_rotation_vector = w_local
605+
587606
# Validators (used to verify an attribute is being set correctly.)
588607

589608
def __validate_dictionary(self, file, dictionary):
@@ -2523,98 +2542,7 @@ def set_earth_geometry(self, datum):
25232542
f"the following recognized datum: {available_datums}"
25242543
) from e
25252544

2526-
# Auxiliary functions - Geodesic Coordinates
2527-
2528-
@staticmethod
2529-
def geodesic_to_utm(
2530-
lat, lon, semi_major_axis=6378137.0, flattening=1 / 298.257223563
2531-
):
2532-
"""Function which converts geodetic coordinates, i.e. lat/lon, to UTM
2533-
projection coordinates. Can be used only for latitudes between -80.00°
2534-
and 84.00°
2535-
2536-
Parameters
2537-
----------
2538-
lat : float
2539-
The latitude coordinates of the point of analysis, must be contained
2540-
between -80.00° and 84.00°
2541-
lon : float
2542-
The longitude coordinates of the point of analysis, must be
2543-
contained between -180.00° and 180.00°
2544-
semi_major_axis : float
2545-
The semi-major axis of the ellipsoid used to represent the Earth,
2546-
must be given in meters (default is 6,378,137.0 m, which corresponds
2547-
to the WGS84 ellipsoid)
2548-
flattening : float
2549-
The flattening of the ellipsoid used to represent the Earth, usually
2550-
between 1/250 and 1/150 (default is 1/298.257223563, which
2551-
corresponds to the WGS84 ellipsoid)
2552-
2553-
Returns
2554-
-------
2555-
x : float
2556-
East coordinate, always positive
2557-
y : float
2558-
North coordinate, always positive
2559-
utm_zone : int
2560-
The number of the UTM zone of the point of analysis, can vary
2561-
between 1 and 60
2562-
utm_letter : string
2563-
The letter of the UTM zone of the point of analysis, can vary
2564-
between C and X, omitting the letters "I" and "O"
2565-
hemis : string
2566-
Returns "S" for southern hemisphere and "N" for Northern hemisphere
2567-
EW : string
2568-
Returns "W" for western hemisphere and "E" for eastern hemisphere
2569-
"""
2570-
warnings.warn(
2571-
"This function is deprecated and will be removed in v1.10.0. "
2572-
"Please use the new method `tools.geodesic_to_utm` instead.",
2573-
DeprecationWarning,
2574-
)
2575-
return geodesic_to_utm_tools(lat, lon, semi_major_axis, flattening)
2576-
2577-
@staticmethod
2578-
def utm_to_geodesic(
2579-
x, y, utm_zone, hemis, semi_major_axis=6378137.0, flattening=1 / 298.257223563
2580-
):
2581-
"""Function to convert UTM coordinates to geodesic coordinates
2582-
(i.e. latitude and longitude).
2583-
2584-
Parameters
2585-
----------
2586-
x : float
2587-
East UTM coordinate in meters
2588-
y : float
2589-
North UTM coordinate in meters
2590-
utm_zone : int
2591-
The number of the UTM zone of the point of analysis, can vary
2592-
between 1 and 60
2593-
hemis : string
2594-
Equals to "S" for southern hemisphere and "N" for Northern
2595-
hemisphere
2596-
semi_major_axis : float
2597-
The semi-major axis of the ellipsoid used to represent the Earth,
2598-
must be given in meters (default is 6,378,137.0 m, which corresponds
2599-
to the WGS84 ellipsoid)
2600-
flattening : float
2601-
The flattening of the ellipsoid used to represent the Earth, usually
2602-
between 1/250 and 1/150 (default is 1/298.257223563, which
2603-
corresponds to the WGS84 ellipsoid)
2604-
2605-
Returns
2606-
-------
2607-
lat : float
2608-
latitude of the analyzed point
2609-
lon : float
2610-
latitude of the analyzed point
2611-
"""
2612-
warnings.warn(
2613-
"This function is deprecated and will be removed in v1.10.0. "
2614-
"Please use the new method `tools.utm_to_geodesic` instead.",
2615-
DeprecationWarning,
2616-
)
2617-
return utm_to_geodesic_tools(x, y, utm_zone, hemis, semi_major_axis, flattening)
2545+
# Auxiliary functions
26182546

26192547
@staticmethod
26202548
def calculate_earth_radius(

rocketpy/mathutils/function.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
from bisect import bisect_left
1111
from collections.abc import Iterable
1212
from copy import deepcopy
13+
from enum import Enum
1314
from functools import cached_property
1415
from inspect import signature
1516
from pathlib import Path
16-
from enum import Enum
1717

1818
import matplotlib.pyplot as plt
1919
import numpy as np
@@ -24,7 +24,7 @@
2424
RBFInterpolator,
2525
)
2626

27-
from rocketpy.tools import from_hex_decode, to_hex_encode
27+
from rocketpy.tools import deprecated, from_hex_decode, to_hex_encode
2828

2929
from ..plots.plot_helpers import show_or_save_plot
3030

@@ -1630,14 +1630,13 @@ def plot(self, *args, **kwargs):
16301630
else:
16311631
print("Error: Only functions with 1D or 2D domains can be plotted.")
16321632

1633+
@deprecated(
1634+
reason="The `Function.plot1D` method is set to be deprecated and fully "
1635+
"removed in rocketpy v2.0.0",
1636+
alternative="Function.plot_1d",
1637+
)
16331638
def plot1D(self, *args, **kwargs): # pragma: no cover
16341639
"""Deprecated method, use Function.plot_1d instead."""
1635-
warnings.warn(
1636-
"The `Function.plot1D` method is set to be deprecated and fully "
1637-
+ "removed in rocketpy v2.0.0, use `Function.plot_1d` instead. "
1638-
+ "This method is calling `Function.plot_1d`.",
1639-
DeprecationWarning,
1640-
)
16411640
return self.plot_1d(*args, **kwargs)
16421641

16431642
def plot_1d( # pylint: disable=too-many-statements
@@ -1736,14 +1735,13 @@ def plot_1d( # pylint: disable=too-many-statements
17361735
if return_object:
17371736
return fig, ax
17381737

1738+
@deprecated(
1739+
reason="The `Function.plot2D` method is set to be deprecated and fully "
1740+
"removed in rocketpy v2.0.0",
1741+
alternative="Function.plot_2d",
1742+
)
17391743
def plot2D(self, *args, **kwargs): # pragma: no cover
17401744
"""Deprecated method, use Function.plot_2d instead."""
1741-
warnings.warn(
1742-
"The `Function.plot2D` method is set to be deprecated and fully "
1743-
+ "removed in rocketpy v2.0.0, use `Function.plot_2d` instead. "
1744-
+ "This method is calling `Function.plot_2d`.",
1745-
DeprecationWarning,
1746-
)
17471745
return self.plot_2d(*args, **kwargs)
17481746

17491747
def plot_2d( # pylint: disable=too-many-statements

rocketpy/motors/motor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1151,7 +1151,7 @@ def vacuum_thrust(self):
11511151
Returns
11521152
-------
11531153
vacuum_thrust : Function
1154-
The rocket's thrust in a vaccum.
1154+
The rocket's thrust in a vacuum.
11551155
"""
11561156
if self.reference_pressure is None:
11571157
warnings.warn(

rocketpy/plots/monte_carlo_plots.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ def all(self, keys=None):
183183
ax2 = fig.add_subplot(gs[1])
184184

185185
# Plot boxplot
186+
# TODO: changes vert to orientation="horizontal" when support for Py3.9 ends
186187
ax1.boxplot(self.monte_carlo.results[key], vert=False)
187188
ax1.set_title(f"Box Plot of {key}")
188189
ax1.set_yticks([])

rocketpy/prints/hybrid_motor_prints.py

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import numpy as np
22

3+
from .motor_prints import _MotorPrints
34

4-
class _HybridMotorPrints:
5+
6+
class _HybridMotorPrints(_MotorPrints):
57
"""Class that holds prints methods for HybridMotor class.
68
79
Attributes
@@ -26,6 +28,7 @@ def __init__(
2628
-------
2729
None
2830
"""
31+
super().__init__(hybrid_motor)
2932
self.hybrid_motor = hybrid_motor
3033

3134
def nozzle_details(self):
@@ -63,28 +66,6 @@ def grain_details(self):
6366
print(f"Grain Volume: {self.hybrid_motor.solid.grain_initial_volume:.3f} m3")
6467
print(f"Grain Mass: {self.hybrid_motor.solid.grain_initial_mass:.3f} kg\n")
6568

66-
def motor_details(self):
67-
"""Prints out all data available about the HybridMotor.
68-
69-
Returns
70-
-------
71-
None
72-
"""
73-
print("Motor Details")
74-
print(f"Total Burning Time: {self.hybrid_motor.burn_duration} s")
75-
print(
76-
f"Total Propellant Mass: {self.hybrid_motor.propellant_initial_mass:.3f} kg"
77-
)
78-
print(f"Structural Mass Ratio: {self.hybrid_motor.structural_mass_ratio:.3f}")
79-
avg = self.hybrid_motor.exhaust_velocity.average(*self.hybrid_motor.burn_time)
80-
print(f"Average Propellant Exhaust Velocity: {avg:.3f} m/s")
81-
print(f"Average Thrust: {self.hybrid_motor.average_thrust:.3f} N")
82-
print(
83-
f"Maximum Thrust: {self.hybrid_motor.max_thrust} N at "
84-
f"{self.hybrid_motor.max_thrust_time} s after ignition."
85-
)
86-
print(f"Total Impulse: {self.hybrid_motor.total_impulse:.3f} Ns\n")
87-
8869
def all(self):
8970
"""Prints out all data available about the HybridMotor.
9071

rocketpy/prints/liquid_motor_prints.py

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
class _LiquidMotorPrints:
1+
from .motor_prints import _MotorPrints
2+
3+
4+
class _LiquidMotorPrints(_MotorPrints):
25
"""Class that holds prints methods for LiquidMotor class.
36
47
Attributes
@@ -23,6 +26,7 @@ def __init__(
2326
-------
2427
None
2528
"""
29+
super().__init__(liquid_motor)
2630
self.liquid_motor = liquid_motor
2731

2832
def nozzle_details(self):
@@ -35,28 +39,6 @@ def nozzle_details(self):
3539
print("Nozzle Details")
3640
print("Nozzle Radius: " + str(self.liquid_motor.nozzle_radius) + " m\n")
3741

38-
def motor_details(self):
39-
"""Prints out all data available about the motor.
40-
41-
Returns
42-
-------
43-
None
44-
"""
45-
print("Motor Details")
46-
print(f"Total Burning Time: {self.liquid_motor.burn_duration} s")
47-
print(
48-
f"Total Propellant Mass: {self.liquid_motor.propellant_initial_mass:.3f} kg"
49-
)
50-
print(f"Structural Mass Ratio: {self.liquid_motor.structural_mass_ratio:.3f}")
51-
avg = self.liquid_motor.exhaust_velocity.average(*self.liquid_motor.burn_time)
52-
print(f"Average Propellant Exhaust Velocity: {avg:.3f} m/s")
53-
print(f"Average Thrust: {self.liquid_motor.average_thrust:.3f} N")
54-
print(
55-
f"Maximum Thrust: {self.liquid_motor.max_thrust} N at "
56-
f"{self.liquid_motor.max_thrust_time} s after ignition."
57-
)
58-
print(f"Total Impulse: {self.liquid_motor.total_impulse:.3f} Ns\n")
59-
6042
def all(self):
6143
"""Prints out all data available about the LiquidMotor.
6244

0 commit comments

Comments
 (0)