Skip to content

Commit 1a6f8d9

Browse files
MNT: update code and remove deprecated functions
1 parent a8aef59 commit 1a6f8d9

File tree

8 files changed

+16
-216
lines changed

8 files changed

+16
-216
lines changed

rocketpy/environment/environment.py

Lines changed: 2 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ def __initialize_utm_coordinates(self):
451451
self.initial_utm_letter,
452452
self.initial_hemisphere,
453453
self.initial_ew,
454-
) = self.geodesic_to_utm(
454+
) = geodesic_to_utm_tools(
455455
lat=self.latitude,
456456
lon=self.longitude,
457457
flattening=self.ellipsoid.flattening,
@@ -2523,98 +2523,7 @@ def set_earth_geometry(self, datum):
25232523
f"the following recognized datum: {available_datums}"
25242524
) from e
25252525

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)
2526+
# Auxiliary functions
26182527

26192528
@staticmethod
26202529
def calculate_earth_radius(

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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def all(self, keys=None):
183183
ax2 = fig.add_subplot(gs[1])
184184

185185
# Plot boxplot
186-
ax1.boxplot(self.monte_carlo.results[key], vert=False)
186+
ax1.boxplot(self.monte_carlo.results[key], orientation="horizontal")
187187
ax1.set_title(f"Box Plot of {key}")
188188
ax1.set_yticks([])
189189

@@ -226,7 +226,7 @@ def plot_comparison(self, other_monte_carlo):
226226
# Plot boxplot
227227
bp = ax1.boxplot(
228228
[other_monte_carlo.results[key], self.monte_carlo.results[key]],
229-
vert=False,
229+
orientation="horizontal",
230230
tick_labels=["Other", "Original"],
231231
patch_artist=True,
232232
)

rocketpy/rocket/aero_surface/air_brakes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ def deployment_level(self, value):
131131
warnings.warn(
132132
f"Deployment level of {self.name} is smaller than 0 or "
133133
+ "larger than 1. Extrapolation for the drag coefficient "
134-
+ "curve will be used."
134+
+ "curve will be used.",
135+
UserWarning,
135136
)
136137
self._deployment_level = value
137138

rocketpy/simulation/flight.py

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3055,14 +3055,16 @@ def __calculate_rail_button_forces(self): # TODO: complex method.
30553055
null_force = Function(0)
30563056
if self.out_of_rail_time_index == 0: # No rail phase, no rail button forces
30573057
warnings.warn(
3058-
"Trying to calculate rail button forces without a rail phase defined."
3059-
+ "The rail button forces will be set to zero."
3058+
"Trying to calculate rail button forces without a rail phase defined. "
3059+
+ "The rail button forces will be set to zero.",
3060+
UserWarning,
30603061
)
30613062
return null_force, null_force, null_force, null_force
30623063
if len(self.rocket.rail_buttons) == 0:
30633064
warnings.warn(
3064-
"Trying to calculate rail button forces without rail buttons defined."
3065-
+ "The rail button forces will be set to zero."
3065+
"Trying to calculate rail button forces without rail buttons defined. "
3066+
+ "The rail button forces will be set to zero.",
3067+
UserWarning,
30663068
)
30673069
return null_force, null_force, null_force, null_force
30683070

@@ -3174,28 +3176,6 @@ def __evaluate_post_process(self):
31743176

31753177
return np.array(self.__post_processed_variables)
31763178

3177-
def post_process(self, interpolation="spline", extrapolation="natural"):
3178-
"""This method is **deprecated** and is only kept here for backwards
3179-
compatibility. All attributes that need to be post processed are
3180-
computed just in time.
3181-
3182-
Post-process all Flight information produced during
3183-
simulation. Includes the calculation of maximum values,
3184-
calculation of secondary values such as energy and conversion
3185-
of lists to Function objects to facilitate plotting.
3186-
3187-
Returns
3188-
-------
3189-
None
3190-
"""
3191-
# pylint: disable=unused-argument
3192-
warnings.warn(
3193-
"The method post_process is deprecated and will be removed in v1.10. "
3194-
"All attributes that need to be post processed are computed just in time.",
3195-
DeprecationWarning,
3196-
)
3197-
self.post_processed = True
3198-
31993179
def calculate_stall_wind_velocity(self, stall_angle): # TODO: move to utilities
32003180
"""Function to calculate the maximum wind velocity before the angle of
32013181
attack exceeds a desired angle, at the instant of departing rail launch.

rocketpy/utilities.py

Lines changed: 0 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -444,96 +444,6 @@ def _flutter_prints(
444444
print(f"Altitude of minimum Safety Factor: {altitude_min_sf:.3f} m (AGL)\n")
445445

446446

447-
def create_dispersion_dictionary(filename): # pragma: no cover
448-
"""Creates a dictionary with the rocket data provided by a .csv file.
449-
File should be organized in four columns: attribute_class, parameter_name,
450-
mean_value, standard_deviation. The first row should be the header.
451-
It is advised to use ";" as separator, but "," should work on most of cases.
452-
The "," separator might cause problems if the data set contains lists where
453-
the items are separated by commas.
454-
455-
Parameters
456-
----------
457-
filename : string
458-
String with the path to the .csv file. The file should follow the
459-
following structure:
460-
461-
.. code-block::
462-
463-
attribute_class; parameter_name; mean_value; standard_deviation;
464-
465-
environment; ensemble_member; [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];;
466-
467-
motor; impulse; 1415.15; 35.3;
468-
469-
motor; burn_time; 5.274; 1;
470-
471-
motor; nozzle_radius; 0.021642; 0.0005;
472-
473-
motor; throat_radius; 0.008; 0.0005;
474-
475-
motor; grain_separation; 0.006; 0.001;
476-
477-
motor; grain_density; 1707; 50;
478-
479-
Returns
480-
-------
481-
dictionary
482-
Dictionary with all rocket data to be used in dispersion analysis. The
483-
dictionary will follow the following structure:
484-
485-
.. code-block:: python
486-
487-
analysis_parameters = {
488-
'environment': {
489-
'ensemble_member': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
490-
},
491-
'motor': {
492-
'impulse': (1415.15, 35.3),
493-
'burn_time': (5.274, 1),
494-
'nozzle_radius': (0.021642, 0.0005),
495-
'throat_radius': (0.008, 0.0005),
496-
'grain_separation': (0.006, 0.001),
497-
'grain_density': (1707, 50),
498-
}
499-
}
500-
"""
501-
warnings.warn(
502-
"This function is deprecated and will be removed in v1.10.0.",
503-
DeprecationWarning,
504-
)
505-
try:
506-
file = np.genfromtxt(
507-
filename, usecols=(1, 2, 3), skip_header=1, delimiter=";", dtype=str
508-
)
509-
except ValueError:
510-
warnings.warn(
511-
"Error caught: the recommended delimiter is ';'. If using ',' "
512-
"instead, be aware that some resources might not work as "
513-
"expected if your data set contains lists where the items are "
514-
"separated by commas. Please consider changing the delimiter to "
515-
"';' if that is the case."
516-
)
517-
warnings.warn(traceback.format_exc())
518-
file = np.genfromtxt(
519-
filename, usecols=(1, 2, 3), skip_header=1, delimiter=",", dtype=str
520-
)
521-
analysis_parameters = {}
522-
for row in file:
523-
if row[0] != "":
524-
if row[2] == "":
525-
try:
526-
analysis_parameters[row[0].strip()] = float(row[1])
527-
except ValueError:
528-
analysis_parameters[row[0].strip()] = ast.literal_eval(row[1])
529-
else:
530-
try:
531-
analysis_parameters[row[0].strip()] = (float(row[1]), float(row[2]))
532-
except ValueError:
533-
analysis_parameters[row[0].strip()] = ""
534-
return analysis_parameters
535-
536-
537447
def apogee_by_mass(flight, min_mass, max_mass, points=10, plot=True):
538448
"""Returns a Function object that estimates the apogee of a rocket given
539449
its mass (no motor). The function will use the rocket's mass as the

tests/acceptance/test_bella_lui_rocket.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ def drogue_trigger(p, h, y):
182182
inclination=parameters.get("inclination")[0],
183183
heading=parameters.get("heading")[0],
184184
)
185-
test_flight.post_process()
186185

187186
# Comparison with Real Data
188187
flight_data = np.loadtxt(

tests/unit/test_environment.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import pytz
77

88
from rocketpy import Environment
9+
from rocketpy.environment.tools import geodesic_to_utm, utm_to_geodesic
910

1011

1112
@pytest.mark.parametrize(
@@ -78,7 +79,7 @@ def test_geodesic_coordinate_geodesic_to_utm_converts_coordinate():
7879
utm_letter,
7980
north_south_hemis,
8081
east_west_hemis,
81-
) = Environment.geodesic_to_utm(
82+
) = geodesic_to_utm(
8283
lat=32.990254,
8384
lon=-106.974998,
8485
semi_major_axis=6378137.0, # WGS84
@@ -98,7 +99,7 @@ class and checks the conversion results from UTM to geodesic
9899
coordinates.
99100
"""
100101

101-
lat, lon = Environment.utm_to_geodesic(
102+
lat, lon = utm_to_geodesic(
102103
x=315468.64,
103104
y=3651938.65,
104105
utm_zone=13,

0 commit comments

Comments
 (0)