festim-dev / V-V-report

https://festim-vv-report.readthedocs.io/
MIT License
4 stars 1 forks source link

Add trapping parameter tables #29

Open rekomodo opened 1 week ago

rekomodo commented 1 week ago

We can display parameters dynamically using MyST-NB's {glue} directive. We define variables in code cells using glue('name', value) and use them in markdown via {glue}`name` .

Here's the code for dynamically adding trap variables to the document

from myst_nb import glue

traps = [trap_1, trap_2, trap_3]

for i, trap in enumerate(traps):
    for key, value in trap.__dict__.items():
        glue(f'trap{i}{key}', value, display=False)
RemDelaporteMathurin commented 1 week ago

@rekomodo can you add the markdown code to display the values in a table pls?

rekomodo commented 1 week ago

Syntax from this guide . The example I used was

|Trap|k_0|E_k|p_0|...|
|:---|:--|:--|:--|:--|
|1|{glue}`trap1k_0`|{glue}`trap1E_k`|{glue}`trap1p_0`|...|
|2|{glue}`trap2k_0`|{glue}`trap2E_k` | ... | ... |
Which renders to Trap k_0 E_k p_0 ...
1 {glue}trap1k_0 {glue}trap1E_k {glue}trap1p_0 ...
2 {glue}trap2k_0 {glue}trap2E_k ... ...

We can definitely generate the markdown for these with a script if need be, but I doubt we'll need more than 3 anytime soon...