Connectivity - Maple Help

 Connectivity

Maple 18 includes new and expanded tools to connect to and work with external data sources and file formats. These include new support for connecting with Internet data sources, support for importing from and exporting to popular 3-D graphics formats, and working with compressed files.

Connecting to URL Data Sources

The new URL package offers efficient tools for connecting to remote data sources using the HTTP, HTTP Secure (HTTPS), and FTP transfer protocols. For HTTP and Secure HTTP, both GET and POST operations are supported.

$\mathrm{length}\left(\mathrm{sitecontent}\right)$

 ${32144}$ (1.1)

As well, support for URLs has now been extended in many other places in Maple where filenames were previously supported, simplifying the steps necessary to connect to this data using Maple.

 $\left[\begin{array}{c}{\mathrm{1..240 x 1..256}}{\mathrm{Array}}\\ {\mathrm{Data Type:}}{{\mathrm{float}}}_{{8}}\\ {\mathrm{Storage:}}{\mathrm{rectangular}}\\ {\mathrm{Order:}}{\mathrm{C_order}}\end{array}\right]$ (1.2)

$\mathrm{ImageTools}:-\mathrm{Embed}\left(\mathrm{fingerprint}\right)$

3-D Graphics Import/Export

The updated plottools package offers new tools and functionality for generating, importing, exporting 3-D graphic models in a variety of formats.

Importing and Exporting 3-D models

The new importplot and exportplot commands permit the exchange of 3-D geometric data between a variety of formats and Maple plots. After import, a geometric object can then be combined with other visualizations in Maple using existing tools such as plots[display].  The following new data formats are supported for both import and export:

 BYU - Movie.BYU geometry PLY - Stanford triangle format (ASCII & binary) JVX - JavaView geometry STL - Stereolithography file format (ASCII & binary) OBJ - Wavefront file format VTK - Visualization ToolKit file format OFF - Object File Format

In addition to importing from a local file, importplot also allows the user to import directly from a URL.

Import Examples

The following examples illustrate imports from PLY and STL file formats.

$\mathrm{gear}≔\mathrm{cat}\left(\mathrm{kernelopts}\left(\mathrm{datadir}\right),"/example/gear.ply"\right):$

$\mathrm{plottools}\left[\mathrm{importplot}\right]\left(\mathrm{gear}\right)$

${}$

$\mathrm{figure}≔"http://www.maplesoft.com/data/examples/stl/dodecahedron.stl":$

$\mathrm{plottools}\left[\mathrm{importplot}\right]\left(\mathrm{figure}\right)$

Export Examples

The following examples illustrate exporting Maple 3-D objects to BYU and OFF formats, then importing them back.

$f≔\left(y^3-x^7\right)*\left(y^2-2*x^5\right):$

$\mathrm{knot}≔\mathrm{algcurves}\left[\mathrm{plot_knot}\right]\left(f,x,y,\mathrm{epsilon}=0.8,\mathrm{radius}=0.1,\mathrm{tubepoints}=9,\mathrm{axes}=\mathrm{none}\right):$

$\mathrm{plots}:-\mathrm{display}\left(\mathrm{surface},\mathrm{axes}=\mathrm{none}\right)$

$\mathrm{plottools}\left[\mathrm{exportplot}\right]\left(\mathrm{KnotFile},\mathrm{knot}\right):$

$\mathrm{plottools}\left[\mathrm{importplot}\right]\left(\mathrm{KnotFile}\right);$

${}$

$\mathrm{plottools}\left[\mathrm{importplot}\right]\left(\mathrm{SaddleFile}\right)$

Import and Export of Tabular and Spreadsheet Data

The improved ImportMatrix and ExportMatrix commands enable tabular and spreadsheet data in a variety of formats to be imported to and exported from Maple matrices. The following new data formats are supported for both import and export:

 DIF - Data Interchange Format ODS - OpenDocument Spreadsheet SXC - Sun XML Calc spreadsheet

These commands also now handle Excel spreadsheet files using the previously existing ExcelTools package. As a result, in total, they now support four additional formats. In addition to importing from a local file, ImportMatrix also supports importing data directly from a URL.

