SCaVis supports many different types of I/O (input-output), in most cases the I/O part of SCaVis is based on self-descriptive file formats.
Here is the list of I/O supported by SCaVis:
SCaVis is 100% Java, but the unique feature is that it fully supports many ways to share data between Java and C++ or other programming languages.
SCaVis contains several powerful classes for persistent storage of objects (data) in files. It should be noted that many SCaVis objects described in data_structures and histograms have their own methods for file input/output (with or without compression). Any data container for arrays can be initialized form a file (on the disk or from URL).
For example, let's create a PND object representing a multidimensional matrix. We will initialize this object from URL. You can examine this file here. The number of columns and rows can be arbitrary.
>>> from jhplot import * >>> pn=PND('data','http://jwork.org/scavis/examples/data/pnd.d') >>> print pn.toString()
Run this class and you will see the output of this container. Now you can project this matrix into 1D, or make X-Y plot using ant column or row. This is explained in data_structures section.
Still, one can use external classes from the package jhplot.io to write and read data in a persistent form. This will be considered in this section.
Here is a short summary of the input-output classes for data:
jhplot.io.Serialized- Write/read read any Java object (lists, maps, etc.) using the Java serialization.
jhplot.io.HFile- Write/read read any Java object in sequential order using the Java serialization.
jhplot.io.HFileXML- Write/read read any Java object in sequential order using the XML serialization.
jhplot.io.EFile- Write/read SCaVis data structures (P1D,P2D,H1D,H2D) in files using Google's Prototype Buffer (cross platform)
jhplot.io.EFile- Write/read SCaVis data structures (P1D,P2D,H1D,H2D) in sequential order into ntuples using Google's Prototype Buffer (cross platform)
SCaVis supports the following formats:
* External ROOT and AIDA file formats. SCaVis can read and display data from such files, but does not write data in such formats. Read about this [man:io:root_aida]].
You can list and read data stored in the files with the extensions:
using a data browser. You can open such data file and plot them (or show as a table) as this:
You can open data browser for any supported file inside a Java or Jython script. In this case, the program executes the script and will bring up 2 windows: one is a canvas and the second window with the objects inside the input files. The file should have the extension *.jdat, *.jpbu, *.jser, *.root or *.aida. The file can be located on URL.
Data objects can be organized in directories and can be shown in the data browser as a trees. This is discussed in hbook_class
You can find below a simple script which brings up the file browser and the canvas exactly as it is shown in figure above:
This is a data interchange format (extension .dif) and comma-separated values (CSV) with file extension .csv, are text file formats used to import/export single spreadsheets. This small example shows how to read DIF files:
import dif f=open("nature04632-s16-2.dif",'r') d = dif.DIF(f) print d.header print d.vectors print d.data
Note that this module is pure Python, so this example will not work using Java. The DIF file format can write most of data structures supported by ScaVis. Read more in DIF file format section that describes Java implementation of this format. Section CSV format explains how to write data in CSV files.
Here we compare performance of the PFile and HFile classes for read and write mode. Benchmark results are given together with the code.
click here if you want to know more
click here if you want to know more
here are a lot of other Java-based I/O classes designed for storing and retrieving data. A complete description of how to use Java, Jython and SCaVis for scientific analysis is described in the book Scientific data analysis using Jython and Java published by Springer Verlag, London, 2010 (by S.V.Chekanov)
— Sergei Chekanov 2010/03/07 17:35