# Path: gridded/pysgrid/utils.py
# def pair_arrays(x_array, y_array):
# def check_element_equal(lst):
# def does_intersection_exist(a, b):
# def determine_variable_slicing(sgrid_obj, nc_variable, method='center'):
# def infer_avg_axes(sgrid_obj, nc_var_obj):
# def infer_variable_location(sgrid, variable):
# def calculate_bearing(lon_lat_1, lon_lat_2):
# def calculate_angle_from_true_east(lon_lat_1, lon_lat_2):
# def points_in_polys(points, polys, polyy=None):


import re
from gridded.pysgrid.lookup import X_COORDINATES, Y_COORDINATES
from gridded.pysgrid.utils import GridPadding

    Use regex expressions to break apart an
    attribute string containing padding types
    for each variable with a cf_role of
    'grid_topology'.

    Padding information is returned within a named tuple
    for each node dimension of an edge, face, or vertical
    dimension. The named tuples have the following attributes:
    mesh_topology_var, dim_name, dim_var, and padding.
    Padding information is returned as a list
    of these named tuples.

    :param str padding_str: string containing padding types from
                            a netCDF attribute.
    :return: named tuples with padding information.
    :rtype: list.

    """
    p = re.compile('([a-zA-Z0-9_]+:) ([a-zA-Z0-9_]+) (\(padding: [a-zA-Z]+\))')
    padding_matches = p.findall(padding_str)
    padding_type_list = []
    for padding_match in padding_matches:
        raw_dim, raw_sub_dim, raw_padding_var = padding_match
        dim = raw_dim.split(':')[0]
        sub_dim = raw_sub_dim
        # Remove parentheses. (That is why regular expressions are bad!
        # You need a commend to explain what is going on!!)
        cleaned_padding_var = re.sub('[\(\)]', '', raw_padding_var)
        # Get the padding value and remove spaces.
        padding_type = cleaned_padding_var.split(':')[1].strip()

# Path: gridded/pysgrid/utils.py
# def pair_arrays(x_array, y_array):
# def check_element_equal(lst):
# def does_intersection_exist(a, b):
# def determine_variable_slicing(sgrid_obj, nc_variable, method='center'):
# def infer_avg_axes(sgrid_obj, nc_var_obj):
# def infer_variable_location(sgrid, variable):
# def calculate_bearing(lon_lat_1, lon_lat_2):
# def calculate_angle_from_true_east(lon_lat_1, lon_lat_2):
# def points_in_polys(points, polys, polyy=None):


# Path: gridded/pysgrid/read_netcdf.py
import re
from gridded.pysgrid.lookup import X_COORDINATES, Y_COORDINATES
from gridded.pysgrid.utils import GridPadding

    Use regex expressions to break apart an
    attribute string containing padding types
    for each variable with a cf_role of
    'grid_topology'.

    Padding information is returned within a named tuple
    for each node dimension of an edge, face, or vertical
    dimension. The named tuples have the following attributes:
    mesh_topology_var, dim_name, dim_var, and padding.
    Padding information is returned as a list
    of these named tuples.

    :param str padding_str: string containing padding types from
                            a netCDF attribute.
    :return: named tuples with padding information.
    :rtype: list.

    """
    p = re.compile('([a-zA-Z0-9_]+:) ([a-zA-Z0-9_]+) (\(padding: [a-zA-Z]+\))')
    padding_matches = p.findall(padding_str)
    padding_type_list = []
    for padding_match in padding_matches:
        raw_dim, raw_sub_dim, raw_padding_var = padding_match
        dim = raw_dim.split(':')[0]
        sub_dim = raw_sub_dim
        # Remove parentheses. (That is why regular expressions are bad!
        # You need a commend to explain what is going on!!)
        cleaned_padding_var = re.sub('[\(\)]', '', raw_padding_var)
        # Get the padding value and remove spaces.
        padding_type = cleaned_padding_var.split(':')[1].strip()

        grid_padding = GridPadding(mesh_topology_var=mesh_topology_var,
