Tablespoon (tbs) for a teaspoon (tsp)?
- Jun 25, 2020
- Blog Post
Knowing which unit of measurement you’re working with is vital when you’re baking – just ask anyone who’s ever mistaken a tablespoon (tbs) for a teaspoon (tsp) when adding salt to a dish. Units are equally important when extracting data from STK, a physics-based engine.
The STK graphical user interface (GUI) makes it easy to customize the units being displayed in a scenario or report, but what if you aren’t using the GUI, and what if you do a lot of scripting with STK instead?
As you may know, there are two primary programmatic interfaces to STK: Connect and the Object Model. Connect works through a TCP/IP or COM interface connection to STK. The structure of Connect consists of text-specific commands. The Object Model is built on Microsoft’s COM interface and follows object-oriented programming methodology. While the majority of STK’s functionality is accessible from both Connect and the Object Model, there are a few exceptions where a function is only accessible from one of our interfaces. Some of the unit settings are among these exceptions.
There are only a handful of units that are unique to commands sent through Connect. You can retrieve the list with the following commands (shown in MATLAB context):
result = root.ExecuteCommand(‘Units_Get * Connect’); result.Item(0) Distance Meters; Time Seconds; Date GregorianUTC; Latitude Degrees; Longitude Degrees;
While the default Distance unit for STK in the GUI is kilometers (km), in Connect it is meters (m). You can change the default unit with the ‘Units_Set’ command. It is vital that you’re aware of the default unit when passing in data — say for setting the properties of a satellite’s orbit.
What about underlying computed data in STK? STK computes over 40,000 metrics, and this data proves invaluable to usersfor post-processing, manipulation, or passing to other programs. When accessing Data Providers, do you know what units are in use? And what if you want to toggle them? Here, we need to rely on the Object Model. Luckily this can be blended into the same script.
To see what distance unit would be returned in, we run the command:
currentDistanceUnit = root.UnitPreferences.GetCurrentUnitAbbrv(‘DistanceUnit’);
To modify the distance unit, we can issue one of two versions of the same command:
In this example, both variants will change the Distance Unit to return data as Nautical Miles.
To view a full listing of the available Unit field names and their valid abbreviations, visit this topic of the STK Programming Interface Help: http://help.agi.com/stkdevkit/index.htm#stkUtil/introUnitPrefs.htm
Good luck with those scripts!