Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
cp -R /home/graphics/cgx/tutorials/wmsflextra_tutorial  $HOME~/metview 

Otherwise, please download the following file:

...

and save it in your $HOME/metview directory. You should see it appear on your main Metview desktop, from where you can right-click on it, then choose execute to extract the files.

You should now see a wms flextra_tutorial folder which contains the solutions and also some additional icons required by these exercises. You will work in the wms_tutorial folder so open it up. You should see the following contents:

...


Duplicate the 'step2' Macro icon (right-click duplicate) and rename the duplicate 'step3'. In this step we will change our symbol plotting settings and the map area as well.
Position the cursor above the plot() command in the Macro editor and drop your 'symbol' icon into it. Repeat with the 'map_Katla' icon. Then modify the plot() command by adding these new arguments to it:
plot(map_Katla,plot_normal,symbol)
Now, if you run this macro you should see your modified plot in the Display Window.

- Data Access in Macro


In this example we will see how to read metadata and data from our FLEXTRA outputs. We will get to know the usage of two FLEXTRA-specific macro functions: flextra_group_get() and flextra_tr_get(), respectively. Please open folder 'metadata' in folder 'flextra_tutorial' to start the work.

...


Because our 'run_multi' FLEXTRA Run icon stores two groups of trajectories we need to tell the visualiser which one we want to actually plot.
First, we will visualise the trajectories for starting point Katla. It goes exactly in the same way as in the previous chapters. Create a new FLEXTRA Visualiser icon with the name of 'plot_Katla'. Edit it and drop your 'run_multi' icon into the Flextra Data field.
In the next step we need to set parameter Flextra Group Index, which specifies the index of the trajectory group we want to visualise. The data for Katla has the index of 1 because it was our first starting point (it can be also checked with the examiner). Save your settings (Apply) then right-click and visualise to plot the trajectories.
Now create another FLEXTRA Visualiser icon with the name of 'plot_Stromboli'. Edit it and drop your 'run_multi' icon into the Flextra Data field. Since Stromboli was our second starting point parameter Flextra Group Index has to be set to the value of 2.
Save your settings (Apply) then drop the icon into the plot. After zooming into the proper area (or dropping icon 'map_Eu' into the plot) you should see something like this.

Plotting in Macro


In this example we will write the macro equivalent of the visualisation exercise we have just finished.
Create a new Macro icon and rename it 'step1'. We start editing the macro with reading in our FLEXTRA output file.
#Metview Macro
flx=read("res_multi.txt")
Now variable flx holds all the data in our FLEXTRA output containing two groups of trajectories. We can use the [] operator to access a particular group in it. Keeping this in mind we will create two visualiser objects: one for the first group and another one for the second group.
plot_Katla=flextra_visualiser(flextra_data: flx[1])
plot_Stromboli=flextra_visualiser(flextra_data: flx[2])
We simply pass these objects to the plot() command:
plot(plot_Katla, plot_Stromboli)
Now, if you run this macro you should see a Display Window popping up showing both groups of trajectories using the default FLEXTRA visualisation.
Remarks

...


Just like the other FLEXTRA icons the FLEXTRA Prepare icon can also be used in Macro. Its macro command equivalent is flextra_prepare().
However, please note that it should be used with extra care. The reason for it is that flextra_prepare() is executed asynchronously and if we do not reference the variable it returns we can run into problems. The following macro code illustrates this situation:
res=flextra_prepare(
flextra_output_path:
"/scratch/graphics/cgr/flextra_data",
...
)
flextra_run(
flextra_input_mode : "path",
flextra_input_path : "/scratch/graphics/cgr/flextra_data",
...
)
With this code we want to generate the input data for FLEXTRA with flextra_prepare() but we do not use the variable it returns in flextra_run(). Instead we simply use the path where the generated input data should be located. Now, because flextra_prepare() is executed asynchronously the macro starts to execute it and does not wait until it finishes but jumps immediately to flextra_run(). Then flextra_run() fails because the input data is not yet in place so the macro fails as well.
We can overcome this difficulty by simply referencing the return value of flextra_prepare() right after it is called e.g. by printing it.
res=flextra_prepare( ...
)
print(res)
flextra_run( ...
)
Alternatively we can set the Macro execution mode to synchronous by using the waitmode() function. We need to place it before calling flextra prepare() like this:
waitmode(1)
res=flextra_prepare( ...
)
flextra_run( ...
)