Skip to content

ENH: New example files and some parser fixes#40

Merged
Gui-FernandesBR merged 11 commits intomasterfrom
enh/databank-testing-and-parser-fixes
Mar 30, 2026
Merged

ENH: New example files and some parser fixes#40
Gui-FernandesBR merged 11 commits intomasterfrom
enh/databank-testing-and-parser-fixes

Conversation

@Gui-FernandesBR
Copy link
Copy Markdown
Member

This increases the library reliability

Detect common non-English labels (German, French, Spanish, Italian)
and provide a clear message with instructions to re-save in English,
instead of the misleading 'missing simulation data' message.
get_rocket_radius() was failing with an empty sequence error for rockets
that have all body tubes with radius="auto" and no nosecone, since it
only looked at bodytubes and nosecones. Now also collects foreradius and
aftradius from <transition> elements, which serves as fallback.

Also gracefully returns 0.0 and logs a warning if no radius is found
at all, instead of raising a cryptic ValueError.
search_transitions() was using ork.getRocket().getChild(0).getChildren()
which only retrieves direct children of stage 0. For rockets with
transitions nested inside other components, this caused an IndexError
when trying to index into the smaller Java list with a BS4-based index.

Added _find_transitions_recursive() to walk the full component tree.
Also added name-based matching between BS4 and Java transitions to
handle count mismatches, with index fallback.
bs.find_all('datapoint') was collecting datapoints from all databranch
tags in the file. .ork files with multiple simulations or recovery
events can have secondary branches with fewer columns, causing
IndexError when accessing labels by index (e.g. 'Thrust' at index 28
but branch only has 28 columns).

Now parse_ork_file() and __init_vectors() scope datapoints to the first
<databranch> only, which contains the main flight simulation data.
__get_parameter() had two issues:
1. isinstance(position, np.int64) did not match np.intp (returned by
   np.argwhere on some platforms) or plain Python int.
2. After NaN filtering, the array can be shorter than the original
   datapoints list, making the burnout_position index out of bounds.

Now accepts any (int, np.integer) type and clamps the position to the
valid array range with a warning log when clamping occurs.
Selected for parser path diversity:
- Anonymous--Alpha: tails + rail buttons + 2 parachutes
- Anonymous--Beta: 2 trapezoidal fin sets + 4 parachutes
- Anonymous--Gamma: no nosecone, 4 transitions, rail buttons, 4 parachutes
- Anonymous--Delta: 4 tails, 3 parachutes, multiple databranches

Each directory contains rocket.ork, parameters.json, drag_curve.csv
and thrust_source.csv. Identity information has been anonymized.
- conftest.py: add fixtures for the 4 new anonymous examples plus
  WERT and rocket_with_elliptical_fins (previously untested)
- test_ork_extractor.py: parametrize over 9 examples (was 3)
- Add acceptance baseline CSV files for new examples
- Update NDRT baseline CSV files regenerated with fixed parser
- Uncomment pytest step in test-pytest.yaml
- Add actions/setup-java@v4 (Temurin 17) before running tests,
  since the parser requires a JVM to load OpenRocket
- Add pytest-timeout to requirements-dev.txt to prevent CI hangs
@Gui-FernandesBR Gui-FernandesBR merged commit 2ac30a6 into master Mar 30, 2026
5 checks passed
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.

1 participant