Tricks of the Trade
In and Out
Download This Issue
Mathematica 4.2: A Technical Review
Additional Import and Export Formats
Mathematica 4.2 added support for a number of new import and export formats. In addition to the NotebookML and MathML formats for notebooks and mathematical formulas mentioned earlier in this article, other formats supported include FITS, SDTS, SVG, and XHTML.
FITS is a data format designed by the astronomy community for the worldwide interchange of astronomical data. The standard is controlled by the International Astronomical Union. NASA has mandated the use of the FITS format for all data sets it produces, and the FITS standard is described in several NASA Office of Standards and Technology documents.
You can import a FITS file using the standard Import command. Here a conversion option is used to specify that the header information can also be imported.
You can download this file from the TMJ website at www.mathematica-journal.com/issue/v9i1.
In the case of image data, you can plot the data portion of the file by using ListDensityPlot.
You can view the header information in the file by simply requesting the corresponding part of the imported data.
The SDTS format was designed by the United States government for transfer of spatial data such as digital elevation maps (DEMs) and satellite images. Each data archive contains a set of files. The specific file corresponding to the elevation data can be imported for analysis.
You can download this file from the TMJ web site at www.mathematica-journal.com/issue/v9i1.
Once imported, the data can be prepared for display. Here a ColorFunction is defined to make the data easier to visualize.
You can construct a contour map with ListContourPlot using the ColorFunction defined above.
You can also visualize the data by creating a three-dimensional plot.
Scalable Vector Graphics (SVG) is an XML format developed by the W3C for describing two-dimensional graphics. It provides a convenient format for including images in web pages because it is more compact than other image formats and also allows for various types of interactivity. Mathematica 4.2 supports the export of graphics in SVG format.
Here is a simple graphic generated by Mathematica.
Here is the SVG markup describing the graphic.
You can export the graphic as an SVG file using the standard Export function.
It is now possible to import arbitrary Encapsulated PostScript (EPS) code into a notebook by using the File ⊳ Import menu. The imported EPS code will not be rendered until the notebook is printed to a PostScript printer.
XHTML and CSS
The Export and HTMLSave functions now support XHTML by default. When exporting a notebook as HTML, you can now use conversion options to include style information in Cascading Style Sheets (CSS) syntax. Below are two examples that show how CSS style rules can be applied to HTML documents created by Mathematica.
The first example exports a single cell as HTML. The conversion option specified embeds a CSS style rule in the head element of the resulting HTML document.
You can also insert a reference to an external style sheet in the form of an HTML link element. Here is a notebook formatted using the built-in Mathematica style sheet Classroom.nb.
Here is the style sheet Classroom.css that contains definitions for some of the styles defined in the style sheet Classroom.nb.
This exports the notebook to an HTML file that references the CSS style sheet defined above.
Here is the exported HTML document as seen in a web browser. You can see the close correspondence between the appearance of the HTML document and the original notebook. Using a CSS style sheet thus provides a convenient way to control the appearance of HTML documents created using Mathematica.
About Mathematica Download Mathematica Player
Copyright © Wolfram Media, Inc. All rights reserved.