Example #1
0
def main():
    version = open( op.join( init_sfepy.install_dir,
                             'VERSION' ) ).readlines()[0][:-1]

    parser = OptionParser( usage = usage, version = "%prog " + version )
    parser.add_option( "-o", "", metavar = 'filename',
                       action = "store", dest = "output_filename_trunk",
                       default = None, help = help['filename'] )
    parser.add_option( "-d", "--dump",
                       action = "store_true", dest = "dump",
                       default = False, help = help['dump'] )
    parser.add_option( "-f", "--from", type = int, metavar = 'ii',
                       action = "store", dest = "step0",
                       default = 0, help = help['from'] )
    parser.add_option( "-e", "--extract", metavar = 'list',
                       action = "store", dest = "extract_list",
                       default = None, help = help['extract'] )
    parser.add_option( "-a", "--average",
                       action = "store_true", dest = "average",
                       default = False, help = help['average'] )

    (options, args) = parser.parse_args()
    print options
    print args
    if (len( args ) == 1):
        filename_in = args[0];
    else:
        parser.print_help(),
        return

    if options.dump:
        dump_to_vtk( filename_in, options )

    if options.extract_list:
        ths = extract_time_history( filename_in, options )
##         print ths

        if options.average:
            ths = average_vertex_var_in_cells( ths )
##             print ths

        if options.output_filename_trunk:
            ts = TimeStepper( *HDF5MeshIO( filename_in ).read_time_stepper() )
            ths.update( {'times' : ts.times, 'dt' : ts.dt} )
            write_dict_hdf5( options.output_filename_trunk + '.h5', ths )
Example #2
0
    def test_recursive_dict_hdf5(self):
        from sfepy.base.ioutils import write_dict_hdf5, read_dict_hdf5
        from sfepy.base.ioutils import pt
        if pt is None:
            self.report('skipped (no pytables)')
            return True
        filename = op.join(self.options.out_dir, 'dict.h5')

        test = {'A': 0, 'B': {'C': [0, 1], 'D': {'E': {'F': {'G': 2.0}}}}}

        self.report('%s' % test)
        self.report('saving into %s...' % filename)
        write_dict_hdf5(filename, test)
        self.report('reading...')
        test2 = read_dict_hdf5(filename)
        self.report('%s' % test2)

        assert_(test == test2)

        return True
Example #3
0
    def test_recursive_dict_hdf5( self ):
        from sfepy.base.ioutils import write_dict_hdf5, read_dict_hdf5
        from sfepy.base.ioutils import pt
        if pt is None:
            self.report( 'skipped (no pytables)' )
            return True
        filename = op.join( self.options.out_dir, 'dict.h5' )

        test = {'A' : 0, 'B' : {'C' : [0, 1],
                                'D' : {'E' : {'F' : {'G' : 2.0}}}}}

        self.report( '%s' % test )
        self.report( 'saving into %s...' % filename )
        write_dict_hdf5( filename, test )
        self.report( 'reading...' )
        test2 = read_dict_hdf5( filename )
        self.report( '%s' % test2 )

        assert_( test == test2 )

        return True
Example #4
0
 def save_dict(self, filename, data):
     """
     Utility function to save a dictionary `data` to a HDF5 file
     `filename`.
     """
     io.write_dict_hdf5(filename, data)
 def save_dict(self, filename, data):
     """
     Utility function to save a dictionary `data` to a HDF5 file
     `filename`.
     """
     io.write_dict_hdf5(filename, data)
Example #6
0
 def to_file_hdf5(self, filename):
     write_dict_hdf5(filename, self.__dict__)
Example #7
0
 def to_file_hdf5( self, filename ):
     write_dict_hdf5( filename, self.__dict__ )
Example #8
0
def save_time_history(ths, ts, filename_out):
    """Save time history and time-stepping information in a HDF5 file."""
    ths.update({'times' : ts.times, 'dt' : ts.dt})
    write_dict_hdf5(filename_out, ths)