hdf5
index
/home/alf/pencil-code/python/pencil/files/hdf5.py

 
Modules
       
numpy
h5py
os
time

 
Classes
       
h5file
param_file

 
class h5file
    High level access to a pencil code HDF5 file
self.datadir: data directory (surprising, isn't it!)
self.f: HDF5 file, accessed through h5py module
self.param: parameter subgroup
self.data: data subgroup
self.etc: etc subgroup
self.notes: Notes dataset
self.precision: precision of the float data ('d' for double, 'f' for single)
self.nbslices: number of variables recorded in slices
 
  Methods defined here:
__del__(self)
__init__(self, workdir='', datafile='datafile.hdf5', force_create=False, force_single=False)
Create a hdf5 file from pencil code data.
Warning!!! This first implementation either reads an existing file
or write a new file. Set force_create to True if you want to force
the re-creation of the data with new data.
No possibility (yet...) to update the file with new data.
 
workdir: working directory
datafile: name of the hdf5 file
set force_single to true to force to stock the floats in single precision
(useful to decrease the file size, if single precision is sufficient for plotting purpose)
add_note(self, text='')
Add a new note
flush(self)
Force synchronisation of the data on disk
read_note(self, num=0)
Read the note num (None returned if non existent)
write_note(self, num=0, text='')
Overwrite note num

 
class param_file
     Methods defined here:
__del__(self)
Close the file
__init__(self, datafile='data/params.log', trailing=True, precision='d')
open the file datafile (defaults to params.log in data dir)
if trailing is set to True, then is aware of trailing commas (params files)
if set to False, expect no trailing commas (e.g. for index.pro)
precision is 'd' by default (double, i.e. N.float64=8bit float); 
if set to something else, floats will be single (N.float32=4bit float)
readline(self)
Read the current line of the parameter file
and returns it formatted as a tuple (descr,res)
descr is the description of the line, that can be:
'c': comment line
'i': enters a new Initializing zone
'r': enters a new Running zone
'd': gives the date of the recording
't': gives the initial simulation time of the run
'&': enters a new Namelist zone
'p': gives a parameter
'e': end of file reached
res is the information of the line:
'c','i','r','e': always None
'd': a string containing the date and time
't': a float containing the simulation time
'&': a string containing the name of the Namelist
'p': a tuple (name,val)
    name is a string containing the name of the parameter
    val is a list (possibly of one single element) of the
      parameter values (can be of various types)

 
Functions
       
append(dataset, new)
Increment the first dimension of the dataset and add the new element in the new position
datestring()
Return a formatted string giving local date and time
The format is the same as the one used in param files

 
Data
        VERSION = 'v0.1'