Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ Attention: The newest changes should be on top -->

- ENH: _MotorPrints inheritance - issue #460 [#828](https://github.com/RocketPy-Team/RocketPy/pull/828)

- MNT: fix deprecations and warnings [#829](https://github.com/RocketPy-Team/RocketPy/pull/829)

### Fixed


Expand All @@ -45,7 +47,7 @@ Attention: The newest changes should be on top -->
### Added
- ENH: Support for ND arithmetic in Function class. [#810] (https://github.com/RocketPy-Team/RocketPy/pull/810)
- ENH: allow users to provide custom samplers [#803](https://github.com/RocketPy-Team/RocketPy/pull/803)
- ENH: Implement Multivariate Rejection Sampling (MRS) [#738] (https://github.com/RocketPy-Team/RocketPy/pull/738)
- ENH: Implement Multivariate Rejection Sampling (MRS) [#738] (https://github.com/RocketPy-Team/RocketPy/pull/738)
- ENH: Create a rocketpy file to store flight simulations [#800](https://github.com/RocketPy-Team/RocketPy/pull/800)
- ENH: Support for the RSE file format has been added to the library [#798](https://github.com/RocketPy-Team/RocketPy/pull/798)
- ENH: Introduce Net Thrust with pressure corrections [#789](https://github.com/RocketPy-Team/RocketPy/pull/789)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
numpy>=1.13
scipy>=1.0
matplotlib>=3.0
matplotlib>=3.9.0 # Released May 15th 2024
netCDF4>=1.6.4
requests
pytz
Expand Down
98 changes: 3 additions & 95 deletions rocketpy/environment/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,14 @@
find_latitude_index,
find_longitude_index,
find_time_index,
geodesic_to_utm,
get_elevation_data_from_dataset,
get_final_date_from_time_array,
get_initial_date_from_time_array,
get_interval_date_from_time_array,
get_pressure_levels_from_file,
mask_and_clean_dataset,
)
from rocketpy.environment.tools import geodesic_to_utm as geodesic_to_utm_tools
from rocketpy.environment.tools import utm_to_geodesic as utm_to_geodesic_tools
from rocketpy.environment.weather_model_mapping import WeatherModelMapping
from rocketpy.mathutils.function import NUMERICAL_TYPES, Function, funcify_method
from rocketpy.plots.environment_plots import _EnvironmentPlots
Expand Down Expand Up @@ -451,7 +450,7 @@ def __initialize_utm_coordinates(self):
self.initial_utm_letter,
self.initial_hemisphere,
self.initial_ew,
) = self.geodesic_to_utm(
) = geodesic_to_utm(
lat=self.latitude,
lon=self.longitude,
flattening=self.ellipsoid.flattening,
Expand Down Expand Up @@ -2523,98 +2522,7 @@ def set_earth_geometry(self, datum):
f"the following recognized datum: {available_datums}"
) from e

# Auxiliary functions - Geodesic Coordinates

@staticmethod
def geodesic_to_utm(
lat, lon, semi_major_axis=6378137.0, flattening=1 / 298.257223563
):
"""Function which converts geodetic coordinates, i.e. lat/lon, to UTM
projection coordinates. Can be used only for latitudes between -80.00°
and 84.00°

Parameters
----------
lat : float
The latitude coordinates of the point of analysis, must be contained
between -80.00° and 84.00°
lon : float
The longitude coordinates of the point of analysis, must be
contained between -180.00° and 180.00°
semi_major_axis : float
The semi-major axis of the ellipsoid used to represent the Earth,
must be given in meters (default is 6,378,137.0 m, which corresponds
to the WGS84 ellipsoid)
flattening : float
The flattening of the ellipsoid used to represent the Earth, usually
between 1/250 and 1/150 (default is 1/298.257223563, which
corresponds to the WGS84 ellipsoid)

Returns
-------
x : float
East coordinate, always positive
y : float
North coordinate, always positive
utm_zone : int
The number of the UTM zone of the point of analysis, can vary
between 1 and 60
utm_letter : string
The letter of the UTM zone of the point of analysis, can vary
between C and X, omitting the letters "I" and "O"
hemis : string
Returns "S" for southern hemisphere and "N" for Northern hemisphere
EW : string
Returns "W" for western hemisphere and "E" for eastern hemisphere
"""
warnings.warn(
"This function is deprecated and will be removed in v1.10.0. "
"Please use the new method `tools.geodesic_to_utm` instead.",
DeprecationWarning,
)
return geodesic_to_utm_tools(lat, lon, semi_major_axis, flattening)

@staticmethod
def utm_to_geodesic(
x, y, utm_zone, hemis, semi_major_axis=6378137.0, flattening=1 / 298.257223563
):
"""Function to convert UTM coordinates to geodesic coordinates
(i.e. latitude and longitude).

Parameters
----------
x : float
East UTM coordinate in meters
y : float
North UTM coordinate in meters
utm_zone : int
The number of the UTM zone of the point of analysis, can vary
between 1 and 60
hemis : string
Equals to "S" for southern hemisphere and "N" for Northern
hemisphere
semi_major_axis : float
The semi-major axis of the ellipsoid used to represent the Earth,
must be given in meters (default is 6,378,137.0 m, which corresponds
to the WGS84 ellipsoid)
flattening : float
The flattening of the ellipsoid used to represent the Earth, usually
between 1/250 and 1/150 (default is 1/298.257223563, which
corresponds to the WGS84 ellipsoid)

Returns
-------
lat : float
latitude of the analyzed point
lon : float
latitude of the analyzed point
"""
warnings.warn(
"This function is deprecated and will be removed in v1.10.0. "
"Please use the new method `tools.utm_to_geodesic` instead.",
DeprecationWarning,
)
return utm_to_geodesic_tools(x, y, utm_zone, hemis, semi_major_axis, flattening)
# Auxiliary functions

@staticmethod
def calculate_earth_radius(
Expand Down
2 changes: 1 addition & 1 deletion rocketpy/motors/motor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1151,7 +1151,7 @@ def vacuum_thrust(self):
Returns
-------
vacuum_thrust : Function
The rocket's thrust in a vaccum.
The rocket's thrust in a vacuum.
"""
if self.reference_pressure is None:
warnings.warn(
Expand Down
1 change: 1 addition & 0 deletions rocketpy/plots/monte_carlo_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ def all(self, keys=None):
ax2 = fig.add_subplot(gs[1])

# Plot boxplot
# TODO: changes vert to orientation="horizontal" when support for Py3.9 ends
ax1.boxplot(self.monte_carlo.results[key], vert=False)
ax1.set_title(f"Box Plot of {key}")
ax1.set_yticks([])
Expand Down
3 changes: 2 additions & 1 deletion rocketpy/rocket/aero_surface/air_brakes.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ def deployment_level(self, value):
warnings.warn(
f"Deployment level of {self.name} is smaller than 0 or "
+ "larger than 1. Extrapolation for the drag coefficient "
+ "curve will be used."
+ "curve will be used.",
UserWarning,
)
self._deployment_level = value

Expand Down
35 changes: 6 additions & 29 deletions rocketpy/simulation/flight.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,6 @@ class Flight:
Current integration time.
Flight.y : list
Current integration state vector u.
Flight.post_processed : bool
Defines if solution data has been post processed.
Flight.initial_solution : list
List defines initial condition - [tInit, x_init,
y_init, z_init, vx_init, vy_init, vz_init, e0_init, e1_init,
Expand Down Expand Up @@ -1102,7 +1100,6 @@ def __init_solution_monitors(self):
self.impact_velocity = 0
self.impact_state = np.array([0])
self.parachute_events = []
self.post_processed = False
self.__post_processed_variables = []

def __init_flight_state(self):
Expand Down Expand Up @@ -3055,14 +3052,16 @@ def __calculate_rail_button_forces(self): # TODO: complex method.
null_force = Function(0)
if self.out_of_rail_time_index == 0: # No rail phase, no rail button forces
warnings.warn(
"Trying to calculate rail button forces without a rail phase defined."
+ "The rail button forces will be set to zero."
"Trying to calculate rail button forces without a rail phase defined. "
+ "The rail button forces will be set to zero.",
UserWarning,
)
return null_force, null_force, null_force, null_force
if len(self.rocket.rail_buttons) == 0:
warnings.warn(
"Trying to calculate rail button forces without rail buttons defined."
+ "The rail button forces will be set to zero."
"Trying to calculate rail button forces without rail buttons defined. "
+ "The rail button forces will be set to zero.",
UserWarning,
)
return null_force, null_force, null_force, null_force

Expand Down Expand Up @@ -3174,28 +3173,6 @@ def __evaluate_post_process(self):

return np.array(self.__post_processed_variables)

def post_process(self, interpolation="spline", extrapolation="natural"):
"""This method is **deprecated** and is only kept here for backwards
compatibility. All attributes that need to be post processed are
computed just in time.

Post-process all Flight information produced during
simulation. Includes the calculation of maximum values,
calculation of secondary values such as energy and conversion
of lists to Function objects to facilitate plotting.

Returns
-------
None
"""
# pylint: disable=unused-argument
warnings.warn(
"The method post_process is deprecated and will be removed in v1.10. "
"All attributes that need to be post processed are computed just in time.",
DeprecationWarning,
)
self.post_processed = True

def calculate_stall_wind_velocity(self, stall_angle): # TODO: move to utilities
"""Function to calculate the maximum wind velocity before the angle of
attack exceeds a desired angle, at the instant of departing rail launch.
Expand Down
92 changes: 0 additions & 92 deletions rocketpy/utilities.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import ast
import inspect
import json
import os
import traceback
import warnings
from datetime import date
from importlib.metadata import version
Expand Down Expand Up @@ -444,96 +442,6 @@ def _flutter_prints(
print(f"Altitude of minimum Safety Factor: {altitude_min_sf:.3f} m (AGL)\n")


def create_dispersion_dictionary(filename): # pragma: no cover
"""Creates a dictionary with the rocket data provided by a .csv file.
File should be organized in four columns: attribute_class, parameter_name,
mean_value, standard_deviation. The first row should be the header.
It is advised to use ";" as separator, but "," should work on most of cases.
The "," separator might cause problems if the data set contains lists where
the items are separated by commas.

Parameters
----------
filename : string
String with the path to the .csv file. The file should follow the
following structure:

.. code-block::

attribute_class; parameter_name; mean_value; standard_deviation;

environment; ensemble_member; [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];;

motor; impulse; 1415.15; 35.3;

motor; burn_time; 5.274; 1;

motor; nozzle_radius; 0.021642; 0.0005;

motor; throat_radius; 0.008; 0.0005;

motor; grain_separation; 0.006; 0.001;

motor; grain_density; 1707; 50;

Returns
-------
dictionary
Dictionary with all rocket data to be used in dispersion analysis. The
dictionary will follow the following structure:

.. code-block:: python

analysis_parameters = {
'environment': {
'ensemble_member': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
},
'motor': {
'impulse': (1415.15, 35.3),
'burn_time': (5.274, 1),
'nozzle_radius': (0.021642, 0.0005),
'throat_radius': (0.008, 0.0005),
'grain_separation': (0.006, 0.001),
'grain_density': (1707, 50),
}
}
"""
warnings.warn(
"This function is deprecated and will be removed in v1.10.0.",
DeprecationWarning,
)
try:
file = np.genfromtxt(
filename, usecols=(1, 2, 3), skip_header=1, delimiter=";", dtype=str
)
except ValueError:
warnings.warn(
"Error caught: the recommended delimiter is ';'. If using ',' "
"instead, be aware that some resources might not work as "
"expected if your data set contains lists where the items are "
"separated by commas. Please consider changing the delimiter to "
"';' if that is the case."
)
warnings.warn(traceback.format_exc())
file = np.genfromtxt(
filename, usecols=(1, 2, 3), skip_header=1, delimiter=",", dtype=str
)
analysis_parameters = {}
for row in file:
if row[0] != "":
if row[2] == "":
try:
analysis_parameters[row[0].strip()] = float(row[1])
except ValueError:
analysis_parameters[row[0].strip()] = ast.literal_eval(row[1])
else:
try:
analysis_parameters[row[0].strip()] = (float(row[1]), float(row[2]))
except ValueError:
analysis_parameters[row[0].strip()] = ""
return analysis_parameters


def apogee_by_mass(flight, min_mass, max_mass, points=10, plot=True):
"""Returns a Function object that estimates the apogee of a rocket given
its mass (no motor). The function will use the rocket's mass as the
Expand Down
1 change: 0 additions & 1 deletion tests/acceptance/test_bella_lui_rocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ def drogue_trigger(p, h, y):
inclination=parameters.get("inclination")[0],
heading=parameters.get("heading")[0],
)
test_flight.post_process()

# Comparison with Real Data
flight_data = np.loadtxt(
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/test_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import pytz

from rocketpy import Environment
from rocketpy.environment.tools import geodesic_to_utm, utm_to_geodesic


@pytest.mark.parametrize(
Expand Down Expand Up @@ -78,7 +79,7 @@ def test_geodesic_coordinate_geodesic_to_utm_converts_coordinate():
utm_letter,
north_south_hemis,
east_west_hemis,
) = Environment.geodesic_to_utm(
) = geodesic_to_utm(
lat=32.990254,
lon=-106.974998,
semi_major_axis=6378137.0, # WGS84
Expand All @@ -98,7 +99,7 @@ class and checks the conversion results from UTM to geodesic
coordinates.
"""

lat, lon = Environment.utm_to_geodesic(
lat, lon = utm_to_geodesic(
x=315468.64,
y=3651938.65,
utm_zone=13,
Expand Down