import logging


def rescale_log_data(log_data, acceleration_scale = 256.):
	"""
	Rescale raw acceleration data to g values

	Parameters
	----------
	log_data : np.array()
		array with YXZ acceleration data (in integers otherwise no scaling required)
	acceleration_scale : float (optional)
		value to scale the acceleration

	Returns
	-------
	scaled_log_data : np.array()
		log_data scaled by acceleration scale
	"""

	try:

		# calculate the scaling factor
		scale_factor = 1. / float(acceleration_scale)

		# apply scaling and return
		return log_data * scale_factor
	except Exception as e:
		logging.error('Error rescaling log data: {}'.format(e))
		exit(1)