def check_variable_dim(variable_dim, data):
    """Check that the correct variable dimension (for DataArray) is specified."""
    # Check type
    if variable_dim is None: 
        return None
    if not isinstance(variable_dim, str):
        raise TypeError("Provide 'variable_dim' as a string")  
    # Check validity
    dims = list(data.dims)
    if variable_dim not in dims:
        raise ValueError("'variable_dim' must be a dimension coordinate of the xarray object") 
    # Return variable_dim as a string    
    return variable_dim