Skip to content

Commit 1ac4d1f

Browse files
MNT: satisfy pylint on the pressure_ISA discretization changes
CI runs pylint unpinned; three messages were attributable to this PR: - C0415 import-outside-toplevel: move the tools import to the test module top level. - R0915 too-many-statements: keep the discretization block compact so pressure_ISA stays within the 25-statement limit. - C0302 too-many-lines: the terser block keeps environment.py under the 3050-line module limit. np.append over two linspaces yields the same grid as the previous np.concatenate, so all numeric results are unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 0c24858 commit 1ac4d1f

2 files changed

Lines changed: 8 additions & 16 deletions

File tree

rocketpy/environment/environment.py

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2554,22 +2554,14 @@ def pressure_function(h):
25542554
)
25552555
return P
25562556

2557-
# Discretize this Function to speed up the trajectory simulation.
2558-
# The ISA model is only defined between the lowest and highest
2559-
# geopotential layers, so convert those bounds to geometric height and
2560-
# sample the whole valid range (including below sea level, which the
2561-
# previous grid starting at 0 m did not cover).
2562-
min_height = geopotential_height_to_geometric_height(
2563-
geopotential_height[0], earth_radius
2557+
# Discretize across the full ISA range (geopotential layers -> geometric
2558+
# height), keeping 0 m as a knot and now covering below sea level too.
2559+
gph_to_geo = geopotential_height_to_geometric_height
2560+
min_h = gph_to_geo(geopotential_height[0], earth_radius)
2561+
altitudes = np.append(
2562+
np.linspace(min_h, 0, 10, endpoint=False),
2563+
np.linspace(0, gph_to_geo(geopotential_height[-1], earth_radius), 90),
25642564
)
2565-
max_height = geopotential_height_to_geometric_height(
2566-
geopotential_height[-1], earth_radius
2567-
)
2568-
# Split the 100 samples between the narrow sub-sea-level band and the
2569-
# much wider region above it.
2570-
altitudes_below = np.linspace(min_height, 0, 10, endpoint=False)
2571-
altitudes_above = np.linspace(0, max_height, 90)
2572-
altitudes = np.concatenate((altitudes_below, altitudes_above))
25732565
pressures = [pressure_function(h) for h in altitudes]
25742566

25752567
return np.column_stack([altitudes, pressures])

tests/unit/environment/test_environment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
utm_to_geodesic,
2020
)
2121
from rocketpy.environment.weather_model_mapping import WeatherModelMapping
22+
from rocketpy.tools import geopotential_height_to_geometric_height
2223

2324

2425
class DummyLambertProjection:
@@ -837,7 +838,6 @@ def test_pressure_isa_discretization_bounds(example_plain_env):
837838
be a physically sane pressure curve: altitude strictly increasing, pressure
838839
strictly decreasing, and sea level (0 m) sampled exactly.
839840
"""
840-
from rocketpy.tools import geopotential_height_to_geometric_height
841841

842842
# Act
843843
pressure_isa_function = example_plain_env.pressure_ISA

0 commit comments

Comments
 (0)