def pack_unit(value):
 pack = np.zeros((value.shape + (4,)), dtype=np.ubyte)
 for i in range(4):
  (value, pack[..., i]) = np.modf((value * 256.0))
 return pack

def pack_unit ( value ) : pack = np . zeros ( ( value . shape + ( 4 , ) ) , dtype = np . ubyte ) for i in range ( 4 ) : ( value , pack [ ... , i ] ) = np . modf ( ( value * 256.0 ) ) return pack
packs float values between [0 .