Webnucleo.org

Mail Lists | Developers
small logo

This tutorial demonstrates how to use Webnucleo's Perl script for converting an ascii file of curve fitting input data into an XML file appropriate for use in Webnucleo's Curve Fitting Tool. The data used are the sample data provided in Markwardt's curve fitting tutorial, and the xml file produced here will be used in the upload tutorial. This tutorial assumes you are in a Linux or Unix environment. If you are using a different operating system, please adjust the following instructions as appropriate.

Download Perl Code

To begin, download the Curve Fitting Tool distribution available in the downloads page.

Unpack the distribution. For example, the command below should work.

tar  xzvf  curve_fit_x.tar.gz

where x is the version number, such as 0.1. The perl script, curve_fitting_ascii_to_xml.pl, is located in the pl directory and the example input file, markwardt.txt, is in the data_pub directory.

In markwardt.txt, each data point is given as a space-delimited triplet of x, y, and error (perr). Thus, the first column in the file contains all the independent variable values, the second column all the dependent variable values, and the third column all the error values in the dependent variable.

Make the Perl script executable by typing:

chmod  +x  curve_fitting_ascii_to_xml.pl

You are now ready to create the XML file.

-top-

Create the XML

You can now run the Perl script to convert the ascii data in markwardt.txt into XML. To do this, type the following:

perl  curve_fitting_ascii_to_xml.pl  ../data_pub/markwardt.txt  markwardt.xml

The resulting XML file markwardt.xml is ready to be uploaded to the Curve Fitting Tool. In fact it is used in the upload tutorial.

-top-

Challenges

Can you edit the markwardt.txt file and run the Perl script to get a different XML file? Can you locate Perl on your system by typing:

which  perl

and then editing the shebang (# !) line in the curve_fitting_ascii_to_xml.pl appropriately so you can simply type

curve_fitting_ascii_to_xml.pl  my_input.txt  my_input.xml

to convert ascii to XML? This will save you time if you plan to use the Perl script to convert ascii input data to XML in the future.

-top-



Valid XHTML 1.1        Copyright © 2001-2012, Clemson University. All rights reserved.        Valid CSS!
Page last modified on 2007/12/15 12:11