Lookup tables in more than 3 dimensions#1443
Conversation
|
Thanks for the PR @agodemar. I think you need to clean it up a bit:
I have not yet reviewed the rest of your changes, the suggestions above are only meant to focus the PR to the changes that are directly related to the N dimensional interpolation. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1443 +/- ##
==========================================
+ Coverage 25.11% 25.18% +0.06%
==========================================
Files 169 169
Lines 18721 18783 +62
==========================================
+ Hits 4702 4730 +28
- Misses 14019 14053 +34 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@bcoconni thank you for your suggestions. I cleand up the PR as you requested |
bcoconni
left a comment
There was a problem hiding this comment.
@agodemar I have only reviewed the changes you made since the comments I made in #1425 (comment).
So I made a few comments that, hopefully should make the code slightly easier to read (at least for me).
|
I have pushed a couple of commits to this PR to restore the CI workflow (i.e. the file Also I have renamed the PR to the title of the discussion #1425 that you have initiated: Finally, for the record, this PR will fix issue #1117. |
There was a problem hiding this comment.
Pull request overview
This PR extends FGTable to support lookup tables with more than 3 dimensions by introducing an N-dimensional parsing/evaluation path based on nested <tableData breakPoint="..."> elements, and updates related schema, examples, and unit tests.
Changes:
- Generalize FGTable parsing and interpolation from fixed 1D/2D/3D to N-D via nested
<tableData>breakpoints. - Add public APIs for 4D–6D lookups plus a vector-based lookup overload.
- Update XML schema and add new unit tests and an example aircraft configuration demonstrating ND table syntax.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
src/math/FGTable.cpp |
Implements ND XML parsing, breakpoint nesting, and recursive interpolation for N-D tables. |
src/math/FGTable.h |
Updates table API/documentation to expose ND lookup overloads and store lookup axes dynamically. |
tests/unit_tests/FGTableTest.h |
Adds basic load tests for 4D/5D/6D XML table structures. |
JSBSimCommon.xsd |
Extends schema to allow recursively nested <tableData> for ND tables and adds missing type attribute. |
aircraft/ballx/ballx.xml |
Provides a concrete 4D table example within an aircraft config. |
aircraft/ballx/reset00.xml |
Adds an initialization preset for the new example aircraft. |
.gitignore |
Adds ignores for devcontainer and environment/venv files. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| <xs:complexType name="table-data" mixed="true"> | ||
| <xs:sequence> | ||
| <xs:element name="tableData" type="table-data" minOccurs="0" maxOccurs="unbounded"/> | ||
| </xs:sequence> | ||
| <xs:attribute name="breakPoint" type="xs:double" use="optional"/> | ||
| </xs:complexType> |
There was a problem hiding this comment.
The new recursive table-data type is mixed="true" and no longer constrains leaf <tableData> content to numbers-list, so schema validation will now accept empty/non-numeric <tableData> that JSBSim rejects at runtime. If possible, consider a stricter schema (e.g., XSD 1.1 xs:assert, or separate leaf/container types) or at least document this loss of validation explicitly.
|
@bcoconni thank you for reviewing this PR.
|
Yes, I can see them as well, and I guess everyone can. Just for the record, I have pushed the button because I have some premium requests left on my Pro plan and I know I will not be able to use all of them before the reset on May 1st 😄
If you push the button "Commit suggestion", it is supposed to apply on the latest commit in your branch which includes the ones I have pushed earlier.
Yes, sorry I took the liberty to push directly on the PR branch because they were trivial changes that restored the CI workflow. I needed that to check that everything was working in your branch. Apologies for that. I cannot modify (nor anyone else) anything in your repo beyond the branch that you pushed for this PR. If you do not want other maintainers from JSBSim to push on branches you submit for PRs, you need to untick the option "Allow edits and access to secrets by maintainers" next to the "Create Pull Request" button:
You should be able to restore everything on your side with Once again, apologies for the confusion that it brought. |
|
@bcoconni no problem, nothing to apologize for. I'm just trying to understand who's doing what. Regarding the suggestions by Copilot, I'll accepr them. In our unit tests we are only proving that parsing the tables succeeds. We should also assert at least that one expected lookup result (exact-grid and interpolated) to exercise the added ND lookup path. |
Looks good to me. When you will do that, please use the button "Add suggestion to batch" to include all the suggestions in one single commit and avoid launching as many CI jobs as there are suggestions. |
|
I have pushed some commits to this PR:
|
Agent-Logs-Url: https://github.com/agodemar/jsbsim/sessions/a4c66e35-4c80-4bdc-aa36-666f994acb76 Co-authored-by: agodemar <819499+agodemar@users.noreply.github.com>
Agent-Logs-Url: https://github.com/agodemar/jsbsim/sessions/9f60a1c1-fd7b-47ad-b001-dd7b49d7490c Co-authored-by: agodemar <819499+agodemar@users.noreply.github.com>
Agent-Logs-Url: https://github.com/agodemar/jsbsim/sessions/20b68ff4-bc52-475e-b0f9-3ab1b56b94ac Co-authored-by: agodemar <819499+agodemar@users.noreply.github.com>
Agent-Logs-Url: https://github.com/agodemar/jsbsim/sessions/146abfc5-c19b-4794-94d1-03a08c429881 Co-authored-by: agodemar <819499+agodemar@users.noreply.github.com>
Co-authored-by: Bertrand Coconnier <bcoconni@users.noreply.github.com>
Co-authored-by: Bertrand Coconnier <bcoconni@users.noreply.github.com>
Co-authored-by: Bertrand Coconnier <bcoconni@users.noreply.github.com>
Basically, besides parsing, add tests on the results of n-dimensional interpolations Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
c7a1ec4 to
3fe29ee
Compare
…ion, data stored in ballx.xml
|
I added the Jupyter notebook examples/python/test_ballx.ipynb to experiment with the 4D interpolation. At the moment the result doesn't look correct. In the bottom-right plot, the red dot should be on the gray surface, but it's not: There's probably something wrong with the function @seanmcleod70 @bcoconni ideas? |
|
@seanmcleod70 @bcoconni did you have the chance to look at my notebook examples/python/test_ballx.ipynb yet? |
|
I did briefly look at it at the time you posted, but didn't spot anything obviously wrong, and had a couple of questions, but then got distracted by the JOSS paper etc. 😉 # Interpolated lookup at row=1, col=1 for the current (axis3, axis4) slice.
x0, y0 = 1.0, 1.0
ax3 = 20.0
ax4 = 1.0
z_ = float(np.asarray(jsbsim_lookup4D(row=x0, col=y0, axis3=ax3, axis4=ax4)))
#z_=5.0 # just to test
ax.scatter([x0], [y0], [z_], color="red", s=120, edgecolor="k", linewidth=0.7)
ax.text(x0, y0, z_, f" ({x0:.1f}, {y0:.1f}, {ax3:.1f}, {ax4:.1f}; {z_:.3f})", color="red", fontsize=9, weight="bold")So you mention |
|
Ah, shouldn't this: def jsbsim_lookup4D(row, col, axis3=0.0, axis4=0.0):
fdm['aero/dummy4D/aero/alpha-deg'] = row
fdm['aero/dummy4D/aero/beta-deg'] = col
fdm['aero/dummy4D/fcs/flap-pos-deg'] = axis3
fdm['aero/dummy4D/fcs/parachute_reef_pos_norm'] = axis4Rather be: def jsbsim_lookup4D(row, col, axis3=0.0, axis4=0.0):
fdm['aero/alpha-deg'] = row
fdm['aero/beta-deg'] = col
fdm['fcs/flap-pos-deg'] = axis3
fdm['fcs/parachute_reef_pos_norm'] = axis4In other words I don't think you were actually setting the relevant properties, and your lookup was for |
|
@seanmcleod70 oh, thanks! |
|
@bcoconni @seanmcleod70 I fixed the example examples/python/test_ballx.ipynb that gives this output when I test the 4D-interpolation on data provided in
The two bigger dots, colored in red and magenta, look correctly placed onto the light blue surfaces, in the right-top and right-bottom subplots. What do you think? PS: Some days ago, I configured the hook betweeen JSBSim releases and the Zenodo artifact uploads. I kindly ask @bcoconni to double check if the settings is OK. If we decide to merge this PR, it would be a good chance to make a minor release and see if the artifacts are correctly uploaded to Zenodo. |
Oh, never mind. It's a setting that I can configure from Zenodo when I log with my GitHub credentials. When a new release comes out, I expect tha Zenodo will emit a badge and the DOI that we can use later on. |
|
@seanmcleod70 are you OK with merging this PR? |
Yes. |
|
Great! The PR is now merged. |
|
@agodemar I meant to ask, what are the particular dimensions you're looking at for the high dimensional data you need to use? |
I'm supervising a project work where some provided lookup tables are 5D and 6D. Not more than that. |
|
I should've been clearer, I was looking for a list of parameters for the dimensions, e.g. (alpha, beta, flaps, speedbrake, aileron) for force/moment X. |




Pull request as per discussion #1425 (reply in thread)