This tutorial demonstrates how to use Webnucleo's Perl script for converting an ASCII file of solar abundance input data into an XML file appropriate for use in Webnucleo's Solar Abundances Tool. It 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 Solar Abundances Tool distribution available in the downloads page.
Unpack the distribution. For example, the command below should work.
tar xzvf solar_abundances_x.tar.gz
where x is the number of the distribution you are downloading. For example, if you are downloading version 0.2, type
tar xzvf solar_abundances_0.2.tar.gz
The perl script, input_abundances_ascii_to_xml.pl, is located in the bin directory and the example input files, input_abundances.txt and input_names.dat, are in the data_pub directory.
Two files will be extracted, namely, input_abundances_ascii_to_xml.pl and input_abundances.dat. The first is the Perl script, and the second is the input solar abundances data file.
In input_abundances.dat, each element of data is given as a space-delimited triplet of Z, A, and abundance. Thus, the first column in the file contains all the Z values, the second column all the A values, and the third column all the abundance values. An optional fourth column is included that is a comma delimited list of the nucleosynthesis processes.
Make the Perl script executable by typing:
chmod +x input_abundances_ascii_to_xml.pl
You are now ready to modify the data.
Modify the Data
One way to modify the data in input_abundances.dat is to use a spreadsheet program such as Microsoft Excel.
In Excel, open the input_abundances.xml. To do this, select 'All files (*.*)' in 'Files of type' and click open.
The 'Text Import Wizard' will pop up. The default settings should be correct for input_abundances.xml. To double check, 'Fixed Width' should be selected, then click next.
Double check to make sure the line breaks are in the right position. Click Next.
Each column should be marked 'General' and click 'Finish'.
Once the data has been loaded into Excel, you can modify the data.
For example, here, some of the processes have been removed and some abundances have been changed.
To save these changes, click 'File' and selected 'Save As'. Select 'Text (Tab Delimited) (*.txt)' as the 'Save as Type'. Click 'Save' and use your new file with the perl script.
Create the XML
You can now run the Perl script to convert the ascii data in input_abundances.dat into XML. To do this, type the following:
perl input_abundances_ascii_to_xml.pl input_abundances.dat my_input_abundances.xml
The resulting XML file my_input_abundances.xml is ready to be uploaded to the Solar Abundances Tool.
Challenges
Can you edit the input_abundances.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 input_abundances_ascii_to_xml.pl appropriately so you can simply type
input_abundances_ascii_to_xml.pl input_abundances.dat my_input_abundances.xml
to convert ascii to XML? This will save you time if you plan to use the Perl script to convert ascii input abundances data to XML in the future.