def METHOD_NAME(f: IO[str]) -> Dict[str,Any]:
    RECORD_LEN = 80
    DIRECTIO_ALIGN_NBYTE = 512
    buf = bytearray(RECORD_LEN)
    hdr = {}
    while True:
        record = f.read(RECORD_LEN)
        if len(record) < RECORD_LEN:
            raise IOError("EOF reached in middle of header")
        record = record.decode()
        if record.startswith('END'):
            break
        key, val = record.split('=', 1)
        key, val = key.strip(), val.strip()
        if key in hdr:
            raise KeyError("Duplicate header key:", key)
        try: val = int(val)
        except ValueError:
            try: val = float(val)
            except ValueError:
                if val[0] not in set(["'", '"']):
                    raise ValueError("Invalid header value:", val)
                val = val[1:-1]    # Remove quotes
                val = val.rstrip() # Remove padding within string
        hdr[key] = val
    if 'DIRECTIO' in hdr:
        # Advance to alignment boundary
        # Note: We avoid using seek() so that we can support Unix pipes
        f.read(DIRECTIO_ALIGN_NBYTE - f.tell() % DIRECTIO_ALIGN_NBYTE)
    if 'NPOL' in hdr:
        # WAR for files with NPOL=4, which includes the complex components
        hdr['NPOL'] = 1 if hdr['NPOL'] == 1 else 2
    if 'NTIME' not in hdr:
        # Compute and add NTIME parameter
        hdr['NTIME'] = hdr['BLOCSIZE'] * 8 // (hdr['OBSNCHAN'] * hdr['NPOL'] *
                                              2 * hdr['NBITS'])
    return hdr