Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
96 changes: 2 additions & 94 deletions rocketpy/environment/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
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_tools(
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
26 changes: 12 additions & 14 deletions rocketpy/mathutils/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
from bisect import bisect_left
from collections.abc import Iterable
from copy import deepcopy
from enum import Enum
from functools import cached_property
from inspect import signature
from pathlib import Path
from enum import Enum

import matplotlib.pyplot as plt
import numpy as np
Expand All @@ -24,7 +24,7 @@
RBFInterpolator,
)

from rocketpy.tools import from_hex_decode, to_hex_encode
from rocketpy.tools import deprecated, from_hex_decode, to_hex_encode

from ..plots.plot_helpers import show_or_save_plot

Expand Down Expand Up @@ -1459,14 +1459,13 @@ def plot(self, *args, **kwargs):
else:
print("Error: Only functions with 1D or 2D domains can be plotted.")

@deprecated(
reason="The `Function.plot1D` method is set to be deprecated and fully "
"removed in rocketpy v2.0.0",
alternative="Function.plot_1d",
)
def plot1D(self, *args, **kwargs): # pragma: no cover
"""Deprecated method, use Function.plot_1d instead."""
warnings.warn(
"The `Function.plot1D` method is set to be deprecated and fully "
+ "removed in rocketpy v2.0.0, use `Function.plot_1d` instead. "
+ "This method is calling `Function.plot_1d`.",
DeprecationWarning,
)
return self.plot_1d(*args, **kwargs)

