<s> """<STR_LIT>""" <EOL> from __future__ import print_function <EOL> import os <EOL> import traceback <EOL> SECTION = "<STR_LIT>" <EOL> def tutsep ( ) : <EOL> print ( '<STR_LIT>' , SECTION , '<STR_LIT>' ) <EOL> def tutprint ( obj ) : <EOL> tutsep ( ) <EOL> print ( obj ) <EOL> def tutrepr ( obj ) : <EOL> tutsep ( ) <EOL> print ( repr ( obj ) ) <EOL> def tutexc ( ) : <EOL> tutsep ( ) <EOL> traceback . print_exc ( file = sys . stdout ) <EOL> SECTION = "<STR_LIT>" <EOL> from numpy import * <EOL> from tables import * <EOL> SECTION = "<STR_LIT>" <EOL> class Particle ( IsDescription ) : <EOL> name = StringCol ( <NUM_LIT:16> ) <EOL> idnumber = Int64Col ( ) <EOL> ADCcount = UInt16Col ( ) <EOL> TDCcount = UInt8Col ( ) <EOL> grid_i = Int32Col ( ) <EOL> grid_j = IntCol ( ) <EOL> pressure = Float32Col ( ) <EOL> energy = FloatCol ( ) <EOL> SECTION = "<STR_LIT>" <EOL> h5file = open_file ( '<STR_LIT>' , mode = "<STR_LIT:w>" , title = "<STR_LIT>" ) <EOL> SECTION = "<STR_LIT>" <EOL> group = h5file . create_group ( "<STR_LIT:/>" , '<STR_LIT>' , '<STR_LIT>' ) <EOL> SECTION = "<STR_LIT>" <EOL> table = h5file . create_table ( group , '<STR_LIT>' , Particle , "<STR_LIT>" ) <EOL> tutprint ( h5file ) <EOL> tutrepr ( h5file ) <EOL> particle = table . row <EOL> for i in range ( <NUM_LIT:10> ) : <EOL> particle [ '<STR_LIT:name>' ] = '<STR_LIT>' % ( i ) <EOL> particle [ '<STR_LIT>' ] = i % <NUM_LIT> <EOL> particle [ '<STR_LIT>' ] = ( i * <NUM_LIT> ) % ( <NUM_LIT:1> << <NUM_LIT:16> ) <EOL> particle [ '<STR_LIT>' ] = i <EOL> particle [ '<STR_LIT>' ] = <NUM_LIT:10> - i <EOL> particle [ '<STR_LIT>' ] = float ( i * i ) <EOL> particle [ '<STR_LIT>' ] = float ( particle [ '<STR_LIT>' ] ** <NUM_LIT:4> ) <EOL> particle [ '<STR_LIT>' ] = i * ( <NUM_LIT:2> ** <NUM_LIT> ) <EOL> particle . append ( ) <EOL> table . flush ( ) <EOL> SECTION = "<STR_LIT>" <EOL> table = h5file . root . detector . readout <EOL> pressure = [ <EOL> x [ '<STR_LIT>' ] for x in table <EOL> if x [ '<STR_LIT>' ] > <NUM_LIT:3> and <NUM_LIT:20> <= x [ '<STR_LIT>' ] < <NUM_LIT:50> <EOL> ] <EOL> tutrepr ( pressure ) <EOL> names = [ <EOL> x [ '<STR_LIT:name>' ] for x in table <EOL> if x [ '<STR_LIT>' ] > <NUM_LIT:3> and <NUM_LIT:20> <= x [ '<STR_LIT>' ] < <NUM_LIT:50> <EOL> ] <EOL> tutrepr ( names ) <EOL> SECTION = "<STR_LIT>" <EOL> gcolumns = h5file . create_group ( h5file . root , "<STR_LIT>" , "<STR_LIT>" ) <EOL> tutrepr ( <EOL> h5file . create_array ( gcolumns , '<STR_LIT>' , array ( pressure ) , <EOL> "<STR_LIT>" ) <EOL> ) <EOL> tutrepr ( <EOL> h5file . create_array ( '<STR_LIT>' , '<STR_LIT:name>' , names , "<STR_LIT>" ) <EOL> ) <EOL> tutprint ( h5file ) <EOL> SECTION = "<STR_LIT>" <EOL> h5file . close ( ) <EOL> tutsep ( ) <EOL> os . system ( '<STR_LIT>' ) <EOL> tutsep ( ) <EOL> os . system ( '<STR_LIT>' ) <EOL> """<STR_LIT>""" <EOL> SECTION = "<STR_LIT>" <EOL> h5file = open_file ( "<STR_LIT>" , "<STR_LIT:a>" ) <EOL> tutprint ( h5file ) <EOL> tutsep ( ) <EOL> for node in h5file : <EOL> print ( node ) <EOL> tutsep ( ) <EOL> for group in h5file . walk_groups ( "<STR_LIT:/>" ) : <EOL> print ( group ) <EOL> tutsep ( ) <EOL> for group in h5file . walk_groups ( "<STR_LIT:/>" ) : <EOL> for array in h5file . list_nodes ( group , classname = '<STR_LIT>' ) : <EOL> print ( array ) <EOL> tutsep ( ) <EOL> for array in h5file . walk_nodes ( "<STR_LIT:/>" , "<STR_LIT>" ) : <EOL> print ( array ) <EOL> tutsep ( ) <EOL> for leaf in h5file . root . detector ( '<STR_LIT>' ) : <EOL> print ( leaf ) <EOL> SECTION = "<STR_LIT>" <EOL> table = h5file . root . detector . readout <EOL> table . attrs . gath_date = "<STR_LIT>" <EOL> table . attrs . temperature = <NUM_LIT> <EOL> table . attrs . temp_scale = "<STR_LIT>" <EOL> detector = h5file . root . detector <EOL> detector . _v_attrs . stuff = [ <NUM_LIT:5> , ( <NUM_LIT> , <NUM_LIT> ) , "<STR_LIT>" ] <EOL> tutrepr ( table . attrs . gath_date ) <EOL> tutrepr ( table . attrs . temperature ) <EOL> tutrepr ( table . attrs . temp_scale ) <EOL> tutrepr ( detector . _v_attrs . stuff ) <EOL> del table . attrs . gath_date <EOL> tutrepr ( table . attrs ) <EOL> tutprint ( table . attrs . _f_list ( "<STR_LIT:user>" ) ) <EOL> tutprint ( table . attrs . _f_list ( "<STR_LIT>" ) ) <EOL> table . attrs . _f_rename ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> tutprint ( table . attrs . _f_list ( ) ) <EOL> try : <EOL> table . attrs . _f_rename ( "<STR_LIT>" , "<STR_LIT:version>" ) <EOL> except : <EOL> tutexc ( ) <EOL> h5file . flush ( ) <EOL> tutsep ( ) <EOL> os . system ( '<STR_LIT>' ) <EOL> SECTION = "<STR_LIT>" <EOL> tutsep ( ) <EOL> print ( "<STR_LIT>" , table ) <EOL> tutsep ( ) <EOL> print ( "<STR_LIT>" , table . name ) <EOL> tutsep ( ) <EOL> print ( "<STR_LIT>" , table . title ) <EOL> tutsep ( ) <EOL> print ( "<STR_LIT>" , table . nrows ) <EOL> tutsep ( ) <EOL> print ( "<STR_LIT>" ) <EOL> tutsep ( ) <EOL> for name in table . colnames : <EOL> print ( name , '<STR_LIT>' % ( table . coltypes [ name ] , table . colshapes [ name ] ) ) <EOL> tutprint ( table . __doc__ ) <EOL> pressureObject = h5file . get_node ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> tutsep ( ) <EOL> print ( "<STR_LIT>" , repr ( pressureObject ) ) <EOL> tutsep ( ) <EOL> print ( "<STR_LIT>" , pressureObject . shape ) <EOL> tutsep ( ) <EOL> print ( "<STR_LIT>" , pressureObject . title ) <EOL> tutsep ( ) <EOL> print ( "<STR_LIT>" , pressureObject . type ) <EOL> SECTION = "<STR_LIT>" <EOL> pressureArray = pressureObject . read ( ) <EOL> tutrepr ( pressureArray ) <EOL> tutsep ( ) <EOL> print ( "<STR_LIT>" , type ( pressureArray ) ) <EOL> nameArray = h5file . root . columns . name . read ( ) <EOL> tutrepr ( nameArray ) <EOL> print ( "<STR_LIT>" , type ( nameArray ) ) <EOL> tutprint ( "<STR_LIT>" ) <EOL> tutsep ( ) <EOL> for i in range ( pressureObject . shape [ <NUM_LIT:0> ] ) : <EOL> print ( nameArray [ i ] , "<STR_LIT>" , pressureArray [ i ] ) <EOL> tutrepr ( pressureObject . name ) <EOL> SECTION = "<STR_LIT>" <EOL> table = h5file . root . detector . readout <EOL> particle = table . row <EOL> for i in range ( <NUM_LIT:10> , <NUM_LIT:15> ) : <EOL> particle [ '<STR_LIT:name>' ] = '<STR_LIT>' % ( i ) <EOL> particle [ '<STR_LIT>' ] = i % <NUM_LIT> <EOL> particle [ '<STR_LIT>' ] = ( i * <NUM_LIT> ) % ( <NUM_LIT:1> << <NUM_LIT:16> ) <EOL> particle [ '<STR_LIT>' ] = i <EOL> particle [ '<STR_LIT>' ] = <NUM_LIT:10> - i <EOL> particle [ '<STR_LIT>' ] = float ( i * i ) <EOL> particle [ '<STR_LIT>' ] = float ( particle [ '<STR_LIT>' ] ** <NUM_LIT:4> ) <EOL> particle [ '<STR_LIT>' ] = i * ( <NUM_LIT:2> ** <NUM_LIT> ) <EOL> particle . append ( ) <EOL> table . flush ( ) <EOL> tutsep ( ) <EOL> for r in table : <EOL> print ( "<STR_LIT>" % ( r [ '<STR_LIT:name>' ] , r [ '<STR_LIT>' ] , r [ '<STR_LIT>' ] , r [ '<STR_LIT>' ] , r [ '<STR_LIT>' ] , <EOL> r [ '<STR_LIT>' ] ) ) <EOL> tutrepr ( table . remove_rows ( <NUM_LIT:5> , <NUM_LIT:10> ) ) <EOL> h5file . close ( ) </s>
