def from_hdf5(cls, file_or_path):
"""
Read data to an HDF5 file.
Parameters
----------
file_or_path : str, `h5py.File`, `h5py.Group`
"""
import h5py
if isinstance(file_or_path, str):
f = h5py.File(file_or_path, 'r')
close = True
else:
f = file_or_path
close = False
t = f['mjd']
rv = f['rv'][:] * u.Unit(f['rv'].attrs['unit'])
stddev = f['rv_err'][:] * u.Unit(f['rv_err'].attrs['unit'])
if close:
f.close()
return cls(t=t, rv=rv, stddev=stddev)
评论列表
文章目录