Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEP: Remove Pending Deprecations and Add Warnings Where Needed #794

Merged
merged 6 commits into from
Mar 24, 2025
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Attention: The newest changes should be on top -->

### Changed

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

Expand Down
62 changes: 10 additions & 52 deletions rocketpy/environment/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -1653,38 +1653,6 @@ def process_wyoming_sounding(self, file): # pylint: disable=too-many-statements
# Save maximum expected height
self._max_expected_height = data_array[-1, 1]

def process_noaaruc_sounding(self, file): # pylint: disable=too-many-statements
"""Import and process the upper air sounding data from `NOAA
Ruc Soundings` database (https://rucsoundings.noaa.gov/) given as
ASCII GSD format pages passed by its url to the file parameter. Sets
pressure, temperature, wind-u, wind-v profiles and surface elevation.

Parameters
----------
file : string
URL of an upper air sounding data output from `NOAA Ruc Soundings`
in ASCII GSD format.

Example:

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


See also
--------
This method is deprecated and will be fully deleted in version 1.8.0.

Returns
-------
None
"""
warnings.warn(
"NOAA RUC models are no longer available. "
"This method is deprecated and will be fully deleted in version 1.8.0.",
DeprecationWarning,
)
return file

def process_forecast_reanalysis(self, file, dictionary): # pylint: disable=too-many-locals,too-many-statements
"""Import and process atmospheric data from weather forecasts
and reanalysis given as ``netCDF`` or ``OPeNDAP`` files.
Expand Down Expand Up @@ -2259,26 +2227,6 @@ def select_ensemble_member(self, member=0):
self.calculate_speed_of_sound_profile()
self.calculate_dynamic_viscosity()

def load_international_standard_atmosphere(self): # pragma: no cover
"""Defines the pressure and temperature profile functions set
by `ISO 2533` for the International Standard atmosphere and saves
them as ``Environment.pressure_ISA`` and ``Environment.temperature_ISA``.

Notes
-----
This method is **deprecated** and will be removed in version 1.6.0. You
can access :meth:`rocketpy.Environment.pressure_ISA` and
:meth:`rocketpy.Environment.temperature_ISA` directly without the need
to call this method.
"""
warnings.warn(
"load_international_standard_atmosphere() is deprecated in version "
"1.5.0 and will be removed in version 1.7.0. This method is no longer "
"needed as the International Standard Atmosphere is already calculated "
"when the Environment object is created.",
DeprecationWarning,
)

@funcify_method("Height Above Sea Level (m)", "Pressure (Pa)", "spline", "natural")
def pressure_ISA(self):
"""Pressure, in Pa, as a function of height above sea level as defined
Expand Down Expand Up @@ -2619,6 +2567,11 @@ def geodesic_to_utm(
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
Expand Down Expand Up @@ -2656,6 +2609,11 @@ def utm_to_geodesic(
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)

@staticmethod
Expand Down
28 changes: 0 additions & 28 deletions rocketpy/environment/fetchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import re
import time
import warnings
from datetime import datetime, timedelta, timezone

import netCDF4
Expand Down Expand Up @@ -328,33 +327,6 @@ def fetch_wyoming_sounding(file):
return response


@exponential_backoff(max_attempts=5, base_delay=2, max_delay=60)
def fetch_noaaruc_sounding(file): # pragma: no cover
"""Fetches sounding data from a specified file using the NOAA RUC soundings.

Parameters
----------
file : str
The URL of the file to fetch.

Returns
-------
str
The content of the fetched file.

Raises
------
ImportError
If unable to load the specified file or the file content is too short.
"""
warnings.warn(
"The NOAA RUC soundings are deprecated since September 30th, 2024. "
"This method will be removed in version 1.8.0.",
DeprecationWarning,
)
return file


@exponential_backoff(max_attempts=5, base_delay=2, max_delay=60)
def fetch_gefs_ensemble():
"""Fetches the latest GEFS (Global Ensemble Forecast System) dataset from
Expand Down
71 changes: 67 additions & 4 deletions rocketpy/environment/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,9 +443,44 @@ def get_interval_date_from_time_array(time_array, units=None):


def geodesic_to_utm(lat, lon, semi_major_axis=6378137.0, flattening=1 / 298.257223563): # pylint: disable=too-many-locals,too-many-statements
# NOTE: already documented in the Environment class.
# TODO: deprecated the static method from the environment class, use only this one.
"""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
"""
# Calculate the central meridian of UTM zone
if lon != 0:
signal = lon / abs(lon)
Expand Down Expand Up @@ -529,9 +564,37 @@ def geodesic_to_utm(lat, lon, semi_major_axis=6378137.0, flattening=1 / 298.2572
def utm_to_geodesic( # pylint: disable=too-many-locals,too-many-statements
x, y, utm_zone, hemis, semi_major_axis=6378137.0, flattening=1 / 298.257223563
):
# NOTE: already documented in the Environment class.
# TODO: deprecate the static method from the environment class, use only this one.
"""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
"""
if hemis == "N":
y = y + 10000000

Expand Down
36 changes: 0 additions & 36 deletions rocketpy/plots/rocket_plots.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import warnings

import matplotlib.pyplot as plt
import numpy as np

Expand Down Expand Up @@ -88,40 +86,6 @@ def stability_margin(self):
alpha=1,
)

def power_on_drag(self):
"""Plots power on drag of the rocket as a function of time.

Returns
-------
None
"""

warnings.warn(
"The method 'power_on_drag' is deprecated as of version "
+ "1.2 and will be removed in version 1.4 "
+ "Use 'plots.drag_curves' instead.",
DeprecationWarning,
)

self.rocket.power_on_drag()

def power_off_drag(self):
"""Plots power off drag of the rocket as a function of time.

Returns
-------
None
"""

warnings.warn(
"The method 'power_off_drag' is deprecated as of version "
+ "1.2 and will be removed in version 1.4 "
+ "Use 'plots.drag_curves' instead.",
DeprecationWarning,
)

self.rocket.power_off_drag()

# pylint: disable=too-many-statements
def drag_curves(self, *, filename=None):
"""Plots power off and on drag curves of the rocket as a function of time.
Expand Down
2 changes: 1 addition & 1 deletion rocketpy/rocket/rocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,7 @@ def add_fins(self, *args, **kwargs): # pragma: no cover
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",
PendingDeprecationWarning,
DeprecationWarning,
)
return self.add_trapezoidal_fins(*args, **kwargs)

Expand Down
6 changes: 5 additions & 1 deletion rocketpy/simulation/flight.py
Original file line number Diff line number Diff line change
Expand Up @@ -3091,7 +3091,11 @@ def post_process(self, interpolation="spline", extrapolation="natural"):
None
"""
# pylint: disable=unused-argument
# TODO: add a deprecation warning maybe?
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
Expand Down
5 changes: 4 additions & 1 deletion rocketpy/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,6 @@ def _flutter_prints(
print(f"Altitude of minimum Safety Factor: {altitude_min_sf:.3f} m (AGL)\n")


# TODO: deprecate and delete this function. Never used and now we have Monte Carlo.
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,
Expand Down Expand Up @@ -492,6 +491,10 @@ def create_dispersion_dictionary(filename): # pragma: no cover
}
}
"""
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
Expand Down