Skip to content

Commit 5328d66

Browse files
authored
DEP: Remove Pending Deprecations and Add Warnings Where Needed (#794)
* DEP: Add deprecation warnings for outdated methods and functions * DEP: Remove deprecated methods for NOAA RUC soundings and power drag plots * DEV: changelog * MNT: ruff * DEP: Update deprecation warning for post_process method to specify removal in v1.10 * MNT: Remove unused imports
1 parent 76fb5ef commit 5328d66

File tree

8 files changed

+88
-123
lines changed

8 files changed

+88
-123
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Attention: The newest changes should be on top -->
3939

4040
### Changed
4141

42+
- DEP: Remove Pending Deprecations and Add Warnings Where Needed [#794](https://github.com/RocketPy-Team/RocketPy/pull/794)
4243
- DOCS: reshape docs (closes #659) [#781](https://github.com/RocketPy-Team/RocketPy/pull/781)
4344
- MNT: EmptyMotor class inherits from Motor(ABC) [#779](https://github.com/RocketPy-Team/RocketPy/pull/779)
4445

rocketpy/environment/environment.py

Lines changed: 10 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1653,38 +1653,6 @@ def process_wyoming_sounding(self, file): # pylint: disable=too-many-statements
16531653
# Save maximum expected height
16541654
self._max_expected_height = data_array[-1, 1]
16551655

1656-
def process_noaaruc_sounding(self, file): # pylint: disable=too-many-statements
1657-
"""Import and process the upper air sounding data from `NOAA
1658-
Ruc Soundings` database (https://rucsoundings.noaa.gov/) given as
1659-
ASCII GSD format pages passed by its url to the file parameter. Sets
1660-
pressure, temperature, wind-u, wind-v profiles and surface elevation.
1661-
1662-
Parameters
1663-
----------
1664-
file : string
1665-
URL of an upper air sounding data output from `NOAA Ruc Soundings`
1666-
in ASCII GSD format.
1667-
1668-
Example:
1669-
1670-
https://rucsoundings.noaa.gov/get_raobs.cgi?data_source=RAOB&latest=latest&start_year=2019&start_month_name=Feb&start_mday=5&start_hour=12&start_min=0&n_hrs=1.0&fcst_len=shortest&airport=83779&text=Ascii%20text%20%28GSD%20format%29&hydrometeors=false&start=latest
1671-
1672-
1673-
See also
1674-
--------
1675-
This method is deprecated and will be fully deleted in version 1.8.0.
1676-
1677-
Returns
1678-
-------
1679-
None
1680-
"""
1681-
warnings.warn(
1682-
"NOAA RUC models are no longer available. "
1683-
"This method is deprecated and will be fully deleted in version 1.8.0.",
1684-
DeprecationWarning,
1685-
)
1686-
return file
1687-
16881656
def process_forecast_reanalysis(self, file, dictionary): # pylint: disable=too-many-locals,too-many-statements
16891657
"""Import and process atmospheric data from weather forecasts
16901658
and reanalysis given as ``netCDF`` or ``OPeNDAP`` files.
@@ -2259,26 +2227,6 @@ def select_ensemble_member(self, member=0):
22592227
self.calculate_speed_of_sound_profile()
22602228
self.calculate_dynamic_viscosity()
22612229

2262-
def load_international_standard_atmosphere(self): # pragma: no cover
2263-
"""Defines the pressure and temperature profile functions set
2264-
by `ISO 2533` for the International Standard atmosphere and saves
2265-
them as ``Environment.pressure_ISA`` and ``Environment.temperature_ISA``.
2266-
2267-
Notes
2268-
-----
2269-
This method is **deprecated** and will be removed in version 1.6.0. You
2270-
can access :meth:`rocketpy.Environment.pressure_ISA` and
2271-
:meth:`rocketpy.Environment.temperature_ISA` directly without the need
2272-
to call this method.
2273-
"""
2274-
warnings.warn(
2275-
"load_international_standard_atmosphere() is deprecated in version "
2276-
"1.5.0 and will be removed in version 1.7.0. This method is no longer "
2277-
"needed as the International Standard Atmosphere is already calculated "
2278-
"when the Environment object is created.",
2279-
DeprecationWarning,
2280-
)
2281-
22822230
@funcify_method("Height Above Sea Level (m)", "Pressure (Pa)", "spline", "natural")
22832231
def pressure_ISA(self):
22842232
"""Pressure, in Pa, as a function of height above sea level as defined
@@ -2619,6 +2567,11 @@ def geodesic_to_utm(
26192567
EW : string
26202568
Returns "W" for western hemisphere and "E" for eastern hemisphere
26212569
"""
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+
)
26222575
return geodesic_to_utm_tools(lat, lon, semi_major_axis, flattening)
26232576

26242577
@staticmethod
@@ -2656,6 +2609,11 @@ def utm_to_geodesic(
26562609
lon : float
26572610
latitude of the analyzed point
26582611
"""
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+
)
26592617
return utm_to_geodesic_tools(x, y, utm_zone, hemis, semi_major_axis, flattening)
26602618

26612619
@staticmethod

rocketpy/environment/fetchers.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import re
77
import time
8-
import warnings
98
from datetime import datetime, timedelta, timezone
109

1110
import netCDF4
@@ -328,33 +327,6 @@ def fetch_wyoming_sounding(file):
328327
return response
329328

330329

331-
@exponential_backoff(max_attempts=5, base_delay=2, max_delay=60)
332-
def fetch_noaaruc_sounding(file): # pragma: no cover
333-
"""Fetches sounding data from a specified file using the NOAA RUC soundings.
334-
335-
Parameters
336-
----------
337-
file : str
338-
The URL of the file to fetch.
339-
340-
Returns
341-
-------
342-
str
343-
The content of the fetched file.
344-
345-
Raises
346-
------
347-
ImportError
348-
If unable to load the specified file or the file content is too short.
349-
"""
350-
warnings.warn(
351-
"The NOAA RUC soundings are deprecated since September 30th, 2024. "
352-
"This method will be removed in version 1.8.0.",
353-
DeprecationWarning,
354-
)
355-
return file
356-
357-
358330
@exponential_backoff(max_attempts=5, base_delay=2, max_delay=60)
359331
def fetch_gefs_ensemble():
360332
"""Fetches the latest GEFS (Global Ensemble Forecast System) dataset from

rocketpy/environment/tools.py

Lines changed: 67 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -443,9 +443,44 @@ def get_interval_date_from_time_array(time_array, units=None):
443443

444444

445445
def geodesic_to_utm(lat, lon, semi_major_axis=6378137.0, flattening=1 / 298.257223563): # pylint: disable=too-many-locals,too-many-statements
446-
# NOTE: already documented in the Environment class.
447-
# TODO: deprecated the static method from the environment class, use only this one.
446+
"""Function which converts geodetic coordinates, i.e. lat/lon, to UTM
447+
projection coordinates. Can be used only for latitudes between -80.00°
448+
and 84.00°
448449
450+
Parameters
451+
----------
452+
lat : float
453+
The latitude coordinates of the point of analysis, must be contained
454+
between -80.00° and 84.00°
455+
lon : float
456+
The longitude coordinates of the point of analysis, must be
457+
contained between -180.00° and 180.00°
458+
semi_major_axis : float
459+
The semi-major axis of the ellipsoid used to represent the Earth,
460+
must be given in meters (default is 6,378,137.0 m, which corresponds
461+
to the WGS84 ellipsoid)
462+
flattening : float
463+
The flattening of the ellipsoid used to represent the Earth, usually
464+
between 1/250 and 1/150 (default is 1/298.257223563, which
465+
corresponds to the WGS84 ellipsoid)
466+
467+
Returns
468+
-------
469+
x : float
470+
East coordinate, always positive
471+
y : float
472+
North coordinate, always positive
473+
utm_zone : int
474+
The number of the UTM zone of the point of analysis, can vary
475+
between 1 and 60
476+
utm_letter : string
477+
The letter of the UTM zone of the point of analysis, can vary
478+
between C and X, omitting the letters "I" and "O"
479+
hemis : string
480+
Returns "S" for southern hemisphere and "N" for Northern hemisphere
481+
EW : string
482+
Returns "W" for western hemisphere and "E" for eastern hemisphere
483+
"""
449484
# Calculate the central meridian of UTM zone
450485
if lon != 0:
451486
signal = lon / abs(lon)
@@ -529,9 +564,37 @@ def geodesic_to_utm(lat, lon, semi_major_axis=6378137.0, flattening=1 / 298.2572
529564
def utm_to_geodesic( # pylint: disable=too-many-locals,too-many-statements
530565
x, y, utm_zone, hemis, semi_major_axis=6378137.0, flattening=1 / 298.257223563
531566
):
532-
# NOTE: already documented in the Environment class.
533-
# TODO: deprecate the static method from the environment class, use only this one.
567+
"""Function to convert UTM coordinates to geodesic coordinates
568+
(i.e. latitude and longitude).
534569
570+
Parameters
571+
----------
572+
x : float
573+
East UTM coordinate in meters
574+
y : float
575+
North UTM coordinate in meters
576+
utm_zone : int
577+
The number of the UTM zone of the point of analysis, can vary
578+
between 1 and 60
579+
hemis : string
580+
Equals to "S" for southern hemisphere and "N" for Northern
581+
hemisphere
582+
semi_major_axis : float
583+
The semi-major axis of the ellipsoid used to represent the Earth,
584+
must be given in meters (default is 6,378,137.0 m, which corresponds
585+
to the WGS84 ellipsoid)
586+
flattening : float
587+
The flattening of the ellipsoid used to represent the Earth, usually
588+
between 1/250 and 1/150 (default is 1/298.257223563, which
589+
corresponds to the WGS84 ellipsoid)
590+
591+
Returns
592+
-------
593+
lat : float
594+
latitude of the analyzed point
595+
lon : float
596+
latitude of the analyzed point
597+
"""
535598
if hemis == "N":
536599
y = y + 10000000
537600

rocketpy/plots/rocket_plots.py

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import warnings
2-
31
import matplotlib.pyplot as plt
42
import numpy as np
53

@@ -88,40 +86,6 @@ def stability_margin(self):
8886
alpha=1,
8987
)
9088

91-
def power_on_drag(self):
92-
"""Plots power on drag of the rocket as a function of time.
93-
94-
Returns
95-
-------
96-
None
97-
"""
98-
99-
warnings.warn(
100-
"The method 'power_on_drag' is deprecated as of version "
101-
+ "1.2 and will be removed in version 1.4 "
102-
+ "Use 'plots.drag_curves' instead.",
103-
DeprecationWarning,
104-
)
105-
106-
self.rocket.power_on_drag()
107-
108-
def power_off_drag(self):
109-
"""Plots power off drag of the rocket as a function of time.
110-
111-
Returns
112-
-------
113-
None
114-
"""
115-
116-
warnings.warn(
117-
"The method 'power_off_drag' is deprecated as of version "
118-
+ "1.2 and will be removed in version 1.4 "
119-
+ "Use 'plots.drag_curves' instead.",
120-
DeprecationWarning,
121-
)
122-
123-
self.rocket.power_off_drag()
124-
12589
# pylint: disable=too-many-statements
12690
def drag_curves(self, *, filename=None):
12791
"""Plots power off and on drag curves of the rocket as a function of time.

rocketpy/rocket/rocket.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1181,7 +1181,7 @@ def add_fins(self, *args, **kwargs): # pragma: no cover
11811181
warnings.warn(
11821182
"This method is set to be deprecated in version 1.0.0 and fully "
11831183
"removed by version 2.0.0. Use Rocket.add_trapezoidal_fins instead",
1184-
PendingDeprecationWarning,
1184+
DeprecationWarning,
11851185
)
11861186
return self.add_trapezoidal_fins(*args, **kwargs)
11871187

rocketpy/simulation/flight.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3091,7 +3091,11 @@ def post_process(self, interpolation="spline", extrapolation="natural"):
30913091
None
30923092
"""
30933093
# pylint: disable=unused-argument
3094-
# TODO: add a deprecation warning maybe?
3094+
warnings.warn(
3095+
"The method post_process is deprecated and will be removed in v1.10. "
3096+
"All attributes that need to be post processed are computed just in time.",
3097+
DeprecationWarning,
3098+
)
30953099
self.post_processed = True
30963100

30973101
def calculate_stall_wind_velocity(self, stall_angle): # TODO: move to utilities

rocketpy/utilities.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,6 @@ def _flutter_prints(
437437
print(f"Altitude of minimum Safety Factor: {altitude_min_sf:.3f} m (AGL)\n")
438438

439439

440-
# TODO: deprecate and delete this function. Never used and now we have Monte Carlo.
441440
def create_dispersion_dictionary(filename): # pragma: no cover
442441
"""Creates a dictionary with the rocket data provided by a .csv file.
443442
File should be organized in four columns: attribute_class, parameter_name,
@@ -492,6 +491,10 @@ def create_dispersion_dictionary(filename): # pragma: no cover
492491
}
493492
}
494493
"""
494+
warnings.warn(
495+
"This function is deprecated and will be removed in v1.10.0.",
496+
DeprecationWarning,
497+
)
495498
try:
496499
file = np.genfromtxt(
497500
filename, usecols=(1, 2, 3), skip_header=1, delimiter=";", dtype=str

0 commit comments

Comments
 (0)