Skip to content

Commit 5db64a9

Browse files
committed
add export exercises
1 parent 48ddded commit 5db64a9

File tree

2 files changed

+165
-22
lines changed

2 files changed

+165
-22
lines changed

docs/source/gui.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ You can start a new configuration or open an existing one from the sidebar's
6868
**File > 📁 Open...**. This will open a file dialog where you can navigate to and
6969
select your ``.yaml`` file.
7070

71+
.. _saving_config:
72+
7173
Saving a Configuration
7274
^^^^^^^^^^^^^^^^^^^^^^
7375

@@ -79,6 +81,8 @@ You can save your work in two ways:
7981
* **File > 💾 Save As...**: This opens a file dialog, allowing you to save the
8082
current configuration to a new file or overwrite an existing one.
8183

84+
.. _export_config:
85+
8286
Exporting a Configuration
8387
^^^^^^^^^^^^^^^^^^^^^^^^^
8488

docs/source/training/training.rst

Lines changed: 161 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Exercise 1a: Creating a new waveform
2222
so create a new group, and create a new waveform inside it.
2323

2424
.. hint::
25-
Detailed instructions on how to edit the waveform configuration can be found :ref:`here <gui>`.
25+
Detailed instructions on how to edit the waveform configuration can be found :ref:`here <edit_config>`.
2626

2727
.. md-tab-item:: Solution
2828

@@ -142,11 +142,11 @@ Exercise 2a: Creating a Plasma Current
142142
in the editor.
143143

144144
We will now design a simple waveform representing the plasma current during
145-
a single pulse. Create a waveform called equilibrium/time_slice/global_quantities/ip``,
145+
a single pulse. Create a waveform called ``equilibrium/time_slice/global_quantities/ip``,
146146
which has the following shape:
147147

148148
1. A linear ramp up from 0 to 1.5e7 A, in a duration of 100 seconds.
149-
2. A flat-top at 1.5e7 A held for 400 seconds.
149+
2. A flat-top at 1.5e7 A, held for 400 seconds.
150150
3. A ramp down back to 0 A, in a duration of 200 seconds.
151151

152152
.. md-tab-item:: Solution
@@ -172,7 +172,7 @@ Exercise 2b: Shortform notation
172172
.. md-tab-item:: Exercise
173173

174174
In the previous exercise, the solution proposed was very quite lengthy. The
175-
Waveform Editor can sometimes deduce some information about the tendencies, if
175+
Waveform Editor can sometimes deduce some information about the tendencies if
176176
information is missing.
177177

178178
Some examples:
@@ -190,7 +190,7 @@ Exercise 2b: Shortform notation
190190

191191
#. The first tendency - No ``start`` or ``from`` is needed because it begins at 0 by default.
192192
#. The second tendency - No ``type`` is provided, so it is a linear tendency by default.
193-
The ``start``, from``, and ``to`` attributes are by default set to the respective
193+
The ``start``, ``from``, and ``to`` attributes are by default set to the respective
194194
values at the end of the previous tendency.
195195
#. The third tendency - Again, the ``start`` and ``from`` attributes are inferred from the
196196
previous tendency. In this case, we do need to specify the ``to`` attribute, otherwise
@@ -301,6 +301,7 @@ Exercise 3c: Repeating Waveforms
301301
.. note:: You can also change the frequency of the repeated waveform, see the
302302
:ref:`documentation <repeat-tendency>` to see how.
303303

304+
304305
Exercise 4a: Derived Waveforms
305306
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
306307

@@ -325,6 +326,10 @@ Exercise 4a: Derived Waveforms
325326
.. hint::
326327
Detailed instructions on derived waveforms can be found :ref:`here <derived-waveforms>`.
327328

329+
Before starting with Exercise 4b, save the configuration containing the two created waveforms
330+
to disk. This will be used in a later exercise. To see how to save a configuration, have a
331+
look at the :ref:`instructions <saving_config>`.
332+
328333
.. md-tab-item:: Solution
329334

330335
Create a new waveform called ``total_power`` which contains:
@@ -395,28 +400,162 @@ Exercise 4b: Derived Waveforms - part 2
395400
.. image:: ../images/training/derived_nbi.png
396401
:align: center
397402

398-
Exporting
399-
---------
400-
- exporting different types
401-
- change global properties DD version?
403+
Exporting Waveforms
404+
-------------------
405+
406+
In this exercise you will learn how to export waveform configurations.
402407

408+
Exercise 5a: Exporting from the UI
409+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
403410

404-
plasma shape editor
405-
-------------------
406-
- run inverse mode
407-
- run direct mode?
408-
- store coils as waveforms
411+
.. md-tab-set::
412+
.. md-tab-item:: Exercise
413+
414+
In this exercise, we will continue with the configuration that you stored in
415+
exercise 4a. If you forgot to save it, the YAML is also shown under the tab `Configuration`.
416+
Load this configuration into the Waveform Editor, if you are unsure how to, have a look
417+
at the instructions :ref:`here <gui>`.
418+
419+
We will export our EC beam power values to an ec_launchers IDS. Export the configuration
420+
to an HDF5 file. Sample the time such that there are 20 points in the range from 0 to 800.
421+
422+
Inspect the exported IDS using ``imas print <your URI> ec_launchers``, which
423+
quantities are filled? What happens with the values outside of the waveform range
424+
(time steps later than 700 s)?
425+
426+
.. hint::
427+
Detailed instructions on how to export the waveform configuration can be found :ref:`here <export_config>`.
409428

429+
.. md-tab-item:: Configuration
410430

431+
If you forgot to save the configuration of exercise 4a, copy the following YAML file,
432+
and store it to disk.
411433