ImportMatrix examples



 $\left[\begin{array}{c}{\mathrm{28 x 6}}{\mathrm{Matrix}}\\ {\mathrm{Data Type:}}{\mathrm{anything}}\\ {\mathrm{Storage:}}{\mathrm{rectangular}}\\ {\mathrm{Order:}}{\mathrm{Fortran_order}}\end{array}\right]$ (3.1.1)

 $\left[\begin{array}{c}{\mathrm{1..19 x 1..2}}{\mathrm{Array}}\\ {\mathrm{Data Type:}}{\mathrm{anything}}\\ {\mathrm{Storage:}}{\mathrm{rectangular}}\\ {\mathrm{Order:}}{\mathrm{Fortran_order}}\end{array}\right]$ (3.1.2)

Imported Excel Data

Imported DIF Data

Compressed File Support

Maple 18 supports both zip and gzip file formats.

The gzip format allows lossless compression of data in a single file. Your large matrix can be written to a file using this format, thus taking up less room on disk compared to an ordinary uncompressed data file.

The zip format allows lossless compression of organized collection of data and resources in a single file. Think of it as a collection of files zipped together in a single archive. By splitting the data into a directory structure within the zip file, the data is better organized for easy extraction.

To use the short form of command names, we'll load the package:

$\mathrm{with}\left(\mathrm{FileTools}:-\mathrm{Compressed}\right):$

Now, let's point to a sample zip file and look to see what is included inside it:

$\mathrm{Contents}\left(\mathrm{zipfile}\right);$

 $\left[{"data.m"}{,}{"options.txt"}{,}{"antennas.jpg"}\right]$ (4.1.1)

There are three files, we will read each of them in.



The first file is stored with the suffix ".m", so it is immediately restored as a Maple object when read into Maple.

 $\left[\begin{array}{c}{\mathrm{1..50 x 1..2}}{\mathrm{Array}}\\ {\mathrm{Data Type:}}{{\mathrm{float}}}_{{8}}\\ {\mathrm{Storage:}}{\mathrm{rectangular}}\\ {\mathrm{Order:}}{\mathrm{Fortran_order}}\end{array}\right]$ (4.1.2)

The second file is plain text. In this case we additionally use the parse command to turn the plain text into equations.

 ${\mathrm{axes}}{=}{\mathrm{none}}{,}{\mathrm{view}}{=}\left[{-}{600}{..}{300}{,}{-}{800}{..}{100}\right]$ (4.1.3)

The third file is an image. We will extract it into a temporary directory.



Now, let's plot the data, image, and options we just read in.

Creating and Writing to Zip Files

This short section will show how the sample zip file was created.



Start with naming the container zip file -- "myzip.zip".  Individual files within the zip will be specified using in to separate the container name with the in-zip name. The data is already defined in the previous section, we'll write it out to a sub-file with a .m extension.

 ${1633}$ (4.2.1)

Here the options are written as plain text.

 ${37}$ (4.2.2)

The image is taken from the data directory on disk and put directly into the zip archive.



We are done. Let's look to see what is inside our new zip file.

$\mathrm{Contents}\left(\mathrm{newzipfile}\right);$

 $\left[{"data.m"}{,}{"options.txt"}{,}{"antennas.jpg"}\right]$ (4.2.3)



This new zip file that we created can be read by standard tools like WinZip and pkzip. Similarly, files created using these tools can be opened and read by Maple.

Export of Graphs to LaTeX

The new GraphTheory[Latex]  command generates LaTeX code for displaying a graph using the LaTeX picture environment. It handles directed and undirected graphs in both black and white and color. The vertex labels are placed beside the vertices in the LaTeX picture.

Example

 > $\mathrm{with}\left(\mathrm{GraphTheory}\right):$
 > $\mathrm{with}\left(\mathrm{SpecialGraphs}\right):$

We create an undirected unweighted soccer ball graph.

 > $S:=\mathrm{SoccerBallGraph}\left(\right);$
 ${S}{:=}{\mathrm{Graph 2: an undirected unweighted graph with 60 vertices and 90 edge\left(s\right)}}$ (5.1.1)
 > $\mathrm{DrawGraph}\left(S\right);$

Here we export the soccer ball graph S to a compilable LaTeX file.

 > $\mathrm{Latex}\left(S,"soccer.tex",300,300,\mathrm{true}\right);$

Finally, we compile "soccer.tex" and we obtain a LaTeX output document containing a picture as shown below: