def METHOD_NAME(path):
    fh = open(path)
    text = fh.read()
    fh.close()
    lines = text.splitlines()
    records = list()
    for line in lines:
        if line.startswith("#"):
            # skip comments
            continue
        if len(line) == 0:
            # skip empty lines
            continue
        records.append(line.split())
    records = [
        record for record in records if record[0] != "nv" and record[0] != "default"
    ]
    relative = False
    absolute = False
    for record in records:
        if record[0].endswith("%"):
            relative = True
            record[0] = record[0].rstrip("%")
        else:
            absolute = True
    if absolute:
        if relative:
            minval = -0.04
            maxval = 0.04
        else:
            minval = float(records[0][0])
            # shift min up for floating point values so that
            # first color in color table is visible
            if "." in records[0][0]:
                # assumes that 1% of min does not go to the next value
                # and is still represented as float and does not make
                # too much difference in color
                # works better than 1% of the difference to the next value
                minval += abs(minval / 100)
            maxval = float(records[-1][0])
            maxval = min(maxval, 2500000)
        if os.path.basename(path) in ("ndvi", "ndwi", "ndwi2"):
            minval = -1.0
            maxval = 1.0
        if os.path.basename(path) == "ndvi_MODIS":
            minval = -10000.0
            maxval = 10000.0
        if os.path.basename(path) == "population_dens":
            maxval = 1000.0
        if os.path.basename(path) == "precipitation":
            maxval = 2000.0
        if os.path.basename(path) in ("terrain", "srtm", "srtm_plus"):
            minval = -500.0
            maxval = 3000.0
        grad = tmp_grad_abs
        grass.mapcalc(
            "$grad = "
            " float($min) + (col() - 1) * "
            "  (float($max) - float($min)) / ncols()",
            grad=tmp_grad_abs,
            min=minval,
            max=maxval,
            quiet=True,
        )
    else:
        grad = tmp_grad_rel
    return grad