Title: Writing a WDSSII Application using w2algcreator
1Writing a WDSS-II Applicationusing w2algcreator
- V Lakshmanan
- National Severe Storms Laboratory University of
Oklahoma - lakshman_at_ou.edu
2WDSS-II application development
- WDSS-II provides a easy environment to develop
new applications or algorithms. - Any algorithm developed in WDSS-II can be run
either in archive mode or in real-time. - provided that the algorithm is fast enough to run
in real-time and the machine can handle it!
3WDSS-II for Applications
- What does WDSS-II provide your application?
- Easy ingest of data from multiple sensors
- Easy ways to write out and visualize intermediate
and final outputs. - A common framework for accessing data.
- The framework is written in C.
- Its best if you can write your code in C too.
- But you can call Fortran or C code from C
4Creating a new application
- WDSS-II has a tool to create a new application
quickly. - w2algcreator
- Need to create an input XML file specifying the
inputs to your application. - Will create C main and a template for your
scientific code. - Your then write the scientific code.
5How WDSS-II works
- WDSS-II applications connect to a source of data.
- Called an Index.
- Applications listen for new products in that
Index. - Decide whether or not to process that product.
- Create and process the data if needed.
- Write out outputs (in netcdf or XML).
- Notify an Index about the new products available.
- For other applications listening to that Index
- May be a different index from the source.
6WDSS-II Applications
- WDSS-II Applications are just executables.
- launched on the command line.
- In deployed systems through scripts.
- Inputs are specified on the command-line.
w2vil i xmllb/data/realtime/radar/KTLX/code_inde
x.lb \ -R ReflectivityQC \ -o
/data/realtime/radar/KTLX/ \ -r
7Command-line options
- w2vil algorithm executable name
- VerticalIntegratedLiquid algorithm full name
(used in source code) - Input RadarIndex specified by i option
- Input data type is specified by R option
- Output directory is specified by o option
- Real-time is specified by r option
- The options r, -l (the letter ell), -o are
reserved so that the deployment scripts work
correctly.
- w2vil i xmllb/data/realtime/radar/KTLX/code_inde
x.lb \ - -R ReflectivityQC \
- -o /data/realtime/radar/KTLX/ \
- -r
8Some conventions
- If you need to provide domain extents, use the
following letters - t top to specify the north-west-top corner
- b bottom to specify the south-east-bottom
corner - s to specify the grid spacing
- If you need to process only a certain sub-type,
use colons as a separator - -R ReflectivityQC00.50
- -R ReflectivityMaximumvol
9Creating a new application
- Need to create an XML file.
- Use your favorite text editor. Save it somewhere.
- A template is available as example_alg.xml you
can edit this if you want. - What is the algorithms descriptive name?
- Used to generate class names in template.
- What is the executable name?
- What is the namespace that generated code should
be in? Pick your group (casa) or name (tj) i.e.
something that will distinguish your code from
something someone else might create.
ltalgorithmcreator nameVerticalIntegratedLiq
uid execw2vil namespacew2polargt lt/algori
thmcreatorgt
10Inputs
- Next you need to specify inputs.
- Done within an inputs section.
- How many indexes do you need to connect to?
- Each index or group of indexes will get a new
index tag. - Give each index a name (RadarIndex, ModelIndex,
etc.) so that a user can understand what needs to
be provided to your algorithm. - Supply a mnemonic option letter as well.
- The most important input index is by convention
given the option letter i. - Specify the history (in minutes) that needs to be
maintained for each index (or group of indexes). - Can be just 1 minute if you will never search
backwards in your algorithm (only new data).
11Input Index specification
ltalgorithmcreator . gt ltinputsgt ltindex
history5gt ltoptionvalue
nameRadarIndexes
letteri /gt lt/indexgt ltindex gt
. lt/indexgt lt/inputsgt lt/algorithmcreatorgt
12Input Data specification
- The user may specify either just a single index
or a bunch of index URLs. So each index tag
actually corresponds to a group of indexes in
general. - For each index, specify the data that you will be
listening to in that index. - For each product listened to, specify
- How you will refer to the product (e.g dbz)
- The default name of the product (e.g
ReflectivityQC) - This is the official name of the product that
you can see on the display. - A mnemonic letter for this input
- What type of data is it? WDSS-II data are usually
one of these types - RadialSet
- LatLonGrid
- LatLonHeightGrid
- DataTable
13Input Data Specification
- ltindex history5gt
- ltoptionvalue . /gt
- ltdata typeRadialSetgt
- ltoptionvalue namedbz
- letterR
- defaultReflectivityQC
/gt - lt/datagt
- ltdata gt
-
- lt/datagt
- lt/indexgt
14Option
- The optionvalue tag
- Has a letter, name and default
- The default tag is optional if you leave it out
the user has to specify a value on the
command-line. - If the default is false, then the option is a
boolean option i.e. yes/no.
15Optional data
- To specify an optional index, specify that the
default value is an empy string. - E.g. you will use a model index if one is
available, otherwise, you will run only on radar
data. - You need to specify a default name for all input
data types - otherwise we wont know what to listen for.
16Other options
- Besides the input, do you need any other
parameters specified for your algorithm? - For example, maybe you need to know the radar
name. - For each such option
- Specify the name of the option (e.g RadarName)
- Specify a mnemonic (e.g S for sourceRadar,
since r and R are both taken by realtime and
Reflectivity respectively )
17Other options
- ltalgorithmcreator gt
- ltoptionsgt
- ltoptionvalue letters
- namesourceRadar /gt
- ltoptionvalue /gt
- lt/optionsgt
- lt/algorithmcreatorgt
18Use the w2algcreator
- Now that you have the XML file
- Run the w2algcreator program
- It will create a w2vil_main.cc and
w2vil_VerticalIntegratedLiquid.h file in the
output directory. - Plug in the code for the two functions specified
in the .h file - One function tells you the radar name, the output
directory to write your outputs to and the LB to
notify after you have written the outputs. - The other function is called processdbz()
- Your scientific code goes in there.
w2algcreator i name-of-your-XML-file
-o output-directory
19Final steps
- Fill in the scientific code.
- Compiling
- Use the example_Makefile that is provided to
compile and link against the WDSS-II libraries. - Or put your source code into a subdirectory of
the w2algs repository - Need to create Makefile.am
- See w2algs/w2algcreator/README for details.
20The autogenerated code
- What does the autogenerated code do?
- It creates listeners to listen for the products
your algorithm needs - The user tells the algorithm the Index where
those products may be found - Also specifies that ReflectivityQC_smoothed
should be used where your algorithm expects a
reflectivity - May tell your algorithm to provide heartbeat
messages - The code has fault handling
- If you lose connection to an Index on a remote
machine, the algorithm will reconnect. - If your algorithm hangs or starts to eat up the
CPU, itll stop providing heartbeat messages,
thus allowing an external monitoring program to
kill it and restart it. - A good idea to specify initOnStarttrue for any
product that should re-read if your algorithm is
restarted. - As soon as it receives notification of a product,
it tells your algorithm class about it - Then, you do your thing!
21On a timer
- W2algcreator is for data-driven applications
- Best to process data as it comes in
- So, design your application to be data-driven as
much as possible. - To do things on a timer
- Use a TimedEventHandler (see API documentation)
- Provide a listener that will be called every N
milliseconds.
22Exercises
- The best way to learn is to write simple
data-driven algorithms. - The next module on data formats will help you
accomplish these tasks. - May need to get input data from some source
first. - These examples should get you started
- Read in single-radar reflectivity data and write
out an indexed scan with values below a
user-defined threshold set to MissingData. - Hint PolarGrid is an indexed RadialSet
- User-defined implies you need a command-line
parameter - Use ProcessTimer to determine how long certain
steps take. - Read in both reflectivity and velocity data from
the same radar and index the reflectivity data at
the velocity azimuths. - You will need to operate with RadialSet data
- Wait for matching Reflectivity and Velocity scans
(use the elevation angle to check) - Form a histogram of VIL values to satellite IR
temperatures. - Use DataConverter and/or DataRemapper
- A multi-source algorithm. Makes a difference only
when running, not when writing the algorithm!
23Questions?
- Email me
- lakshman_at_ou.edu
- More documentation (including a more up-to-date
version of this document) is at - http//www.wdssii.org/