def shape_attr_name(name, length=6, keep_layer=False):
    # replace spaces with "_"
    n = name.lower().replace(' ', '_')
    # exclude "_layer_X" portion of string
    if keep_layer:
        length = 10
        n = n.replace('_layer', '_')
    else:
        try:
            idx = n.index('_layer')
            n = n[:idx]
        except:
            pass

    if len(n) > length:
        n = n[:length]
    return n
Function for to format an array name to a maximum of 10 characters to conform
dataset/ETHPy150Open modflowpy/flopy/flopy/export/shapefile_utils.py/shape_attr_name