updated static shift:

< and > signs were wrong way around in calculating res_array, also
generated a masked array for averaging as code was including null values
in averaging.