normalise and resample functions
merged branches