Skip to content

Conversation

@joernu76
Copy link
Member

@joernu76 joernu76 commented Dec 3, 2025

Extend range of SideView to 99km.

Purpose of PR?:

Fixes #2935

Does this PR introduce a breaking change?
no
Additional information for reviewer? :
See also #2930

Checklist:

  • Bug fix. Fixes #
  • New feature (Non-API breaking changes that adds functionality)
  • PR Title follows the convention of <type>: <subject>
  • Commit has unit tests

Copy link
Member

@ReimarBauer ReimarBauer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good so far, but how does I know it's limited to 0-99 km? For example, if I want to change 98.5 to 99.5, it doesn't allow me to until I remove the decimal places.

Maybe all larger values should become replaced by its upper limit.

assert thermolib.isa_temperature(51000 * units.m).magnitude == pytest.approx(270.65)
assert thermolib.isa_temperature(71000 * units.m).magnitude == pytest.approx(214.65)
assert thermolib.isa_temperature(84852 * units.m).magnitude == pytest.approx(186.95)
assert thermolib.isa_temperature(99999 * units.m).magnitude == pytest.approx(186.95)
Copy link
Member

@ReimarBauer ReimarBauer Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this the same value pytest.approx(186.95) as the line before? Seeing that other checks show this pattern too. it looks like a range which gives the same result.

Is that 99999 a 99.999 with fractions? (I can't enter that in the UI)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The conversion routine works from 0 to 99999m/99.999km (effectively for any number < 100km).
I changed the order of the tests to make this more apparent.

The SideView goes only to 99km as we add internally 1km to the selected top height to define the grid.
But this can be improved upon. I just changed the code to allow values up to 99.9km and changed the precision to be dependent on the type, ie for pressure_altitude, a single digit is allowed. 4 digits is only allowed for pressure, where this is necessary for the large altitudes.

I also adapted the code to allow smaller pressures, as previously above 99km the pressure could not be converted back to km.

@ReimarBauer
Copy link
Member

Setting the largest value and toggling through the vertical axis options shows a traceback.

traceback.mp4
Fatal error in MSS 10.2.0 on macOS-26.1-arm64-arm-64bit
Python 3.11.11 | packaged by conda-forge | (main, Dec  5 2024, 14:21:42) [Clang 18.1.8 ]

Please report bugs in MSS to https://github.com/Open-MSS/MSS

Information about the fatal error:

Traceback (most recent call last):
  File "/Users/reimarbauer/MAIN/MSS/mslib/msui/sideview.py", line 276, in verticalunitsclicked
    thermolib.pressure2flightlevel(sb.value() * units.hPa).magnitude, "hft", new_unit))
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/reimarbauer/MAIN/MSS/.pixi/envs/dev/lib/python3.11/site-packages/metpy/xarray.py", line 1330, in wrapper
    result = func(*bound_args.args, **bound_args.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/reimarbauer/MAIN/MSS/.pixi/envs/dev/lib/python3.11/site-packages/metpy/units.py", line 333, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/reimarbauer/MAIN/MSS/mslib/utils/thermolib.py", line 240, in pressure2flightlevel
    raise ValueError("pressure to flight level conversion not implemented for p <= 0.0238725468 Pa")
ValueError: pressure to flight level conversion not implemented for p <= 0.0238725468 Pa

Copy link
Member

@ReimarBauer ReimarBauer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

besides the linter failure I pushed last version, it looks now good, see PR #2961

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extend vertical SideView range

3 participants