def plot_1d( # pylint: disable=too-many-statements
Expand Down Expand Up @@ -1559,14 +1558,13 @@ def plot_1d( # pylint: disable=too-many-statements
if return_object:
return fig, ax

@deprecated(
reason="The `Function.plot2D` method is set to be deprecated and fully "
"removed in rocketpy v2.0.0",
alternative="Function.plot_2d",
)
def plot2D(self, *args, **kwargs): # pragma: no cover
"""Deprecated method, use Function.plot_2d instead."""
warnings.warn(
"The `Function.plot2D` method is set to be deprecated and fully "
+ "removed in rocketpy v2.0.0, use `Function.plot_2d` instead. "
+ "This method is calling `Function.plot_2d`.",
DeprecationWarning,
)
return self.plot_2d(*args, **kwargs)

def plot_2d( # pylint: disable=too-many-statements
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
4 changes: 2 additions & 2 deletions rocketpy/plots/monte_carlo_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def all(self, keys=None):
ax2 = fig.add_subplot(gs[1])

# Plot boxplot
ax1.boxplot(self.monte_carlo.results[key], vert=False)
ax1.boxplot(self.monte_carlo.results[key], orientation="horizontal")
ax1.set_title(f"Box Plot of {key}")
ax1.set_yticks([])

Expand Down Expand Up @@ -226,7 +226,7 @@ def plot_comparison(self, other_monte_carlo):
# Plot boxplot
bp = ax1.boxplot(
[other_monte_carlo.results[key], self.monte_carlo.results[key]],
vert=False,
orientation="horizontal",
tick_labels=["Other", "Original"],
patch_artist=True,
)
Expand Down
27 changes: 4 additions & 23 deletions rocketpy/prints/hybrid_motor_prints.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import numpy as np

from .motor_prints import _MotorPrints

class _HybridMotorPrints:

class _HybridMotorPrints(_MotorPrints):
"""Class that holds prints methods for HybridMotor class.

Attributes
Expand All @@ -26,6 +28,7 @@ def __init__(
-------
None
"""
super().__init__(hybrid_motor)
self.hybrid_motor = hybrid_motor

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

def motor_details(self):
"""Prints out all data available about the HybridMotor.

Returns
-------
None
"""
print("Motor Details")
print(f"Total Burning Time: {self.hybrid_motor.burn_duration} s")
print(
f"Total Propellant Mass: {self.hybrid_motor.propellant_initial_mass:.3f} kg"
)
print(f"Structural Mass Ratio: {self.hybrid_motor.structural_mass_ratio:.3f}")
avg = self.hybrid_motor.exhaust_velocity.average(*self.hybrid_motor.burn_time)
print(f"Average Propellant Exhaust Velocity: {avg:.3f} m/s")
print(f"Average Thrust: {self.hybrid_motor.average_thrust:.3f} N")
print(
f"Maximum Thrust: {self.hybrid_motor.max_thrust} N at "
f"{self.hybrid_motor.max_thrust_time} s after ignition."
)
print(f"Total Impulse: {self.hybrid_motor.total_impulse:.3f} Ns\n")

def all(self):
"""Prints out all data available about the HybridMotor.

Expand Down
28 changes: 5 additions & 23 deletions rocketpy/prints/liquid_motor_prints.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
class _LiquidMotorPrints:
from .motor_prints import _MotorPrints


class _LiquidMotorPrints(_MotorPrints):
"""Class that holds prints methods for LiquidMotor class.

Attributes
Expand All @@ -23,6 +26,7 @@ def __init__(
-------
None
"""
super().__init__(liquid_motor)
self.liquid_motor = liquid_motor

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

def motor_details(self):
"""Prints out all data available about the motor.

Returns
-------
None
"""
print("Motor Details")
print(f"Total Burning Time: {self.liquid_motor.burn_duration} s")
print(
f"Total Propellant Mass: {self.liquid_motor.propellant_initial_mass:.3f} kg"
)
print(f"Structural Mass Ratio: {self.liquid_motor.structural_mass_ratio:.3f}")
avg = self.liquid_motor.exhaust_velocity.average(*self.liquid_motor.burn_time)
print(f"Average Propellant Exhaust Velocity: {avg:.3f} m/s")
print(f"Average Thrust: {self.liquid_motor.average_thrust:.3f} N")
print(
f"Maximum Thrust: {self.liquid_motor.max_thrust} N at "
f"{self.liquid_motor.max_thrust_time} s after ignition."
)
print(f"Total Impulse: {self.liquid_motor.total_impulse:.3f} Ns\n")

def all(self):
"""Prints out all data available about the LiquidMotor.

Expand Down
28 changes: 5 additions & 23 deletions rocketpy/prints/solid_motor_prints.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
class _SolidMotorPrints:
from .motor_prints import _MotorPrints


class _SolidMotorPrints(_MotorPrints):
"""Class that holds prints methods for SolidMotor class.

Attributes
Expand All @@ -23,6 +26,7 @@ def __init__(
-------
None
"""
super().__init__(solid_motor)
self.solid_motor = solid_motor

def nozzle_details(self):
Expand Down Expand Up @@ -53,28 +57,6 @@ def grain_details(self):
print(f"Grain Volume: {self.solid_motor.grain_initial_volume:.3f} m3")
print(f"Grain Mass: {self.solid_motor.grain_initial_mass:.3f} kg\n")

def motor_details(self):
"""Prints out all data available about the SolidMotor.

Returns
-------
None
"""
print("Motor Details")
print("Total Burning Time: " + str(self.solid_motor.burn_duration) + " s")
print(
f"Total Propellant Mass: {self.solid_motor.propellant_initial_mass:.3f} kg"
)
print(f"Structural Mass Ratio: {self.solid_motor.structural_mass_ratio:.3f}")
average = self.solid_motor.exhaust_velocity.average(*self.solid_motor.burn_time)
print(f"Average Propellant Exhaust Velocity: {average:.3f} m/s")
print(f"Average Thrust: {self.solid_motor.average_thrust:.3f} N")
print(
f"Maximum Thrust: {self.solid_motor.max_thrust} N "
f"at {self.solid_motor.max_thrust_time} s after ignition."
)
print(f"Total Impulse: {self.solid_motor.total_impulse:.3f} Ns\n")

def all(self):
"""Prints out all data available about the SolidMotor.

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
13 changes: 6 additions & 7 deletions rocketpy/rocket/rocket.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import math
import warnings

import numpy as np

Expand All @@ -22,7 +21,7 @@
from rocketpy.rocket.aero_surface.generic_surface import GenericSurface
from rocketpy.rocket.components import Components
from rocketpy.rocket.parachute import Parachute
from rocketpy.tools import parallel_axis_theorem_from_com
from rocketpy.tools import deprecated, parallel_axis_theorem_from_com


# pylint: disable=too-many-instance-attributes, too-many-public-methods, too-many-instance-attributes
Expand Down Expand Up @@ -1173,16 +1172,16 @@ def add_nose(
self.add_surfaces(nose, position)
return nose

@deprecated(
reason="This method is set to be deprecated in version 1.0.0 and fully "
"removed by version 2.0.0",
alternative="Rocket.add_trapezoidal_fins",
)
def add_fins(self, *args, **kwargs): # pragma: no cover
"""See Rocket.add_trapezoidal_fins for documentation.
This method is set to be deprecated in version 1.0.0 and fully removed
by version 2.0.0. Use Rocket.add_trapezoidal_fins instead. It keeps the
same arguments and signature."""
warnings.warn(
"This method is set to be deprecated in version 1.0.0 and fully "
"removed by version 2.0.0. Use Rocket.add_trapezoidal_fins instead",
DeprecationWarning,
)
return self.add_trapezoidal_fins(*args, **kwargs)

def add_trapezoidal_fins(
Expand Down
Loading
Loading