The Eclipse Business Intelligence and Reporting Tool (BIRT) is — as its name implies — meant for creating business reports. But that doesn't mean you can't use it for plotting scientific data, as well. As it turns out, BIRT is great for generating a quick, professional-looking 2-D plot of time series data from different data sources — for example, SQL or plain-text files. This article shows how to:
- Find sources of data from the Internet.
- Create a time series plot of a variable-magnitude star using data from a plain-text file.
- Create a plot of the number of sunspots per year, retrieving the data from a database.
It was recently the anniversary of the Apollo landing on the moon, and the name of the new Eclipse release is Galileo, so I just couldn't resist the temptation to do some space science plots.
Depending on the kind of data you want to visualize, you have a plethora of sources to choose from. For example, you can use the National Oceanic and Atmospheric Administration (NOAA), the National Astronomy and Ionosphere Center (NAIC), the European Incoherent Scatter Scientific Association (EISCAT), or the IAU Minor Planet Center. Often, the data you find will be in a binary format, and you may need a third-party library to extract the data. This article focuses on generating the plots with data that is in a simple plain-text file.
You'll be using data from the Time Series Data Library. This site contains data sets from numerous fields, all of which are in text format.
First, download Eclipse, if you don't already have it (see Resources). If you use the most recent version of Eclipse — Galileo — you also need to create a new workspace to avoid some issues. The report files for this article were created and tested using the latest version of Eclipse and BIRT, but you should be able to create the same reports with previous versions. BIRT is a plug-in for Eclipse that has the following dependencies:
- DTP — Data Tools Platform
- EMF — Eclipse Modeling Framework
- GEF — Graphical Editor Framework
- WTP — Web Tools Platform
Fortunately, there is an all-in-one download that includes Eclipse, all the dependencies for BIRT, and BIRT itself (see Resources). After getting and installing BIRT, start Eclipse:
- From the Eclipse menu, click File > New > Other.
- In the window that appears, click Business Intelligence and Reporting Tools > Report Project.
- Enter a project name, then click OK. For this example, use birtPlotting.
- A window appears, asking to switch to the Report Design Perspective; click Yes.
- Right-click the birtPlotting folder on the Navigator tab, then click New > Report.
starmag.rptdesignas the name for the new report, then click Next.
- In the window that appears, select Blank Report, then click Finish.
Plotting star magnitude using a flat-file data source
The first plot is of the changes in magnitude (brightness) from a variable star. According to Wikipedia, "A star is classified as variable if its apparent brightness as seen from Earth changes over time." Your plot will be a simple 2-D plot showing the change in magnitude of a variable star over time — specifically, of observations made over 600 nights. (The data file, starmagnitudetimeseries.ssv, is available in Download.)
Create a bar chart
On the left side, click the Report Items tab. From there, drag a chart to the designer. Although you might be tempted to use a line chart, a bar chart is more suitable. As the number of data points increases, the size of the bars decreases to accommodate space. Click Next.
Add a data source
The data is in space-separated value (SSV) format. To add a data source:
- Select Use Data From, then, from the drop-down list, select <New Data Set>.
- When prompted to add a new data source, click Yes.
- In the window that appears, select Flat File Data Source. Give the data source a name and click Next. For this example, use the name starMagDataSource.
- In the next window, select the flatfile style as ssv. Other options include comma-separated value (CSV), pipe-separated value (PSV), and tab-separated value (TSV).
- Clear the User first line as column name indicator check box.
- Optionally, click Test connection to make sure BIRT can find the SSV file.
- Click Finish to continue.
A window appears, prompting for a data source selection: Your previously created
data source should now appear under Flat file data source. Give the data
set a name, such as starMagDataSet, and click Next. On the
following page, there are two lists: the left side showing the available columns
from the data set, the right side showing the columns selected ready for
use in the chart. There should only be one column on the left side. Select it,
then click the right arrow. Change the column name to
magnitude, select the integer type, then click
Finish. Finally, click OK.
Create the category integers
You should now be back at the bar chart wizard. Perform the following steps to create the category integers:
- In the Select Data area, select the custom-created starMagDataSet. In the preview area, you should see the column name magnitude, along with several integer values.
- Near Category(X) Series, click the button with a function symbol to invoke the expression builder.
- In the Invoke expression builder window, select Available Column Bindings, then choose the subcategory Chart.
- Double-click rowNum.
- In the editor, you should see row.__rownum. Click OK.
Repeat the procedure for the category Y series, but this time, double-click magnitude instead of rowNum.
Customize the chart
Optionally, to make the chart a bit prettier, click the Format Chart tab.
From there, you can change the chart title, remove the legend on the right
side, change the X and Y axis titles, change the colors, or even change the
plot scaling. For example, the default scaling is linear, but you can change it
to a logarithmic scale. For this plot, use the title Variable Star Magnitude
Time Series. Label the X axis
and the Y axis
Magnitude. When you're done,
On the report designer, expand the chart object to fill the full width of the report, and make the height a little more than 3 inches. To preview the plot, click the Preview tab or, from the menu, click Page > Preview.
You'll probably notice that not all 600 nights are on the chart. At the top of the plot, it says something like, "Note: Current maximum number of data rows is...," followed by "Note: (Click to change Preview Preferences)." Click that message. In the resulting window, click No limits of the number of rows to display, then click OK. You will be prompted to refresh the page view: Click Yes. You should now see all 600 points on the plot. Figure 1 shows the finished chart.
Figure 1. A time series of a variable-magnitude star
To save the plot, click Run > View Report > As PDF or whatever format you wish to preview the chart in. Then just save to disk.
Plotting the number of sunspots using a database
In the next plot, you'll enter the data into a relational database, create your report, and use a Java technology program to generate a final product. The plot will be of the number of sunspots within a chosen time span.
First, download the H2 database (see Resources).
H2 is implemented as a pure Java database and has a small size. After
downloading it, extract the file, and navigate to the bin directory. There
should be a JAR file named h2-version-number (on my machine,
h2-1.1.114.jar). You can type
java -jar h2-1.1.114.jar
or run the .sh or .bat file (depending on whether you're running a POSIX or
Now that the server is running, populate it with data. The sunspot data you need is
in the file you downloaded from Download. In the console,
click Tools > Run Script. In the Target database URL field, type
jdbc:h2:~/sunspots.db. Because the database doesn't yet
exist, H2 will create one for you. In the Source script file name field,
type the full path to your sunspots.sql file, then click Run.
Back in Eclipse:
- Right-click the birtPlotting project, then click New > Report.
- Change the name of the new report to
sunspots.rptdesign, then click Finish. In addition to the previously mentioned method for adding data sources and data sets, you can add them using the menu.
- From the menu bar, click Data > New Data Source.
- In the window that appears; select jdbc data source, give the data source a name, then click Next.
- Add the H2 jdbc driver by clicking Manage Drivers and clicking Add.
- In the file chooser, navigate to your H2 installation. Select the h2 JAR file, then click OK. The H2 jdbc should now appear in the Driver class box.
- Select the H2 jdbc driver, then type the driver URL
sain the User Name field.
- Click Test Connection to make sure Eclipse can find the sunspot database, then click Finish. As before, now that you have a data source, you need a data set.
- From the menu bar, click Data > New Data Set > New Data Set.
- In the Data set window, select the sunspot data source you just created, set the data set to sql select query, type a name, then click Next.
- Type the following query in the query text area, then click Finish:
select * from sunspots where year between 1900 and 1980;
Now, drag a new chart object to the layout. Again, you'll be using a bar chart. Click Next in the chart window. Select the Use Data From option, then select sunSpotsDataSet. Click the expression builder button for the category X series, then select Available column bindings > Chart and double-click YEAR. Click OK.
Next, invoke the expression builder for the category Y series. Select Available column bindings > Chart, double-click NUM, then click OK. Make changes to the formatting you desire, then click Finish. Upon previewing the plot, you'll see a very neat time series. The first thing you should notice is that the number of sunspots follows a cycle, as shown below. (Neat, hunh?)
Figure 2. A plot of the number of sunspots per year
One obvious advantage to having the data in a database is the ability to
manipulate the data through queries. Change the query to
select * from sunspots to see all the data.
In this article, you've seen how you can use a business intelligence tool for creating reports of scientific data. You don't have to buy an expensive platform to get a quick visualization of good quality. The point of this article is to demonstrate how this business tool can be used differently from what was originally intended. You could just as easily adapt it for other types of data.
- SSV and SQL data sources
- Check out the Time Series Data Library data source.
- Visit the BIRT Project page.
- Check out the National Oceanic and Atmospheric Administration site.
- Visit the National Astronomy and Ionosphere Center site for the Arecibo Observatory in Puerto Rico.
- Check out the European Incoherent Scatter Scientific Association site.
- Don't miss the IAU Minor Planet Center at Harvard University.
- Check out the "Recommended Eclipse reading list."
- Browse all the Eclipse content on developerWorks.
- Follow developerWorks on Twitter.
- New to Eclipse? Read the developerWorks article "Get started with the Eclipse Platform" to learn its origin and architecture, and how to extend Eclipse with plug-ins.
- Expand your Eclipse skills by checking out IBM developerWorks' Eclipse project resources.
- To listen to interesting interviews and discussions for software developers, check out check out developerWorks podcasts.
- Stay current with developerWorks' Technical events and webcasts.
- Watch and learn about IBM and open source technologies and product functions with the no-cost developerWorks On demand demos.
- Check out upcoming conferences, trade shows, webcasts, and other Events around the world that are of interest to IBM open source developers.
- Visit the developerWorks Open source zone for extensive how-to information, tools, and project updates to help you develop with open source technologies and use them with IBM's products.
Get products and technologies
- Download BIRT. The current build as of this writing is V2_2_2.
- Download the H2 database engine.
- Check out the latest Eclipse technology downloads at IBM alphaWorks.
- Download Eclipse Platform and other projects from the Eclipse Foundation.
- Download IBM product evaluation versions or explore the online trials in the IBM SOA Sandbox and get your hands on application development tools and middleware products from DB2®, Lotus®, Rational®, Tivoli®, and WebSphere®.
- Innovate your next open source development project with IBM trial software, available for download or on DVD.
- The Eclipse Platform newsgroups should be your first stop to discuss questions regarding Eclipse. (Selecting this will launch your default Usenet news reader application and open eclipse.platform.)
- The Eclipse newsgroups has many resources for people interested in using and extending Eclipse.
- Participate in developerWorks blogs and get involved in the developerWorks community.