import warnings


def pull_halo_output(h5file, clusterID, apertureID, dataset):
	"""
	Function to extract a dataset from a Bahamas snapshot output.
	:param h5file: The h5py File object to extract the data from
	:param clusterID: The number of cluster in the order imposed by FoF
	:param apertureID: int(0-22) The index of the spherical aperture centred on the CoP
	:param dataset: The name of the dataset to pull
	:return: None if the cluster does not exist in the file, the dataset as np.ndarray if it exists
	"""
	if f'halo_{clusterID:05d}' not in h5file:
		warnings.warn(f"[-] Cluster {clusterID} not found in snap output.")
		return None
	else:
		return h5file[f'halo_{clusterID:05d}/aperture{apertureID:02d}/{dataset}'][...]