The code checks if masks need to be vertically flipped (if y values are increasing instead of decreasing) or transposed (if the dimension order is x, y instead of y,x)
Also allows users to specify the name of the x/y coordinate variables/dimensions if they are held in groups. Increases flexibility for standards non-conforming datasets