<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def readAltWCS(fobj, ext, wcskey=' ', verbose=False):
 """ Reads in alternate primary WCS from specified extension. Parameters fobj : str, `astropy.io.fits.HDUList` fits filename or fits file object containing alternate/primary WCS(s) to be converted wcskey : str [" ",A-Z] alternate/primary WCS key that will be replaced by the new key ext : int fits extension number Returns ------- hdr: fits.Header header object with ONLY the keywords for specified alternate WCS """

    if isinstance(fobj, str):
        fobj = fits.open(fobj, memmap=False)

    hdr = altwcs._getheader(fobj, ext)
    try:
        original_logging_level = log.level
        log.setLevel(logutil.logging.WARNING)
        nwcs = pywcs.WCS(hdr, fobj=fobj, key=wcskey)

    except KeyError:
        if verbose:
            print('readAltWCS: Could not read WCS with key %s' % wcskey)
            print('            Skipping %s[%s]' % (fobj.filename(), str(ext)))
        return None

    finally:
        log.setLevel(original_logging_level) # restore original logging level

    hwcs = nwcs.to_header()

    if nwcs.wcs.has_cd():
        hwcs = altwcs.pc2cd(hwcs, key=wcskey)
    return hwcs