Can't for you just now, and I am looking through the tiny window, but it looks like you have two three (!) large blocks of code that are nearly identical.
You can try to write a function that is the essence of both. Pass as arguments to that function whatever makes these two blocks different, like they operate on a different sensor, or with different constants of one kind or another or whatever.
Functions + arrays = waaay less code.
Easier to perfect, modify or enhance, one stop shopping.
HTH
a7