Subsections


3.22 Data output to tables and spreadsheets

3.22.1 HTable class

In some cases, instead of plotting, it is convenient to show data in a form of table. jHepWork provides excellent support for this. Use the HTable class:

>>> from jhplot import HTable
>>>
>>> HTable(object)
where object is either H1D, P1D or F1D class holding the data. After executing this statement, the user will see a frame with a table populated with numbers (by default, the numbers are nicely formatted in the scientific format). Using this table, one can sort data as well as search for a particular value. Note: it is impossible to modify the data in the table, as it was developed only for examining the data.

If the data have to be shown as formatted strings using the Java scientific format, use this constructor:

>>> HTable(object,1)
If data values should not be formatted, use "0" instead of "1".

One can call to HTable differently: if a data container is created, one can use the toTable() method. For example, to display a H1D histogram, one can use either statements:

>>> HTable(h1)     # where h1 is H1D histogram, or use
>>> h1.toTable()   #
If toTable() is used with the argument "0" , the numbers will not be formatted to scientific format.

The HTable container can be filled by the standard Java Vector class. You can run the example pdg_table.py, which illustrates how to show the Particle Data Group (PDG) table to the HTable frame for easy sorting and manipulation with particle data entries.

3.22.2 Spreadsheet. The SPsheet class

For more flexibility, one can export the data to a spreadsheet using the SPsheet class. In this case, the data can be modified and edited in a usual way:

To create an empty frame with a spreadsheet, use

>>> from jhplot import SPsheet 
>>>
>>> SPsheet()
If one needs to build a spreadsheet using some data in containers such as P1D, H1D or F1D, use

>>> SPsheet(object)   # where object is class of type P1D, H1D or F1D