230 likes | 249 Views
WDSS-II provides a user-friendly environment for developing new applications or algorithms. It offers easy data ingestion, visualization, and data access frameworks, and supports C++ coding. Create new applications quickly using w2algcreator tool.
E N D
Writing a WDSS-II Applicationusing w2algcreator V Lakshmanan National Severe Storms Laboratory & University of Oklahoma lakshman@ou.edu http://www.wdssii.org/
WDSS-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! http://www.wdssii.org/
WDSS-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++. • It’s best if you can write your code in C++ too. • But you can call Fortran or C code from C++ http://www.wdssii.org/
Creating 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. http://www.wdssii.org/
How 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. http://www.wdssii.org/
WDSS-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_index.lb \ -R ReflectivityQC \ -o /data/realtime/radar/KTLX/ \ -r http://www.wdssii.org/
Command-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_index.lb \ -R ReflectivityQC \ -o /data/realtime/radar/KTLX/ \ -r http://www.wdssii.org/
Some 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 ReflectivityQC:00.50 • -R ReflectivityMaximum:vol http://www.wdssii.org/
Creating 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 algorithm’s 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. <algorithmcreator name=“VerticalIntegratedLiquid exec=“w2vil” namespace=“w2polar”> </algorithmcreator> http://www.wdssii.org/
Inputs • 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). http://www.wdssii.org/
Input Index specification <algorithmcreator …. > <inputs> <index history=“5”> <optionvalue name=“RadarIndexes” letter=“i” /> </index> <index … > …. </index> </inputs> </algorithmcreator> http://www.wdssii.org/
Input 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 http://www.wdssii.org/
Input Data Specification <index history=“5”> <optionvalue …. /> <data type=“RadialSet”> <optionvalue name=“dbz” letter=“R” default=“ReflectivityQC” /> </data> <data … > … </data> </index> http://www.wdssii.org/
Option • 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. http://www.wdssii.org/
Optional 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 won’t know what to listen for. http://www.wdssii.org/
Other 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 …) http://www.wdssii.org/
Other options <algorithmcreator …> <options> <optionvalue letter=“s” name=“sourceRadar” /> <optionvalue …/> </options> </algorithmcreator> http://www.wdssii.org/
Use 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 http://www.wdssii.org/
Final 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. http://www.wdssii.org/
The 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, it’ll stop providing heartbeat messages, thus allowing an external monitoring program to kill it and restart it. • A good idea to specify “initOnStart=true” 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! http://www.wdssii.org/
On 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. http://www.wdssii.org/
Exercises • 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! http://www.wdssii.org/
Questions? Email me: lakshman@ou.edu More documentation (including a more up-to-date version of this document) is at: http://www.wdssii.org/ http://www.wdssii.org/