当前位置: 首页>>代码示例>>Python>>正文


Python tables.Float64Col方法代码示例

本文整理汇总了Python中tables.Float64Col方法的典型用法代码示例。如果您正苦于以下问题:Python tables.Float64Col方法的具体用法?Python tables.Float64Col怎么用?Python tables.Float64Col使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tables的用法示例。


在下文中一共展示了tables.Float64Col方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_clean

# 需要导入模块: import tables [as 别名]
# 或者: from tables import Float64Col [as 别名]
def test_clean(self):
        """Test successful cleaning up of data.
        """
        table_def = {
            'time': tables.Float64Col(pos=0),
            'temperature': tables.Float64Col(pos=1),
            'pressure': tables.Float64Col(pos=2),
            'mass_fractions': tables.Float64Col(pos=3, shape=(2))
            }
        with TemporaryDirectory() as temp_dir:
            sim = Simulation(0, None, 'gri30.cti', path=temp_dir)
            sim.save_file = os.path.join(sim.path, str(sim.idx) + '.h5')

            with tables.open_file(sim.save_file, mode='w', title='0') as h5file:

                table = h5file.create_table(where=h5file.root, name='simulation',
                                            description=table_def
                                            )
                # Row instance to save timestep information to
                timestep = table.row
                timestep['time'] = 1.0
                timestep['temperature'] = 1.0
                timestep['pressure'] = 1.0
                timestep['mass_fractions'] = np.ones(2)
                timestep.append()
                
                table.flush()
            
            sim.clean()
            assert not os.path.isfile(sim.save_file) 
开发者ID:Niemeyer-Research-Group,项目名称:pyMARS,代码行数:32,代码来源:test_simulation.py

示例2: test_process_results

# 需要导入模块: import tables [as 别名]
# 或者: from tables import Float64Col [as 别名]
def test_process_results(self):
        """Test processing of ignition results using artificial data.
        """
        table_def = {
            'time': tables.Float64Col(pos=0),
            'temperature': tables.Float64Col(pos=1),
            'pressure': tables.Float64Col(pos=2),
            'mass_fractions': tables.Float64Col(pos=3, shape=(2))
            }
        with TemporaryDirectory() as temp_dir:
            sim = Simulation(0, None, 'gri30.cti', path=temp_dir)
            
            sim.save_file = os.path.join(sim.path, str(sim.idx) + '.h5')

            time_initial = np.arange(0, 10, 0.02)
            temp_initial = 200 * np.ones(len(time_initial))

            # ignition delay (temp = 600) will be at 10.5 s
            time_ramp = np.arange(10, 11.001, 0.005)
            temp_ramp = 200 + 800 * (time_ramp - 10)

            time_flat = np.arange(11.005, 15, 0.01)
            temp_flat = 1000 * np.ones(len(time_flat))
            
            times = np.concatenate((time_initial, time_ramp, time_flat))
            temps = np.concatenate((temp_initial, temp_ramp, temp_flat))

            # add a very small number to account for floating-point roundoff error
            idx = len(temp_initial) + int((len(time_ramp) - 1) / 2)
            temps[idx] += 1e-9

            with tables.open_file(sim.save_file, mode='w', title='0') as h5file:

                table = h5file.create_table(where=h5file.root, name='simulation',
                                            description=table_def
                                            )
                # Row instance to save timestep information to
                timestep = table.row

                for time, temp in zip(times, temps):
                    timestep['time'] = time
                    timestep['temperature'] = temp
                    timestep['pressure'] = 1.0
                    timestep['mass_fractions'] = np.ones(2)
                    timestep.append()
                
                table.flush()
            
            ignition_delay, sampled_data = sim.process_results()

            assert np.allclose(ignition_delay, 10.5)

            initial_temp = 200.
            delta = 40.
            for idx in range(20):
                assert np.allclose(sampled_data[idx], [initial_temp + delta, 1, 1, 1])
                delta += 40. 
开发者ID:Niemeyer-Research-Group,项目名称:pyMARS,代码行数:59,代码来源:test_simulation.py

示例3: test_process_results_skip_data

# 需要导入模块: import tables [as 别名]
# 或者: from tables import Float64Col [as 别名]
def test_process_results_skip_data(self):
        """Test processing of ignition results, skipping data sampling, using artificial data.
        """
        table_def = {
            'time': tables.Float64Col(pos=0),
            'temperature': tables.Float64Col(pos=1),
            'pressure': tables.Float64Col(pos=2),
            'mass_fractions': tables.Float64Col(pos=3, shape=(2))
            }
        with TemporaryDirectory() as temp_dir:
            sim = Simulation(0, None, 'gri30.cti', path=temp_dir)
            
            sim.save_file = os.path.join(sim.path, str(sim.idx) + '.h5')

            with tables.open_file(sim.save_file, mode='w', title='0') as h5file:

                table = h5file.create_table(where=h5file.root, name='simulation',
                                            description=table_def
                                            )
                # Row instance to save timestep information to
                timestep = table.row

                time_initial = np.arange(0, 10, 0.02)
                temp_initial = 200 * np.ones(len(time_initial))

                # ignition delay (temp = 600) will be at 10.5 s
                time_ramp = np.arange(10, 11.02, 0.02)
                temp_ramp = 200 + 800 * (time_ramp - 10)

                time_flat = np.arange(11.02, 15, 0.02)
                temp_flat = 1000 * np.ones(len(time_flat))
                
                times = np.concatenate((time_initial, time_ramp, time_flat))
                temps = np.concatenate((temp_initial, temp_ramp, temp_flat))

                # add a very small number to account for floating-point roundoff error
                idx = len(temp_initial) + 25
                temps[idx] += 1e-8

                for time, temp in zip(times, temps):
                    timestep['time'] = time
                    timestep['temperature'] = temp
                    timestep['pressure'] = 1.0
                    timestep['mass_fractions'] = np.ones(2)
                    timestep.append()
                
                table.flush()
            
            sim.process_results(skip_data=True)

            assert np.allclose(sim.ignition_delay, 10.5)
            assert not hasattr(sim, 'sampled_data') 
开发者ID:Niemeyer-Research-Group,项目名称:pyMARS,代码行数:54,代码来源:test_simulation.py


注:本文中的tables.Float64Col方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。