412-
Exporting
413-
---------
414-
- exporting different types
415-
- change global properties DD version?
416434

435+
.. code-block:: yaml
436+
437+
globals:
438+
dd_version: 4.0.0
439+
machine_description: {}
440+
ec_launchers:
441+
total_power:
442+
- {type: linear, to: 5e5, duration: 100}
443+
- {type: constant, duration: 500}
444+
- {type: linear, to: 0, duration: 100}
445+
ec_launchers/beam(1:10)/power_launched/data: |
446+
"total_power" / 10
447+
448+
.. md-tab-item:: Solution
449+
450+
Printing the exported ec_launchers IDS shows the output below. Notice how the
451+
time array is filled with values from 0 to 800. The Waveform Editor will only
452+
export waveforms which name matches a path in the IDS. Therefore, the ``total_power``
453+
waveform will not be exported to an IDS. Since we use a slicing notation for the
454+
power_launched waveform (``beam(1:10)``), the first 10 beams are filled with the
455+
same waveform.
456+
457+
Any values which are outside of the defined waveform range (e.g. values later than 700s)
458+
will be set to 0.
459+
460+
.. code-block:: bash
461+
462+
ec_launchers
463+
├── ids_properties
464+
│ ├── homogeneous_time: 1
465+
│ └── ids_properties/version_put
466+
│ ├── data_dictionary: '4.0.0'
467+
│ ├── access_layer: '5.4.3'
468+
│ └── access_layer_language: 'imas 2.0.1'
469+
├── beam[0]
470+
│ └── beam[0]/power_launched
471+
│ └── data: array([ 0. , 21052.6316, 42105.2632, ..., 0. , 0. , 0. ])
472+
├── beam[1]
473+
│ └── beam[1]/power_launched
474+
│ └── data: array([ 0. , 21052.6316, 42105.2632, ..., 0. , 0. , 0. ])
475+
├── beam[2]
476+
│ └── beam[2]/power_launched
477+
│ └── data: array([ 0. , 21052.6316, 42105.2632, ..., 0. , 0. , 0. ])
478+
├── beam[3]
479+
│ └── beam[3]/power_launched
480+
│ └── data: array([ 0. , 21052.6316, 42105.2632, ..., 0. , 0. , 0. ])
481+
├── beam[4]
482+
│ └── beam[4]/power_launched
483+
│ └── data: array([ 0. , 21052.6316, 42105.2632, ..., 0. , 0. , 0. ])
484+
├── beam[5]
485+
│ └── beam[5]/power_launched
486+
│ └── data: array([ 0. , 21052.6316, 42105.2632, ..., 0. , 0. , 0. ])
487+
├── beam[6]
488+
│ └── beam[6]/power_launched
489+
│ └── data: array([ 0. , 21052.6316, 42105.2632, ..., 0. , 0. , 0. ])
490+
├── beam[7]
491+
│ └── beam[7]/power_launched
492+
│ └── data: array([ 0. , 21052.6316, 42105.2632, ..., 0. , 0. , 0. ])
493+
├── beam[8]
494+
│ └── beam[8]/power_launched
495+
│ └── data: array([ 0. , 21052.6316, 42105.2632, ..., 0. , 0. , 0. ])
496+
├── beam[9]
497+
│ └── beam[9]/power_launched
498+
│ └── data: array([ 0. , 21052.6316, 42105.2632, ..., 0. , 0. , 0. ])
499+
└── time: array([ 0. , 42.1053, 84.2105, ..., 715.7895, 757.8947, 800. ])
500+
501+
502+
Exercise 5b: Exporting different Data Dictionary versions
503+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
504+
505+
.. md-tab-set::
506+
.. md-tab-item:: Exercise
507+
508+
Repeat the previous exercise, but this time, before exporting change the data dictionary
509+
version to **3.42.0** in the `Edit Global Properties` tab, and save the configuration.
510+
Ensure you enter a different from previous exercise. Again, print the IDS in your terminal, what has changed?
511+
512+
.. md-tab-item:: Solution
417513

418-
plasma shape editor
514+
You should see that the data dictionary version of the IDS has changed to '3.42.0':
515+
516+
.. code-block:: bash
517+
518+
ec_launchers
519+
├── ids_properties
520+
│ ├── homogeneous_time: 1
521+
│ └── ids_properties/version_put
522+
│ ├── data_dictionary: '3.42.0'
523+
│ ├── access_layer: '5.4.3'
524+
│ └── access_layer_language: 'imas 2.0.1'
525+
...
526+
527+
Exercise 5c: Exporting from the CLI
528+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
529+
530+
.. md-tab-set::
531+
.. md-tab-item:: Exercise
532+
533+
You can also export a configuration using the CLI. Try exporting your configuration
534+
using the same settings with the CLI command. Print the IDS afterwards, is it the
535+
same as before?
536+
537+
.. hint::
538+
539+
Each CLI command has a help page which can be printed by supplying the ``--help``
540+
flag, for example:
541+
542+
.. code-block:: bash
543+
544+
waveform-editor --help
545+
546+
Detailed instructions on how to use the CLI can be found :ref:`here <cli>`.
547+
548+
.. md-tab-item:: Solution
549+
550+
Export the configuration using:
551+
552+
.. code-block:: bash
553+
554+
waveform-editor export-ids <example YAML> imas:hdf5?path=./ex5c --linspace 0,800,20
555+
556+
This exports the same IDS as in previous exercise.
557+
558+
Plasma Shape Editor
419559
-------------------
420-
- run inverse mode
421-
- run direct mode?
422-
- store coils as waveforms
560+
561+
TODO: Exercises for plasma shape editor

0 commit comments

Comments
 (0)