jhplot
Class PNI

java.lang.Object
  extended by jhplot.PNI
All Implemented Interfaces:
Serializable

public class PNI
extends Object
implements Serializable

/** A container to hold data points in many dimensions. All numbers are expected to be integers. It extends ArrayList and adds many new features for data manipulation. The class does not have graphical option (use H1D to show the data or methods of this class which transform P0D to a H1D histogram).

See Also:
Serialized Form

Constructor Summary
PNI()
          Construct an empty container with no title
PNI(String title)
          Construct an empty container with a title
PNI(String title, boolean shallow, PNI pni)
          Construct a copy from a PNI.
PNI(String title, String file)
          Construct a container with a title from external file (see the method toFile() how to write such ASCII file)
 
Method Summary
 void add(int[] values)
          Adds (appends) the specified element to the end of this list.
 void add(P0I values)
          Adds (appends) P0D to the end of this list.
 void clear()
          Clear the container
 PNI copy(String newtitle)
          Create an exact copy of the current P0D.
 void doc()
          Show online documentation.
 int[] get(int row)
          Return a specific row as array
 int get(int row, int column)
          Return a specific value.
 int[][] getArray()
          Get a double array with values.
 ArrayList<int[]> getArrayList()
          Get data in form of ArrayList
 int[] getColumn(int column)
          Return a specific column as an array
 int getDimension()
          Get last dimension of the data.
 H1D getH1D(int bins)
          Create histogram.
 H1D getH1D(int bins, double min, double max)
          Return H1D histogram with PND content.
 H1D getH1D(int bins, double min, double max, int column)
          Make a histogram from a column of PND.
 hep.aida.IDataPointSet getIDataPointSet()
          Get the data point set for JAIDA
 double getMax()
          Get min value
 double getMin()
          Get max value
 P0I getP0I(int column)
          Return a specific column as an array
 P1D getP1D(int c1, int c2)
          Return 2 columns as P1D to show as a X-Y plot
 P2D getP2D(int c1, int c2, int c3)
          Return 3 columns as P2D to show as a X-Y-Z plot
 P0D getRow(int row)
          Return a specific row as array
 P0I getRowP0D(int row)
          Return a specific row as P0D
 PNI getRows(String newtitle, int indexMin, int indexMax)
          Get rows : min is inxluded, max is not;
 String getTitle()
          Get a new title
static void main(String[] args)
          Test
 PNI oper(PNI PNI, String what)
          Operations on PNI containers: add, subtract, multiply, divide.
 PNI oper(PNI PNI, String title, String what)
          Operations on PNI containers: add, subtract, multiply, divide.
 void operScale(double scale)
          Scale each element of data
 void print()
          Print PNI to System.out.
 int read(BufferedReader br)
          Read the data from external file.
 int read(File sfile)
          Read PNI from a file.
 int read(String sfile)
          Read PNI from a file.
 int read(URL url)
          Read data from URL.
 int readGZip(File sfile)
          Read PNI from a GZiped file.
 int readGZip(String sfile)
          Read PNI from a GZiped file.
 PNI readSerialized(String name)
          Read a PNI object from a serialized file
 int readZip(String sfile)
          Read the data from ZIPed external file.
 PNI remove(int index)
          Remove a row
 void set(int index, int[] values)
          Sets (replace) the specified row.
 void set(int index, P0I values)
          Sets (replace) the specified element with P0D.
 PNI setArray(int[][] values)
          Set values from double array Old content will be lost.
 void setArrayList(ArrayList<int[]> array)
          Set the data in form of ArrayList
 void setTitle(String title)
          Set a new title
 int size()
          Data size (number of rows)
 void toFile(String name)
          Write a PNI to an external file.
 String toString()
          Get a string representing PNI
 void write(String name)
          Write a PNI to an external file.
 int writeSerialized(String name)
          Write a P0D object to a serialized file
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PNI

public PNI(String title)
Construct an empty container with a title

Parameters:
title - A title

PNI

public PNI(String title,
           boolean shallow,
           PNI pni)
Construct a copy from a PNI. If the last argument is true, a shallow copy of a collection. In this case a new collection contains references to same objects as the source collection. Data are not cloned

Parameters:
title - new title
shallow - if true, a shallow copy of a collection.
PNI - inpit data

PNI

public PNI(String title,
           String file)
Construct a container with a title from external file (see the method toFile() how to write such ASCII file)

Parameters:
title - A title
file - input file name. It can be either a file on a file system or URL location (must start from http or ftp)

PNI

public PNI()
Construct an empty container with no title

Method Detail

setTitle

public void setTitle(String title)
Set a new title

Parameters:
title - New Title

getTitle

public String getTitle()
Get a new title

Returns:
Title

clear

public void clear()
Clear the container


get

public int[] get(int row)
Return a specific row as array

Parameters:
row - index of the row
Returns:
array of values

getRowP0D

public P0I getRowP0D(int row)
Return a specific row as P0D

Parameters:
row - index of the row
Returns:
array of values

get

public int get(int row,
               int column)
Return a specific value.

Parameters:
row - row index
column - column index
Returns:
value

toString

public String toString()
Get a string representing PNI

Overrides:
toString in class Object
Returns:
String with all values

print

public void print()
Print PNI to System.out.


getColumn

public int[] getColumn(int column)
Return a specific column as an array

Parameters:
column - index of the column
Returns:
array with values.

getP1D

public P1D getP1D(int c1,
                  int c2)
Return 2 columns as P1D to show as a X-Y plot

Parameters:
c1 - index of the first column
c2 - index of the second column
Returns:
P1D array with X-Y values.

getP0I

public P0I getP0I(int column)
Return a specific column as an array

Parameters:
column - index of the column
Returns:
P0D array with values.

getP2D

public P2D getP2D(int c1,
                  int c2,
                  int c3)
Return 3 columns as P2D to show as a X-Y-Z plot

Parameters:
c1 - index of the first column
c2 - index of the second column
c3 - index of the third column
Returns:
P3D array with X-Y-Z values.

getDimension

public int getDimension()
Get last dimension of the data.

Returns:
dimension (number of elements in a row)

getRow

public P0D getRow(int row)
Return a specific row as array

Parameters:
row - index of the row
Returns:
array of values

getArrayList

public ArrayList<int[]> getArrayList()
Get data in form of ArrayList

Returns:
data in form of ArrayList

getIDataPointSet

public hep.aida.IDataPointSet getIDataPointSet()
Get the data point set for JAIDA

Returns:

add

public void add(int[] values)
Adds (appends) the specified element to the end of this list.

Parameters:
values - array of values to be added.

add

public void add(P0I values)
Adds (appends) P0D to the end of this list.

Parameters:
values - array of values to be added.

set

public void set(int index,
                int[] values)
Sets (replace) the specified row.

Parameters:
index - position index
values - array of values to be added.

set

public void set(int index,
                P0I values)
Sets (replace) the specified element with P0D.

Parameters:
index - position index
values - array of values to be added.

read

public int read(BufferedReader br)
Read the data from external file. Old data will be lost. Use "#" or "*" for comments.

Parameters:
sfile - File name with input
Returns:
zero if success.

readZip

public int readZip(String sfile)
Read the data from ZIPed external file. Old data will be lost. Use "#" or "*" for comments.

Parameters:
sfile - File name with the input (extension .zip)
Returns:
zero if success.

read

public int read(File sfile)
Read PNI from a file. The old content will be lost. Use a space to separate values in columns and tab to put new row. Comment lines starting with "#" and "*" are ignored.

Parameters:
sfile - input file
Returns:
zero if success

read

public int read(URL url)
Read data from URL. Use a space to separate values in columns and tab to put new row.

Parameters:
url - URL location of input file

readGZip

public int readGZip(String sfile)
Read PNI from a GZiped file. It can read URL if the string starts from http or ftp, otherwise a file on the file system is assumed.

Use a space to separate values in columns and tab to put new row.

Parameters:
sfile - File name with input (extension .gz)
Returns:
zero if success

read

public int read(String sfile)
Read PNI from a file. It can read URL if the string starts from http or ftp, otherwise a file on the file system is assumed.

The old content will be lost. Use a space to separate values in columns and tab to put new row. Comment lines starting with "#" and "*" are ignored.

Parameters:
sfile - File name with input
Returns:
zero if success

readGZip

public int readGZip(File sfile)
Read PNI from a GZiped file. The old content will be lost. Use a space to separate values in columns and tab to put new row. Comment lines start from "#" and "*" are ignored.

Parameters:
sfile - File name with input (extension .gz)
Returns:
zero if success

write

public void write(String name)
Write a PNI to an external file. Same method as toFile()

Parameters:
name - File name with output

writeSerialized

public int writeSerialized(String name)
Write a P0D object to a serialized file

Parameters:
name - serialized file name for output.
Returns:
zero if no errors

readSerialized

public PNI readSerialized(String name)
Read a PNI object from a serialized file

Parameters:
name - serialized file name for input.
Returns:
new PNI object

toFile

public void toFile(String name)
Write a PNI to an external file.

Parameters:
name - File name with output

remove

public PNI remove(int index)
Remove a row

Parameters:
index - row index to be removed

oper

public PNI oper(PNI PNI,
                String what)
Operations on PNI containers: add, subtract, multiply, divide. Keep the same graphical attributes and title.

Parameters:
PNI - Input PNI container for operation
what - String representing the operation: "+" add a P0D container to the original; "-" subtract a P0D from the original; "*" multiply; "/" divide by P0D
Returns:
original PNI after the operation.

oper

public PNI oper(PNI PNI,
                String title,
                String what)
Operations on PNI containers: add, subtract, multiply, divide. Keep the same graphical attributes

Parameters:
PNI - Input PNI container for operation
title - New title
what - String representing the operation: "+" add a P0D container to the original; "-" subtract a P0D from the original; "*" multiply; "/" divide by P0D
Returns:
original PNI after the operation.

operScale

public void operScale(double scale)
Scale each element of data

Parameters:
scale - Scale factor

size

public int size()
Data size (number of rows)

Returns:
number of rows

copy

public PNI copy(String newtitle)
Create an exact copy of the current P0D. New object is created.

Parameters:
newtitle - new title

getRows

public PNI getRows(String newtitle,
                   int indexMin,
                   int indexMax)
Get rows : min is inxluded, max is not;

Parameters:
title - New title
indexMin - min index of row
indexMax - max index of row
Returns:
new PNI with rows indexMin-indexMax

setArrayList

public void setArrayList(ArrayList<int[]> array)
Set the data in form of ArrayList

Parameters:
array - ArrayList to be set.

getArray

public int[][] getArray()
Get a double array with values.

Returns:
double array with values

setArray

public PNI setArray(int[][] values)
Set values from double array Old content will be lost.

Parameters:
values - array to be set: [ROWS][dimension];
Returns:
PNI with new values

main

public static void main(String[] args)
Test

Parameters:
args -

getH1D

public H1D getH1D(int bins,
                  double min,
                  double max)
Return H1D histogram with PND content. All values are added. Histogram range is defined by Min and Max values.

Parameters:
bins - Number of bins for the histogram.
min - Min value of histogram
max - Max value of histogram
Returns:
H2D histogram filled with P0D.

getH1D

public H1D getH1D(int bins)
Create histogram. Min and Max are determined authomatically.

Parameters:
bins - Number of bins
Returns:

getH1D

public H1D getH1D(int bins,
                  double min,
                  double max,
                  int column)
Make a histogram from a column of PND.

Parameters:
bins - Number of bins
min - Min value
max - Max value
column - column of PND (Returns:
histogram

getMax

public double getMax()
Get min value

Returns:
minimum value

getMin

public double getMin()
Get max value

Returns:

doc

public void doc()
Show online documentation.



jHepWork 3.1 ©