def load_h5(cls, filename, simulation_name="run001", beam_name="begin"): b4 = Beam_shadow4.load_h5(filename, simulation_name=simulation_name, beam_name=beam_name) b3 = Beam3(N=b4.rays.shape[0]) b3.rays = b4.rays.copy() return b3
def test_write_and_load(self): print("# ") print("# file write/load ") print("# ") a = Beam.initialize_as_pencil(200) a.rays[:, 0] = numpy.random.rand(200) a.rays[:, 2] = numpy.random.rand(200) a.write_h5("tmp.h5", simulation_name="run1", beam_name="begin", overwrite=True) a.write_h5("tmp.h5", simulation_name="run1", beam_name="star01", overwrite=False) a.write_h5("tmp.h5", simulation_name="run2", beam_name="begin", overwrite=False) b = Beam.load_h5("tmp.h5",simulation_name="run2", beam_name="begin") print("a is equal to b ? ", a.identical(b)) assert(a.identical(b)) a.difference(b)