def METHOD_NAME(cls, filename):
    """Parse the HDR file."""
    # HDR Format Specifications: http://paulbourke.net/dataformats/pic/
    #
    # Typical header:
    #     #?RADIANCE
    #     SOFTWARE=gegl 0.4.12
    #     FORMAT=32-bit_rle_rgbe
    #
    #     -Y 1024 +X 2048
    #     Data
    hdr = HDR()
    data = []
    header = False
    with open(filename, "rb") as f:
        while True:
            line = ''
            c = f.read(1).decode('ascii')
            while c != '\n':
                line += c
                c = f.read(1).decode('ascii')
            # Case: Empty lines
            if line == '' or (len(line) == 1 and ord(line[0]) == 10):
                continue
            # Case: header
            m = re.match(r'^#\?RADIANCE$', line)
            if m:
                header = True
                continue
            # Case: Size
            m = re.match(r'^(.)(.)\s(\d+)\s(.)(.)\s(\d+)$', line)
            if m:
                hdr.rotated = m.group(2) == 'X'
                hdr.xFlipped = m.group(1 if hdr.rotated else 4) == '-'
                hdr.yFlipped = m.group(4 if hdr.rotated else 1) == '+'
                hdr.width = int(m.group(6))
                hdr.height = int(m.group(3))
                break
            # Case: ignored header entries
            if line.startswith('FORMAT=') or \
                    line.startswith('EXPOSURE=') or \
                    line.startswith('COLORCORR=') or \
                    line.startswith('SOFTWARE=') or \
                    line.startswith('PIXASPECT=') or \
                    line.startswith('VIEW=') or \
                    line.startswith('PRIMARIES=') or \
                    line.startswith('GAMMA=') or \
                    line.startswith('# '):
                continue
            break
        # Case: Data
        data = f.read()
    assert header, 'Invalid header.'
    assert 4 * hdr.width * hdr.height == len(data) and len(data) > 0, \
        'Invalid dimensions (expected dimension: 4x%dx%d, get %d floats)' % (hdr.width, hdr.height, len(data))
    assert not (hdr.rotated or hdr.xFlipped or hdr.yFlipped), 'Flip or rotation flags are not supported.'
    # Convert data to floats
    hdr.data = [0.0] * (3 * hdr.width * hdr.height)
    for i in range(hdr.width * hdr.height):
        r = float(data[4 * i])
        g = float(data[4 * i + 1])
        b = float(data[4 * i + 2])
        e = pow(2.0, float(data[4 * i + 3]) - 128.0 + 8.0)
        hdr.data[3 * i] = pow(r * e, 1.0 / GAMMA) / 255.0
        hdr.data[3 * i + 1] = pow(g * e, 1.0 / GAMMA) / 255.0
        hdr.data[3 * i + 2] = pow(b * e, 1.0 / GAMMA) / 255.0
    return hdr