def get_hfac(grid, data):
    """Figure out the correct hfac given array dimensions."""
    hfac = None
    if 'i' in data.dims and 'j' in data.dims and 'hFacC' in grid._ds:
        hfac = grid._ds.hFacC
    if 'i' in data.dims and 'j_g' in data.dims and 'hFacS' in grid._ds:
        hfac = grid._ds.hFacS
    if 'i_g' in data.dims and 'j' in data.dims and 'hFacW' in grid._ds:
        hfac = grid._ds.hFacW
    return hfac
