From 5328d66c6869145ed6c8488b5b72f2f305b67db6 Mon Sep 17 00:00:00 2001 From: MateusStano <69485049+MateusStano@users.noreply.github.com> Date: Mon, 24 Mar 2025 13:07:52 +0100 Subject: [PATCH 1/2] 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 --- CHANGELOG.md | 1 + rocketpy/environment/environment.py | 62 ++++--------------------- rocketpy/environment/fetchers.py | 28 ------------ rocketpy/environment/tools.py | 71 +++++++++++++++++++++++++++-- rocketpy/plots/rocket_plots.py | 36 --------------- rocketpy/rocket/rocket.py | 2 +- rocketpy/simulation/flight.py | 6 ++- rocketpy/utilities.py | 5 +- 8 files changed, 88 insertions(+), 123 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a0d664c8..0fce25cd1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/rocketpy/environment/environment.py b/rocketpy/environment/environment.py index 1a0c044ed..a0a8c4238 100644 --- a/rocketpy/environment/environment.py +++ b/rocketpy/environment/environment.py @@ -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. @@ -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 @@ -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 @@ -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 diff --git a/rocketpy/environment/fetchers.py b/rocketpy/environment/fetchers.py index baeef329c..d5ac2a1df 100644 --- a/rocketpy/environment/fetchers.py +++ b/rocketpy/environment/fetchers.py @@ -5,7 +5,6 @@ import re import time -import warnings from datetime import datetime, timedelta, timezone import netCDF4 @@ -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 diff --git a/rocketpy/environment/tools.py b/rocketpy/environment/tools.py index bd3bad804..1239ee6b9 100644 --- a/rocketpy/environment/tools.py +++ b/rocketpy/environment/tools.py @@ -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) @@ -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 diff --git a/rocketpy/plots/rocket_plots.py b/rocketpy/plots/rocket_plots.py index db53f6f49..8eaaded16 100644 --- a/rocketpy/plots/rocket_plots.py +++ b/rocketpy/plots/rocket_plots.py @@ -1,5 +1,3 @@ -import warnings - import matplotlib.pyplot as plt import numpy as np @@ -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. diff --git a/rocketpy/rocket/rocket.py b/rocketpy/rocket/rocket.py index 415f54790..bf938d4be 100644 --- a/rocketpy/rocket/rocket.py +++ b/rocketpy/rocket/rocket.py @@ -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) diff --git a/rocketpy/simulation/flight.py b/rocketpy/simulation/flight.py index 9d53ae2d6..6c0e14312 100644 --- a/rocketpy/simulation/flight.py +++ b/rocketpy/simulation/flight.py @@ -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 diff --git a/rocketpy/utilities.py b/rocketpy/utilities.py index 5166578dc..b3a1d7f8d 100644 --- a/rocketpy/utilities.py +++ b/rocketpy/utilities.py @@ -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, @@ -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 From 4df0b383c2886c7804b6848bbe5b9cbe612b2cd5 Mon Sep 17 00:00:00 2001 From: MateusStano <69485049+MateusStano@users.noreply.github.com> Date: Mon, 24 Mar 2025 17:35:03 +0100 Subject: [PATCH 2/2] REL: Update version to 1.9.0 (#795) --- CHANGELOG.md | 11 +++++++++++ docs/conf.py | 2 +- docs/user/installation.rst | 2 +- pyproject.toml | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fce25cd1..6a2503d23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,17 @@ Attention: The newest changes should be on top --> ### Added + +### Changed + + +### Fixed + + +## v1.9.0 - 2025-03-24 + +### Added + - ENH: Parallel mode for monte-carlo simulations 2 [#768](https://github.com/RocketPy-Team/RocketPy/pull/768) - DOC: ASTRA Flight Example [#770](https://github.com/RocketPy-Team/RocketPy/pull/770) - ENH: Add Eccentricity to Stochastic Simulations [#792](https://github.com/RocketPy-Team/RocketPy/pull/792) diff --git a/docs/conf.py b/docs/conf.py index cf4d942dc..209a9c810 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -27,7 +27,7 @@ author = "RocketPy Team" # The full version, including alpha/beta/rc tags -release = "1.8.0" +release = "1.9.0" # -- General configuration --------------------------------------------------- diff --git a/docs/user/installation.rst b/docs/user/installation.rst index fe5939e98..844edd2b8 100644 --- a/docs/user/installation.rst +++ b/docs/user/installation.rst @@ -19,7 +19,7 @@ If you want to choose a specific version to guarantee compatibility, you may ins .. code-block:: shell - pip install rocketpy==1.8.0 + pip install rocketpy==1.9.0 Optional Installation Method: ``conda`` diff --git a/pyproject.toml b/pyproject.toml index e1d8474c8..e0f225efb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "rocketpy" -version = "1.8.0" +version = "1.9.0" description="Advanced 6-DOF trajectory simulation for High-Power Rocketry." dynamic = ["dependencies"] readme = "README.md"